diff options
author | maheshgudi | 2017-01-13 01:24:27 +0530 |
---|---|---|
committer | maheshgudi | 2017-01-13 01:24:27 +0530 |
commit | 57a5d99c7ed5aed498943686b2c951bdaba3852a (patch) | |
tree | 8969f5db3aeb70350e089e97fb5e37bd0e4db1ab /yaksh/test_models.py | |
parent | 7fb288ffd992c912a8e2288aa97d6c6ceeedf1a1 (diff) | |
download | online_test-57a5d99c7ed5aed498943686b2c951bdaba3852a.tar.gz online_test-57a5d99c7ed5aed498943686b2c951bdaba3852a.tar.bz2 online_test-57a5d99c7ed5aed498943686b2c951bdaba3852a.zip |
Fixed a bug which would mark all MCQ and MCC questions' answers as correct
1. Due to the new evaluator, an unchecked bug, which marked all mcq and mcc attempts as correct, despite actually marking the wrong answer, has been fixed.
2. Added Test case to check for incorrect mcq and mcc questions
3. question.html would also render error msg for mcq and mcc questions. This has also been fixed.
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r-- | yaksh/test_models.py | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 48dfb8e..1a6bcba 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -533,22 +533,22 @@ class AnswerPaperTestCases(unittest.TestCase): ) self.mcc_based_testcase.save() - def test_validate_and_regrade_mcc_question(self): + def test_validate_and_regrade_mcc_correct_answer(self): # Given mcc_answer = ['a'] self.answer = Answer(question=self.question3, - answer=mcc_answer, - ) + answer=mcc_answer, + ) self.answer.save() self.answerpaper.answers.add(self.answer) # When json_data = None - correct, result = self.answerpaper.validate_answer(mcc_answer, - self.question3, json_data) + result = self.answerpaper.validate_answer(mcc_answer, + self.question3, json_data + ) # Then - self.assertTrue(correct) self.assertTrue(result['success']) self.assertEqual(result['error'], ['Correct answer']) self.answer.correct = True @@ -570,7 +570,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(self.answer.marks, 0) self.assertFalse(self.answer.correct) - def test_validate_and_regrade_mcq_question(self): + def test_validate_and_regrade_mcq_correct_answer(self): # Given mcq_answer = 'a' self.answer = Answer(question=self.question2, @@ -581,11 +581,11 @@ class AnswerPaperTestCases(unittest.TestCase): # When json_data = None - correct, result = self.answerpaper.validate_answer(mcq_answer, - self.question2, json_data) + result = self.answerpaper.validate_answer(mcq_answer, + self.question2, json_data + ) # Then - self.assertTrue(correct) self.assertTrue(result['success']) self.answer.correct = True self.answer.marks = 1 @@ -607,6 +607,42 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertFalse(self.answer.correct) + def test_mcq_incorrect_answer(self): + # Given + mcq_answer = 'a' + self.answer = Answer(question=self.question2, + answer=mcq_answer, + ) + self.answer.save() + self.answerpaper.answers.add(self.answer) + + # When + json_data = None + result = self.answerpaper.validate_answer(mcq_answer, + self.question2, json_data + ) + + # Then + self.assertTrue(result['success']) + + def test_mcc_incorrect_answer(self): + # Given + mcc_answer = ['b'] + self.answer = Answer(question=self.question3, + answer=mcc_answer, + ) + self.answer.save() + self.answerpaper.answers.add(self.answer) + + # When + json_data = None + result = self.answerpaper.validate_answer(mcc_answer, + self.question3, json_data + ) + + # Then + self.assertFalse(result['success']) + def test_answerpaper(self): """ Test Answer Paper""" self.assertEqual(self.answerpaper.user.username, 'demo_user') |