From d6a54c697df5d7ad486911ec1415622f25520689 Mon Sep 17 00:00:00 2001 From: jmclaus Date: Wed, 28 May 2014 13:21:38 +0200 Subject: [PATCH] i18n of Image Response [BLD-723] --- CHANGELOG.rst | 5 +++-- common/lib/capa/capa/responsetypes.py | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4619a0ec57..13a0856151 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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. diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index f28cc949b3..5b65fb3870 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -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 @@ -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 = {}