Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions problem_builder/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
StudentViewUserStateMixin,
XBlockWithTranslationServiceMixin)
from .models import Answer
from .utils import I18NService

# Globals ###########################################################

Expand All @@ -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.
"""
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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))
Expand Down
19 changes: 18 additions & 1 deletion problem_builder/questionnaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__

Expand All @@ -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()
Expand All @@ -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

Expand Down
Binary file modified problem_builder/translations/ko_KR/LC_MESSAGES/text.mo
Binary file not shown.
8 changes: 4 additions & 4 deletions problem_builder/translations/ko_KR/LC_MESSAGES/text.po
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# Constants #########################################################

VERSION = '4.0.3'
VERSION = '4.0.4'

# Functions #########################################################

Expand Down