.
This commit is contained in:
@@ -200,6 +200,11 @@ def generic_exam_urls(generic_exam_view):
|
||||
generic_exam_view.exam_toggle_results_published,
|
||||
name="exam_toggle_results_published",
|
||||
),
|
||||
path(
|
||||
"exam/<int:pk>/toggle_archived",
|
||||
generic_exam_view.exam_toggle_archived,
|
||||
name="exam_toggle_archived",
|
||||
),
|
||||
path(
|
||||
"exam/submit",
|
||||
generic_exam_view.postExamAnswers,
|
||||
|
||||
@@ -459,6 +459,33 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
return False
|
||||
return True
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_toggle_archived(self, request, pk):
|
||||
print("TOGGLE ARCHIVED", request.POST)
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
|
||||
if not self.check_user_edit_access(request.user):
|
||||
data = {"status": "error, insufficient permission"}
|
||||
return JsonResponse(data, status=400)
|
||||
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
exam.archive = (
|
||||
True if request.POST.get("archive") == "true" else False
|
||||
)
|
||||
print(f"{exam.archive=}")
|
||||
exam.save()
|
||||
data = {
|
||||
"status": "success",
|
||||
"archive": exam.archive,
|
||||
"name": exam.name,
|
||||
"id": exam.id,
|
||||
}
|
||||
return JsonResponse(data, status=200)
|
||||
else:
|
||||
data = {"status": "error"}
|
||||
return JsonResponse(data, status=400)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_toggle_results_published(self, request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
|
||||
Reference in New Issue
Block a user