Commit d9423680 by Xavier Antoviaque

Merge pull request #19 from aboudreault/mrq-hide-results

Mrq hide results
parents a2e3724d 3b6ade2a
...@@ -78,7 +78,7 @@ Second XBlock instance: ...@@ -78,7 +78,7 @@ Second XBlock instance:
### Self-assessment MRQs ### Self-assessment MRQs
```xml ```xml
<mentoring url_name="mcq_1" enforce_dependency="false"> <mentoring url_name="mcq_1" enforce_dependency="false">
<mrq name="mrq_1_1" type="choices" max_attempts="3"> <mrq name="mrq_1_1" type="choices" hide_results="true">
<question>What do you like in this MRQ?</question> <question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice> <choice value="elegance">Its elegance</choice>
<choice value="beauty">Its beauty</choice> <choice value="beauty">Its beauty</choice>
...@@ -122,6 +122,23 @@ Second XBlock instance: ...@@ -122,6 +122,23 @@ Second XBlock instance:
</vertical> </vertical>
``` ```
### Maximum Attempts
You can set the number of maximum attempts for the unit completion:
```xml
<mentoring url_name="mcq_1" enforce_dependency="false" max_attempts="3">
<mrq name="mrq_1_1" type="choices" hide_results="true">
<question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice>
...
</mrq>
<message type="completed">
All is good now...
<html><p>Congratulations!</p></html>
</message>
</mentoring>
```
### Custom feedback popup window ### Custom feedback popup window
You can use the `feedback` child to have a custom popup window. Currently, only the *width* and You can use the `feedback` child to have a custom popup window. Currently, only the *width* and
...@@ -129,7 +146,7 @@ You can use the `feedback` child to have a custom popup window. Currently, only ...@@ -129,7 +146,7 @@ You can use the `feedback` child to have a custom popup window. Currently, only
```xml ```xml
<mentoring url_name="mcq_1" enforce_dependency="false"> <mentoring url_name="mcq_1" enforce_dependency="false">
<mrq name="mrq_1_1" type="choices" max_attempts="3"> <mrq name="mrq_1_1" type="choices">
<question>What do you like in this MRQ?</question> <question>What do you like in this MRQ?</question>
<choice value="elegance">Its elegance</choice> <choice value="elegance">Its elegance</choice>
... ...
......
...@@ -331,6 +331,7 @@ class LightChildField(object): ...@@ -331,6 +331,7 @@ class LightChildField(object):
def __set__(self, instance, value): def __set__(self, instance, value):
self.data[instance] = value self.data[instance] = value
class String(LightChildField): class String(LightChildField):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(String, self).__init__(*args, **kwargs) super(String, self).__init__(*args, **kwargs)
...@@ -353,7 +354,15 @@ class Integer(LightChildField): ...@@ -353,7 +354,15 @@ class Integer(LightChildField):
class Boolean(LightChildField): class Boolean(LightChildField):
pass def __init__(self, *args, **kwargs):
super(Boolean, self).__init__(*args, **kwargs)
self.default = kwargs.get('default', False)
def __set__(self, instance, value):
if isinstance(value, basestring):
value = value.lower() == 'true'
self.data[instance] = value
class List(LightChildField): class List(LightChildField):
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
import logging import logging
from .light_children import List, Scope from .light_children import List, Scope, Boolean
from .questionnaire import QuestionnaireAbstractBlock from .questionnaire import QuestionnaireAbstractBlock
from .utils import render_template from .utils import render_template
...@@ -43,6 +43,7 @@ class MRQBlock(QuestionnaireAbstractBlock): ...@@ -43,6 +43,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
An XBlock used to ask multiple-response questions An XBlock used to ask multiple-response questions
""" """
student_choices = List(help="Last submissions by the student", default=[], scope=Scope.user_state) student_choices = List(help="Last submissions by the student", default=[], scope=Scope.user_state)
hide_results = Boolean(help="Hide results", scope=Scope.content, default=False)
def submit(self, submissions): def submit(self, submissions):
log.debug(u'Received MRQ submissions: "%s"', submissions) log.debug(u'Received MRQ submissions: "%s"', submissions)
......
...@@ -27,6 +27,12 @@ function AnswerBlock(runtime, element) { ...@@ -27,6 +27,12 @@ function AnswerBlock(runtime, element) {
// Returns `true` if the child is valid, else `false` // Returns `true` if the child is valid, else `false`
validate: function() { validate: function() {
// return true if the answer is read only
var blockquote_ro = $('blockquote.answer.read_only', element);
if (blockquote_ro.length > 0)
return true;
var input = $(':input', element), var input = $(':input', element),
input_value = input.val().replace(/^\s+|\s+$/gm,''), input_value = input.val().replace(/^\s+|\s+$/gm,''),
answer_length = input_value.length, answer_length = input_value.length,
......
...@@ -112,6 +112,10 @@ function MRQBlock(runtime, element) { ...@@ -112,6 +112,10 @@ function MRQBlock(runtime, element) {
result.message + '</div>'); result.message + '</div>');
} }
var questionnaireDOM = $('fieldset.questionnaire', element),
data = questionnaireDOM.data(),
hide_results = (data.hide_results === 'True') ? true : false;
$.each(result.choices, function(index, choice) { $.each(result.choices, function(index, choice) {
var choiceInputDOM = $('.choice input[value='+choice.value+']', element), var choiceInputDOM = $('.choice input[value='+choice.value+']', element),
choiceDOM = choiceInputDOM.closest('.choice'), choiceDOM = choiceInputDOM.closest('.choice'),
...@@ -120,11 +124,12 @@ function MRQBlock(runtime, element) { ...@@ -120,11 +124,12 @@ function MRQBlock(runtime, element) {
choiceTipsCloseDOM; choiceTipsCloseDOM;
choiceResultDOM.removeClass( choiceResultDOM.removeClass(
'checkmark-incorrect icon-exclamation checkmark-correct icon-ok fa-check' 'checkmark-incorrect icon-exclamation fa-exclamation checkmark-correct icon-ok fa-check'
); );
/* show hint if checked or max_attempts is disabled */ /* show hint if checked or max_attempts is disabled */
if (result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0) { if (!hide_results &&
(result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0)) {
if (choice.completed) { if (choice.completed) {
choiceResultDOM.addClass('checkmark-correct icon-ok fa-check'); choiceResultDOM.addClass('checkmark-correct icon-ok fa-check');
} else if (!choice.completed) { } else if (!choice.completed) {
......
<h2 class="problem-header">Multiple Response</h2> <h2 class="problem-header">Multiple Response</h2>
<fieldset class="choices questionnaire"> <fieldset class="choices questionnaire" data-hide_results="{{self.hide_results}}">
<legend class="question">{{ self.question }}</legend> <legend class="question">{{ self.question }}</legend>
<div class="choices-list"> <div class="choices-list">
{% for choice in custom_choices %} {% for choice in custom_choices %}
......
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