.
This commit is contained in:
+38
-1
@@ -651,4 +651,41 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
return JsonResponse(question_json)
|
||||
|
||||
|
||||
|
||||
class GenericViewBase:
|
||||
def __init__(self, app_name, QuestionObject, CidUserAnswerObject, ExamObject, question_type, loadJsonAnswer):
|
||||
self.question_object = QuestionObject
|
||||
self.cid_user_answer_object = CidUserAnswerObject
|
||||
self.exam_object = ExamObject
|
||||
self.app_name = app_name
|
||||
|
||||
def question_review(self, request, pk):
|
||||
"""
|
||||
Return a json representation of the question when the exam is active
|
||||
"""
|
||||
if request.is_ajax():
|
||||
exam = get_object_or_404(self.exam_object, pk=pk)
|
||||
|
||||
print(request.POST["question_number"])
|
||||
print(type(request.POST["question_number"]))
|
||||
|
||||
if not exam.publish_results:
|
||||
raise Http404
|
||||
|
||||
question = exam.exam_questions.all()[int(request.POST["question_number"])]
|
||||
|
||||
question_json = question.get_question_json(based=False)
|
||||
return JsonResponse(question_json)
|
||||
return JsonResponse({"status": "error"})
|
||||
|
||||
@user_passes_test(lambda u: u.is_superuser)
|
||||
def user_answer_delete_multiple(self, request):
|
||||
if request.is_ajax():
|
||||
print(request.POST["answer_ids"])
|
||||
answer_ids = json.loads(request.POST["answer_ids"])
|
||||
|
||||
# We could probably delete them all at once....
|
||||
for id in answer_ids:
|
||||
self.cid_user_answer_object.objects.get(pk=id).delete()
|
||||
return JsonResponse({"status": "success"})
|
||||
return JsonResponse({"status": "error"})
|
||||
Reference in New Issue
Block a user