Skip to content

Commit

Permalink
Merge pull request #7 from jspayd/editable-message
Browse files Browse the repository at this point in the history
Make message editable
  • Loading branch information
caseylitton authored Jul 25, 2017
2 parents 2b5b8bb + 8154437 commit 1e7ce55
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Instructors define the following paramters in Studio:
- survey id
- university
- link text
- message
- parameter name for userid

Students click on a link within the unit and this takes them to the survey.
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_qualtrics_survey",
"title": "Qualtrics Survey",
"description": "Xblock for creating a Qualtrics survey.",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/Stanford-Online/xblock-qualtrics-survey",
"author": {
"name": "David Adams",
Expand Down
4 changes: 2 additions & 2 deletions qualtricssurvey/private/view.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="qualtricssurvey_block">
<p>The survey will open in a new browser tab or window.</p>
<p><a href="https://{your_university}.qualtrics.com/jfe/form/{survey_id}{user_id_string}" target="_blank">{link_text}</a></p>
<p>{message}</p>
<p><a class="button primary-button qualtrics-button" href="https://{your_university}.qualtrics.com/jfe/form/{survey_id}{user_id_string}" target="_blank">{link_text}</a></p>
</div>
5 changes: 1 addition & 4 deletions qualtricssurvey/public/view.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<div class="qualtricssurvey_block">
<p>The survey will open in a new browser tab or window.</p>
<p><a class="button primary-button qualtrics-button" href="https://{your_university}.qualtrics.com/jfe/form/{survey_id}{user_id_string}" target="_blank">{link_text}</a></p>
</div>
<div class="qualtricssurvey_block"><p>{message}</p><p><a class="button primary-button qualtrics-button" href="https://{your_university}.qualtrics.com/jfe/form/{survey_id}{user_id_string}" target="_blank">{link_text}</a></p></div>
9 changes: 9 additions & 0 deletions qualtricssurvey/qualtricssurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class QualtricsSurvey(StudioEditableXBlockMixin, XBlock):
scope=Scope.settings,
help=_('This is the text that will link to your survey.'),
)
message = String(
display_name=_('Message:'),
default=_('The survey will open in a new browser tab or window.'),
scope=Scope.settings,
help=_('This is the text that will be displayed above the link to your survey.'),
)
param_name = String(
display_name=_('Param Name:'),
default=_('a'),
Expand All @@ -64,6 +70,7 @@ class QualtricsSurvey(StudioEditableXBlockMixin, XBlock):
'your_university',
'link_text',
'param_name',
'message',
)

# Decorate the view in order to support multiple devices e.g. mobile
Expand All @@ -80,6 +87,7 @@ def student_view(self, context=None):
your_university = self.your_university
link_text = self.link_text
param_name = self.param_name
message = self.message

anon_user_id = self.xmodule_runtime.anonymous_student_id

Expand All @@ -100,6 +108,7 @@ def student_view(self, context=None):
your_university=your_university,
link_text=link_text,
user_id_string=user_id_string,
message=message,
)

fragment = self.build_fragment(
Expand Down
15 changes: 15 additions & 0 deletions qualtricssurvey/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def test_student_view(self):
self.assertIn(url_frag, fragment.content)
url_frag = '>" target="_blank">Begin Survey'
self.assertIn(url_frag, fragment.content)
messageHTML = '<p>' + xblock.message + '</p>'
self.assertIn(messageHTML, fragment.content)

def test_student_view_no_param_name(self):
"""
Expand All @@ -51,3 +53,16 @@ def test_student_view_no_param_name(self):
'here." target="_blank">Begin Survey'
)
self.assertIn(url, fragment.content)

def test_student_view_custom_message(self):
"""
Checks the student view with a custom message.
"""

message = "test message"
xblock = self.make_an_xblock()
xblock.message = message
fragment = xblock.student_view()

messageHTML = '<p>' + message + '</p>'
self.assertIn(messageHTML, fragment.content)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name=package_json.get('name', 'xblock-test'),
version=package_json.get('version', '0.1.0'),
version=package_json.get('version', '0.1.1'),
description=package_json.get('description'),
long_description=package_json.get('description'),
author=package_json.get('author', {}).get('name'),
Expand Down

0 comments on commit 1e7ce55

Please sign in to comment.