diff options
author | maheshgudi | 2016-09-06 12:44:49 +0530 |
---|---|---|
committer | maheshgudi | 2016-09-06 12:47:26 +0530 |
commit | 848f7945811f1d16bdf8d5e2a99d157d9ed9a18c (patch) | |
tree | 5d106375e3f8613f1afc14caf0ebf51ddd4dab2b /yaksh/views.py | |
parent | 01e08dd15b59ce353043d541c9be81592cda3fe0 (diff) | |
download | online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.tar.gz online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.tar.bz2 online_test-848f7945811f1d16bdf8d5e2a99d157d9ed9a18c.zip |
added 'add new quiz' button to each course
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 1abf248..0fb2214 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -246,7 +246,7 @@ def edit_question(request, question_id=None): context_instance=ci) @login_required -def add_quiz(request, quiz_id=None): +def add_quiz(request, course_id, quiz_id=None): """To add a new quiz in the database. Create a new quiz and store it.""" user = request.user @@ -256,23 +256,29 @@ def add_quiz(request, quiz_id=None): context = {} if request.method == "POST": if quiz_id is None: - form = QuizForm(request.POST, user=user) + form = QuizForm(request.POST, user=user, course=course_id) if form.is_valid(): form.save() return my_redirect(reverse('yaksh:design_questionpaper')) + 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, instance=quiz) + form = QuizForm(request.POST, user=user, course=course_id, + instance=quiz) if form.is_valid(): form.save() context["quiz_id"] = quiz_id return my_redirect("/exam/manage/") else: if quiz_id is None: - form = QuizForm(user=user) + form = QuizForm(course=course_id, user=user) else: quiz = Quiz.objects.get(id=quiz_id) - form = QuizForm(user=user, instance=quiz) + 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', |