.
This commit is contained in:
+6
-2
@@ -147,8 +147,12 @@ class ExamBase(models.Model):
|
|||||||
authors = [i for i in self.author.all()]
|
authors = [i for i in self.author.all()]
|
||||||
return authors
|
return authors
|
||||||
|
|
||||||
def check_cid_user(self, cid, passcode):
|
def check_cid_user(self, cid, passcode, request=None):
|
||||||
|
if request is not None and request.user.is_superuser():
|
||||||
|
return True
|
||||||
|
|
||||||
if self.valid_users.exists():
|
if self.valid_users.exists():
|
||||||
|
|
||||||
user = self.valid_users.filter(cid=cid).first()
|
user = self.valid_users.filter(cid=cid).first()
|
||||||
|
|
||||||
if not user or user.passcode != passcode:
|
if not user or user.passcode != passcode:
|
||||||
@@ -270,7 +274,7 @@ class CidUser(models.Model):
|
|||||||
"test@xkjq.uk",
|
"test@xkjq.uk",
|
||||||
[self.email, self.supervisor_email],
|
[self.email, self.supervisor_email],
|
||||||
fail_silently=False,
|
fail_silently=False,
|
||||||
html_message=html_msg
|
html_message=html_msg,
|
||||||
)
|
)
|
||||||
except SMTPException as e:
|
except SMTPException as e:
|
||||||
return False, e
|
return False, e
|
||||||
|
|||||||
+3
-3
@@ -936,7 +936,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
user_answers_marks = defaultdict(list)
|
user_answers_marks = defaultdict(list)
|
||||||
user_answers = defaultdict(list)
|
user_answers = defaultdict(list)
|
||||||
user_names = {}
|
user_names = {}
|
||||||
cid_passcodes = {}
|
#cid_passcodes = {}
|
||||||
|
|
||||||
by_question = defaultdict(dict)
|
by_question = defaultdict(dict)
|
||||||
unmarked = set()
|
unmarked = set()
|
||||||
@@ -954,7 +954,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
for cid_user_answer in cid_user_answers:
|
for cid_user_answer in cid_user_answers:
|
||||||
# Convoluted (probably...)
|
# Convoluted (probably...)
|
||||||
cid = cid_user_answer.cid
|
cid = cid_user_answer.cid
|
||||||
cid_passcodes[cid] = cid_user_answer.passcode
|
#cid_passcodes[cid] = cid_user_answer.passcode
|
||||||
cids.add(cid)
|
cids.add(cid)
|
||||||
s = cid_user_answer
|
s = cid_user_answer
|
||||||
user_names[cid] = cid
|
user_names[cid] = cid
|
||||||
@@ -1055,7 +1055,7 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
f"{self.app_name}/exam_scores_new.html",
|
f"{self.app_name}/exam_scores_new.html",
|
||||||
{
|
{
|
||||||
"cids": sorted(cids),
|
"cids": sorted(cids),
|
||||||
"cid_passcodes": cid_passcodes,
|
#"cid_passcodes": cid_passcodes,
|
||||||
"exam": exam,
|
"exam": exam,
|
||||||
"unmarked": unmarked,
|
"unmarked": unmarked,
|
||||||
"questions": questions,
|
"questions": questions,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Candidate</th>
|
<th>Candidate</th>
|
||||||
{% for cid in cids %}
|
{% for cid in cids %}
|
||||||
<th><a href="{% url 'sbas:exam_scores_cid_user' exam.pk cid cid_passcodes|get_item:cid %}">{{cid}}</a></th>
|
<th><a href="{% url 'sbas:exam_scores_cid_user' exam.pk cid 'None' %}">{{cid}}</a></th>
|
||||||
{% comment %} <th><a href="">{{cid}}</a></th> {% endcomment %}
|
{% comment %} <th><a href="">{{cid}}</a></th> {% endcomment %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -81,11 +81,10 @@ def active_exams(request):
|
|||||||
return render(request, "sbas/available_exam_list.html", {"exams": active_exams})
|
return render(request, "sbas/available_exam_list.html", {"exams": active_exams})
|
||||||
|
|
||||||
|
|
||||||
def exam_scores_cid_user(request, pk, sk, passcode):
|
def exam_scores_cid_user(request, pk, cid, passcode):
|
||||||
exam = get_object_or_404(Exam, pk=pk)
|
exam = get_object_or_404(Exam, pk=pk)
|
||||||
|
|
||||||
cid = sk
|
if not exam.check_cid_user(cid, passcode, request):
|
||||||
if not exam.check_cid_user(cid, passcode):
|
|
||||||
raise Http404("Error accessing exam")
|
raise Http404("Error accessing exam")
|
||||||
|
|
||||||
questions = exam.exam_questions.all()
|
questions = exam.exam_questions.all()
|
||||||
|
|||||||
Reference in New Issue
Block a user