diff options
author | ankitjavalkar | 2020-09-29 17:27:10 +0530 |
---|---|---|
committer | GitHub | 2020-09-29 17:27:10 +0530 |
commit | d2a125668bccad5edca9c07368a58946a136e5ba (patch) | |
tree | bfde45df2ea0cff7b9d234756a4b0f04a3897957 /yaksh | |
parent | 0af9b77e63aa02a29cc8b150efe6f9ef86c8d344 (diff) | |
parent | 668f3ab5b74977df1793393d596f489d15e2e830 (diff) | |
download | online_test-d2a125668bccad5edca9c07368a58946a136e5ba.tar.gz online_test-d2a125668bccad5edca9c07368a58946a136e5ba.tar.bz2 online_test-d2a125668bccad5edca9c07368a58946a136e5ba.zip |
Merge pull request #771 from ankitjavalkar/recalc-paper-marks
Re calculate and save total marks of paper
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 2 | ||||
-rw-r--r-- | yaksh/test_models.py | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index dc08307..1b76eed 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1769,6 +1769,8 @@ class QuestionPaper(models.Model): for question in questions: marks += question.points for question_set in self.random_questions.all(): + question_set.marks = question_set.questions.first().points + question_set.save() marks += question_set.marks * question_set.num_questions self.total_marks = marks self.save() diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 7ef1ca7..11ab6cd 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -994,7 +994,7 @@ class QuestionPaperTestCases(unittest.TestCase): # create two QuestionSet for random questions # QuestionSet 1 self.question_set_1 = QuestionSet.objects.create( - marks=2, num_questions=2 + marks=1, num_questions=2 ) # add pool of questions for random sampling @@ -1007,7 +1007,7 @@ class QuestionPaperTestCases(unittest.TestCase): # QuestionSet 2 self.question_set_2 = QuestionSet.objects.create( - marks=3, num_questions=3 + marks=1, num_questions=3 ) # add pool of questions @@ -1074,7 +1074,7 @@ class QuestionPaperTestCases(unittest.TestCase): """ Test update_total_marks() method of Question Paper""" self.assertEqual(self.question_paper.total_marks, 0) self.question_paper.update_total_marks() - self.assertEqual(self.question_paper.total_marks, 15) + self.assertEqual(self.question_paper.total_marks, 7.0) def test_get_random_questions(self): """ Test get_random_questions() method of Question Paper""" |