diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/evaluator_tests/test_simple_question_types.py | 38 | ||||
-rw-r--r-- | yaksh/forms.py | 2 | ||||
-rw-r--r-- | yaksh/models.py | 12 | ||||
-rw-r--r-- | yaksh/static/yaksh/js/add_question.js | 17 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_question.html | 1 | ||||
-rw-r--r-- | yaksh/templates/yaksh/design_questionpaper.html | 8 |
6 files changed, 33 insertions, 45 deletions
diff --git a/yaksh/evaluator_tests/test_simple_question_types.py b/yaksh/evaluator_tests/test_simple_question_types.py index 2d991a7..cbf2abd 100644 --- a/yaksh/evaluator_tests/test_simple_question_types.py +++ b/yaksh/evaluator_tests/test_simple_question_types.py @@ -485,7 +485,6 @@ class FloatQuestionTestCases(unittest.TestCase): self.assertTrue(details[0]) self.assertEqual(self.answer.marks, 1) self.assertTrue(self.answer.correct) - class MCQQuestionTestCases(unittest.TestCase): @classmethod def setUpClass(self): @@ -493,13 +492,15 @@ class MCQQuestionTestCases(unittest.TestCase): self.user = User.objects.get(username='demo_user_100') self.user2 = User.objects.get(username='demo_user_101') self.user_ip = '127.0.0.1' - + #Creating Course self.course = Course.objects.get(name="Python Course 100") # Creating Quiz self.quiz = Quiz.objects.get(description="demo quiz 100") # Creating Question paper self.question_paper = QuestionPaper.objects.get(quiz=self.quiz) + self.question_paper.shuffle_testcases = True + self.question_paper.save() #Creating Question self.question1 = Question.objects.create(summary='mcq1', points=1, type='code', user=self.user, @@ -508,7 +509,6 @@ class MCQQuestionTestCases(unittest.TestCase): self.question1.type = "mcq" self.question1.test_case_type = 'Mcqtestcase' self.question1.description = 'Which option is Correct?' - self.question1.shuffle_testcases = True self.question1.save() # For questions @@ -518,21 +518,21 @@ class MCQQuestionTestCases(unittest.TestCase): type='mcqtestcase', ) self.mcq_based_testcase_1.save() - + self.mcq_based_testcase_2 = McqTestCase(question=self.question1, options="Incorrect", correct=False, type='mcqtestcase', ) self.mcq_based_testcase_2.save() - + self.mcq_based_testcase_3 = McqTestCase(question=self.question1, options="Incorrect", correct=False, type='mcqtestcase', ) self.mcq_based_testcase_3.save() - + self.mcq_based_testcase_4 = McqTestCase(question=self.question1, options="Incorrect", correct=False, @@ -544,7 +544,7 @@ class MCQQuestionTestCases(unittest.TestCase): self.answerpaper = self.question_paper.make_answerpaper( user=self.user, ip=self.user_ip, - attempt_num=1, + attempt_num=1, course_id=self.course.id ) @@ -554,24 +554,16 @@ class MCQQuestionTestCases(unittest.TestCase): attempt_num=1, course_id=self.course.id ) - self.answerpaper3 = AnswerPaper.objects.create( - user=self.user, - question_paper=self.question_paper, - course=self.course, - attempt_number=self.answerpaper.attempt_number+1, - start_time=timezone.now(), - end_time=timezone.now()+timedelta(minutes=5), - user_ip="127.0.0.1" - ) - @classmethod def tearDownClass(self): self.question1.delete() + self.answerpaper.delete() + self.answerpaper2.delete() def test_shuffle_test_cases(self): # Given - # Answerpaper for user 1 # When + user_testcase = self.question1.get_ordered_test_cases( self.answerpaper ) @@ -580,10 +572,18 @@ class MCQQuestionTestCases(unittest.TestCase): self.answerpaper2 ) order2 = [tc.id for tc in user2_testcase] + self.question_paper.shuffle_testcases = False + self.question_paper.save() + answerpaper3 = self.question_paper.make_answerpaper( + user=self.user2, ip=self.user_ip, + attempt_num=self.answerpaper.attempt_number+1, + course_id=self.course.id + ) not_ordered_testcase = self.question1.get_ordered_test_cases( - self.answerpaper3 + answerpaper3 ) get_test_cases = self.question1.get_test_cases() # Then self.assertNotEqual(order1, order2) self.assertEqual(get_test_cases, not_ordered_testcase) + answerpaper3.delete() diff --git a/yaksh/forms.py b/yaksh/forms.py index 258a1ee..e53eda3 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -308,7 +308,7 @@ class UploadFileForm(forms.Form): class QuestionPaperForm(forms.ModelForm): class Meta: model = QuestionPaper - fields = ['shuffle_questions'] + fields = ['shuffle_questions', 'shuffle_testcases'] class LessonForm(forms.ModelForm): diff --git a/yaksh/models.py b/yaksh/models.py index 0bb1e66..8e0bb4d 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -818,10 +818,6 @@ class Question(models.Model): #Solution for the question. solution = models.TextField(blank=True) - # Shuffle testcase order. - shuffle_testcases = models.BooleanField("Shuffle testcase for each user", - default=False - ) def consolidate_answer_data(self, user_answer, user=None): question_data = {} @@ -1151,6 +1147,11 @@ class QuestionPaper(models.Model): # Sequence or Order of fixed questions fixed_question_order = models.CharField(max_length=255, blank=True) + # Shuffle testcase order. + shuffle_testcases = models.BooleanField("Shuffle testcase for each user", + default=True + ) + objects = QuestionPaperManager() def get_question_bank(self): @@ -1218,7 +1219,8 @@ class QuestionPaper(models.Model): for question in questions: question_ids.append(str(question.id)) testcases = question.get_test_cases() - if question.shuffle_testcases: + if self.shuffle_testcases and \ + question.type in ["mcq", "mcc"]: random.shuffle(testcases) testcases_ids = ",".join([str(tc.id) for tc in testcases]) testcases_order = TestCaseOrder.objects.create( diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js index 579904b..0f02aab 100644 --- a/yaksh/static/yaksh/js/add_question.js +++ b/yaksh/static/yaksh/js/add_question.js @@ -143,23 +143,6 @@ function textareaformat() $("#id_grade_assignment_upload").prop("disabled", true); } }); - - if (document.getElementById('id_shuffle_testcases').checked || - question_type == "mcc" || question_type == "mcq"){ - $("#id_shuffle_testcases").prop("disabled", false); - } - else{ - $("#id_shuffle_testcases").prop("disabled", true); - } - - $('#id_type').change(function() { - if ($(this).val() == "mcc" || $(this).val() == "mcq"){ - $("#id_shuffle_testcases").prop("disabled", false); - } - else{ - $("#id_shuffle_testcases").prop("disabled", true); - } - }); } function autosubmit() diff --git a/yaksh/templates/yaksh/add_question.html b/yaksh/templates/yaksh/add_question.html index b02487c..ed69657 100644 --- a/yaksh/templates/yaksh/add_question.html +++ b/yaksh/templates/yaksh/add_question.html @@ -29,7 +29,6 @@ <tr><td>Snippet: <td>{{ qform.snippet }} <tr><td>Minimum Time(in minutes):<td> {{ qform.min_time }} <tr><td>Partial Grading: <td>{{ qform.partial_grading }} - <tr><td>Shuffle Testcases: <td> {{ qform.shuffle_testcases }} <tr><td>Grade Assignment Upload:<td> {{ qform.grade_assignment_upload }} <tr><td> File: <td> {{ fileform.file_field }}{{ fileform.file_field.errors }} {% if uploaded_files %}<br><b>Uploaded files:</b><br>Check on delete to delete files, diff --git a/yaksh/templates/yaksh/design_questionpaper.html b/yaksh/templates/yaksh/design_questionpaper.html index 1656e2b..d982d27 100644 --- a/yaksh/templates/yaksh/design_questionpaper.html +++ b/yaksh/templates/yaksh/design_questionpaper.html @@ -192,10 +192,14 @@ select <div class="tab-pane" id="finish"> <center> - <h5>Almost finished creating your question paper</h5> + <h5><u>Almost finished creating your question paper</u></h5> <label style="float: none;"> {{ qpaper_form.shuffle_questions }} - <span>Auto shuffle.</span> + <span>Shuffle questions' order for each student</span> + </label> <br><br> + <label style="float: none;"> + {{ qpaper_form.shuffle_testcases }} + <span>Shuffle MCQ/MCC options for each student</span> </label> <br><br> <input class ="btn primary large" type="submit" name="save" id="save" value="Save question paper"> <br> |