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
17 changes: 17 additions & 0 deletions problem_builder/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import logging
import uuid

import pkg_resources
import six
from lazy import lazy
from django import utils
from xblock.core import XBlock
from xblock.fields import Integer, Scope, String
from xblock.fragment import Fragment
Expand Down Expand Up @@ -178,6 +180,20 @@ class AnswerBlock(SubmittingXBlockMixin, AnswerMixin, QuestionMixin, StudioEdita

editable_fields = ('question', 'name', 'min_characters', 'weight', 'default_from', 'display_name', 'show_title')

@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 mentoring_view(self, context=None):
""" Render this XBlock within a mentoring block. """
context = context.copy() if context else {}
Expand All @@ -189,6 +205,7 @@ def mentoring_view(self, context=None):
fragment = Fragment(html)
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/answer.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/answer.js'))
fragment.add_javascript(self.get_translation_content())
fragment.initialize_js('AnswerBlock')
return fragment

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.2'
VERSION = '4.0.3'

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

Expand Down