Commit 755ba357 by Braden MacDonald

Fix extended review

parent cf68d838
......@@ -175,22 +175,6 @@ class BaseMentoringBlock(
for theme_file in theme_files:
fragment.add_css(ResourceLoader(theme_package).load_unicode(theme_file))
def feedback_dispatch(self, target_data, stringify):
if self.show_extended_feedback():
if stringify:
return json.dumps(target_data)
else:
return target_data
def correct_json(self, stringify=True):
return self.feedback_dispatch(self.score.correct, stringify)
def incorrect_json(self, stringify=True):
return self.feedback_dispatch(self.score.incorrect, stringify)
def partial_json(self, stringify=True):
return self.feedback_dispatch(self.score.partially_correct, stringify)
@XBlock.json_handler
def view(self, data, suffix=''):
"""
......@@ -675,6 +659,22 @@ class MentoringBlock(BaseMentoringBlock, StudioContainerXBlockMixin, StepParentM
'num_attempts': self.num_attempts,
}
def feedback_dispatch(self, target_data, stringify):
if self.show_extended_feedback():
if stringify:
return json.dumps(target_data)
else:
return target_data
def correct_json(self, stringify=True):
return self.feedback_dispatch(self.score.correct, stringify)
def incorrect_json(self, stringify=True):
return self.feedback_dispatch(self.score.incorrect, stringify)
def partial_json(self, stringify=True):
return self.feedback_dispatch(self.score.partially_correct, stringify)
def handle_assessment_submit(self, submissions, suffix):
completed = False
current_child = None
......@@ -979,7 +979,7 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
return review_tips
def show_extended_feedback(self):
return self.extended_feedback
return self.extended_feedback and self.max_attempts_reached
def student_view(self, context):
fragment = Fragment()
......@@ -1087,11 +1087,12 @@ class MentoringWithExplicitStepsBlock(BaseMentoringBlock, StudioContainerWithNes
'correct_answers': len(score.correct),
'incorrect_answers': len(score.incorrect),
'partially_correct_answers': len(score.partially_correct),
'correct': self.correct_json(stringify=False),
'incorrect': self.incorrect_json(stringify=False),
'partial': self.partial_json(stringify=False),
'correct': score.correct,
'incorrect': score.incorrect,
'partial': score.partially_correct,
'complete': self.complete,
'max_attempts_reached': self.max_attempts_reached,
'show_extended_review': self.show_extended_feedback(),
'review_tips': self.review_tips,
}
......
function MentoringWithStepsBlock(runtime, element, params) {
function MentoringWithStepsBlock(runtime, element) {
// Set up gettext in case it isn't available in the client runtime:
if (typeof gettext == "undefined") {
......@@ -41,10 +41,6 @@ function MentoringWithStepsBlock(runtime, element, params) {
return (data.num_attempts < data.max_attempts);
}
function extendedFeedbackEnabled() {
return !!(params.extended_feedback); // Show extended feedback when all attempts are used up?
}
function showFeedback(response) {
if (response.step_status === 'correct') {
checkmark.addClass('checkmark-correct icon-ok fa-check');
......@@ -419,7 +415,7 @@ function MentoringWithStepsBlock(runtime, element, params) {
reviewLinkDOM.on('click', showGrade);
// Add click handler that takes care of links to steps on the extended review:
$('a.step-link', element).on('click', getStepToReview);
$(element).on('click', 'a.step-link', getStepToReview);
// Initialize individual steps
// (sets up click handlers for questions and makes sure answer data is up-to-date)
......
......@@ -166,6 +166,7 @@ class ScoreSummaryBlock(XBlockWithTranslationServiceMixin, XBlockWithPreviewMixi
'partial': [],
'complete': True,
'max_attempts_reached': False,
'show_extended_review': False,
'is_example': True,
}
......
......@@ -23,7 +23,7 @@
{% for question in correct %}
<li>
{% if forloop.last and not forloop.first %} {% trans "and" %} {% endif %}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans %}Question {{question.number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and correct|length > 2 %},{%endif%}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans with number=question.number %}Question {{number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and correct|length > 2 %},{%endif%}
</li>
{% endfor %}
</ul>
......@@ -46,7 +46,7 @@
{% for question in partial %}
<li>
{% if forloop.last and not forloop.first %} {% trans "and" %} {% endif %}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans %}Question {{question.number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and partial|length > 2 %},{%endif%}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans with number=question.number %}Question {{number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and partial|length > 2 %},{%endif%}
</li>
{% endfor %}
</ul>
......@@ -69,7 +69,7 @@
{% for question in incorrect %}
<li>
{% if forloop.last and not forloop.first %} {% trans "and" %} {% endif %}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans %}Question {{question.number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and incorrect|length > 2 %},{%endif%}
<a href="#" class="step-link" data-step="{{ question.step }}">{% blocktrans with number=question.number %}Question {{number}}{% endblocktrans %}</a>{% if forloop.revcounter > 1 and incorrect|length > 2 %},{%endif%}
</li>
{% endfor %}
</ul>
......
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