diff options
author | Prabhu Ramachandran | 2018-01-03 22:23:19 +0530 |
---|---|---|
committer | GitHub | 2018-01-03 22:23:19 +0530 |
commit | feb295b4107a95621e9430f5c7042cfde4674cc0 (patch) | |
tree | 098c7cdc1e97d5e7bd859e35107a4733e800a586 /yaksh/models.py | |
parent | e566d54239efcb46f253e324b7295a676378f656 (diff) | |
parent | 4310d5905a9cc702198e42830c1b670957cd7360 (diff) | |
download | online_test-feb295b4107a95621e9430f5c7042cfde4674cc0.tar.gz online_test-feb295b4107a95621e9430f5c7042cfde4674cc0.tar.bz2 online_test-feb295b4107a95621e9430f5c7042cfde4674cc0.zip |
Merge pull request #408 from prathamesh920/exercise
Exercise feature in video lessons
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 5eca3d1..1d24bda 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -311,6 +311,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() @@ -757,6 +759,10 @@ 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) + + solution = models.TextField(blank=True) + def consolidate_answer_data(self, user_answer, user=None): question_data = {} metadata = {} @@ -1527,15 +1533,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.""" |