begin correct sorting of exams/collection
This commit is contained in:
+9
-2
@@ -828,8 +828,15 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def get_questions(self):
|
||||
"""Returns a list of questions in the exam in the correct order"""
|
||||
return self.exam_questions.all().order_by("examquestiondetail__sort_order")
|
||||
|
||||
def order_questions(self):
|
||||
"""Modifies the examquestiondetail sort_order to sequentially order the cases"""
|
||||
for n, c in enumerate(self.examquestiondetail_set.all().order_by("sort_order")):
|
||||
c.sort_order = n
|
||||
c.save()
|
||||
|
||||
def get_exam_stats(self, name=True):
|
||||
if self.stats_candidates < int(4):
|
||||
return f"- Candidates: {int(self.stats_candidates)} (too few to generate stats)"
|
||||
@@ -889,11 +896,11 @@ class ExamBase(ExamOrCollectionGenericBase):
|
||||
return time_limit.strip()
|
||||
|
||||
def get_question_index(self, question):
|
||||
return list(self.exam_questions.all()).index(question)
|
||||
return list(self.get_questions()).index(question)
|
||||
|
||||
def get_question_by_index(self, index: int):
|
||||
# There must be a better way to do this
|
||||
return list(self.exam_questions.all())[index]
|
||||
return list(self.get_questions)[index]
|
||||
|
||||
def get_cid_user_score(self, cid_user):
|
||||
c = "c/" + str(cid_user)
|
||||
|
||||
Reference in New Issue
Block a user