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