diff options
author | adityacp | 2018-02-27 15:41:08 +0530 |
---|---|---|
committer | adityacp | 2018-02-27 15:41:08 +0530 |
commit | 0ae21e437775b056d346311bd9f50220e5d9fb28 (patch) | |
tree | d1b1ff94bbb85c89f54c942c0403d6041db05a3b /yaksh | |
parent | 333859a8c1ab57e70ea57e92a22eaac6a1a1c0ac (diff) | |
download | online_test-0ae21e437775b056d346311bd9f50220e5d9fb28.tar.gz online_test-0ae21e437775b056d346311bd9f50220e5d9fb28.tar.bz2 online_test-0ae21e437775b056d346311bd9f50220e5d9fb28.zip |
Change in models.py, views.py, urls.py, test_views.py, courses.html
- Allow only deep cloning of a course
- Remove tests for shallow course clone
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 10 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 9 | ||||
-rw-r--r-- | yaksh/test_views.py | 32 | ||||
-rw-r--r-- | yaksh/urls.py | 2 | ||||
-rw-r--r-- | yaksh/views.py | 12 |
5 files changed, 10 insertions, 55 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 252bde6..7aa5f83 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -613,16 +613,6 @@ class Course(models.Model): return new_course def create_duplicate_course(self, user): - learning_modules = self.learning_module.all() - - new_course_name = "Copy Of {0}".format(self.name) - new_course = self._create_duplicate_instance(user, new_course_name) - - new_course.learning_module.add(*learning_modules) - - return new_course - - def create_shallow_copy(self, user): learning_modules = self.learning_module.order_by("order") copy_course_name = "Copy Of {0}".format(self.name) new_course = self._create_duplicate_instance(user, copy_course_name) diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index b19f094..78d21bf 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -133,12 +133,7 @@ </li> <br> <li> - <a class="test" href="{{URL_ROOT}}/exam/manage/duplicate_course/shallow/{{ course.id }}/" data-toggle="tooltip" title="Creates a new copy and link modules of selected course to the copy" data-placement="top"> - Copy Course</a> - </li> - <br> - <li> - <a class="test" href="{{URL_ROOT}}/exam/manage/duplicate_course/deep/{{ course.id }}/" data-toggle="tooltip" title="Creates Copy of selected Course as well as its Modules, Lessons/Quizzes" data-placement="top"> + <a class="test" href="{{URL_ROOT}}/exam/manage/duplicate_course/{{ course.id }}/" data-toggle="tooltip" title="Creates Copy of selected Course as well as its Modules, Lessons/Quizzes" data-placement="top"> Clone Course</a> </li> </ul> @@ -274,7 +269,7 @@ </li> <br> <li> - <a class="test" href="{{URL_ROOT}}/exam/manage/duplicate_course/deep/{{ course.id }}/" data-toggle="tooltip" title="Creates Copy of selected Course as well as its Modules, Lessons/Quizzes" data-placement="top"> + <a class="test" href="{{URL_ROOT}}/exam/manage/duplicate_course/{{ course.id }}/" data-toggle="tooltip" title="Creates Copy of selected Course as well as its Modules, Lessons/Quizzes" data-placement="top"> Clone Course</a> </li> </ul> diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 8695479..faac617 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -1870,8 +1870,7 @@ class TestCourses(TestCase): response = self.client.get( reverse('yaksh:duplicate_course', - kwargs={"course_id": self.user2_course.id, - "copy_type": "shallow"}), + kwargs={"course_id": self.user2_course.id}), follow=True ) self.assertEqual(response.status_code, 404) @@ -1885,8 +1884,7 @@ class TestCourses(TestCase): # Denies teacher not added in the course response = self.client.get( reverse('yaksh:duplicate_course', - kwargs={"course_id": self.user2_course.id, - "copy_type": "shallow"}), + kwargs={"course_id": self.user2_course.id}), follow=True ) err_msg = "You do not have permissions" @@ -1894,29 +1892,6 @@ class TestCourses(TestCase): self.assertTemplateUsed(response, "yaksh/complete.html") self.assertIn(err_msg, response.context['message']) - # Moderator/Course creator login - self.client.login( - username=self.user2.username, - password=self.user2_plaintext_pass - ) - - # Allows creator to duplicate the course - response = self.client.get( - reverse('yaksh:duplicate_course', - kwargs={"course_id": self.user2_course.id, - "copy_type": "shallow"}), - follow=True - ) - - self.assertEqual(response.status_code, 200) - courses = Course.objects.filter( - creator=self.user2).order_by("id") - self.assertEqual(courses.count(), 2) - self.assertEqual(courses.last().creator, self.user2) - self.assertEqual(courses.last().name, "Copy Of Java Course") - self.assertEqual(courses.last().get_learning_modules()[0].id, - self.user2_course.get_learning_modules()[0].id) - # Test clone/duplicate courses and create copies of modules and units # Teacher Login @@ -1936,8 +1911,7 @@ class TestCourses(TestCase): ) response = self.client.get( reverse('yaksh:duplicate_course', - kwargs={"course_id": self.user1_course.id, - "copy_type": "deep"}), + kwargs={"course_id": self.user1_course.id}), follow=True ) diff --git a/yaksh/urls.py b/yaksh/urls.py index 473a854..b81c7b2 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -86,7 +86,7 @@ urlpatterns = [ views.show_statistics, name="show_statistics"), url(r'^manage/download_quiz_csv/(?P<course_id>\d+)/(?P<quiz_id>\d+)/$', views.download_quiz_csv, name="download_quiz_csv"), - url(r'^manage/duplicate_course/(?P<copy_type>shallow|deep)/(?P<course_id>\d+)/$', + url(r'^manage/duplicate_course/(?P<course_id>\d+)/$', views.duplicate_course, name='duplicate_course'), url(r'manage/courses/$', views.courses, name='courses'), url(r'manage/add_course/$', views.add_course, name='add_course'), diff --git a/yaksh/views.py b/yaksh/views.py index b4b0c76..ce11558 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2246,20 +2246,16 @@ def download_sample_csv(request): @login_required @email_verified -def duplicate_course(request, copy_type, course_id): +def duplicate_course(request, course_id): user = request.user course = Course.objects.get(id=course_id) if not is_moderator(user): raise Http404('You are not allowed to view this page!') if course.is_teacher(user) or course.is_creator(user): - if copy_type == "shallow": - # Link all the modules from current course to copied course - course.create_duplicate_course(user) - else: - # Create new entries of modules, lessons/quizzes - # from current course to copied course - course.create_shallow_copy(user) + # Create new entries of modules, lessons/quizzes + # from current course to copied course + course.create_duplicate_course(user) else: msg = dedent( '''\ |