diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 8 | ||||
-rw-r--r-- | yaksh/test_models.py | 6 | ||||
-rw-r--r-- | yaksh/test_views.py | 2 | ||||
-rw-r--r-- | yaksh/urls.py | 2 | ||||
-rw-r--r-- | yaksh/views.py | 31 |
6 files changed, 16 insertions, 37 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index a0eee71..f7f7a10 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -276,8 +276,8 @@ class CourseForm(forms.ModelForm): class Meta: model = Course - fields = ['name', 'active', 'enrollment', - 'start_enroll_time', 'end_enroll_time', 'instructions'] + exclude = ['creator', 'requests', 'students', 'rejected', + 'created_on', 'is_trial', 'teachers'] class ProfileForm(forms.ModelForm): diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 075d5aa..c304e1a 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -78,11 +78,9 @@ </div> </div> <br/> - <div class="btn-group" role="group" aria-label="..."> - <a class="btn btn-success" href="{{URL_ROOT}}/exam/manage/addquiz/{{course.id}}/">Add New Quiz</a> - <a class="btn btn-primary"href="{{URL_ROOT}}/exam/manage/edit_course/{{course.id}}">Edit Course</a> - <a class="btn btn-default"href="{{URL_ROOT}}/exam/manage/courses/download_course_csv/{{course.id}}">Download CSV</a> - </div> + <a class="btn btn-success" href="{{URL_ROOT}}/exam/manage/addquiz/{{course.id}}/">Add New Quiz</a> + <a class="btn btn-primary"href="{{URL_ROOT}}/exam/manage/edit_course/{{course.id}}">Edit Course</a> + <a class="btn btn-default"href="{{URL_ROOT}}/exam/manage/courses/download_course_csv/{{course.id}}">Download CSV</a> </div> </div> <br><br> diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 7e14ce7..dbd367b 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -843,7 +843,7 @@ class CourseTestCases(unittest.TestCase): self.quiz1 = Quiz.objects.get(description='demo quiz 1') self.quiz2 = Quiz.objects.get(description='demo quiz 2') - # create courses with + # create courses with disabled enrollment self.enroll_request_course = Course.objects.create( name="Enrollment Request Course With Enrollment Disabled", enrollment="Enroll Request", @@ -949,6 +949,10 @@ class CourseTestCases(unittest.TestCase): self.assertIn(self.creator, trial_course.students.all()) self.assertTrue(trial_course.is_trial) + def test_enabled_enrollment_for_course(self): + """Test to check enrollment is closed for open course""" + self.assertTrue(self.course.is_active_enrollment()) + def test_disabled_enrollment_for_open_course(self): """Test to check enrollment is closed for open course""" self.assertFalse(self.open_course.is_active_enrollment()) diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 4e262dc..3fcdde2 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -1131,7 +1131,7 @@ class TestEnrollRequest(TestCase): ), follow=True ) - self.assertRedirects(response, '/exam/manage/') + self.assertRedirects(response, '/exam/manage/courses/') class TestViewAnswerPaper(TestCase): diff --git a/yaksh/urls.py b/yaksh/urls.py index 05d167e..00b34e4 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -56,7 +56,7 @@ urlpatterns = [ views.download_csv), url(r'manage/courses/$', views.courses, name='courses'), url(r'manage/add_course/$', views.add_course, name='add_course'), - url(r'manage/edit_course/(?P<course_id>\d+)$', views.edit_course, name='edit_course'), + url(r'manage/edit_course/(?P<course_id>\d+)$', views.add_course, name='edit_course'), url(r'manage/course_detail/(?P<course_id>\d+)/$', views.course_detail, name='course_detail'), url(r'manage/enroll/(?P<course_id>\d+)/(?P<user_id>\d+)/$', views.enroll), url(r'manage/enroll/rejected/(?P<course_id>\d+)/(?P<user_id>\d+)/$', diff --git a/yaksh/views.py b/yaksh/views.py index 7208e82..275cb6f 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -591,30 +591,7 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None): @login_required -def add_course(request): - user = request.user - ci = RequestContext(request) - if not is_moderator(user): - raise Http404('You are not allowed to view this page') - if request.method == 'POST': - form = CourseForm(request.POST) - if form.is_valid(): - new_course = form.save(commit=False) - new_course.creator = user - new_course.save() - return my_redirect('/exam/manage/') - else: - return my_render_to_response('yaksh/add_course.html', - {'form': form}, - context_instance=ci) - else: - form = CourseForm() - return my_render_to_response('yaksh/add_course.html', {'form': form}, - context_instance=ci) - - -@login_required -def edit_course(request, course_id=None): +def add_course(request, course_id=None): user = request.user ci = RequestContext(request) if course_id: @@ -649,11 +626,11 @@ def enroll_request(request, course_id): if not course.is_active_enrollment: msg = 'Enrollment for this course has been closed, please contact your '\ 'instructor/administrator.' - return complete(request, msg, attempt_num, questionpaper_id=None) + return complete(request, msg, attempt_num=None, questionpaper_id=None) course.request(user) if is_moderator(user): - return my_redirect('/exam/manage/') + return my_redirect('/exam/manage/courses') else: return my_redirect('/exam/quizzes/') @@ -712,7 +689,7 @@ def enroll(request, course_id, user_id=None, was_rejected=False): if not course.is_active_enrollment: msg = 'Enrollment for this course has been closed, please contact your '\ 'instructor/administrator.' - return complete(request, msg, attempt_num, questionpaper_id=None) + return complete(request, msg, attempt_num=None, questionpaper_id=None) if not course.is_creator(user) and not course.is_teacher(user): raise Http404('This course does not belong to you') |