summaryrefslogtreecommitdiff
path: root/exam/management/commands/load_questions_xml.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2011-11-25 18:48:13 +0530
committerPrabhu Ramachandran2011-11-25 18:48:13 +0530
commitfdc531b561565345847812f409ee44af0a784e82 (patch)
tree447b297d28dccb700dcd244404e6cd748191890d /exam/management/commands/load_questions_xml.py
parentb4023e17d6f97e51ffde740c17d19630b5a9c2d1 (diff)
downloadonline_test-fdc531b561565345847812f409ee44af0a784e82.tar.gz
online_test-fdc531b561565345847812f409ee44af0a784e82.tar.bz2
online_test-fdc531b561565345847812f409ee44af0a784e82.zip
ENH: Adding support for Multiple Choice Questions
Adds simple support for multiple choice questions that are also auto-checked. Many fixes to the templates and useful feature additions. This changes the database.
Diffstat (limited to 'exam/management/commands/load_questions_xml.py')
-rw-r--r--exam/management/commands/load_questions_xml.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/exam/management/commands/load_questions_xml.py b/exam/management/commands/load_questions_xml.py
index b4151ae..8bc2701 100644
--- a/exam/management/commands/load_questions_xml.py
+++ b/exam/management/commands/load_questions_xml.py
@@ -35,20 +35,24 @@ def load_questions_xml(filename):
desc_node = question.getElementsByTagName("description")[0]
description = (desc_node.childNodes[0].data).strip()
- lang_node = question.getElementsByTagName("language")[0]
- language = (lang_node.childNodes[0].data).strip()
+ type_node = question.getElementsByTagName("type")[0]
+ type = (type_node.childNodes[0].data).strip()
points_node = question.getElementsByTagName("points")[0]
- points = int((points_node.childNodes[0].data).strip()) \
- if points_node else 1
+ points = float((points_node.childNodes[0].data).strip()) \
+ if points_node else 1.0
test_node = question.getElementsByTagName("test")[0]
test = decode_html((test_node.childNodes[0].data).strip())
+ opt_node = question.getElementsByTagName("options")[0]
+ opt = decode_html((opt_node.childNodes[0].data).strip())
+
new_question = Question(summary=summary,
description=description,
points=points,
- language=language,
+ options=opt,
+ type=type,
test=test)
new_question.save()