summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authorprathamesh2017-12-27 17:32:21 +0530
committerprathamesh2017-12-27 17:53:50 +0530
commit51a93b42b1d7b3a94e227796aa8d4f6e97de9929 (patch)
treedb35061da2b9891dd597337be78946eb67c5df3c /yaksh/models.py
parentb44db042059e69df4c4a948d6dff73604c7abf83 (diff)
downloadonline_test-51a93b42b1d7b3a94e227796aa8d4f6e97de9929.tar.gz
online_test-51a93b42b1d7b3a94e227796aa8d4f6e97de9929.tar.bz2
online_test-51a93b42b1d7b3a94e227796aa8d4f6e97de9929.zip
Exercise feature in video lessons
Exercise is same as quiz except for following differences: - no time limit - no marks weightage - no instruction page - skip denied for a particular time An attribute 'is_exercise' in Quiz determines whether the quiz is exercise or not. Questions contains 'min_time' attribute. For an exercise a question cannot be skipped for an allotted minimum time, after which either django or JavaScript makes Next button available. Implementation is as such due to complexity of our existing views and templates. Also, after min_time, same question with Next button is available to move on, assuming that solution is present in the video.
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index c65e9ef..839043f 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -308,6 +308,8 @@ class Quiz(models.Model):
weightage = models.FloatField(default=1.0)
+ is_exercise = models.BooleanField(default=False)
+
creator = models.ForeignKey(User, null=True)
objects = QuizManager()
@@ -747,6 +749,8 @@ class Question(models.Model):
# Check assignment upload based question
grade_assignment_upload = models.BooleanField(default=False)
+ min_time = models.IntegerField("time in minutes", default=0)
+
def consolidate_answer_data(self, user_answer, user=None):
question_data = {}
metadata = {}
@@ -1517,15 +1521,25 @@ class AnswerPaper(models.Model):
def time_left(self):
"""Return the time remaining for the user in seconds."""
+ secs = self._get_total_seconds()
+ total = self.question_paper.quiz.duration*60.0
+ remain = max(total - secs, 0)
+ return int(remain)
+
+ def time_left_on_question(self, question):
+ secs = self._get_total_seconds()
+ total = question.min_time*60.0
+ remain = max(total - secs, 0)
+ return int(remain)
+
+ def _get_total_seconds(self):
dt = timezone.now() - self.start_time
try:
secs = dt.total_seconds()
except AttributeError:
# total_seconds is new in Python 2.7. :(
secs = dt.seconds + dt.days*24*3600
- total = self.question_paper.quiz.duration*60.0
- remain = max(total - secs, 0)
- return int(remain)
+ return secs
def _update_marks_obtained(self):
"""Updates the total marks earned by student for this paper."""