diff options
author | maheshgudi | 2017-03-11 02:17:41 +0530 |
---|---|---|
committer | maheshgudi | 2017-03-11 03:03:28 +0530 |
commit | ac292ed1099b49f9d0e8a7ed3699bacdd8031de3 (patch) | |
tree | 0856b97e9bcf418b40103d7679169e657c817948 | |
parent | 6961ff1cf46d4b8591a4528a2c3fef156268eec5 (diff) | |
download | online_test-ac292ed1099b49f9d0e8a7ed3699bacdd8031de3.tar.gz online_test-ac292ed1099b49f9d0e8a7ed3699bacdd8031de3.tar.bz2 online_test-ac292ed1099b49f9d0e8a7ed3699bacdd8031de3.zip |
made minor template changes and fixed test_models
-rw-r--r-- | yaksh/models.py | 11 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 8 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 4 | ||||
-rw-r--r-- | yaksh/test_models.py | 18 |
4 files changed, 21 insertions, 20 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index a323994..d583f7b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1163,13 +1163,14 @@ class AnswerPaper(models.Model): result['success'] = True result['error'] = ['Correct answer'] else: - if testcase.correct.splitlines() == user_answer.splitlines(): + if testcase.correct.splitlines()\ + == user_answer.splitlines(): result['success'] = True result['error'] = ['Correct answer'] elif question.type == 'float': testcase = question.get_test_case() - if abs(testcase.correct-user_answer) <= testcase.error_margin: + if abs(testcase.correct - user_answer) <= testcase.error_margin: result['success'] = True result['error'] = ['Correct answer'] @@ -1353,6 +1354,6 @@ class FloatTestCase(TestCase): "error_margin":self.error_margin} def __str__(self): - return u'Testcase | Correct: {0} | Error Margin: +or- {1}'.format(self.correct, - self.error_margin - ) + return u'Testcase | Correct: {0} | Error Margin: +or- {1}'.format( + self.correct, self.error_margin + ) diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index 4818717..02ff70a 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -86,13 +86,9 @@ <div class="panel-body"><pre><code>{{ error }}</code></pre></div> </div> {% endfor %} - {% if error != "Incorrect answer" %} - <div class="panel-heading">Testcase No. {{ forloop.counter }}</div> - <div class="panel-body"><pre><code>{{ error }}</code></pre></div> - {% endif %} + </div> - {% endfor %} - </div> + {% endif %} {% endif %} </div> </div> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 93ed531..3f668cd 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -194,7 +194,7 @@ function call_skip(url) {% endif %} {% if question.type == "integer" %} - Enter Integer: + Enter Integer:<br/> <input name="answer" type="textbox" id="integer" /> <br/><br/> {% endif %} @@ -206,7 +206,7 @@ function call_skip(url) {% endif %} {% if question.type == "float" %} - Enter Decimal Value : + Enter Decimal Value :<br/> <input name="answer" type="textbox" id="float" /> <br/><br/> {% endif %} diff --git a/yaksh/test_models.py b/yaksh/test_models.py index f0bb310..e6e4f74 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -669,7 +669,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(current_question.summary, "Question1") # Test completed_question() method of Answer Paper - question = self.answerpaper.completed_question(self.question1.id) + question = self.answerpaper.add_completed_question(self.question1.id) self.assertEqual(self.answerpaper.questions_left(), 2) # Test next_question() method of Answer Paper @@ -684,7 +684,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertEqual(next_question_id.summary, "Question3") # Given, here question is already answered - current_question_id = 1 + current_question_id = self.question1.id # When next_question_id = self.answerpaper.next_question(current_question_id) @@ -702,10 +702,10 @@ class AnswerPaperTestCases(unittest.TestCase): # Then self.assertTrue(next_question_id is not None) - self.assertEqual(next_question_id.summary, "Question2") + self.assertEqual(next_question_id.summary, "Question1") # Given, last question in the list - current_question_id = 3 + current_question_id = self.question3.id # When next_question_id = self.answerpaper.next_question(current_question_id) @@ -713,7 +713,7 @@ class AnswerPaperTestCases(unittest.TestCase): # Then self.assertTrue(next_question_id is not None) - self.assertEqual(next_question_id.summary, "Question2") + self.assertEqual(next_question_id.summary, "Question1") # Test get_questions_answered() method # When @@ -734,14 +734,18 @@ class AnswerPaperTestCases(unittest.TestCase): # Test completed_question and next_question # When all questions are answered - current_question = self.answerpaper.completed_question(self.question2.id) + current_question = self.answerpaper.add_completed_question( + self.question2.id + ) # Then self.assertEqual(self.answerpaper.questions_left(), 1) self.assertEqual(current_question.summary, "Question3") # When - current_question = self.answerpaper.completed_question(self.question3.id) + current_question = self.answerpaper.add_completed_question( + self.question3.id + ) # Then self.assertEqual(self.answerpaper.questions_left(), 0) |