Skip to content

Commit

Permalink
Merge pull request #17 from caseylitton/fix-prompt-html-support
Browse files Browse the repository at this point in the history
Fix prompt html support
  • Loading branch information
caseylitton authored Jun 26, 2017
2 parents 464f448 + 6b1be49 commit 66c9d59
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
1 change: 0 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ module.exports = function (grunt) {
gruntFile,
directoryPrivateJsAll,
directoryPrivateLessAll,
directoryPrivateHtmlAll,
],
tasks: [
'default',
Expand Down
2 changes: 1 addition & 1 deletion freetextresponse/templates/freetextresponse_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="freetextresponse xmodule_display xmodule_CapaModule problem">
<h2 class="problem-header">{{ display_name }}</h2>
<div class="problem-progress">{{ problem_progress }}</div>
<p>{{ prompt }}</p>
<p>{{ prompt|safe }}</p>
<div class="word-count-message">{{ word_count_message }}</div>
<div class="capa_inputtype textline">
<div class="user_input {{ indicator_class }}">
Expand Down
24 changes: 24 additions & 0 deletions freetextresponse/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
'&lt;p&gt;Please enter your response here&lt;/p&gt;'
"""
studio_settings_prompt = "<p>Please enter your response here</p>"
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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 66c9d59

Please sign in to comment.