Commit ba90e14d by Alan Boudreault

A few corrections:

- Fix cursor pointer on checkmark icons
- Fix on success, checkmarks should all be displayed
- Fix don't increase counter when the mrq is completed successfully
parent 01776bb8
......@@ -217,7 +217,7 @@ class LightChild(Plugin, LightChildrenMixin):
fields = [(attr, value) for attr, value in self.__class__.__dict__.iteritems() if \
isinstance(value, LightChildField)]
for attr, value in fields:
self.__dict__[attr] = value.value # set the default value
self.__dict__[attr] = value.get() # set the default value
@lazy
def student_data(self):
......@@ -323,9 +323,6 @@ class LightChildField(object):
def __nonzero__(self):
return bool(self.value)
def set(self, value):
self.value = value
def get(self):
return self.value
......@@ -348,6 +345,9 @@ class Integer(LightChildField):
def __str__(self):
return str(self.value)
def get(self):
return int(self.value)
def __nonzero__(self):
try:
int(self.value)
......
......@@ -89,15 +89,14 @@ class MRQBlock(QuestionnaireAbstractBlock):
self.message = u'Your answer is correct!' if completed else u'Your answer is incorrect.'
setattr(self, 'num_attempts', self.num_attempts + 1)
max_attempts_reached = False
if self.max_attempts:
max_attempts = self.max_attempts
num_attempts = self.num_attempts
max_attempts_reached = num_attempts >= max_attempts
if max_attempts_reached and (not completed or num_attempts > max_attempts):
# Do not increase the counter is the answer is correct
if not completed:
setattr(self, 'num_attempts', self.num_attempts + 1)
# TODO do a proper fix, max_attempts is set as 'str' with the xml loading code.
# will find a better solution tomorrow
max_attempts = int(self.max_attempts)
if self.num_attempts >= max_attempts and (not completed or self.num_attempts > max_attempts):
completed = True
self.message += 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.'
......@@ -109,7 +108,7 @@ class MRQBlock(QuestionnaireAbstractBlock):
'completed': completed,
'choices': results,
'message': self.message,
'max_attempts': self.max_attempts,
'max_attempts': max_attempts,
'num_attempts': self.num_attempts
}
......
......@@ -21,15 +21,17 @@
display: inline-block;
width: 40px;
vertical-align: middle;
cursor: pointer;
}
.mentoring .choices .choice-result.correct, .choice-answer.correct {
cursor: pointer;
color: #006600;
position: relative;
top: -3px;
}
.mentoring .choices .choice-result.incorrect, .choice-answer.incorrect {
.mentoring .choices .choice-result.incorrect {
text-align:center;
color: #ff0000;
}
......
......@@ -86,6 +86,7 @@ function MRQBlock(runtime, element) {
var choiceInputDOM = $('.choice input[value='+choice.value+']', element),
choiceDOM = choiceInputDOM.closest('.choice'),
choiceResultDOM = $('.choice-result', choiceDOM),
choiceAnswerDOM = $('.choice-answer', choiceDOM),
choiceTipsDOM = $('.choice-tips', choiceDOM),
choiceTipsCloseDOM;
......@@ -97,7 +98,7 @@ function MRQBlock(runtime, element) {
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok');
/* show hint if checked or max_attempts is disabled */
if (choiceInputDOM.prop('checked') || result.max_attempts <= 0) {
if (result.completed || choiceInputDOM.prop('checked') || result.max_attempts <= 0) {
if (choice.completed) {
choiceResultDOM.addClass('correct icon-ok');
} else if (!choice.completed) {
......@@ -111,6 +112,11 @@ function MRQBlock(runtime, element) {
choiceResultDOM.off('click').on('click', function() {
showPopup(choiceTipsDOM);
});
choiceAnswerDOM.off('click').on('click', function() {
showPopup(choiceTipsDOM);
});
});
this.answers = answers;
......@@ -124,7 +130,7 @@ function MRQBlock(runtime, element) {
_.each(this.answers, function(answer) {
var choiceResultDOM = $('.choice-answer', answer.input.closest('.choice'));
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok');
choiceResultDOM.removeClass('correct icon-ok');
if (answers_displayed) {
if (answer.answer)
choiceResultDOM.addClass('correct icon-ok');
......
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