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