summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2018-06-07 14:23:07 +0530
committerGitHub2018-06-07 14:23:07 +0530
commit94d009bde0bdf3565cf31112a38ff3317fb80f3c (patch)
treef3af495d8c76a36a2d3e82f361c7ca433ccf5612 /yaksh/models.py
parentcd4a76d2bb8eb39621729536fbd9a8f2036d13cf (diff)
parentbd2672ea701fb3f6270a3e7af41cc44568f7330b (diff)
downloadonline_test-94d009bde0bdf3565cf31112a38ff3317fb80f3c.tar.gz
online_test-94d009bde0bdf3565cf31112a38ff3317fb80f3c.tar.bz2
online_test-94d009bde0bdf3565cf31112a38ff3317fb80f3c.zip
Merge pull request #461 from adityacp/fix_quiz_completion
Quiz Completion Status
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 3010a3c..1ca293b 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -387,6 +387,20 @@ class Quiz(models.Model):
course=course, passed=False
).values_list("user", flat=True).distinct().count()
+ def get_answerpaper_status(self, user, course):
+ try:
+ qp = self.questionpaper_set.get().id
+ except QuestionPaper.DoesNotExist:
+ qp = None
+ ans_ppr = AnswerPaper.objects.filter(
+ user=user, course=course, question_paper=qp
+ ).order_by("-attempt_number")
+ if ans_ppr.exists():
+ status = ans_ppr.first().status
+ else:
+ status = "not attempted"
+ return status
+
def _create_quiz_copy(self, user):
question_papers = self.questionpaper_set.all()
new_quiz = self
@@ -425,6 +439,8 @@ class LearningUnit(models.Model):
if course_status.exists():
if self in course_status.first().completed_units.all():
state = "completed"
+ elif self.type == "quiz":
+ state = self.quiz.get_answerpaper_status(user, course)
elif course_status.first().current_unit == self:
state = "inprogress"
return state