summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorankitjavalkar2016-05-02 11:14:26 +0530
committerankitjavalkar2016-05-05 19:21:34 +0530
commitb40b668bcecd01b3c7f9f16b87775770ba06a33a (patch)
treeac600f7abf789745913b791e1f73d6bc9790560e /yaksh
parent34fb6b71ce5fcbd9a5537b305504cadaeb86d9a3 (diff)
downloadonline_test-b40b668bcecd01b3c7f9f16b87775770ba06a33a.tar.gz
online_test-b40b668bcecd01b3c7f9f16b87775770ba06a33a.tar.bz2
online_test-b40b668bcecd01b3c7f9f16b87775770ba06a33a.zip
- Fix redirections after saving Question
- Rename Cancel button to 'Back to QUestions' in Add Questions page
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/templates/yaksh/add_question.html2
-rw-r--r--yaksh/views.py27
2 files changed, 15 insertions, 14 deletions
diff --git a/yaksh/templates/yaksh/add_question.html b/yaksh/templates/yaksh/add_question.html
index bba8db2..bc700d1 100644
--- a/yaksh/templates/yaksh/add_question.html
+++ b/yaksh/templates/yaksh/add_question.html
@@ -45,7 +45,7 @@
</table></center>
<center>
<button class="btn" type="submit" name="save_question">Save</button>
- <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Cancel</button>
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Back to Questions</button>
</center>
</form>
{% endblock %}
diff --git a/yaksh/views.py b/yaksh/views.py
index 9492166..59a51aa 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -154,12 +154,12 @@ def add_question(request):
question_form = QuestionForm(request.POST)
if question_form.is_valid():
new_question = question_form.save()
- tags = question_form['tags'].data.split(',')
- for i in range(0, len(tags)):
- tag = tags[i].strip()
- new_question.tags.add(tag)
- new_question.save()
- return my_redirect("/exam/manage/questions")
+ # tags = question_form['tags'].data.split(',')
+ # for i in range(0, len(tags)):
+ # tag = tags[i].strip()
+ # new_question.tags.add(tag)
+ # new_question.save()
+ return my_redirect("/exam/manage/addquestion/{0}".format(new_question.id))
else:
return my_render_to_response('yaksh/add_question.html',
{'form': question_form},
@@ -185,20 +185,21 @@ def edit_question(request, question_id=None):
question_form = QuestionForm(request.POST, instance=question_instance)
if question_form.is_valid():
new_question = question_form.save(commit=False)
- tags = question_form['tags'].data.split(',')
- for i in range(0, len(tags)):
- tag = tags[i].strip()
- new_question.tags.add(tag)
+ # tags = question_form['tags'].data.split(',')
+ # for i in range(0, len(tags)):
+ # tag = tags[i].strip()
+ # new_question.tags.add(tag)
# new_question.save()
test_case_type = question_form.cleaned_data.get('test_case_type')
test_case_form_class = get_object_form(model=test_case_type, exclude_fields=['question'])
test_case_model_class = get_model_class(test_case_type)
- TestCaseInlineFormSet = inlineformset_factory(Question, test_case_model_class, form=test_case_form_class)
+ TestCaseInlineFormSet = inlineformset_factory(Question, test_case_model_class, form=test_case_form_class, extra=1)
test_case_formset = TestCaseInlineFormSet(request.POST, request.FILES, instance=new_question)
if test_case_formset.is_valid():
new_question.save()
test_case_formset.save()
- return my_redirect("/exam/manage/questions")
+ # return my_redirect("/exam/manage/questions")
+ return my_redirect("/exam/manage/addquestion/{0}".format(new_question.id))
else:
return my_render_to_response('yaksh/add_question.html',
{'form': question_form,
@@ -210,7 +211,7 @@ def edit_question(request, question_id=None):
test_case_type = question_instance.test_case_type
test_case_form_class = get_object_form(model=test_case_type, exclude_fields=['question'])
test_case_model_class = get_model_class(test_case_type)
- TestCaseInlineFormSet = inlineformset_factory(Question, test_case_model_class, form=test_case_form_class)
+ TestCaseInlineFormSet = inlineformset_factory(Question, test_case_model_class, form=test_case_form_class, extra=1)
test_case_formset = TestCaseInlineFormSet(instance=question_instance)
return my_render_to_response('yaksh/add_question.html',