summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2017-03-30 18:10:09 +0530
committerankitjavalkar2017-03-31 11:24:06 +0530
commit171a82aa3ef07fc9344c8c5b42542bec0a3ca5ab (patch)
tree5180d1920b1d936aeeadb3f07760d4d4db08e0d6 /yaksh/views.py
parent734ad94d177be8ad400eb6f97e98612ce099e56a (diff)
downloadonline_test-171a82aa3ef07fc9344c8c5b42542bec0a3ca5ab.tar.gz
online_test-171a82aa3ef07fc9344c8c5b42542bec0a3ca5ab.tar.bz2
online_test-171a82aa3ef07fc9344c8c5b42542bec0a3ca5ab.zip
Multiple changes to Course:
- Allow a start and end time for Course enrollment - Allow Course to be editable
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 2adc2c3..7208e82 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -614,10 +614,43 @@ def add_course(request):
@login_required
+def edit_course(request, course_id=None):
+ user = request.user
+ ci = RequestContext(request)
+ if course_id:
+ course = Course.objects.get(id=course_id)
+ else:
+ course = None
+
+ if not is_moderator(user):
+ raise Http404('You are not allowed to view this page')
+ if request.method == 'POST':
+ form = CourseForm(request.POST, instance=course)
+ 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(instance=course)
+ return my_render_to_response('yaksh/add_course.html', {'form': form},
+ context_instance=ci)
+
+
+@login_required
def enroll_request(request, course_id):
user = request.user
ci = RequestContext(request)
course = get_object_or_404(Course, pk=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)
+
course.request(user)
if is_moderator(user):
return my_redirect('/exam/manage/')
@@ -676,6 +709,11 @@ def enroll(request, course_id, user_id=None, was_rejected=False):
raise Http404('You are not allowed to view this page')
course = get_object_or_404(Course, pk=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)
+
if not course.is_creator(user) and not course.is_teacher(user):
raise Http404('This course does not belong to you')