Commit 2a9a65a8 by Alan Boudreault

Various fixes

parent dbf5365b
...@@ -75,6 +75,28 @@ Second XBlock instance: ...@@ -75,6 +75,28 @@ Second XBlock instance:
</mentoring> </mentoring>
``` ```
### Self-assessment MRQs
```xml
<mentoring url_name="mcq_1" enforce_dependency="false">
<mrq name="mrq_1_1" type="choices" max_attempts="3">
<question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice>
<choice value="beauty">Its beauty</choice>
<choice value="gracefulness">Its gracefulness</choice>
<choice value="bugs">Its bugs</choice>
<tip require="gracefulness">This MRQ is indeed very graceful</tip>
<tip require="elegance,beauty">This is something everyone has to like about this MRQ</tip>
<tip reject="bugs">Nah, there isn't any!</tip>
<message type="on-submit">Thank you for answering!</message>
</mrq>
<message type="completed">
All is good now...
<html><p>Congratulations!</p></html>
</message>
</mentoring>
### Tables ### Tables
```xml ```xml
......
...@@ -103,14 +103,6 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin): ...@@ -103,14 +103,6 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
child = child_class(block) child = child_class(block)
child.name = u'{}_{}'.format(block.name, child_id) child.name = u'{}_{}'.format(block.name, child_id)
# Instanciate our LightChild fields
# TODO HACK, Since we are not replacing the fields attribute with directly, we need to
# instanciate new fields for our LightChild.
fields = [(attr, value) for attr, value in child_class.__dict__.iteritems() if \
isinstance(value, LightChildField)]
for attr, value in fields:
child.__dict__[attr] = copy.deepcopy(value)
# Add any children the child may itself have # Add any children the child may itself have
child_class.init_block_from_node(child, xml_child, xml_child.items()) child_class.init_block_from_node(child, xml_child, xml_child.items())
...@@ -219,6 +211,14 @@ class LightChild(Plugin, LightChildrenMixin): ...@@ -219,6 +211,14 @@ class LightChild(Plugin, LightChildrenMixin):
self.parent = parent self.parent = parent
self.xblock_container = parent.xblock_container self.xblock_container = parent.xblock_container
# Instanciate our LightChild fields
# TODO HACK, Since we are not replacing the fields attribute directly, we need to
# instanciate new fields for our LightChild.
fields = [(attr, value) for attr, value in self.__class__.__dict__.iteritems() if \
isinstance(value, LightChildField)]
for attr, value in fields:
self.__dict__[attr] = copy.deepcopy(value)
def __setattr__(self, name, value): def __setattr__(self, name, value):
field = getattr(self, name) if hasattr(self, name) else None field = getattr(self, name) if hasattr(self, name) else None
...@@ -262,11 +262,12 @@ class LightChild(Plugin, LightChildrenMixin): ...@@ -262,11 +262,12 @@ class LightChild(Plugin, LightChildrenMixin):
""" """
Load the values from the student_data in the database. Load the values from the student_data in the database.
""" """
if not self.student_data:
fields = self.get_fields_to_save()
if not fields or not self.student_data:
return return
student_data = json.loads(self.student_data) student_data = json.loads(self.student_data)
fields = self.get_fields_to_save()
for field in fields: for field in fields:
if field in student_data: if field in student_data:
setattr(self, field, student_data[field]) setattr(self, field, student_data[field])
...@@ -381,7 +382,10 @@ class Integer(LightChildField): ...@@ -381,7 +382,10 @@ class Integer(LightChildField):
return self.value is not None return self.value is not None
def set(self, value): def set(self, value):
try:
self.value = int(value) self.value = int(value)
except (TypeError, ValueError): # not an integer
self.value = None
def from_json(self, value): def from_json(self, value):
if value is None or value == '': if value is None or value == '':
......
...@@ -103,7 +103,7 @@ class MRQBlock(QuestionnaireAbstractBlock): ...@@ -103,7 +103,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
completed = True completed = True
self.message = self.message.get() + u' You have reached the maximum number of attempts for this question. ' \ self.message = self.message.get() + u' You have reached the maximum number of attempts for this question. ' \
u'Your next answers won''t be saved. You can check the answer(s) using the "Show Answer(s)" button.' u'Your next answers won''t be saved. You can check the answer(s) using the "Show Answer(s)" button.'
else:
self.student_choices = submissions self.student_choices = submissions
result = { result = {
......
...@@ -74,7 +74,7 @@ function MentoringBlock(runtime, element) { ...@@ -74,7 +74,7 @@ function MentoringBlock(runtime, element) {
} }
function initXBlock() { function initXBlock() {
var submit_dom = $(element).find('.submit input'); var submit_dom = $(element).find('.submit .input-main');
submit_dom.bind('click', function() { submit_dom.bind('click', function() {
var data = {}; var data = {};
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{% endfor %} {% endfor %}
{% if self.display_submit %} {% if self.display_submit %}
<div class="submit"> <div class="submit">
<input type="button" value="Submit"></input> <input type="button" class="input-main" value="Submit"></input>
<span class="progress" data-completed="{{ self.completed }}" data-attempted="{{ self.attempted }}"> <span class="progress" data-completed="{{ self.completed }}" data-attempted="{{ self.attempted }}">
<span class='indicator'></span> <span class='indicator'></span>
</span> </span>
......
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