From 059034c0ec77d130eeb55af62c456773c2a64b2a Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 11 Jan 2017 18:18:06 +0530 Subject: changed mcq to single correct choice --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 2d84622..4292cc0 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -36,7 +36,7 @@ languages = ( ) question_types = ( - ("mcq", "Multiple Choice"), + ("mcq", "Single Correct Choice"), ("mcc", "Multiple Correct Choices"), ("code", "Code"), ("upload", "Assignment Upload"), -- cgit From 4ef5f9377c27a3e88ae3a1a4e2a446984fc14b70 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 26 Jan 2017 01:43:47 +0530 Subject: added integer based question type --- yaksh/models.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'yaksh/models.py') 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) -- cgit From ddf3e13669f7232acf6019a0f2f33f397a6e6d51 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Mon, 30 Jan 2017 16:20:18 +0530 Subject: added string based questions. --- yaksh/models.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 81b8d7f..6381d4b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -41,6 +41,7 @@ question_types = ( ("code", "Code"), ("upload", "Assignment Upload"), ("integer", "Answer in Integer"), + ("string", "Answer in String"), ) enrollment_methods = ( @@ -54,6 +55,12 @@ test_case_types = ( ("mcqtestcase", "MCQ Testcase"), ("hooktestcase", "Hook Testcase"), ("integertestcase", "Integer Testcase"), + ("stringtestcase", "String Testcase"), + ) + +string_check_type = ( + ("lower", "Lower case Checking"), + ("exact", "Exact case String Checking"), ) attempts = [(i, i) for i in range(1, 6)] @@ -1135,11 +1142,24 @@ 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 == 'string': + testcase = question.get_test_case() + if testcase.string_check == "lower": + if testcase.correct.lower() == user_answer.lower(): + result['success'] = True + result['error'] = ['Correct answer'] + else: + if testcase.correct == 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( @@ -1289,10 +1309,22 @@ class HookTestCase(TestCase): return u'Hook Testcase | Correct: {0}'.format(self.hook_code) class IntegerTestCase(TestCase): - correct = models.IntegerField(default=False) + correct = models.IntegerField(default=None) 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) + + +class StringTestCase(TestCase): + correct = models.TextField(default=None) + string_check = models.CharField(max_length=200,choices=string_check_type) + + def get_field_value(self): + return {"test_case_type": "stringtestcase", "correct": self.correct, + "string_check":self.string_check} + + def __str__(self): + return u'String Testcase | Correct: {0}'.format(self.correct) -- cgit From 321343d45bc1f4d20cd348773bd8b214d9c4d692 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Fri, 3 Feb 2017 23:42:30 +0530 Subject: added float based questions --- yaksh/models.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 6381d4b..12c4a1c 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -42,6 +42,7 @@ question_types = ( ("upload", "Assignment Upload"), ("integer", "Answer in Integer"), ("string", "Answer in String"), + ("float", "Answer in Decimal"), ) enrollment_methods = ( @@ -56,6 +57,7 @@ test_case_types = ( ("hooktestcase", "Hook Testcase"), ("integertestcase", "Integer Testcase"), ("stringtestcase", "String Testcase"), + ("floattestcase", "Float Testcase"), ) string_check_type = ( @@ -1160,6 +1162,14 @@ class AnswerPaper(models.Model): result['success'] = True result['error'] = ['Correct answer'] + elif question.type == 'float': + testcase = question.get_test_case() + if testcase.correct-testcase.error_margin\ + <= float(user_answer)\ + <= testcase.correct+testcase.error_margin: + 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( @@ -1328,3 +1338,18 @@ class StringTestCase(TestCase): def __str__(self): return u'String Testcase | Correct: {0}'.format(self.correct) + + +class FloatTestCase(TestCase): + correct = models.FloatField(default=None) + error_margin = models.FloatField(default=0.0, null=True, blank=True, + help_text="Margin of error") + + def get_field_value(self): + return {"test_case_type": "floattestcase", "correct": self.correct, + "error_margin":self.error_margin} + + def __str__(self): + return u'Testcase | Correct: {0} | Error Margin: +or- {1}'.format(self.correct, + self.error_margin + ) \ No newline at end of file -- cgit From 23018fa38afcdfec93f1338bd783a769a0fe91e7 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 8 Feb 2017 17:48:55 +0530 Subject: changed string check names --- yaksh/models.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 12c4a1c..665805e 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -42,7 +42,7 @@ question_types = ( ("upload", "Assignment Upload"), ("integer", "Answer in Integer"), ("string", "Answer in String"), - ("float", "Answer in Decimal"), + ("float", "Answer in Float"), ) enrollment_methods = ( @@ -61,8 +61,8 @@ test_case_types = ( ) string_check_type = ( - ("lower", "Lower case Checking"), - ("exact", "Exact case String Checking"), + ("lower", "Case Insensitive"), + ("exact", "Case Sensitive"), ) attempts = [(i, i) for i in range(1, 6)] @@ -1154,19 +1154,17 @@ class AnswerPaper(models.Model): elif question.type == 'string': testcase = question.get_test_case() if testcase.string_check == "lower": - if testcase.correct.lower() == user_answer.lower(): + if testcase.correct.lower().splitlines() == user_answer.lower().splitlines(): result['success'] = True result['error'] = ['Correct answer'] else: - if testcase.correct == user_answer: + if testcase.correct.splitlines() == user_answer.splitlines(): result['success'] = True result['error'] = ['Correct answer'] elif question.type == 'float': testcase = question.get_test_case() - if testcase.correct-testcase.error_margin\ - <= float(user_answer)\ - <= testcase.correct+testcase.error_margin: + if abs(testcase.correct-user_answer) <= testcase.error_margin: result['success'] = True result['error'] = ['Correct answer'] -- cgit From a7a54b43f36571adc5bb999f454fe57e1dcb5c0f Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 9 Feb 2017 00:48:34 +0530 Subject: added test cases for float,integer and string type questions --- yaksh/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 665805e..a356ec1 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1350,4 +1350,4 @@ class FloatTestCase(TestCase): def __str__(self): return u'Testcase | Correct: {0} | Error Margin: +or- {1}'.format(self.correct, self.error_margin - ) \ No newline at end of file + ) -- cgit From 211c12eb1c2002945e228e0f33cd45d494df74ff Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 2 Mar 2017 20:33:34 +0530 Subject: removed pk/id based querying in test cases --- yaksh/models.py | 1 - 1 file changed, 1 deletion(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index a356ec1..d60a377 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -683,7 +683,6 @@ class QuestionPaper(models.Model): # Total marks for the question paper. total_marks = models.FloatField(default=0.0, blank=True) - objects = QuestionPaperManager() def update_total_marks(self): -- cgit From 1c5e1dfef3fb4af8bc070fe190cec552ef3732b0 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Thu, 9 Mar 2017 01:18:51 +0530 Subject: pep8 changes in models and user_data --- yaksh/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index d60a377..fdf10bd 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1153,7 +1153,8 @@ class AnswerPaper(models.Model): elif question.type == 'string': testcase = question.get_test_case() if testcase.string_check == "lower": - if testcase.correct.lower().splitlines() == user_answer.lower().splitlines(): + if testcase.correct.lower().splitlines()\ + == user_answer.lower().splitlines(): result['success'] = True result['error'] = ['Correct answer'] else: @@ -1164,8 +1165,8 @@ class AnswerPaper(models.Model): elif question.type == 'float': testcase = question.get_test_case() if abs(testcase.correct-user_answer) <= testcase.error_margin: - result['success'] = True - result['error'] = ['Correct answer'] + result['success'] = True + result['error'] = ['Correct answer'] elif question.type == 'code': user_dir = self.user.profile.get_user_dir() -- cgit From ac292ed1099b49f9d0e8a7ed3699bacdd8031de3 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Sat, 11 Mar 2017 02:17:41 +0530 Subject: made minor template changes and fixed test_models --- yaksh/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') 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 + ) -- cgit