summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py1
-rw-r--r--yaksh/models.py12
-rw-r--r--yaksh/test_models.py8
3 files changed, 11 insertions, 10 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index da64dc4..fdc1c35 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -61,7 +61,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
result = evaluator.evaluate(**kwargs)
# Then
- print repr(result.get('error'))
self.assertFalse(result.get('success'))
self.assertEqual(result.get('error'),
('AssertionError in: assert(add(1,2)==3)\n'
diff --git a/yaksh/models.py b/yaksh/models.py
index e7a96c9..33c3b42 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -941,14 +941,10 @@ class AnswerPaper(models.Model):
def _update_marks_obtained(self):
"""Updates the total marks earned by student for this paper."""
- # marks = sum([x.marks for x in self.answers.filter(marks__gt=0.0)])
- # if not marks:
- # self.marks_obtained = 0
- # else:
- # self.marks_obtained = marks
marks = 0
for question in self.questions.all():
- max_marks = max([a.marks for a in self.answers.filter(question=question)])
+ marks_list = [a.marks for a in self.answers.filter(question=question)]
+ max_marks = max(marks_list) if marks_list else 0.0
marks += max_marks
self.marks_obtained = marks
@@ -1128,10 +1124,12 @@ class StandardTestCase(TestCase):
class StdioBasedTestCase(TestCase):
expected_input = models.TextField(blank=True)
expected_output = models.TextField()
+ marks = models.FloatField(default=0.0)
def get_field_value(self):
return {"expected_output": self.expected_output,
- "expected_input": self.expected_input}
+ "expected_input": self.expected_input,
+ "marks": self.marks}
def __str__(self):
return u'Question: {0} | Exp. Output: {1} | Exp. Input: {2}'.format(self.question,
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 019a339..50d39c1 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -141,7 +141,9 @@ class QuestionTestCases(unittest.TestCase):
)
self.upload_test_case.save()
self.user_answer = "demo_answer"
- self.test_case_upload_data = [{"test_case": "assert fact(3)==6"}]
+ self.test_case_upload_data = [{"test_case": "assert fact(3)==6",
+ "marks": 0.0
+ }]
questions_data = [{"snippet": "def fact()", "active": True,
"points": 1.0,
"description": "factorial of a no",
@@ -877,7 +879,9 @@ class TestCaseTestCases(unittest.TestCase):
self.stdout_based_testcase.save()
answer_data = {"user_answer": "demo_answer",
"test_case_data": [
- {"test_case": "assert myfunc(12, 13) == 15"}
+ {"test_case": "assert myfunc(12, 13) == 15",
+ "marks": 0.0
+ }
]
}
self.answer_data_json = json.dumps(answer_data)