summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2017-10-17 12:14:40 +0530
committermaheshgudi2017-10-17 12:14:40 +0530
commit774b184347c0460117356ccae85acd9b2dc45b3d (patch)
treedc2d7a944bf0ec4a4003b454e936bd4af4c475af /yaksh
parent964506a34c92f2c8b0c6a926bd9615fa9cfa36c0 (diff)
downloadonline_test-774b184347c0460117356ccae85acd9b2dc45b3d.tar.gz
online_test-774b184347c0460117356ccae85acd9b2dc45b3d.tar.bz2
online_test-774b184347c0460117356ccae85acd9b2dc45b3d.zip
Yaml fields are sorted according to relevance
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 4c15fce..39a2a7a 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -504,8 +504,20 @@ class Question(models.Model):
tmp_file_path = tempfile.mkdtemp()
yaml_path = os.path.join(tmp_file_path, "questions_dump.yaml")
for elem in q_dict:
- sorted_dict = CommentedMap(sorted(elem.items(), key=lambda x:x[0]))
- yaml_block = dict_to_yaml(sorted_dict)
+ relevant_dict = CommentedMap()
+ irrelevant_dict = CommentedMap()
+ relevant_dict['summary'] = elem.pop('summary')
+ relevant_dict['type'] = elem.pop('type')
+ relevant_dict['language'] = elem.pop('language')
+ relevant_dict['description'] = elem.pop('description')
+ relevant_dict['points'] = elem.pop('points')
+ relevant_dict['testcase'] = elem.pop('testcase')
+ relevant_dict.update(CommentedMap(sorted(elem.items(),
+ key=lambda x:x[0]
+ ))
+ )
+
+ yaml_block = dict_to_yaml(relevant_dict)
with open(yaml_path, "a") as yaml_file:
yaml_file.write(yaml_block)
zip_file.write(yaml_path, os.path.basename(yaml_path))