add time limit to exams
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2020-12-28 10:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('anatomy', '0013_auto_20201227_1200'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='time_limit',
|
||||||
|
field=models.IntegerField(default=False, help_text='Exam time limit (in seconds)'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+10
-6
@@ -181,7 +181,9 @@ class AnatomyQuestion(models.Model):
|
|||||||
if i.status != i.MarkOptions.UNMARKED
|
if i.status != i.MarkOptions.UNMARKED
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
correct_answers = set([i.answer.get_compare_string() for i in self.answers.all()])
|
correct_answers = set(
|
||||||
|
[i.answer.get_compare_string() for i in self.answers.all()]
|
||||||
|
)
|
||||||
half_mark_answers = set(
|
half_mark_answers = set(
|
||||||
[i.answer.get_compare_string() for i in self.half_mark_answers.all()]
|
[i.answer.get_compare_string() for i in self.half_mark_answers.all()]
|
||||||
)
|
)
|
||||||
@@ -266,6 +268,10 @@ class Exam(models.Model):
|
|||||||
help_text="If the json cache needs updating", default=False
|
help_text="If the json cache needs updating", default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
time_limit = models.IntegerField(
|
||||||
|
help_text="Exam time limit (in seconds)", default=False
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@@ -366,11 +372,9 @@ class CidUserAnswer(models.Model):
|
|||||||
is not None
|
is not None
|
||||||
):
|
):
|
||||||
mark = 1
|
mark = 1
|
||||||
elif (
|
elif q.answers.filter(
|
||||||
q.answers.filter(
|
answer__iexact=ans, status=Answer.MarkOptions.INCORRECT
|
||||||
answer__iexact=ans, status=Answer.MarkOptions.INCORRECT
|
).first():
|
||||||
).first()
|
|
||||||
):
|
|
||||||
mark = 0
|
mark = 0
|
||||||
else:
|
else:
|
||||||
mark = "unmarked"
|
mark = "unmarked"
|
||||||
|
|||||||
@@ -585,6 +585,9 @@ def exam_json(request, pk):
|
|||||||
"questions": exam_questions,
|
"questions": exam_questions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if exam.time_limit:
|
||||||
|
exam_json["exam_time"] = exam.time_limit
|
||||||
|
|
||||||
exam.recreate_json = False
|
exam.recreate_json = False
|
||||||
exam.save()
|
exam.save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user