From 2efa18a68f4d2e639f3c2ed0b8b099bf5e2b0bb1 Mon Sep 17 00:00:00 2001 From: caseylitton Date: Thu, 22 Jun 2017 12:18:36 -0700 Subject: [PATCH 1/3] Remove undefined variable from Gruntfile grunt watch was crashing becuase of an undefined variable. The variable was removed in the xblock vi translation update becuase the html file can no longer be minified. --- Gruntfile.js | 1 - 1 file changed, 1 deletion(-) 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', From 540be402ec7547d0b2369e0ff616223764c2a539 Mon Sep 17 00:00:00 2001 From: caseylitton Date: Thu, 22 Jun 2017 15:09:53 -0700 Subject: [PATCH 2/3] Allow html input to studio setting prompt box The safe tag is a 'djagno template pipeline' builtin to escape html injected into the template. --- .../templates/freetextresponse_view.html | 2 +- freetextresponse/tests.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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 From 6b1be49358675d308b2c2f8c88f1f2899ccb000c Mon Sep 17 00:00:00 2001 From: caseylitton Date: Mon, 26 Jun 2017 15:04:47 -0700 Subject: [PATCH 3/3] Update to version 0.1.4 --- package.json | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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=[