summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2017-10-17 12:48:51 +0530
committerankitjavalkar2018-03-06 11:37:18 +0530
commit91fa9c6a40e16f43d935db9641b6833605afc1e8 (patch)
tree0bfcdf7653127cc4161e56c93c5458ba782b1a59 /yaksh/views.py
parent438f8657021981fc7b2e5adbacc13eb332a2e6d3 (diff)
downloadonline_test-91fa9c6a40e16f43d935db9641b6833605afc1e8.tar.gz
online_test-91fa9c6a40e16f43d935db9641b6833605afc1e8.tar.bz2
online_test-91fa9c6a40e16f43d935db9641b6833605afc1e8.zip
Add a view to preview and download questionpapers
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 011b417..0dab227 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -9,6 +9,7 @@ from django.core.urlresolvers import reverse
from django.contrib.auth import login, logout, authenticate
from django.shortcuts import render_to_response, get_object_or_404, redirect
from django.template import RequestContext, Context, Template
+from django.template.loader import get_template, render_to_string
from django.http import Http404
from django.db.models import Sum, Max, Q, F
from django.views.decorators.csrf import csrf_exempt
@@ -2744,3 +2745,20 @@ def _update_unit_status(course_id, user, unit):
# make next available unit as current unit
course_status.current_unit = unit
course_status.save()
+
+
+@login_required
+@email_verified
+def download_questionpaper(request, questionpaper_id):
+ user = request.user
+ if not is_moderator(user):
+ raise Http404('You are not allowed to view this page!')
+ paper = QuestionPaper.objects.get(id=questionpaper_id)
+ context = {
+ 'questions': paper._get_questions_for_answerpaper(),
+ 'paper': paper,
+ }
+
+ return my_render_to_response(
+ 'yaksh/download_questionpaper.html', context
+ )