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
84 changes: 80 additions & 4 deletions src/qualtricssurvey/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,88 @@ Using the Studio editor, you can edit the following fields:
- survey id
- university
- link text
- extra parameters
- message
- parameter name for userid

Note: If you plan to make use of the "Param Name" field to store User ID
data, you will need to configure your Qualtrics surveys to in turn
collect that data on Qualtrics' end.
Configuration
~~~~~~~~~~~~~

Operators can configure system-wide defaults via ``XBLOCK_SETTINGS`` in
the Django settings:

.. code-block:: python

XBLOCK_SETTINGS["QualtricsSurvey"] = {
"DEFAULT_UNIVERSITY": "stanforduniversity",
"USER_QUERY_PARAMS": {
"edxuid": "user_id",
"email": "email",
},
}

``DEFAULT_UNIVERSITY``
The default Qualtrics subdomain for your institution. Used when the
per-instance university field is left blank.

``USER_QUERY_PARAMS``
A mapping of URL parameter names to user attributes. The key is the
query parameter name that appears in the survey URL, and the value is
the user attribute to resolve. Supported attributes:

- ``user_id`` - platform user ID (with fallback to anonymous ID)
- ``anonymous_id`` - course-specific anonymous user ID
- ``email`` - primary email address
- ``username`` - platform username

These values come from the XBlock user service. edx-platform only
provides them for authenticated users, so any attribute that cannot be
resolved (for example, for an anonymous visitor) is left out of the URL.

If ``USER_QUERY_PARAMS`` is not configured, no user parameters are
sent by default. To start sending user data to Qualtrics, operators
must explicitly configure this setting.
Existing blocks that already store a legacy ``param_name`` value
continue to use that value as a fallback.

Privacy
~~~~~~~

Values sent through ``USER_QUERY_PARAMS`` become part of the survey URL.
Query strings are recorded in web server and proxy logs, kept in browser
history, and may be forwarded in ``Referer`` headers. Before mapping
``email``, ``username``, or ``user_id``, confirm that sending that data to
Qualtrics is acceptable under your institution's privacy policy.
``anonymous_id`` is the least identifying option.


Upgrading
~~~~~~~~~

Version 2.0 changed two defaults. Blocks that never set these fields in
Studio relied on the old defaults will behave differently after upgrading.

``param_name`` default changed from ``"a"`` to ``""``
Blocks that never set this field used to send ``?a=<anonymous id>``.
They now send no user parameters. The field is no longer editable in
Studio; blocks that explicitly saved a value keep using it. To restore
the old behaviour platform-wide, configure:

.. code-block:: python

XBLOCK_SETTINGS["QualtricsSurvey"] = {
"USER_QUERY_PARAMS": {"a": "anonymous_id"},
}

``your_university`` default changed from ``"stanforduniversity"`` to ``""``
Blocks that never set this field now render a link without a
subdomain unless ``DEFAULT_UNIVERSITY`` is configured. To restore the
old behaviour platform-wide, configure:

.. code-block:: python

XBLOCK_SETTINGS["QualtricsSurvey"] = {
"DEFAULT_UNIVERSITY": "stanforduniversity",
}


Participants
Expand Down
40 changes: 21 additions & 19 deletions src/qualtricssurvey/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class QualtricsSurveyModelMixin:
"survey_id",
"your_university",
"link_text",
"param_name",
"extra_params",
"message",
]
display_name = String(
Expand All @@ -37,11 +37,15 @@ class QualtricsSurveyModelMixin:
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",
extra_params = String(
display_name=_("Extra Parameters:"),
default="",
scope=Scope.settings,
help=_("This is the name for the User ID parameter in the url. If blank, User ID is ommitted from the url."),
help=_(
"Additional query parameters to include in the survey URL. "
"Format: key1=value1&key2=value2. "
"If blank, no extra parameters are added."
),
)
survey_id = String(
display_name=_("Survey ID:"),
Expand All @@ -55,19 +59,17 @@ class QualtricsSurveyModelMixin:
)
your_university = String(
display_name=_("Your University:"),
default="stanforduniversity",
default="",
scope=Scope.settings,
help=_(
"The subdomain for your university's Qualtrics account "
"(e.g.'stanforduniversity'). "
"If left blank, the system-wide default is used."
),
)
# Deprecated: kept for backward compatibility with existing course data.
# Not included in editable_fields so it no longer appears in Studio.
param_name = String(
default="",
scope=Scope.settings,
help=_("This is the name of your university."),
)

def get_anon_id(self):
"""
Return an anonymous user id
"""
try:
user_id = self.xmodule_runtime.anonymous_student_id
except AttributeError:
user_id = -1
return user_id

# pylint: enable=no-member
2 changes: 1 addition & 1 deletion src/qualtricssurvey/templates/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<p>{{ message }}</p>
<p>
<a class="button primary-button qualtrics-button"
href="https://{{ your_university }}.qualtrics.com/jfe/form/{{ survey_id }}{{ user_id_string }}"
href="https://{{ your_university }}.qualtrics.com/jfe/form/{{ survey_id }}{{ query_string }}"
target="_blank">{{ link_text }}</a>
</p>
</div>
Loading