improving physics / sba exams
This commit is contained in:
+18
-1
@@ -1,4 +1,5 @@
|
||||
from collections import defaultdict
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
from typing import Self, Tuple
|
||||
@@ -712,6 +713,20 @@ class ExamBase(ExamCollectionGenericBase):
|
||||
"{}:exam_json_cid".format(self.app_name), args=(self.pk, cid, passcode)
|
||||
)
|
||||
|
||||
def get_time_limit(self):
|
||||
"""Returns a human readable time limit"""
|
||||
h, m, s = str(datetime.timedelta(seconds=self.time_limit)).split(":")
|
||||
|
||||
time_limit = ""
|
||||
if s != "0":
|
||||
time_limit = f" {s} second(s)"
|
||||
if m != "0":
|
||||
time_limit = f"{m} minute(s) {time_limit}"
|
||||
if h != "0":
|
||||
time_limit = f"{h} hour(s) {time_limit}"
|
||||
|
||||
return time_limit.strip()
|
||||
|
||||
def get_question_index(self, question):
|
||||
return list(self.exam_questions.all()).index(question)
|
||||
|
||||
@@ -955,10 +970,12 @@ class CidUser(models.Model):
|
||||
def check_passcode(self, passcode) -> bool:
|
||||
return self.passcode == passcode
|
||||
|
||||
def get_cid_exams(self):
|
||||
def get_cid_exams(self, include_case_collections=True):
|
||||
available_exams = []
|
||||
|
||||
for n, t in EXAM_TYPES:
|
||||
if not include_case_collections and n == "casecollection":
|
||||
continue
|
||||
exam_rel = getattr(self, t)
|
||||
if exam_rel.exists():
|
||||
exams = exam_rel.filter(exam_mode=True, archive=False).order_by("name")
|
||||
|
||||
Reference in New Issue
Block a user