diff options
author | ankitjavalkar | 2019-02-05 12:14:32 +0530 |
---|---|---|
committer | ankitjavalkar | 2019-02-26 19:00:49 +0530 |
commit | 055dcaa679d50baab56b7e0c20b8de19a400d11c (patch) | |
tree | af218c3eac3f0305a826b5b4b87edc7c60fc47f0 /yaksh | |
parent | c70cf2a0fd8e51d4b689e08d78021cac848b0187 (diff) | |
download | online_test-055dcaa679d50baab56b7e0c20b8de19a400d11c.tar.gz online_test-055dcaa679d50baab56b7e0c20b8de19a400d11c.tar.bz2 online_test-055dcaa679d50baab56b7e0c20b8de19a400d11c.zip |
Multiple changes
- Fix failing test cases and make changes based on feedback
- Fix PEP8
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/test_views.py | 18 | ||||
-rw-r--r-- | yaksh/views.py | 9 |
2 files changed, 21 insertions, 6 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 274bcda..0af2a0c 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -420,10 +420,14 @@ class TestStudentDashboard(TestCase): response = self.client.get(reverse('yaksh:quizlist_user'), follow=True ) + courses_in_context = { + 'data': self.course, + 'completion_percentage': None, + } self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "yaksh/quizzes_user.html") self.assertEqual(response.context['title'], 'All Courses') - self.assertEqual(response.context['courses'][0], self.course) + self.assertEqual(response.context['courses'][0], courses_in_context) def test_student_dashboard_enrolled_courses_get(self): """ @@ -439,10 +443,14 @@ class TestStudentDashboard(TestCase): kwargs={'enrolled': "enrolled"}), follow=True ) + courses_in_context = { + 'data': self.course, + 'completion_percentage': 0, + } self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "yaksh/quizzes_user.html") self.assertEqual(response.context['title'], 'Enrolled Courses') - self.assertEqual(response.context['courses'][0], self.course) + self.assertEqual(response.context['courses'][0], courses_in_context) def test_student_dashboard_hidden_courses_post(self): """ @@ -456,10 +464,14 @@ class TestStudentDashboard(TestCase): response = self.client.post(reverse('yaksh:quizlist_user'), data={'course_code': 'hide'} ) + courses_in_context = { + 'data': self.hidden_course, + 'completion_percentage': None, + } self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "yaksh/quizzes_user.html") self.assertEqual(response.context['title'], 'Search') - self.assertEqual(response.context['courses'][0], self.hidden_course) + self.assertEqual(response.context['courses'][0], courses_in_context) class TestMonitor(TestCase): diff --git a/yaksh/views.py b/yaksh/views.py index 4c1b7f7..1ba9890 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -175,11 +175,14 @@ def quizlist_user(request, enrolled=None, msg=None): ).order_by('-id') title = 'All Courses' - for c in courses: - _percent = c.get_completion_percent(user) if user in c.students.all() else None + for course in courses: + if user in course.students.all(): + _percent = course.get_completion_percent(user) + else: + _percent = None courses_data.append( { - 'data': c, + 'data': course, 'completion_percentage': _percent, } ) |