summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-11-10 17:51:03 +0530
committerGitHub2017-11-10 17:51:03 +0530
commit1aeb0997affaf8d6da3cdceee2d3ba8df59c4083 (patch)
tree7fca2a2ade81633308d00346b75707730d346a82 /yaksh
parent96f8e0af5b39338741c758de918e32e02b95f0c8 (diff)
parent716fb091d3472d5d696d4994aa4f9f4d99a0626e (diff)
downloadonline_test-1aeb0997affaf8d6da3cdceee2d3ba8df59c4083.tar.gz
online_test-1aeb0997affaf8d6da3cdceee2d3ba8df59c4083.tar.bz2
online_test-1aeb0997affaf8d6da3cdceee2d3ba8df59c4083.zip
Merge pull request #384 from ankitjavalkar/fix-extra-field-testcase
Prepopulate the test case type field when adding test cases to questions
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/views.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 0ba3270..df002a4 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -254,12 +254,19 @@ def add_question(request, question_id=None):
formsets = []
for testcase in TestCase.__subclasses__():
if test_case_type == testcase.__name__.lower():
- formset = inlineformset_factory(Question, testcase, extra=1,
- fields='__all__')
+ formset = inlineformset_factory(
+ Question, testcase, extra=1, fields='__all__'
+ )
else:
- formset = inlineformset_factory(Question, testcase, extra=0,
- fields='__all__')
- formsets.append(formset(instance=question))
+ formset = inlineformset_factory(
+ Question, testcase, extra=0, fields='__all__'
+ )
+ formsets.append(
+ formset(
+ instance=question,
+ initial=[{'type': test_case_type}]
+ )
+ )
context = {'qform': qform, 'fileform': fileform, 'question': question,
'formsets': formsets, 'uploaded_files': uploaded_files}
return my_render_to_response(