summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-08-24 11:15:57 +0530
committerGitHub2017-08-24 11:15:57 +0530
commit9dedf409a1da3c801d82a6a77d3f48f66e25264e (patch)
tree86ef943c5dc9d9beb6204e0ba07cd10fe1e887b1 /yaksh/views.py
parent13b087846f66f450ad1ed12fd534ae2b30cddbcf (diff)
parentc277c1f742d8d984fc7ab066cd3ac513e83f0d89 (diff)
downloadonline_test-9dedf409a1da3c801d82a6a77d3f48f66e25264e.tar.gz
online_test-9dedf409a1da3c801d82a6a77d3f48f66e25264e.tar.bz2
online_test-9dedf409a1da3c801d82a6a77d3f48f66e25264e.zip
Merge pull request #300 from ankitjavalkar/validate-quiz-prerequisite
Validate quiz prerequisite field
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index db45a89..7f907aa 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -256,30 +256,24 @@ def add_quiz(request, course_id, quiz_id=None):
if form.is_valid():
form.save()
return my_redirect("/exam/manage/courses/")
- else:
- context["form"] = form
- return my_render_to_response('yaksh/add_quiz.html',
- context,
- context_instance=ci)
+
else:
quiz = Quiz.objects.get(id=quiz_id)
form = QuizForm(request.POST, user=user, course=course_id,
- instance=quiz)
+ instance=quiz
+ )
if form.is_valid():
form.save()
- context["quiz_id"] = quiz_id
return my_redirect("/exam/manage/courses/")
+
else:
- if quiz_id is None:
- form = QuizForm(course=course_id, user=user)
- else:
- quiz = Quiz.objects.get(id=quiz_id)
- form = QuizForm(user=user,course=course_id, instance=quiz)
- context["quiz_id"] = quiz_id
- context["form"] = form
- return my_render_to_response('yaksh/add_quiz.html',
- context,
- context_instance=ci)
+ quiz = Quiz.objects.get(id=quiz_id) if quiz_id else None
+ form = QuizForm(user=user,course=course_id, instance=quiz)
+ context["quiz_id"] = quiz_id
+ context["form"] = form
+ return my_render_to_response('yaksh/add_quiz.html',
+ context,
+ context_instance=ci)
@login_required
@email_verified