Commit 755ba357 by Braden MacDonald

Fix extended review

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