Commit ff029120 by dragonfi

Add question header and question to answer block

parent ea841fb8
......@@ -53,9 +53,24 @@ class AnswerBlock(LightChild):
default=None, scope=Scope.content)
min_characters = Integer(help="Minimum number of characters allowed for the answer",
default=0, scope=Scope.content)
question = String(help="Question to ask the student", scope=Scope.content, default="")
weight = Float(help="Defines the maximum total grade of the light child block.",
default=1, scope=Scope.content, enforce_type=True)
@classmethod
def init_block_from_node(cls, block, node, attr):
block.light_children = []
for child_id, xml_child in enumerate(node):
if xml_child.tag == 'question':
block.question = xml_child.text
else:
cls.add_node_as_child(block, xml_child, child_id)
for name, value in attr:
setattr(block, name, value)
return block
@lazy
def student_input(self):
"""
......
<div class="xblock-answer" data-completed="{{ self.completed }}">
<h3 class="question-title">QUESTION {{ self.index }}</h3>
<p>{{ self.question }}</p>
<textarea
class="answer editable" cols="50" rows="10" name="input"
data-min_characters="{{ self.min_characters }}"
......
<div class="xblock-answer" data-completed="{{ self.completed }}">
<h3 class="question-title">QUESTION {{ self.index }}</h3>
<p>{{ self.question }}</p>
<blockquote class="answer read_only">
{{ self.student_input|linebreaksbr }}
</blockquote>
......
......@@ -5,10 +5,12 @@
</shared-header>
<html>
<p>What is your goal?</p>
<p>Please answer the questions below.</p>
</html>
<answer name="goal" />
<answer name="goal">
<question>What is your goal?</question>
</answer>
<mcq name="mcq_1_1" type="choices">
<question>Do you like this MCQ?</question>
......
<mentoring url_name="{{ url_name }}" display_name="Nav tooltip title" weight="1" mode="standard">
<title>Default Title</title>
<html>
<p>What is your goal?</p>
<p>Please answer the questions below.</p>
</html>
<answer name="goal" />
<answer name="goal">
<question>What is your goal?</question>
</answer>
<mcq name="mcq_1_1" type="choices">
<question>Do you like this MCQ?</question>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment