From 0fa910aa3d0e826e118f0291a887f1cbd3c1122d Mon Sep 17 00:00:00 2001 From: polesye Date: Mon, 5 May 2014 15:46:02 +0300 Subject: [PATCH] BLD-714: CustomResponse i18n. --- common/lib/capa/capa/responsetypes.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 2c2868a1a2..8f3839f4f7 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1505,6 +1505,7 @@ class CustomResponse(LoncapaResponse): student_answers is a dict with everything from request.POST, but with the first part of each key removed (the string before the first "_"). """ + _ = self.capa_system.i18n.ugettext log.debug('%s: student_answers=%s', unicode(self), student_answers) @@ -1514,9 +1515,16 @@ class CustomResponse(LoncapaResponse): # ordered list of answers submission = [student_answers[k] for k in idset] except Exception as err: - msg = ('[courseware.capa.responsetypes.customresponse] error getting' - ' student answer from %s' % student_answers) - msg += '\n idset = %s, error = %s' % (idset, err) + msg = _( + "[courseware.capa.responsetypes.customresponse] error getting" + " student answer from {student_answers}" + "\n idset = {idset}, error = {err}" + ).format( + student_answers=student_answers, + idset=idset, + err=err + ); + log.error(msg) raise Exception(msg) @@ -1529,7 +1537,7 @@ class CustomResponse(LoncapaResponse): # default to no error message on empty answer (to be consistent with other # responsetypes) but allow author to still have the old behavior by setting # empty_answer_err attribute - msg = ('No answer entered!' + msg = (u'{0}'.format(_(u'No answer entered!')) if self.xml.get('empty_answer_err') else '') return CorrectMap(idset[0], 'incorrect', msg=msg)