summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2017-03-16 17:15:38 +0530
committeradityacp2017-03-16 17:15:38 +0530
commit69ab40cc3d4d769d0d3f1c783f950cac52f7935e (patch)
tree267e343f6cafbaa77b86515ea9b2e1418cf3c7c3 /yaksh/models.py
parenteb3afa3b86ca7a129c9d1365e0ae7946b0c25d32 (diff)
downloadonline_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.tar.gz
online_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.tar.bz2
online_test-69ab40cc3d4d769d0d3f1c783f950cac52f7935e.zip
Fix test cases for loading questions
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index dc015d5..c10f953 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -318,18 +318,17 @@ class Question(models.Model):
file_names = question.pop('files')
test_cases = question.pop('testcase')
que, result = Question.objects.get_or_create(**question)
- if not result:
- if file_names:
- que._add_files_to_db(file_names, file_path)
- for test_case in test_cases:
- test_case_type = test_case.pop('test_case_type')
- model_class = get_model_class(test_case_type)
- new_test_case, obj_create_status = \
- model_class.objects.get_or_create(
- question=que, **test_case
- )
- new_test_case.type = test_case_type
- new_test_case.save()
+ if file_names:
+ que._add_files_to_db(file_names, file_path)
+ for test_case in test_cases:
+ test_case_type = test_case.pop('test_case_type')
+ model_class = get_model_class(test_case_type)
+ new_test_case, obj_create_status = \
+ model_class.objects.get_or_create(
+ question=que, **test_case
+ )
+ new_test_case.type = test_case_type
+ new_test_case.save()
if files_list:
delete_files(files_list, file_path)