Commit ac26130e by jmclaus

Merge pull request #3897 from edx/jmclaus/i18n_image_response

i18n of Image Response [BLD-723]
parents ca66d982 d6a54c69
...@@ -6,7 +6,7 @@ in roughly chronological order, most recent first. Add your entries at or near ...@@ -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. the top. Include a label indicating the component affected.
All: refactored code to handle course_ids, module_ids, etc in a cleaner way. 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. Blades: Remove Video player outline. BLD-975.
...@@ -22,7 +22,8 @@ Studio: Add drag-and-drop support to the container page. STUD-1309. ...@@ -22,7 +22,8 @@ Studio: Add drag-and-drop support to the container page. STUD-1309.
Common: Add extensible third-party auth module. 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") LMS: Switch default instructor dashboard to the new (formerly "beta")
instructor dashboard. Puts the old (now "legacy") dash behind a feature flag. instructor dashboard. Puts the old (now "legacy") dash behind a feature flag.
......
...@@ -2554,6 +2554,7 @@ class ImageResponse(LoncapaResponse): ...@@ -2554,6 +2554,7 @@ class ImageResponse(LoncapaResponse):
self.answer_ids = [ie.get('id') for ie in self.ielements] self.answer_ids = [ie.get('id') for ie in self.ielements]
def get_score(self, student_answers): def get_score(self, student_answers):
_ = self.capa_system.i18n.ugettext
correct_map = CorrectMap() correct_map = CorrectMap()
expectedset = self.get_mapped_answers() expectedset = self.get_mapped_answers()
for aid in self.answer_ids: # loop through IDs of <imageinput> for aid in self.answer_ids: # loop through IDs of <imageinput>
...@@ -2565,8 +2566,12 @@ class ImageResponse(LoncapaResponse): ...@@ -2565,8 +2566,12 @@ class ImageResponse(LoncapaResponse):
# Parse given answer # Parse given answer
acoords = re.match(r'\[([0-9]+),([0-9]+)]', given.strip().replace(' ', '')) acoords = re.match(r'\[([0-9]+),([0-9]+)]', given.strip().replace(' ', ''))
if not acoords: if not acoords:
raise Exception('[capamodule.capa.responsetypes.imageinput] ' msg = _('error grading {image_input_id} (input={user_input})').format(
'error grading {0} (input={1})'.format(aid, given)) 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()] (ans_x, ans_y) = [int(x) for x in acoords.groups()]
rectangles, regions = expectedset rectangles, regions = expectedset
...@@ -2581,10 +2586,12 @@ class ImageResponse(LoncapaResponse): ...@@ -2581,10 +2586,12 @@ class ImageResponse(LoncapaResponse):
r'[\(\[]([0-9]+),([0-9]+)[\)\]]-[\(\[]([0-9]+),([0-9]+)[\)\]]', r'[\(\[]([0-9]+),([0-9]+)[\)\]]-[\(\[]([0-9]+),([0-9]+)[\)\]]',
solution_rectangle.strip().replace(' ', '')) solution_rectangle.strip().replace(' ', ''))
if not sr_coords: if not sr_coords:
msg = 'Error in problem specification! cannot parse rectangle in %s' % ( # Translators: {sr_coords} are the coordinates of a rectangle
etree.tostring(self.ielements[aid], pretty_print=True)) msg = _('Error in problem specification! Cannot parse rectangle in {sr_coords}').format(
raise Exception( sr_coords=etree.tostring(self.ielements[aid], pretty_print=True)
'[capamodule.capa.responsetypes.imageinput] ' + msg) )
raise Exception('[capamodule.capa.responsetypes.imageinput] ' + msg)
(llx, lly, urx, ury) = [int(x) for x in sr_coords.groups()] (llx, lly, urx, ury) = [int(x) for x in sr_coords.groups()]
# answer is correct if (x,y) is within the specified # answer is correct if (x,y) is within the specified
...@@ -2632,7 +2639,7 @@ class ImageResponse(LoncapaResponse): ...@@ -2632,7 +2639,7 @@ class ImageResponse(LoncapaResponse):
Input: Input:
None None
Returns: 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 and their regions
""" """
answers = {} answers = {}
......
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