diff options
author | ankitjavalkar | 2017-11-09 17:45:16 +0530 |
---|---|---|
committer | ankitjavalkar | 2017-11-09 17:45:16 +0530 |
commit | 716fb091d3472d5d696d4994aa4f9f4d99a0626e (patch) | |
tree | c70789f51efe7bfc129b2d41b66ff105813efe1f | |
parent | e65b605e59c1384ad9607c99484107929248f220 (diff) | |
download | online_test-716fb091d3472d5d696d4994aa4f9f4d99a0626e.tar.gz online_test-716fb091d3472d5d696d4994aa4f9f4d99a0626e.tar.bz2 online_test-716fb091d3472d5d696d4994aa4f9f4d99a0626e.zip |
Prepopulate the test case type field when adding test cases to questions
-rw-r--r-- | yaksh/views.py | 17 |
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( |