diff options
author | prathamesh | 2020-09-08 02:49:24 +0530 |
---|---|---|
committer | prathamesh | 2020-09-08 02:49:24 +0530 |
commit | 44b64f9ad0f0618d15ee99026a33df14937d3ef4 (patch) | |
tree | 97b40b2f4f4dc04cc81c42e965331477d6bc2c46 /yaksh/test_models.py | |
parent | 9569e3ef6bbaeb8b36ad78c272006a538e044894 (diff) | |
download | online_test-44b64f9ad0f0618d15ee99026a33df14937d3ef4.tar.gz online_test-44b64f9ad0f0618d15ee99026a33df14937d3ef4.tar.bz2 online_test-44b64f9ad0f0618d15ee99026a33df14937d3ef4.zip |
Provide additional attempt to a selected student or extend time.
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r-- | yaksh/test_models.py | 141 |
1 files changed, 139 insertions, 2 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index a77c8bf..e24a38e 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -5,7 +5,7 @@ from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\ StdIOBasedTestCase, FileUpload, McqTestCase, AssignmentUpload,\ LearningModule, LearningUnit, Lesson, LessonFile, CourseStatus, \ - create_group, legend_display_types, Post, Comment + create_group, legend_display_types, Post, Comment, MicroManager from yaksh.code_server import ( ServerPool, get_result as get_result_from_code_server ) @@ -103,7 +103,8 @@ def setUpModule(): course.save() LessonFile.objects.create(lesson=lesson) CourseStatus.objects.create(course=course, user=course_user) - + MicroManager.objects.create(manager=user, course=course, quiz=quiz, + student=course_user) def tearDownModule(): User.objects.all().delete() @@ -116,6 +117,7 @@ def tearDownModule(): LearningUnit.objects.all().delete() LearningModule.objects.all().delete() AnswerPaper.objects.all().delete() + MicroManager.objects.all().delete() Group.objects.all().delete() @@ -129,6 +131,141 @@ class GlobalMethodsTestCases(unittest.TestCase): ############################################################################### +class MicroManagerTestCase(unittest.TestCase): + def setUp(self): + self.micromanager = MicroManager.objects.first() + self.course = self.micromanager.course + quiz = self.micromanager.quiz + self.questionpaper = QuestionPaper.objects.create(quiz=quiz) + question = Question.objects.get(summary='Q1') + self.questionpaper.fixed_questions.add(question) + self.questionpaper.update_total_marks() + self.student = User.objects.get(username='course_user') + + def tearDown(self): + self.questionpaper.delete() + + def test_micromanager(self): + # Given + user = User.objects.get(username='creator') + course = Course.objects.get(name='Python Course', creator=user) + quiz = Quiz.objects.get(description='demo quiz 1') + student = User.objects.get(username='course_user') + + # When + micromanager = MicroManager.objects.first() + + # Then + self.assertIsNotNone(micromanager) + self.assertEqual(micromanager.manager, user) + self.assertEqual(micromanager.student, student) + self.assertEqual(micromanager.course, course) + self.assertEqual(micromanager.quiz, quiz) + self.assertFalse(micromanager.special_attempt) + self.assertEqual(micromanager.attempts_permitted, 0) + self.assertEqual(micromanager.attempts_utilised, 0) + self.assertEqual(micromanager.wait_time, 0) + self.assertEqual(micromanager.attempt_valid_for, 90) + self.assertEqual(user.micromanaging.first(), micromanager) + self.assertEqual(student.micromanaged.first(), micromanager) + + def test_set_wait_time(self): + # Given + micromanager = self.micromanager + + # When + micromanager.set_wait_time(days=2) + + # Then + self.assertEqual(micromanager.wait_time, 2) + + def self_increment_attempts_permitted(self): + # Given + micromanager = self.micromanager + + # When + micromanager.increment_attempts_permitted() + + # Then + self.assertEqual(micromanager.attempts_permitted, 1) + + def test_update_permitted_time(self): + # Given + micromanager = self.micromanager + permit_time = timezone.now() + + # When + micromanager.update_permitted_time(permit_time) + + # Then + self.assertEqual(micromanager.permitted_time, permit_time) + + def test_has_student_attempts_exhausted(self): + # Given + micromanager = self.micromanager + + # Then + self.assertFalse(micromanager.has_student_attempts_exhausted()) + + def test_has_quiz_time_exhausted(self): + # Given + micromanager = self.micromanager + + # Then + self.assertFalse(micromanager.has_quiz_time_exhausted()) + + def test_is_special_attempt_required(self): + # Given + micromanager = self.micromanager + attempt = 1 + ip = '127.0.0.1' + + # Then + self.assertFalse(micromanager.is_special_attempt_required()) + + # When + answerpaper = self.questionpaper.make_answerpaper(self.student, ip, + attempt, + self.course.id) + answerpaper.update_marks(state='completed') + + # Then + self.assertTrue(micromanager.is_special_attempt_required()) + + answerpaper.delete() + + def test_allow_special_attempt(self): + # Given + micromanager = self.micromanager + + # When + micromanager.allow_special_attempt() + + # Then + self.assertFalse(micromanager.special_attempt) + + def test_has_special_attempt(self): + # Given + micromanager = self.micromanager + + # Then + self.assertFalse(micromanager.has_special_attempt()) + + def test_is_attempt_time_valid(self): + # Given + micromanager = self.micromanager + + # Then + self.assertTrue(micromanager.is_attempt_time_valid()) + + def test_can_student_attempt(self): + # Given + micromanager = self.micromanager + + # Then + self.assertFalse(micromanager.can_student_attempt()) + + class LessonTestCases(unittest.TestCase): def setUp(self): self.lesson = Lesson.objects.get(name='L1') |