add publish results feature

This commit is contained in:
Ross
2020-12-10 23:26:44 +00:00
parent cdd466ecb5
commit 75516f38e5
8 changed files with 79 additions and 4 deletions
+17
View File
@@ -457,6 +457,19 @@ def mark(request, pk, sk):
},
)
def exam_toggle_results_published(request, pk):
if request.is_ajax() and request.method=='POST':
exam = get_object_or_404(Exam, pk=pk)
exam.publish_results = True if request.POST.get('publish_results') == 'true' else False
exam.save()
data = {'status':'success', 'publish_results':exam.publish_results}
return JsonResponse(data, status=200)
else:
data = {'status':'error'}
return JsonResponse(data, status=400)
def exam_toggle_active(request, pk):
if request.is_ajax() and request.method=='POST':
@@ -664,6 +677,10 @@ def exam_scores_cid_user(request, pk, sk):
answer_score = user_answer.get_answer_score()
correct_answer = q.GetPrimaryAnswer()
if not exam.publish_results:
correct_answer = "*****"
answer_score = 0
answers.append(ans)
answers_marks.append(answer_score)
answers_and_marks.append((ans, answer_score, correct_answer))