diff options
author | Prabhu Ramachandran | 2018-01-19 22:28:17 +0530 |
---|---|---|
committer | GitHub | 2018-01-19 22:28:17 +0530 |
commit | b78b5d0b46114caefca35e82c502d1f7598e8e59 (patch) | |
tree | a38164139a46eaad8696eaa12ef05f7f06f8358c /yaksh/test_views.py | |
parent | 0824e419c6aa52bb9b788db1208dc2b70c104d8f (diff) | |
parent | 1ab5018b89f6d566471eba26b1d206b1b142b8a0 (diff) | |
download | online_test-b78b5d0b46114caefca35e82c502d1f7598e8e59.tar.gz online_test-b78b5d0b46114caefca35e82c502d1f7598e8e59.tar.bz2 online_test-b78b5d0b46114caefca35e82c502d1f7598e8e59.zip |
Merge pull request #426 from adityacp/fix_lessons_redirect
Fix lessons related bug
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r-- | yaksh/test_views.py | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 0b43079..9be8d13 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -4604,6 +4604,7 @@ class TestLearningModule(TestCase): check_prerequisite=False, creator=self.user) self.course.teachers.add(self.teacher) self.course.learning_module.add(self.learning_module) + self.course.learning_module.add(self.learning_module1) self.expected_url = "/exam/manage/courses/all_learning_module/" @@ -4868,13 +4869,35 @@ class TestLearningModule(TestCase): self.assertEqual(response.context["current_unit"].id, self.learning_unit1.id) + # Go to next module with empty module + response = self.client.get( + reverse('yaksh:next_unit', + kwargs={"module_id": self.learning_module1.id, + "course_id": self.course.id}), + follow=True) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.context["state"], "module") + self.assertEqual(response.context["learning_module"].id, + self.learning_module.id) + + # Go to next module from last unit of previous unit + response = self.client.get( + reverse('yaksh:next_unit', + kwargs={"module_id": self.learning_module.id, + "course_id": self.course.id, + "current_unit_id": self.learning_unit1.id}), + follow=True) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.context["state"], "module") + self.assertEqual(response.context["learning_module"].id, + self.learning_module1.id) + class TestLessons(TestCase): def setUp(self): self.client = Client() self.mod_group = Group.objects.create(name='moderator') - tzone = pytz.timezone('UTC') # Create Moderator with profile self.user_plaintext_pass = 'demo' self.user = User.objects.create_user( @@ -4922,25 +4945,30 @@ class TestLessons(TestCase): name="Python Course", enrollment="Open Enrollment", creator=self.user) - self.quiz = Quiz.objects.create( - start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0, tzone), - end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzone), - duration=30, active=True, instructions="Demo Instructions", - attempts_allowed=-1, time_between_attempts=0, - description='demo quiz', pass_criteria=40, - creator=self.user - ) - self.lesson = Lesson.objects.create( name="test lesson", description="test description", creator=self.user) + self.lesson2 = Lesson.objects.create( + name="test lesson2", description="test description2", + creator=self.user) self.learning_unit = LearningUnit.objects.create( - order=0, type="lesson", lesson=self.lesson) + order=0, type="lesson", lesson=self.lesson + ) + self.learning_unit2 = LearningUnit.objects.create( + order=0, type="lesson", lesson=self.lesson2 + ) self.learning_module = LearningModule.objects.create( order=0, name="test module", description="module", - check_prerequisite=False, creator=self.user) + check_prerequisite=False, creator=self.user + ) + self.learning_module2 = LearningModule.objects.create( + order=1, name="test module 2", description="module 2", + check_prerequisite=True, creator=self.user + ) self.learning_module.learning_unit.add(self.learning_unit.id) - self.course.learning_module.add(self.learning_module.id) + self.learning_module2.learning_unit.add(self.learning_unit2.id) + self.course.learning_module.add(*[ + self.learning_module.id, self.learning_module2.id]) self.course.teachers.add(self.teacher.id) self.expected_url = "/exam/manage/courses/" @@ -4949,11 +4977,13 @@ class TestLessons(TestCase): self.user.delete() self.student.delete() self.teacher.delete() - self.quiz.delete() self.course.delete() self.learning_unit.delete() + self.learning_unit2.delete() self.learning_module.delete() + self.learning_module2.delete() self.lesson.delete() + self.lesson2.delete() def test_edit_lesson_denies_non_moderator(self): """ Student should not be allowed to edit lesson """ @@ -5038,6 +5068,17 @@ class TestLessons(TestCase): self.assertEqual(response.context["state"], "lesson") self.assertEqual(response.context["current_unit"], self.learning_unit) + # Check unit module prerequisite completion status + response = self.client.get( + reverse('yaksh:show_lesson', + kwargs={"lesson_id": self.lesson2.id, + "module_id": self.learning_module2.id, + "course_id": self.course.id})) + err_msg = "You have not completed the module previous to {0}".format( + self.learning_module2.name) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.context["msg"], err_msg) + def test_show_all_lessons(self): """ Moderator should be able to see all created lessons""" self.client.login( |