summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2016-04-01 11:18:04 +0530
committerankitjavalkar2016-05-05 19:16:26 +0530
commitf120f5763904589d3c18b6cc0f4e227bcaef9a0a (patch)
treef129657e1b767c9f5cc6a61d583d5aec46e8334b /yaksh/views.py
parent0b5a48f0ba4c4510c0026101ab84e19099691635 (diff)
downloadonline_test-f120f5763904589d3c18b6cc0f4e227bcaef9a0a.tar.gz
online_test-f120f5763904589d3c18b6cc0f4e227bcaef9a0a.tar.bz2
online_test-f120f5763904589d3c18b6cc0f4e227bcaef9a0a.zip
Add testcase addition templates, views and forms
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py44
1 files changed, 25 insertions, 19 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 2faf127..c7fdc7f 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -217,26 +217,32 @@ def add_question(request, question_id=None):
# 'formset': test_case_formset},
context_instance=ci)
-# @login_required
-# def add_testcase(request, question_id=None):
-# """To add new test case for a question"""
-
-# ci = RequestContext(request)
-# if not question_id:
-# raise Http404('No Question Found')
-# question = Question.objects.get(id=question_id)
-# initial = {'question': question}
-
-# # if question.test
-
-# if request.method == "POST":
-# pass
-# else:
-# form = TestCaseForm(user=user)
-# return my_render_to_response('yaksh/add_testcase.html',
-# {'form': form},
-# context_instance=ci)
+@login_required
+def add_testcase(request, question_id=None):
+ """To add new test case for a question"""
+
+ ci = RequestContext(request)
+ if not question_id:
+ raise Http404('No Question Found')
+ question = Question.objects.get(id=question_id)
+ initial = {'question': question}
+
+ test_case_type = question.test_case_type
+
+ if test_case_type == "standardtestcase":
+ from yaksh.forms import StandardTestCaseForm
+ if request.method == "POST":
+ form = StandardTestCaseForm(request.POST)
+ initial = {'question': question}
+ form = StandardTestCaseForm(initial)
+ if request.method == "POST":
+ if form.is_valid():
+ form.save()
+ else:
+ return my_render_to_response('yaksh/add_testcase.html',
+ {'form': form},
+ context_instance=ci)
@login_required
def add_quiz(request, quiz_id=None):