diff --git a/Gruntfile.js b/Gruntfile.js index 2ba42b6c..820b5aae 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -120,7 +120,6 @@ module.exports = function (grunt) { gruntFile, directoryPrivateJsAll, directoryPrivateLessAll, - directoryPrivateHtmlAll, ], tasks: [ 'default', diff --git a/freetextresponse/templates/freetextresponse_view.html b/freetextresponse/templates/freetextresponse_view.html index 07b75802..2ddf367d 100644 --- a/freetextresponse/templates/freetextresponse_view.html +++ b/freetextresponse/templates/freetextresponse_view.html @@ -2,7 +2,7 @@

{{ display_name }}

{{ problem_progress }}
-

{{ prompt }}

+

{{ prompt|safe }}

{{ word_count_message }}
diff --git a/freetextresponse/tests.py b/freetextresponse/tests.py index c2efbbe7..7c506344 100644 --- a/freetextresponse/tests.py +++ b/freetextresponse/tests.py @@ -12,6 +12,8 @@ from xblock.field_data import DictFieldData from xblock.validation import ValidationMessage +from django.template.loader import get_template + from .freetextresponse import Credit from .freetextresponse import FreeTextResponse @@ -167,6 +169,28 @@ def test_student_view(self): student_view_html ) + def test_build_fragment_prompt_html(self): + """ + Checks that build_fragment allows html in the prompt variable + + if the 'safe' filter is not used then the django + template pipeline returns html tags like, + '<p>Please enter your response here</p>' + """ + studio_settings_prompt = "

Please enter your response here

" + context = { + 'prompt': studio_settings_prompt, + } + template = get_template('freetextresponse_view.html') + fragment = self.xblock.build_fragment( + template, + context, + initialize_js_func='FreeTextResponseView', + additional_css=[], + additional_js=[], + ) + self.assertIn(studio_settings_prompt, fragment.content) + def test_max_score(self): """ Tests max_score function diff --git a/package.json b/package.json index bf30cbde..8b7bc249 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "xblock-free-text-response", "title": "FreeTextResponse XBlock", "description": "Enables instructors to create questions with free-text responses.", - "version": "0.1.3", + "version": "0.1.4", "homepage": "https://github.com/Stanford-Online/xblock-free-text-response", "author": { "name": "Azim Pradhan", diff --git a/setup.py b/setup.py index 07633410..52d60c61 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def run_tests(self): setup( name="xblock-free-text-response", - version="0.1.3", + version="0.1.4", description="Enables instructors to create questions with free-text responses.", license='AGPL-3.0', packages=[