summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authoradityacp2018-03-22 12:36:45 +0530
committeradityacp2018-03-22 12:36:45 +0530
commit30be89eef46a248fe6f7ff26a923593ea8371fb1 (patch)
tree7af1afd0a403e4c71579f9afe830c482e59c3add /yaksh/views.py
parente1c1d0d0d6ae170d3ce9966b98ec6d03ff35c062 (diff)
parent4b356aa2f6097cd0f46292218f31ded18b631e53 (diff)
downloadonline_test-30be89eef46a248fe6f7ff26a923593ea8371fb1.tar.gz
online_test-30be89eef46a248fe6f7ff26a923593ea8371fb1.tar.bz2
online_test-30be89eef46a248fe6f7ff26a923593ea8371fb1.zip
Resolve conflicts and update to latest changes
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 356c66e..268e15f 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
@@ -390,8 +391,8 @@ def prof_manage(request, msg=None):
return my_redirect('/exam/login')
if not is_moderator(user):
return my_redirect('/exam/')
- courses = Course.objects.filter(creator=user, is_trial=False)
-
+ courses = Course.objects.filter(Q(creator=user) | Q(teachers=user),
+ is_trial=False)
trial_paper = AnswerPaper.objects.filter(
user=user, question_paper__quiz__is_trial=True,
course__is_trial=True
@@ -410,6 +411,7 @@ def prof_manage(request, msg=None):
qpaper.quiz.delete()
else:
answerpaper.delete()
+
context = {'user': user, 'courses': courses,
'trial_paper': trial_paper, 'msg': msg
}
@@ -616,7 +618,10 @@ def show_question(request, question, paper, error_message=None, notification=Non
if question.type == "code" else
'You have already attempted this question'
)
- test_cases = question.get_test_cases()
+ if question.type in ['mcc', 'mcq']:
+ test_cases = question.get_ordered_test_cases(paper)
+ else:
+ test_cases = question.get_test_cases()
files = FileUpload.objects.filter(question_id=question.id, hide=False)
course = Course.objects.get(id=course_id)
module = course.learning_module.get(id=module_id)
@@ -1886,7 +1891,7 @@ def create_demo_course(request):
user = request.user
ci = RequestContext(request)
if not is_moderator(user):
- raise("You are not allowed to view this page")
+ raise Http404("You are not allowed to view this page")
demo_course = Course()
success = demo_course.create_demo(user)
if success:
@@ -2269,10 +2274,15 @@ def duplicate_course(request, course_id):
raise Http404('You are not allowed to view this page!')
if course.is_teacher(user) or course.is_creator(user):
+ # Create new entries of modules, lessons/quizzes
+ # from current course to copied course
course.create_duplicate_course(user)
else:
- msg = 'You do not have permissions to clone this course, please contact your '\
- 'instructor/administrator.'
+ msg = dedent(
+ '''\
+ You do not have permissions to clone {0} course, please contact
+ your instructor/administrator.'''.format(course.name)
+ )
return complete(request, msg, attempt_num=None, questionpaper_id=None)
return my_redirect('/exam/manage/courses/')
@@ -2767,3 +2777,22 @@ 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 preview_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)
+ if not paper.quiz.creator == user:
+ raise Http404('This questionpaper does not belong to you')
+ context = {
+ 'questions': paper._get_questions_for_answerpaper(),
+ 'paper': paper,
+ }
+
+ return my_render_to_response(
+ 'yaksh/preview_questionpaper.html', context
+ )