Commit 5b0b700c by Alan Boudreault

Display MCQ Rating the same way than choices

parent fbc0c303
...@@ -62,29 +62,17 @@ class MCQBlock(QuestionnaireAbstractBlock): ...@@ -62,29 +62,17 @@ class MCQBlock(QuestionnaireAbstractBlock):
if choice.value in tip.display_with_defaults: if choice.value in tip.display_with_defaults:
choice_tips_fragments.append(tip.render()) choice_tips_fragments.append(tip.render())
if self.type == 'choices': tips.append({
tips.append({ 'choice': choice.value,
'choice': choice.value, 'tips': render_template('templates/html/tip_choice_group.html', {
'tips': render_template('templates/html/tip_choice_group.html', { 'self': self,
'self': self, 'tips_fragments': choice_tips_fragments,
'tips_fragments': choice_tips_fragments, 'completed': completed,
'completed': completed,
})
})
else:
tips.append({
'choice': choice.value,
'tips': render_template('templates/html/tip_question_group.html', {
'self': self,
'tips_fragments': choice_tips_fragments,
'submission': submission,
'submission_display': self.get_submission_display(submission),
})
}) })
})
self.student_choice = submission self.student_choice = submission
result = { result = {
'type': self.type,
'submission': submission, 'submission': submission,
'completed': completed, 'completed': completed,
'tips': tips, 'tips': tips,
......
.mentoring .rating .choices-list { .mentoring .questionnaire .choices-list {
margin: 5px 0 10px;
}
.mentoring .choices .choices-list {
position: relative; position: relative;
padding-top: 10px; padding-top: 10px;
margin-bottom: 10px;
} }
.mentoring .choices .choice { .mentoring .questionnaire .choice {
margin: 10px 0; margin: 10px 0;
} }
...@@ -17,27 +14,28 @@ ...@@ -17,27 +14,28 @@
margin-bottom: 5px; margin-bottom: 5px;
} }
.mentoring .choices .choice-result { .mentoring .questionnaire .choice-result {
display: inline-block; display: inline-block;
width: 40px; width: 40px;
vertical-align: middle; vertical-align: middle;
cursor: pointer; cursor: pointer;
} }
.mentoring .choices .choice-result.correct, .choice-answer.correct { .mentoring .questionnaire .choice-result.correct,
.mentoring .questionnaire .choice-answer.correct {
cursor: pointer; cursor: pointer;
color: #006600; color: #006600;
position: relative; position: relative;
top: -3px; top: -3px;
} }
.mentoring .choices .choice-result.incorrect { .mentoring .questionnaire .choice-result.incorrect {
text-align:center; text-align:center;
color: #ff0000; color: #ff0000;
} }
.mentoring .choices .choice-tips, .mentoring .questionnaire .choice-tips,
.mentoring .choices .choice-message { .mentoring .questionnaire .choice-message {
display: none; display: none;
color: #fff; color: #fff;
position: absolute; position: absolute;
...@@ -52,20 +50,20 @@ ...@@ -52,20 +50,20 @@
width: 300px; width: 300px;
} }
.mentoring .choices .choice-tips .title { .mentoring .questionnaire .choice-tips .title {
margin: 0 0 5px; margin: 0 0 5px;
font-size: 18px; font-size: 18px;
font-family: arial; font-family: arial;
} }
.mentoring .choices .choice-tips .tip-choice-group, .mentoring .questionnaire .choice-tips .tip-choice-group,
.mentoring .choices .choice-message .tip-choice-group, .mentoring .questionnaire .choice-message .tip-choice-group,
.mentoring .choices .choice-message .message-content { .mentoring .questionnaire .choice-message .message-content {
position: relative; position: relative;
} }
.mentoring .choices .choice-tips .close, .mentoring .questionnaire .choice-tips .close,
.mentoring .choices .choice-message .close { .mentoring .questionnaire .choice-message .close {
background-image: url({{ close_icon_url }}); background-image: url({{ close_icon_url }});
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
...@@ -75,18 +73,11 @@ ...@@ -75,18 +73,11 @@
height: 21px; height: 21px;
} }
.mentoring .choices .choice-tips p { .mentoring .questionnaire .choice-tips p,
.mentoring .questionnaire .choice-message p {
color: #fff; color: #fff;
} }
.mentoring .choices .choice-message p {
color: #fff;
}
.mentoring .rating .choice {
margin-right: 10px;
}
.mentoring .choices-list .choice-selector { .mentoring .choices-list .choice-selector {
margin-right: 5px; margin-right: 5px;
} }
......
...@@ -10,10 +10,11 @@ function MessageView(element) { ...@@ -10,10 +10,11 @@ function MessageView(element) {
$('.close', this.allPopupsDOM).off('click'); $('.close', this.allPopupsDOM).off('click');
}, },
showPopup: function(popupDOM) { showPopup: function(popupDOM) {
var self = this;
this.clearPopupEvents(); this.clearPopupEvents();
popupDOM.show(); popupDOM.show();
popupDOM.on('click', function() { popupDOM.on('click', function() {
this.clearPopupEvents(); self.clearPopupEvents();
}); });
}, },
showMessage: function(message) { showMessage: function(message) {
...@@ -41,17 +42,6 @@ function MCQBlock(runtime, element) { ...@@ -41,17 +42,6 @@ function MCQBlock(runtime, element) {
}, },
handleSubmit: function(result) { handleSubmit: function(result) {
if (result.type == 'rating') {
if (_.size(result.tips) > 0) {
var tipsDom = $(element).parent().find('.messages'),
tipHtml = result.tips[0].tips || '';
if(tipHtml)
tipsDom.append(tipHtml);
}
}
else { // choices
var messageView = MessageView(element); var messageView = MessageView(element);
var choiceInputs = $('.choice input', element); var choiceInputs = $('.choice input', element);
$.each(choiceInputs, function(index, choiceInput) { $.each(choiceInputs, function(index, choiceInput) {
...@@ -78,7 +68,9 @@ function MCQBlock(runtime, element) { ...@@ -78,7 +68,9 @@ function MCQBlock(runtime, element) {
choiceTipsCloseDOM = $('.close', choiceTipsDOM); choiceTipsCloseDOM = $('.close', choiceTipsDOM);
choiceResultDOM.off('click').on('click', function() { choiceResultDOM.off('click').on('click', function() {
messageView.showMessage(choiceTipsDOM); if (choiceTipsDOM.html() != '') {
messageView.showMessage(choiceTipsDOM);
}
}); });
}); });
...@@ -93,11 +85,10 @@ function MCQBlock(runtime, element) { ...@@ -93,11 +85,10 @@ function MCQBlock(runtime, element) {
if (tips) { if (tips) {
messageView.showMessage(tips.tips); messageView.showMessage(tips.tips);
} else { } else {
clearPopupEvents(); messageView.clearPopupEvents();
} }
} }
} }
}
}; };
} }
......
<fieldset class="choices"> <fieldset class="choices questionnaire">
<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 %}
......
<fieldset class="rating"> <fieldset class="rating questionnaire">
<legend class="question">{{ self.question }}</legend> <legend class="question">{{ self.question }}</legend>
<div class="choices-list"> <div class="choices-list">
<span class="low">{{ self.low }}</span> <div class="choice">
<span class="choice"> <span class="choice-result icon-2x"></span>
<label><input class="choice-selector" type="radio" name="{{ self.name }}" value="1"{% if self.student_choice == '1' %} checked{% endif %}>1</label> <label><input class="choice-selector" type="radio" name="{{ self.name }}" value="1"{% if self.student_choice == '1' %} checked{% endif %}>1</label>
</span> <span class="low"> - {{ self.low }}</span>
<span class="choice"> <div class="choice-tips"></div>
</div>
<div class="choice">
<span class="choice-result icon-2x"></span>
<label><input class="choice-selector" type="radio" name="{{ self.name }}" value="2"{% if self.student_choice == '2' %} checked{% endif %}>2</label> <label><input class="choice-selector" type="radio" name="{{ self.name }}" value="2"{% if self.student_choice == '2' %} checked{% endif %}>2</label>
</span> <div class="choice-tips"></div>
<span class="choice"> </div>
<div class="choice">
<span class="choice-result icon-2x"></span>
<label><input class="choice-selector" type="radio" name="{{ self.name }}" value="3"{% if self.student_choice == '3' %} checked{% endif %}>3</label> <label><input class="choice-selector" type="radio" name="{{ self.name }}" value="3"{% if self.student_choice == '3' %} checked{% endif %}>3</label>
</span> <div class="choice-tips"></div>
<span class="choice"> </div>
<div class="choice">
<span class="choice-result icon-2x"></span>
<label><input class="choice-selector" type="radio" name="{{ self.name }}" value="4"{% if self.student_choice == '4' %} checked{% endif %}>4</label> <label><input class="choice-selector" type="radio" name="{{ self.name }}" value="4"{% if self.student_choice == '4' %} checked{% endif %}>4</label>
</span> <div class="choice-tips"></div>
<span class="choice"> </div>
<div class="choice">
<span class="choice-result icon-2x"></span>
<label><input class="choice-selector" type="radio" name="{{ self.name }}" value="5"{% if self.student_choice == '5' %} checked{% endif %}>5</label> <label><input class="choice-selector" type="radio" name="{{ self.name }}" value="5"{% if self.student_choice == '5' %} checked{% endif %}>5</label>
</span> <span class="low"> - {{ self.high }}</span>
<span class="low">{{ self.high }}</span> <div class="choice-tips"></div>
</div>
{% for choice in custom_choices %} {% for choice in custom_choices %}
<span class="choice"> <div class="choice">
<span class="choice-result icon-2x"></span>
<label><input type="radio" name="{{ self.name }}" value="{{ choice.value }}"{% if self.student_choice == '{{ choice.value }}' %} checked{% endif %}> {{ choice.content }}</label> <label><input type="radio" name="{{ self.name }}" value="{{ choice.value }}"{% if self.student_choice == '{{ choice.value }}' %} checked{% endif %}> {{ choice.content }}</label>
</span> <div class="choice-tips"></div>
</div>
{% endfor %} {% endfor %}
<div class="choice-message"></div>
</div> </div>
</fieldset> </fieldset>
<h2 class="problem-header">Multiple Response</h2> <h2 class="problem-header">Multiple Response</h2>
<fieldset class="choices"> <fieldset class="choices questionnaire">
<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