summaryrefslogtreecommitdiff
path: root/exam/management/commands
diff options
context:
space:
mode:
Diffstat (limited to 'exam/management/commands')
-rw-r--r--exam/management/commands/dump_user_data.py12
-rw-r--r--exam/management/commands/load_questions_xml.py14
2 files changed, 19 insertions, 7 deletions
diff --git a/exam/management/commands/dump_user_data.py b/exam/management/commands/dump_user_data.py
index f081565..6e0ca2a 100644
--- a/exam/management/commands/dump_user_data.py
+++ b/exam/management/commands/dump_user_data.py
@@ -34,12 +34,20 @@ Answers
-------
{% for question, answers in paper.get_question_answers.items %}
Question: {{ question.id }}. {{ question.summary }} (Points: {{ question.points }})
+{% if question.type == "mcq" %}\
+###############################################################################
+Choices: {% for option in question.options.strip.splitlines %} {{option}}, {% endfor %}
+Student answer: {{ answers.0|safe }}
+{% else %}{# non-mcq questions #}\
{% for answer in answers %}\
###############################################################################
-{{ answer.answer|safe }}
+{{ answer.answer.strip|safe }}
# Autocheck: {{ answer.error|safe }}
-# Marks: {{ answer.marks }}
{% endfor %}{# for answer in answers #}\
+{% endif %}\
+{% with answers|last as answer %}\
+Marks: {{answer.marks}}
+{% endwith %}\
{% endfor %}{# for question, answers ... #}\
Teacher comments
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()