diff options
author | maheshgudi | 2017-01-26 01:43:47 +0530 |
---|---|---|
committer | maheshgudi | 2017-03-02 20:38:41 +0530 |
commit | 4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70 (patch) | |
tree | 8cad540dcd71b83b7b308feb9a3d87cc1f7e1128 /yaksh/models.py | |
parent | 059034c0ec77d130eeb55af62c456773c2a64b2a (diff) | |
download | online_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.tar.gz online_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.tar.bz2 online_test-4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70.zip |
added integer based question type
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 4292cc0..81b8d7f 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -40,6 +40,7 @@ question_types = ( ("mcc", "Multiple Correct Choices"), ("code", "Code"), ("upload", "Assignment Upload"), + ("integer", "Answer in Integer"), ) enrollment_methods = ( @@ -52,6 +53,7 @@ test_case_types = ( ("stdiobasedtestcase", "StdIO Based Testcase"), ("mcqtestcase", "MCQ Testcase"), ("hooktestcase", "Hook Testcase"), + ("integertestcase", "Integer Testcase"), ) attempts = [(i, i) for i in range(1, 6)] @@ -1133,6 +1135,11 @@ class AnswerPaper(models.Model): if set(user_answer) == set(expected_answers): result['success'] = True result['error'] = ['Correct answer'] + elif question.type == 'integer': + expected_answer = question.get_test_case().correct + if expected_answer == int(user_answer): + result['success'] = True + result['error'] = ['Correct answer'] elif question.type == 'code': user_dir = self.user.profile.get_user_dir() json_result = code_server.run_code( @@ -1280,3 +1287,12 @@ class HookTestCase(TestCase): def __str__(self): return u'Hook Testcase | Correct: {0}'.format(self.hook_code) + +class IntegerTestCase(TestCase): + correct = models.IntegerField(default=False) + + def get_field_value(self): + return {"test_case_type": "integertestcase", "correct": self.correct} + + def __str__(self): + return u'Integer Testcase | Correct: {0}'.format(self.correct) |