Commit 5da686d1 by Xavier Antoviaque

Merge pull request #14 from aboudreault/submit-progress-icon

Submit progress icon
parents 9a8c20db 3ca91095
...@@ -89,7 +89,6 @@ class MentoringBlock(XBlockWithLightChildren): ...@@ -89,7 +89,6 @@ class MentoringBlock(XBlockWithLightChildren):
fragment.add_javascript_url( fragment.add_javascript_url(
self.runtime.local_resource_url(self, 'public/js/vendor/underscore-min.js')) self.runtime.local_resource_url(self, 'public/js/vendor/underscore-min.js'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring.js')) fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring.js'))
fragment.add_resource(load_resource('templates/html/mentoring_progress.html'), "text/html")
fragment.add_resource(load_resource('templates/html/mentoring_attempts.html'), "text/html") fragment.add_resource(load_resource('templates/html/mentoring_attempts.html'), "text/html")
fragment.initialize_js('MentoringBlock') fragment.initialize_js('MentoringBlock')
......
.mentoring .answer.editable { .mentoring .answer.editable {
height: 250px; height: 250px;
width: 100%; width: 100%;
margin-bottom: 10px;
}
.mentoring .answer-checkmark {
display: inline-block;
margin-bottom: 20px; margin-bottom: 20px;
} }
......
...@@ -49,19 +49,6 @@ ...@@ -49,19 +49,6 @@
margin-top: 20px; margin-top: 20px;
} }
.mentoring .progress .indicator {
display: inline-block;
vertical-align: middle;
}
.mentoring .progress .indicator .checkmark-correct {
color: #006600;
}
.mentoring .progress .indicator .checkmark-incorrect {
color: #ff0000;
}
.mentoring .attempts { .mentoring .attempts {
margin-top: 20px; margin-top: 20px;
display: inline-block; display: inline-block;
...@@ -70,3 +57,11 @@ ...@@ -70,3 +57,11 @@
font-style: italic; font-style: italic;
webkit-font-smoothing: antialiased; webkit-font-smoothing: antialiased;
} }
.mentoring .checkmark-correct {
color: #006600;
}
.mentoring .checkmark-incorrect {
color: #ff0000;
}
...@@ -21,17 +21,14 @@ ...@@ -21,17 +21,14 @@
cursor: pointer; cursor: pointer;
} }
.mentoring .questionnaire .choice-result.correct, .mentoring .questionnaire .choice-result.checkmark-correct,
.mentoring .questionnaire .choice-answer.correct { .mentoring .questionnaire .choice-answer.checkmark-correct {
cursor: pointer;
color: #006600;
position: relative; position: relative;
top: -3px; top: -3px;
} }
.mentoring .questionnaire .choice-result.incorrect { .mentoring .questionnaire .choice-result.checkmark-incorrect {
text-align:center; text-align:center;
color: #ff0000;
} }
.mentoring .questionnaire .choice-tips, .mentoring .questionnaire .choice-tips,
......
...@@ -11,7 +11,16 @@ function AnswerBlock(runtime, element) { ...@@ -11,7 +11,16 @@ function AnswerBlock(runtime, element) {
}, },
handleSubmit: function(result) { handleSubmit: function(result) {
var checkmark = $('.answer-checkmark', element);
$(element).find('.message').text((result || {}).error || ''); $(element).find('.message').text((result || {}).error || '');
checkmark.removeClass('checkmark-incorrect icon-exclamation checkmark-correct icon-ok');
if (result.completed) {
checkmark.addClass('checkmark-correct icon-ok');
}
else {
checkmark.addClass('checkmark-incorrect icon-exclamation');
}
}, },
// Returns `true` if the child is valid, else `false` // Returns `true` if the child is valid, else `false`
......
function MentoringBlock(runtime, element) { function MentoringBlock(runtime, element) {
var progressTemplate = _.template($('#xblock-progress-template').html());
var attemptsTemplate = _.template($('#xblock-attempts-template').html()); var attemptsTemplate = _.template($('#xblock-attempts-template').html());
var children; // Keep track of children. A Child need a single object scope for its data. var children; // Keep track of children. A Child need a single object scope for its data.
function renderProgress() {
var data = $('.progress', element).data();
$('.indicator', element).html(progressTemplate(data));
}
function renderAttempts() { function renderAttempts() {
var data = $('.attempts', element).data(); var data = $('.attempts', element).data();
$('.attempts', element).html(attemptsTemplate(data)); $('.attempts', element).html(attemptsTemplate(data));
...@@ -45,10 +39,6 @@ function MentoringBlock(runtime, element) { ...@@ -45,10 +39,6 @@ function MentoringBlock(runtime, element) {
callIfExists(child, 'handleSubmit', result, options); callIfExists(child, 'handleSubmit', result, options);
}); });
$('.progress', element).data('completed', results.completed ? 'True' : 'False');
$('.progress', element).data('attempted', results.attempted ? 'True' : 'False');
renderProgress();
$('.attempts', element).data('max_attempts', results.max_attempts); $('.attempts', element).data('max_attempts', results.max_attempts);
$('.attempts', element).data('num_attempts', results.num_attempts); $('.attempts', element).data('num_attempts', results.num_attempts);
renderAttempts(); renderAttempts();
...@@ -120,10 +110,6 @@ function MentoringBlock(runtime, element) { ...@@ -120,10 +110,6 @@ function MentoringBlock(runtime, element) {
}); });
if (submit_dom.length) {
renderProgress();
}
renderAttempts(); renderAttempts();
renderDependency(); renderDependency();
......
...@@ -49,12 +49,12 @@ function MCQBlock(runtime, element) { ...@@ -49,12 +49,12 @@ function MCQBlock(runtime, element) {
choiceTipsDOM = $('.choice-tips', choiceDOM), choiceTipsDOM = $('.choice-tips', choiceDOM),
choiceTipsCloseDOM; choiceTipsCloseDOM;
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok'); choiceResultDOM.removeClass('checkmark-incorrect icon-exclamation checkmark-correct icon-ok');
if (result.completed && choiceInputDOM.val() === result.submission) { if (result.completed && choiceInputDOM.val() === result.submission) {
choiceResultDOM.addClass('correct icon-ok'); choiceResultDOM.addClass('checkmark-correct icon-ok');
} }
else if (choiceInputDOM.val() === result.submission || _.isNull(result.submission)) { else if (choiceInputDOM.val() === result.submission || _.isNull(result.submission)) {
choiceResultDOM.addClass('incorrect icon-exclamation'); choiceResultDOM.addClass('checkmark-incorrect icon-exclamation');
} }
var tips = _.find(result.tips, function(obj) { var tips = _.find(result.tips, function(obj) {
...@@ -102,7 +102,7 @@ function MRQBlock(runtime, element) { ...@@ -102,7 +102,7 @@ function MRQBlock(runtime, element) {
// hide answers // hide answers
var choiceInputDOM = $('.choice input', element), var choiceInputDOM = $('.choice input', element),
choiceResultDOM = $('.choice-answer', choiceInputDOM.closest('.choice')); choiceResultDOM = $('.choice-answer', choiceInputDOM.closest('.choice'));
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok'); choiceResultDOM.removeClass('checkmark-incorrect icon-exclamation checkmark-correct icon-ok');
var checkedCheckboxes = $('input[type=checkbox]:checked', element), var checkedCheckboxes = $('input[type=checkbox]:checked', element),
checkedValues = []; checkedValues = [];
...@@ -136,13 +136,13 @@ function MRQBlock(runtime, element) { ...@@ -136,13 +136,13 @@ function MRQBlock(runtime, element) {
answer: choice.completed ? choiceInputDOM.attr('checked') : !choiceInputDOM.attr('checked') answer: choice.completed ? choiceInputDOM.attr('checked') : !choiceInputDOM.attr('checked')
}); });
choiceResultDOM.removeClass('incorrect icon-exclamation correct icon-ok'); choiceResultDOM.removeClass('checkmark-incorrect icon-exclamation checkmark-correct icon-ok');
/* 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 (result.completed || choiceInputDOM.prop('checked') || options.max_attempts <= 0) {
if (choice.completed) { if (choice.completed) {
choiceResultDOM.addClass('correct icon-ok'); choiceResultDOM.addClass('checkmark-correct icon-ok');
} else if (!choice.completed) { } else if (!choice.completed) {
choiceResultDOM.addClass('incorrect icon-exclamation'); choiceResultDOM.addClass('checkmark-incorrect icon-exclamation');
} }
} }
...@@ -181,10 +181,10 @@ function MRQBlock(runtime, element) { ...@@ -181,10 +181,10 @@ 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('correct icon-ok'); choiceResultDOM.removeClass('checkmark-correct icon-ok');
if (answers_displayed) { if (answers_displayed) {
if (answer.answer) if (answer.answer)
choiceResultDOM.addClass('correct icon-ok'); choiceResultDOM.addClass('checkmark-correct icon-ok');
showAnswerButton.text('Hide Answer(s)'); showAnswerButton.text('Hide Answer(s)');
} }
else { else {
......
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
class="answer editable" cols="50" rows="10" name="input" class="answer editable" cols="50" rows="10" name="input"
data-min_characters="{{ self.min_characters }}" data-min_characters="{{ self.min_characters }}"
>{{ self.student_input }}</textarea> >{{ self.student_input }}</textarea>
<span class="answer-checkmark icon-2x"></span>
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
<div class="attempts" data-max_attempts="{{ self.max_attempts }}" data-num_attempts="{{ self.num_attempts }}"></div> <div class="attempts" data-max_attempts="{{ self.max_attempts }}" data-num_attempts="{{ self.num_attempts }}"></div>
<div class="submit"> <div class="submit">
<input type="button" class="input-main" value="Submit"></input> <input type="button" class="input-main" value="Submit"></input>
<span class="progress" data-completed="{{ self.completed }}" data-attempted="{{ self.attempted }}">
<span class='indicator'></span>
</span>
</div> </div>
{% endif %} {% endif %}
<div class="messages"></div> <div class="messages"></div>
......
<script type="text/template" id="xblock-progress-template">
<% if (completed === "True") {{ %>
<i class="icon-ok icon-2x checkmark-correct"></i>
<% }} else if (attempted === "True") {{ %>
<i class="icon-exclamation icon-2x checkmark-incorrect"></i>
<% }} %>
</script>
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