Commit 3d3921b1 by gradyward

Changed the template for rendering feedback to encorporate self feedback, and…

Changed the template for rendering feedback to encorporate self feedback, and changed the handler to provide appropriate context
parent 91a5c710
......@@ -156,7 +156,7 @@
{% endif %}
<ul class="answer--feedback__content {% if criterion.options %}ui-toggle-visibility__content{% endif %}">
{% for feedback in criterion.feedback %}
{% for feedback in criterion.peer_feedback %}
<li class="feedback feedback--{{ forloop.counter }}">
<h6 class="feedback__source">
{% trans "Peer" %} {{ forloop.counter }}
......@@ -167,6 +167,17 @@
</div>
</li>
{% endfor %}
{% if criterion.self_feedback %}
<li class="feedback feedback--{{ forloop.counter }}">
<h6 class="feedback__source">
{% trans "My Assessment" %}
</h6>
<div class="feedback__value">
{{ criterion.self_feedback }}
</div>
</li>
{% endif %}
</ul>
</li>
{% endif %}
......
......@@ -127,7 +127,7 @@ class GradeMixin(object):
'peer_assessments': peer_assessments,
'self_assessment': self_assessment,
'example_based_assessment': example_based_assessment,
'rubric_criteria': self._rubric_criteria_with_feedback(peer_assessments),
'rubric_criteria': self._rubric_criteria_with_feedback(peer_assessments, self_assessment),
'has_submitted_feedback': has_submitted_feedback,
'allow_file_upload': self.allow_file_upload,
'file_url': self.get_download_url_from_submission(student_submission)
......@@ -218,13 +218,14 @@ class GradeMixin(object):
)
return {'success': True, 'msg': _(u"Feedback saved.")}
def _rubric_criteria_with_feedback(self, peer_assessments):
def _rubric_criteria_with_feedback(self, peer_assessments, self_assessment):
"""
Add per-criterion feedback from peer assessments to the rubric criteria.
Filters out empty feedback.
Args:
peer_assessments (list of dict): Serialized assessment models from the peer API.
self_assessment (dict): Serialized assessment model from the self API
Returns:
list of criterion dictionaries
......@@ -245,16 +246,25 @@ class GradeMixin(object):
]
"""
criteria = copy.deepcopy(self.rubric_criteria)
criteria_feedback = defaultdict(list)
peer_criteria_feedback = defaultdict(list)
self_criteria_feedback = {}
for assessment in peer_assessments:
for part in assessment['parts']:
if part['feedback']:
part_criterion_name = part['criterion']['name']
criteria_feedback[part_criterion_name].append(part['feedback'])
peer_criteria_feedback[part_criterion_name].append(part['feedback'])
if self_assessment:
for part in self_assessment['parts']:
if part['feedback']:
part_criterion_name = part['criterion']['name']
self_criteria_feedback[part_criterion_name] = part['feedback']
for criterion in criteria:
criterion_name = criterion['name']
criterion['feedback'] = criteria_feedback[criterion_name]
criterion['peer_feedback'] = peer_criteria_feedback[criterion_name]
if self_criteria_feedback.get(criterion_name, False):
criterion['self_feedback'] = self_criteria_feedback.get(criterion_name)
return criteria
......@@ -179,11 +179,13 @@ class TestGrade(XBlockHandlerTestCase):
# Verify that the context for the grade complete page contains the feedback
_, context = xblock.render_grade_complete(xblock.get_workflow_info())
criteria = context['rubric_criteria']
self.assertEqual(criteria[0]['feedback'], [
self.assertEqual(criteria[0]['peer_feedback'], [
u'Peer 2: ฝﻉɭɭ ɗѻกﻉ!',
u'Peer 1: ฝﻉɭɭ ɗѻกﻉ!',
])
self.assertEqual(criteria[1]['feedback'], [u'Peer 2: ƒαιя נσв'])
self.assertEqual(criteria[0]['self_feedback'], u'Peer 1: ฝﻉɭɭ ɗѻกﻉ!')
self.assertEqual(criteria[1]['peer_feedback'], [u'Peer 2: ƒαιя נσв'])
# The order of the peers in the per-criterion feedback needs
# to match the order of the peer assessments
......
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