def add_report(request): """ Adds a report filled by a user to the site's reports record :param request: Request :return: HttpResponse """ if request.method == 'POST' and request.is_ajax: deq = request.POST.get('description') idq = request.POST.get('idq') quest = Question.objects.get(id=idq) report = Report(report_description=deq) report.question = quest report.save() return HttpResponse("OK") else: return HttpResponse("Something went wrong")
def autoreport(request): """ Generates a report automatically for a denounced question as repeated in an exam :param request: Request :return: HttpResponse """ if request.method == 'POST' and request.is_ajax: txt = Question.objects.get(id=request.POST.get('id1')).question_text deq = "Esta pregunta esta duplicada con la pregunta con \"" + txt + \ "\"" idq = request.POST.get('id2') quest = Question.objects.get(id=idq) report = Report(report_description=deq) report.question = quest report.save() return HttpResponse("OK") else: return HttpResponse("Something went wrong")