summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorprathamesh2017-01-04 15:54:19 +0530
committerprathamesh2017-01-04 15:54:19 +0530
commit241ca3c2b8ab1b1824813833237435153e08b0e9 (patch)
tree624c6bb07dfe239c2773f93a6da4ca20376d1c73 /yaksh/views.py
parent43f2313d75e24a8c11855fb9718e48c1c06fb26f (diff)
downloadonline_test-241ca3c2b8ab1b1824813833237435153e08b0e9.tar.gz
online_test-241ca3c2b8ab1b1824813833237435153e08b0e9.tar.bz2
online_test-241ca3c2b8ab1b1824813833237435153e08b0e9.zip
Student UI modification.
Added side navigation bar. Edit and view Profile base template set properly. Added a tab "Enrolled Courses" for students to only view the courses they are enrolled in.
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 7ecf6aa..257a383 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -105,18 +105,16 @@ def user_register(request):
@login_required
-def quizlist_user(request):
+def quizlist_user(request, enrolled=None):
"""Show All Quizzes that is available to logged-in user."""
user = request.user
- avail_quizzes = Quiz.objects.get_active_quizzes()
- user_answerpapers = AnswerPaper.objects.filter(user=user)
- courses = Course.objects.filter(active=True, is_trial=False)
-
- context = { 'quizzes': avail_quizzes,
- 'user': user,
- 'courses': courses,
- 'quizzes_taken': user_answerpapers,
- }
+ if enrolled is not None:
+ courses = user.students.all()
+ title = 'Enrolled Courses'
+ else:
+ courses = Course.objects.filter(active=True, is_trial=False)
+ title = 'All Courses'
+ context = {'user': user, 'courses': courses, 'title': title}
return my_render_to_response("yaksh/quizzes_user.html", context)
@@ -1065,10 +1063,14 @@ def view_profile(request):
""" view moderators and users profile """
user = request.user
ci = RequestContext(request)
-
- context = {}
+ if is_moderator(user):
+ template = 'manage.html'
+ else:
+ template = 'user.html'
+ context = {'template': template}
if has_profile(user):
- return my_render_to_response('yaksh/view_profile.html', {'user':user})
+ context['user'] = user
+ return my_render_to_response('yaksh/view_profile.html', context)
else:
form = ProfileForm(user=user)
msg = True
@@ -1082,10 +1084,13 @@ def view_profile(request):
def edit_profile(request):
""" edit profile details facility for moderator and students """
- context = {}
user = request.user
ci = RequestContext(request)
-
+ if is_moderator(user):
+ template = 'manage.html'
+ else:
+ template = 'user.html'
+ context = {'template': template}
if has_profile(user):
profile = Profile.objects.get(user_id=user.id)
else: