Merge pull request #3897 from edx/jmclaus/i18n_image_response
i18n of Image Response [BLD-723]
This commit is contained in:
@@ -6,7 +6,7 @@ in roughly chronological order, most recent first. Add your entries at or near
|
||||
the top. Include a label indicating the component affected.
|
||||
|
||||
All: refactored code to handle course_ids, module_ids, etc in a cleaner way.
|
||||
See https://github.com/edx/edx-platform/wiki/Opaque-Keys for details.
|
||||
See https://github.com/edx/edx-platform/wiki/Opaque-Keys for details.
|
||||
|
||||
Blades: Remove Video player outline. BLD-975.
|
||||
|
||||
@@ -22,7 +22,8 @@ Studio: Add drag-and-drop support to the container page. STUD-1309.
|
||||
|
||||
Common: Add extensible third-party auth module.
|
||||
|
||||
Blades: Added new error message that displays when HTML5 video is not supported altogether. Make sure spinner gets hidden when error message is shown. BLD-638.
|
||||
Blades: Added new error message that displays when HTML5 video is not supported
|
||||
altogether. Make sure spinner gets hidden when error message is shown. BLD-638.
|
||||
|
||||
LMS: Switch default instructor dashboard to the new (formerly "beta")
|
||||
instructor dashboard. Puts the old (now "legacy") dash behind a feature flag.
|
||||
|
||||
@@ -2554,6 +2554,7 @@ class ImageResponse(LoncapaResponse):
|
||||
self.answer_ids = [ie.get('id') for ie in self.ielements]
|
||||
|
||||
def get_score(self, student_answers):
|
||||
_ = self.capa_system.i18n.ugettext
|
||||
correct_map = CorrectMap()
|
||||
expectedset = self.get_mapped_answers()
|
||||
for aid in self.answer_ids: # loop through IDs of <imageinput>
|
||||
@@ -2565,8 +2566,12 @@ class ImageResponse(LoncapaResponse):
|
||||
# Parse given answer
|
||||
acoords = re.match(r'\[([0-9]+),([0-9]+)]', given.strip().replace(' ', ''))
|
||||
if not acoords:
|
||||
raise Exception('[capamodule.capa.responsetypes.imageinput] '
|
||||
'error grading {0} (input={1})'.format(aid, given))
|
||||
msg = _('error grading {image_input_id} (input={user_input})').format(
|
||||
image_input_id=aid,
|
||||
user_input=given
|
||||
)
|
||||
raise Exception('[capamodule.capa.responsetypes.imageinput] ' + msg)
|
||||
|
||||
(ans_x, ans_y) = [int(x) for x in acoords.groups()]
|
||||
|
||||
rectangles, regions = expectedset
|
||||
@@ -2581,10 +2586,12 @@ class ImageResponse(LoncapaResponse):
|
||||
r'[\(\[]([0-9]+),([0-9]+)[\)\]]-[\(\[]([0-9]+),([0-9]+)[\)\]]',
|
||||
solution_rectangle.strip().replace(' ', ''))
|
||||
if not sr_coords:
|
||||
msg = 'Error in problem specification! cannot parse rectangle in %s' % (
|
||||
etree.tostring(self.ielements[aid], pretty_print=True))
|
||||
raise Exception(
|
||||
'[capamodule.capa.responsetypes.imageinput] ' + msg)
|
||||
# Translators: {sr_coords} are the coordinates of a rectangle
|
||||
msg = _('Error in problem specification! Cannot parse rectangle in {sr_coords}').format(
|
||||
sr_coords=etree.tostring(self.ielements[aid], pretty_print=True)
|
||||
)
|
||||
raise Exception('[capamodule.capa.responsetypes.imageinput] ' + msg)
|
||||
|
||||
(llx, lly, urx, ury) = [int(x) for x in sr_coords.groups()]
|
||||
|
||||
# answer is correct if (x,y) is within the specified
|
||||
@@ -2632,7 +2639,7 @@ class ImageResponse(LoncapaResponse):
|
||||
Input:
|
||||
None
|
||||
Returns:
|
||||
dict (str, (str, str)) - a map of inputs to a tuple of their rectange
|
||||
dict (str, (str, str)) - a map of inputs to a tuple of their rectangle
|
||||
and their regions
|
||||
"""
|
||||
answers = {}
|
||||
|
||||
Reference in New Issue
Block a user