diff --git a/problem_builder/answer.py b/problem_builder/answer.py index 48737a4b..faaadcd4 100644 --- a/problem_builder/answer.py +++ b/problem_builder/answer.py @@ -40,6 +40,7 @@ StudentViewUserStateMixin, XBlockWithTranslationServiceMixin) from .models import Answer +from .utils import I18NService # Globals ########################################################### @@ -54,7 +55,7 @@ def _(text): # Classes ########################################################### -class AnswerMixin(XBlockWithPreviewMixin, XBlockWithTranslationServiceMixin, StudentViewUserStateMixin): +class AnswerMixin(XBlockWithPreviewMixin, XBlockWithTranslationServiceMixin, StudentViewUserStateMixin, I18NService): """ Mixin to give an XBlock the ability to read/write data to the Answers DB table. """ @@ -200,7 +201,11 @@ def mentoring_view(self, context=None): context['answer_editable_id'] = uuid.uuid4().hex[:15] context['self'] = self context['hide_header'] = context.get('hide_header', False) or not self.show_title - html = loader.render_django_template('templates/html/answer_editable.html', context) + html = loader.render_django_template( + 'templates/html/answer_editable.html', + context, + i18n_service=self.i18n_service + ) fragment = Fragment(html) fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/answer.css')) @@ -349,7 +354,11 @@ def mentoring_view(self, context=None): context['student_input'] = None else: context['student_input'] = self.student_input - html = loader.render_django_template('templates/html/answer_read_only.html', context) + html = loader.render_django_template( + 'templates/html/answer_read_only.html', + context, + i18n_service=self.i18n_service + ) fragment = Fragment(html) fragment.add_css_url(self.runtime.local_resource_url(self, self.css_path)) diff --git a/problem_builder/questionnaire.py b/problem_builder/questionnaire.py index aa255888..41fbc210 100644 --- a/problem_builder/questionnaire.py +++ b/problem_builder/questionnaire.py @@ -20,8 +20,10 @@ # Imports ########################################################### +import pkg_resources import uuid +from django import utils from django.utils.safestring import mark_safe from lazy import lazy from xblock.core import XBlock @@ -85,6 +87,20 @@ def html_id(self): """ return uuid.uuid4().hex[:20] + @staticmethod + def resource_string(path): + """Handy helper for getting resources from our kit.""" + data = pkg_resources.resource_string(__name__, path) + return data.decode("utf8") + + def get_translation_content(self): + try: + return self.resource_string('public/js/translations/{lang}/textjs.js'.format( + lang=utils.translation.to_locale(utils.translation.get_language()), + )) + except IOError: + return self.resource_string('public/js/translations/en/textjs.js') + def student_view(self, context=None): name = getattr(self, "unmixed_class", self.__class__).__name__ @@ -95,7 +111,7 @@ def student_view(self, context=None): context['custom_choices'] = self.custom_choices context['hide_header'] = context.get('hide_header', False) or not self.show_title - fragment = Fragment(loader.render_django_template(template_path, context)) + fragment = Fragment(loader.render_django_template(template_path, context, i18n_service=self.i18n_service)) # If we use local_resource_url(self, ...) the runtime may insert many identical copies # of questionnaire.[css/js] into the DOM. So we use the mentoring block here if possible. block_with_resources = self.get_parent() @@ -105,6 +121,7 @@ def student_view(self, context=None): block_with_resources = self fragment.add_css_url(self.runtime.local_resource_url(block_with_resources, 'public/css/questionnaire.css')) fragment.add_javascript_url(self.runtime.local_resource_url(block_with_resources, 'public/js/questionnaire.js')) + fragment.add_javascript(self.get_translation_content()) fragment.initialize_js(name) return fragment diff --git a/problem_builder/translations/ko_KR/LC_MESSAGES/text.mo b/problem_builder/translations/ko_KR/LC_MESSAGES/text.mo index 1f1797ad..58bee51c 100644 Binary files a/problem_builder/translations/ko_KR/LC_MESSAGES/text.mo and b/problem_builder/translations/ko_KR/LC_MESSAGES/text.mo differ diff --git a/problem_builder/translations/ko_KR/LC_MESSAGES/text.po b/problem_builder/translations/ko_KR/LC_MESSAGES/text.po index c32e073f..9756b0ea 100644 --- a/problem_builder/translations/ko_KR/LC_MESSAGES/text.po +++ b/problem_builder/translations/ko_KR/LC_MESSAGES/text.po @@ -1465,7 +1465,7 @@ msgstr "다음 평가를 시도하기 전에 다음 아이템을 복습하는 #: templates/html/sb-review-score.html:5 #, python-format msgid "You scored %(score)s%% on this assessment. " -msgstr "이 평가에서 %(score)s%%점을 받으셨습니다. " +msgstr "이 평가에서 %(score)s%%를 받으셨습니다. " #: templates/html/sb-review-score.html:8 msgid "Click a question to review feedback on your response." @@ -1483,7 +1483,7 @@ msgid "" " " msgid_plural "\n You answered %(correct_answers)s questions correctly.\n " msgstr[0] "\n" -" 1개 질문의 정답을 맞혔습니다.\n" +" %(correct_answers)s개 질문의 정답을 맞혔습니다.\n" " " msgstr[1] "\n" " %(correct_answers)s개 질문의 정답을 맞혔습니다.\n" @@ -1510,7 +1510,7 @@ msgid "" " " msgid_plural "\n You answered %(partially_correct_answers)s questions partially correctly.\n " msgstr[0] "\n" -" 1개 질문의 정답을 부분적으로 맞혔습니다.\n" +" %(partially_correct_answers)s개 질문의 정답을 부분적으로 맞혔습니다.\n" " " msgstr[1] "\n" " %(partially_correct_answers)s개 질문의 정답을 부분적으로 맞혔습니다.\n" @@ -1524,7 +1524,7 @@ msgid "" " " msgid_plural "\n You answered %(incorrect_answers)s questions incorrectly.\n " msgstr[0] "\n" -" 1개 질문의 정답을 맞히지 못했습니다.\n" +" %(incorrect_answers)s개 질문의 정답을 맞히지 못했습니다.\n" " " msgstr[1] "\n" " %(incorrect_answers)s개 질문의 정답을 맞히지 못했습니다.\n" diff --git a/setup.py b/setup.py index 2a8d3532..c68fa67d 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ # Constants ######################################################### -VERSION = '4.0.3' +VERSION = '4.0.4' # Functions #########################################################