Commit 7ab8773d by Alan Boudreault

Fix various issues and modified the main behavior of answers.

parent 0decd359
...@@ -249,7 +249,6 @@ class String(LightChildField): ...@@ -249,7 +249,6 @@ class String(LightChildField):
class Integer(LightChildField): class Integer(LightChildField):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.value = kwargs.get('default', 0) self.value = kwargs.get('default', 0)
print self.value
def __str__(self): def __str__(self):
return str(self.value) return str(self.value)
......
...@@ -80,7 +80,7 @@ class MRQBlock(QuestionnaireAbstractBlock): ...@@ -80,7 +80,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
# What's the proper way to get my value saved? it doesn't work without '.value' # What's the proper way to get my value saved? it doesn't work without '.value'
# this is incorrect and the num_attempts is resetted if we restart the server. # this is incorrect and the num_attempts is resetted if we restart the server.
self.num_attempts.value = int(self.num_attempts) + 1 self.num_attempts.value = int(self.num_attempts) + 1 if self.max_attempts else 0
max_attempts_reached = False max_attempts_reached = False
if self.max_attempts: if self.max_attempts:
...@@ -89,9 +89,9 @@ class MRQBlock(QuestionnaireAbstractBlock): ...@@ -89,9 +89,9 @@ class MRQBlock(QuestionnaireAbstractBlock):
max_attempts_reached = num_attempts >= max_attempts max_attempts_reached = num_attempts >= max_attempts
if max_attempts_reached and (not completed or num_attempts > max_attempts): if max_attempts_reached and (not completed or num_attempts > max_attempts):
log.debug(u'MRQ max attempts reached');
completed = True completed = True
self.message += u' You have reached the maximum number of attempts for this question. Your next answers won''t be saved. You can check the answer(s) using the "Show Answer(s)" button.' self.message += u' You have reached the maximum number of attempts for this question. ' \
'Your next answers won''t be saved. You can check the answer(s) using the "Show Answer(s)" button.'
else: # only save the student_choices if there was a attempt left, might be incorrect or unuseful else: # only save the student_choices if there was a attempt left, might be incorrect or unuseful
self.student_choices = submissions self.student_choices = submissions
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
.mentoring .progress .indicator { .mentoring .progress .indicator {
display: inline-block; display: inline-block;
margin-top: 5px; vertical-align: middle;
} }
.mentoring .progress .indicator .checkmark-correct { .mentoring .progress .indicator .checkmark-correct {
......
...@@ -11,21 +11,26 @@ ...@@ -11,21 +11,26 @@
margin: 10px 0; margin: 10px 0;
} }
.mentoring .choices .choice-checkbox {
display: inline-block;
margin-top: 5px;
margin-bottom: 5px;
}
.mentoring .choices .choice-result { .mentoring .choices .choice-result {
padding-right: 10px; display: inline-block;
width: 40px;
vertical-align: middle; vertical-align: middle;
} }
.mentoring .choices .choice-result.correct { .mentoring .choices .choice-result.correct, .choice-answer.correct {
color: #006600; color: #006600;
position: relative; position: relative;
top: -3px; top: -3px;
} }
.mentoring .choices .choice-result.incorrect { .mentoring .choices .choice-result.incorrect, .choice-answer.incorrect {
margin-right: 10px; text-align:center;
padding-left: 10px;
padding-right: 10px;
color: #ff0000; color: #ff0000;
} }
......
...@@ -35,7 +35,7 @@ function MRQBlock(runtime, element) { ...@@ -35,7 +35,7 @@ function MRQBlock(runtime, element) {
if (_.isUndefined(this.answers)) if (_.isUndefined(this.answers))
showAnswerButton.hide(); showAnswerButton.hide();
else else
showAnswerButton.on('click', _.bind(this.displayAnswers, this)); showAnswerButton.on('click', _.bind(this.toggleAnswers, this));
} }
}, },
...@@ -44,6 +44,11 @@ function MRQBlock(runtime, element) { ...@@ -44,6 +44,11 @@ function MRQBlock(runtime, element) {
}, },
submit: function() { submit: function() {
// hide answers
var choiceInputDOM = $('.choice input', element),
choiceResultDOM = $('.choice-answer', choiceInputDOM.closest('.choice'));
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok');
var checkedCheckboxes = $('input[type=checkbox]:checked', element), var checkedCheckboxes = $('input[type=checkbox]:checked', element),
checkedValues = []; checkedValues = [];
...@@ -91,7 +96,8 @@ function MRQBlock(runtime, element) { ...@@ -91,7 +96,8 @@ function MRQBlock(runtime, element) {
}); });
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok'); choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok');
if (choiceInputDOM.prop('checked')) { /* show hint if checked */ /* show hint if checked or max_attempts is disabled */
if (choiceInputDOM.prop('checked') || _.isNull(result.max_attempts)) {
if (choice.completed) { if (choice.completed) {
choiceResultDOM.addClass('correct icon-ok'); choiceResultDOM.addClass('correct icon-ok');
} else if (!choice.completed) { } else if (!choice.completed) {
...@@ -112,21 +118,19 @@ function MRQBlock(runtime, element) { ...@@ -112,21 +118,19 @@ function MRQBlock(runtime, element) {
this.renderAttempts(); this.renderAttempts();
}, },
displayAnswers: function() { toggleAnswers: function() {
var showAnswerButton = $('button span', element); var showAnswerButton = $('button span', element);
var answers_displayed = this.answers_displayed = !this.answers_displayed; var answers_displayed = this.answers_displayed = !this.answers_displayed;
_.each(this.answers, function(answer) { _.each(this.answers, function(answer) {
var choiceResultDOM = $('.choice-result', answer.input.closest('.choice')); var choiceResultDOM = $('.choice-answer', answer.input.closest('.choice'));
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok'); choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok');
if (answers_displayed) { if (answers_displayed) {
answer.input.attr('checked', answer.answer);
if (answer.answer) if (answer.answer)
choiceResultDOM.addClass('correct icon-ok'); choiceResultDOM.addClass('correct icon-ok');
showAnswerButton.text('Hide Answer(s)'); showAnswerButton.text('Hide Answer(s)');
} }
else { else {
answer.input.attr('checked', false);
showAnswerButton.text('Show Answer(s)'); showAnswerButton.text('Show Answer(s)');
} }
}); });
......
...@@ -4,10 +4,17 @@ ...@@ -4,10 +4,17 @@
<div class="choices-list"> <div class="choices-list">
{% for choice in custom_choices %} {% for choice in custom_choices %}
<div class="choice"> <div class="choice">
<label class="choice-label">
<input class="choice-selector" type="checkbox" name="{{ self.name }}" value="{{ choice.value }}"{% if choice.value in self.student_choices %} checked{% endif %}> {{ choice.content }}
</label>
<span class="choice-result icon-2x"></span> <span class="choice-result icon-2x"></span>
<div class="choice-checkbox">
<label class="choice-label">
<input class="choice-selector" type="checkbox" name="{{ self.name }}"
value="{{ choice.value }}"
{% if choice.value in self.student_choices %} checked{% endif %}>
{{ choice.content }}
</input>
</label>
</div>
<span class="choice-answer icon-2x"></span>
<div class="choice-tips"></div> <div class="choice-tips"></div>
</div> </div>
{% endfor %} {% endfor %}
......
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