.
This commit is contained in:
+21
-1
@@ -966,4 +966,24 @@ LongExamViews = ExamViews(Exam, Long, "longs", "long", loadJsonAnswer)
|
||||
|
||||
class ExamViewSet(viewsets.ModelViewSet):
|
||||
queryset = Exam.objects.all().order_by('name')
|
||||
serializer_class = ExamSerializer
|
||||
serializer_class = ExamSerializer
|
||||
|
||||
|
||||
def question_json(self, request, pk):
|
||||
question = get_object_or_404(self.Question, pk=pk)
|
||||
#exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
#if not exam.active:
|
||||
# raise Http404("No available exam")
|
||||
|
||||
question_json_cache = cache.get("{}_question_json_{}".format("longs", sk))
|
||||
|
||||
if question_json_cache is not None and not question.recreate_json:
|
||||
question_json_cache["cached"] = True
|
||||
return JsonResponse(question_json_cache)
|
||||
|
||||
question_json = question.get_json(pk)
|
||||
|
||||
cache.set("{}_question_json_{}".format("longs", pk), question_json, 3600)
|
||||
|
||||
return JsonResponse(question_json)
|
||||
Reference in New Issue
Block a user