Skip to content

Commit

Permalink
feat: added Hotjar survey to legacy ORA view (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
jszewczulak authored Nov 13, 2023
1 parent 9bcad98 commit 49817ae
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 28 deletions.
2 changes: 1 addition & 1 deletion openassessment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Initialization Information for Open Assessment Module
"""

__version__ = '6.0.1'
__version__ = '6.0.2'
10 changes: 10 additions & 0 deletions openassessment/templates/legacy/peer/oa_peer_assessment.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{% load tz %}
{% load i18n %}
{% if show_survey %}
<div id="openassessment_hotjar"></div>
<script>
// check to see if hotjar is available, then trigger hotjar event
const hasWindow = typeof window !== 'undefined';
if (hasWindow && window.hj) {
window.hj('event', 'lms_openassessment_survey');
}
</script>
{% endif %}
{% block list_item %}
<li
id="openassessment__peer-assessment__{{ xblock_id }}"
Expand Down
10 changes: 10 additions & 0 deletions openassessment/templates/legacy/self/oa_self_assessment.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{% load i18n %}
{% load tz %}
{% spaceless %}
{% if show_survey %}
<div id="openassessment_hotjar"></div>
<script>
// check to see if hotjar is available, then trigger hotjar event
const hasWindow = typeof window !== 'undefined';
if (hasWindow && window.hj) {
window.hj('event', 'lms_openassessment_survey');
}
</script>
{% endif %}
{% block list_item %}
<li id="openassessment__self-assessment__{{ xblock_id }}"
class="openassessment__steps__step step--self-assessment is--showing is--in-progress ui-slidable__container {% if allow_latex %}allow--latex{%endif%}"
Expand Down
36 changes: 24 additions & 12 deletions openassessment/xblock/test/test_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def test_released_no_submission(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_unavailable.html', expected_context
Expand All @@ -351,7 +352,8 @@ def test_closed_no_submission(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_closed.html', expected_context
Expand All @@ -370,7 +372,8 @@ def test_before_release(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_unavailable.html', expected_context
Expand All @@ -392,7 +395,8 @@ def test_waiting_for_peers(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_waiting.html',
Expand Down Expand Up @@ -426,7 +430,8 @@ def test_peer_assessment_available(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_assessment.html',
Expand All @@ -449,7 +454,8 @@ def test_peer_cancelled_workflow(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}

self._assert_path_and_context(
Expand All @@ -476,7 +482,8 @@ def test_peer_closed_no_assessments_available(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_closed.html',
Expand Down Expand Up @@ -506,7 +513,8 @@ def test_peer_closed_assessments_available(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_closed.html',
Expand Down Expand Up @@ -534,7 +542,8 @@ def test_completed_and_past_due(self, xblock, workflow_status):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}

self._assert_path_and_context(
Expand Down Expand Up @@ -564,7 +573,8 @@ def test_turbo_grade_past_due(self, xblock, workflow_status):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_turbo_mode_waiting.html',
Expand Down Expand Up @@ -595,7 +605,8 @@ def test_turbo_grade_past_due(self, xblock, workflow_status):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_turbo_mode.html',
Expand All @@ -620,7 +631,8 @@ def test_continued_grading_no_submission(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
self._assert_path_and_context(
xblock, 'legacy/peer/oa_peer_unavailable.html',
Expand Down
35 changes: 23 additions & 12 deletions openassessment/xblock/test/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def test_unavailable(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
)

Expand All @@ -189,7 +190,8 @@ def test_closed(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
)

Expand All @@ -203,7 +205,8 @@ def test_open_no_submission(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
}
)

Expand All @@ -224,6 +227,7 @@ def test_open_in_peer_step(self, xblock):
'allow_latex': True,
'user_timezone': True,
'allow_multiple_files': True,
'show_survey': False
}
)

Expand All @@ -240,7 +244,8 @@ def test_open_in_waiting_for_peer_step(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': None,
'user_language': None
'user_language': None,
'show_survey': False
},
workflow_status='waiting',
status_details={
Expand All @@ -262,8 +267,8 @@ def test_self_then_peer(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': None,
'user_language': None

'user_language': None,
'show_survey': False
},
workflow_status="peer",
status_details={
Expand All @@ -283,7 +288,8 @@ def test_open_done_status(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': None,
'user_language': None
'user_language': None,
'show_survey': False
},
workflow_status='done'
)
Expand All @@ -299,7 +305,8 @@ def test_open_cancelled_status(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
},
workflow_status='cancelled'
)
Expand All @@ -319,7 +326,8 @@ def test_open_self_assessing(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
},
workflow_status='self',
submission_uuid=submission['uuid']
Expand All @@ -345,7 +353,8 @@ def test_open_completed_self_assessment(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
},
workflow_status='self',
submission_uuid=submission['uuid']
Expand All @@ -365,7 +374,8 @@ def test_started_and_past_due(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
},
workflow_status='self',
submission_uuid=submission['uuid']
Expand Down Expand Up @@ -398,7 +408,8 @@ def test_completed_and_past_due(self, xblock):
'allow_latex': False,
'prompts_type': 'text',
'user_timezone': pytz.utc,
'user_language': 'en'
'user_language': 'en',
'show_survey': False
},
workflow_status='self',
submission_uuid=submission['uuid']
Expand Down
11 changes: 9 additions & 2 deletions openassessment/xblock/ui_mixins/legacy/views/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
}


def peer_context(config_data, step_data, peer_sub=None):
def peer_context(config_data, step_data, self_assessment_data, peer_sub=None):
user_preferences = get_user_preferences(config_data.user_service)

is_self = "self-assessment" in config_data.assessment_steps
is_self_complete = self_assessment_data.is_self_complete
peer_has_finished = step_data.has_finished[0]
show_survey = (peer_has_finished and not is_self) or (peer_has_finished and is_self_complete)

context_dict = {
"rubric_criteria": config_data.rubric_criteria_with_labels,
"allow_multiple_files": config_data.allow_multiple_files,
Expand All @@ -29,6 +35,7 @@ def peer_context(config_data, step_data, peer_sub=None):
"user_timezone": user_preferences["user_timezone"],
"user_language": user_preferences["user_language"],
"xblock_id": config_data.get_xblock_id(),
"show_survey": show_survey,
}

if config_data.rubric_feedback_prompt is not None:
Expand Down Expand Up @@ -98,7 +105,7 @@ def peer_path_and_context(api_data, continue_grading):
def path_and_context(path_key, peer_sub=None):
return (
template_paths[path_key],
peer_context(api_data.config_data, step_data, peer_sub),
peer_context(api_data.config_data, step_data, api_data.self_assessment_data, peer_sub),
)

if step_data.is_cancelled:
Expand Down
7 changes: 7 additions & 0 deletions openassessment/xblock/ui_mixins/legacy/views/self.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ def render_self_assessment(api_data):
def self_context(api_data, with_sub=False):
config_data = api_data.config_data
user_preferences = get_user_preferences(config_data.user_service)

is_peer = "peer-assessment" in config_data.assessment_steps
is_self = "self-assessment" in config_data.assessment_steps
is_self_complete = api_data.self_assessment_data.is_self_complete
show_survey = is_self and is_self_complete and not is_peer

context = {
"allow_multiple_files": config_data.allow_multiple_files,
"allow_latex": config_data.allow_latex,
"prompts_type": config_data.prompts_type,
"xblock_id": config_data.get_xblock_id(),
"user_timezone": user_preferences["user_timezone"],
"user_language": user_preferences["user_language"],
"show_survey": show_survey,
}

step_data = api_data.self_assessment_data
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edx-ora2",
"version": "6.0.1",
"version": "6.0.2",
"repository": "https://github.com/openedx/edx-ora2.git",
"dependencies": {
"@edx/frontend-build": "^6.1.1",
Expand Down

0 comments on commit 49817ae

Please sign in to comment.