summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
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):