From 66ee0552653ee139491d5166d20f8bce7a5c835a Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 18 Nov 2016 16:24:45 +0530 Subject: Render output errors properly in grade user --- yaksh/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 6e1744c..4fd6967 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1027,9 +1027,9 @@ class AnswerPaper(models.Model): for answer in self.answers.all(): question = answer.question if question in q_a: - q_a[question].append(answer) + q_a[question].append((answer, [e for e in json.loads(answer.error)])) else: - q_a[question] = [answer] + q_a[question] = [(answer, [e for e in json.loads(answer.error)])] return q_a def get_questions(self): -- cgit From a88197040b69a556f9c7b0432350b9d1d4aad06f Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 21 Dec 2016 18:09:49 +0530 Subject: Fix rendering and representation of errors - Error are sent as list - Error are None if answer is fully correct - Error is rendered as in grade user and code questions as neat CSS divs - Fix corresponding test cases - Fix get_question answers in models.py --- yaksh/models.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 4fd6967..378d7a1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1155,9 +1155,7 @@ class StandardTestCase(TestCase): "weight": self.weight} def __str__(self): - return u'Question: {0} | Test Case: {1}'.format(self.question, - self.test_case - ) + return u'Standard TestCase | Test Case: {0}'.format(self.test_case) class StdIOBasedTestCase(TestCase): @@ -1172,7 +1170,7 @@ class StdIOBasedTestCase(TestCase): "weight": self.weight} def __str__(self): - return u'Question: {0} | Exp. Output: {1} | Exp. Input: {2}'.format(self.question, + return u'StdIO Based Testcase | Exp. Output: {0} | Exp. Input: {1}'.format( self.expected_output, self.expected_input ) @@ -1185,9 +1183,7 @@ class McqTestCase(TestCase): return {"test_case_type": "mcqtestcase", "options": self.options, "correct": self.correct} def __str__(self): - return u'Question: {0} | Correct: {1}'.format(self.question, - self.correct - ) + return u'MCQ Testcase | Correct: {0}'.format(self.correct) class HookTestCase(TestCase): -- cgit From 42ed7c142e2c4ff4dccdaec2365e22d30bc276dd Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 22 Dec 2016 15:55:54 +0530 Subject: Refactor check method for cleaner code and fixing multiple issues - Question should skip to new question with new error rendering - Fix test cases Fix change_dir context manager in grader --- yaksh/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 378d7a1..08feab6 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1064,20 +1064,20 @@ class AnswerPaper(models.Model): For code questions success is True only if the answer is correct. """ - result = {'success': True, 'error': 'Incorrect answer', 'weight': 0.0} + result = {'success': True, 'error': ['Incorrect answer'], 'weight': 0.0} correct = False if user_answer is not None: if question.type == 'mcq': expected_answer = question.get_test_case(correct=True).options if user_answer.strip() == expected_answer.strip(): correct = True - result['error'] = 'Correct answer' + result['error'] = ['Correct answer'] elif question.type == 'mcc': expected_answers = [] for opt in question.get_test_cases(correct=True): expected_answers.append(opt.options) if set(user_answer) == set(expected_answers): - result['error'] = 'Correct answer' + result['error'] = ['Correct answer'] correct = True elif question.type == 'code': user_dir = self.user.profile.get_user_dir() -- cgit From 0e56fc6a77ec21db05c9bafb42b1acc652354a32 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 22 Dec 2016 20:16:00 +0530 Subject: - Fix grade user rendering issue when question is skipped - Modify grade user html template to create readable variables for answer and error --- yaksh/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 08feab6..35999d3 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1027,9 +1027,15 @@ class AnswerPaper(models.Model): for answer in self.answers.all(): question = answer.question if question in q_a: - q_a[question].append((answer, [e for e in json.loads(answer.error)])) + q_a[question].append({'answer': answer, + 'error_list': [e for e in json.loads(answer.error)] + } + ) else: - q_a[question] = [(answer, [e for e in json.loads(answer.error)])] + q_a[question] = [{'answer': answer, + 'error_list': [e for e in json.loads(answer.error)] + } + ] return q_a def get_questions(self): -- cgit