Skip to content

Commit

Permalink
chore: stop esg url to show up when the environment is not defined (#…
Browse files Browse the repository at this point in the history
…2200)

* chore: stop esg url to show up when the environment is not defined

* chore: linting

* chore: update js test

* chore: version bump
  • Loading branch information
leangseu-edx authored Apr 4, 2024
1 parent 72b6504 commit ce3c271
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 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.6.1'
__version__ = '6.6.2'
4 changes: 2 additions & 2 deletions openassessment/templates/legacy/staff_area/oa_staff_area.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</button>
<button class="ui-staff__button button-staff-info" aria-expanded="false" data-panel="openassessment__staff-info">{% trans "View Assignment Statistics" %}</button>
{% if staff_assessment_required %}
{% if is_enhanced_staff_grader_enabled %}
{% if is_enhanced_staff_grader_enabled and enhanced_staff_grader_url %}
<a href="{{enhanced_staff_grader_url}}" class="ui-staff__button button-enhanced-staff-grader" aria-expanded="false">{% trans "Grade Available Responses" %} <span class="icon fa fa-external-link" aria-hidden="true"></span></a>
{% else %}
<button class="ui-staff__button button-staff-grading" aria-expanded="false" data-panel="openassessment__staff-grading">{% trans "Grade Available Responses" %}</button>
{% comment %} Remove if block in AU-617 {% endcomment %}
{% if not is_team_assignment %}
{% if not is_team_assignment and enhanced_staff_grader_url %}
<a href="{{enhanced_staff_grader_url}}" class="ui-staff__button button-enhanced-staff-grader button-enhanced-staff-grader-demo" aria-expanded="false">{% trans "Demo the new Grading Experience" %} <span class="icon fa fa-external-link" aria-hidden="true"></span></a>
{% endif %}
{% endif %}
Expand Down
7 changes: 3 additions & 4 deletions openassessment/xblock/staff_area_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ def get_staff_path_and_context(self):
context['is_enhanced_staff_grader_enabled'] = False
else:
context['is_enhanced_staff_grader_enabled'] = self.is_enhanced_staff_grader_enabled
context['enhanced_staff_grader_url'] = '{esg_url}/{block_id}'.format(
esg_url=getattr(settings, 'ORA_GRADING_MICROFRONTEND_URL', ''),
block_id=str(self.get_xblock_id())
)

esg_url = getattr(settings, 'ORA_GRADING_MICROFRONTEND_URL', None)
context['enhanced_staff_grader_url'] = f'{esg_url}/{str(self.get_xblock_id())}' if esg_url else None

context.update(
self.get_staff_assessment_statistics_context(student_item["course_id"], student_item["item_id"])
Expand Down
2 changes: 2 additions & 0 deletions openassessment/xblock/static/js/fixtures/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@
"template": "legacy/staff_area/oa_staff_area.html",
"context": {
"is_enhanced_staff_grader_enabled": false,
"enhanced_staff_grader_url": null,
"staff_assessment_required": true,
"staff_assessment_ungraded": 5,
"staff_assessment_in_progress": 2,
Expand Down Expand Up @@ -816,6 +817,7 @@
"template": "legacy/staff_area/oa_staff_area.html",
"context": {
"is_enhanced_staff_grader_enabled": true,
"enhanced_staff_grader_url": "esg_url",
"staff_assessment_required": true,
"staff_assessment_ungraded": 5,
"staff_assessment_in_progress": 2,
Expand Down
5 changes: 2 additions & 3 deletions openassessment/xblock/static/js/spec/lms/oa_staff_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,12 @@ describe('OpenAssessment.StaffAreaView', function() {
it('when ora staff grader is disabled', function() {
var view = createStaffArea({}, 'oa_staff_area_full_grading_esg_disabled.html'),
$buttons = $('.ui-staff__button', view.element);
expect($buttons.length).toBe(5);
expect($buttons.length).toBe(4);
expect($buttons).toHaveAttr('aria-expanded', 'false');
expect($($buttons[0]).text().trim()).toEqual('Manage Individual Learners');
expect($($buttons[1]).text().trim()).toEqual('View Assignment Statistics');
expect($($buttons[2]).text().trim()).toEqual('Grade Available Responses');
expect($($buttons[3]).text().trim()).toEqual('Demo the new Grading Experience');
expect($($buttons[4]).text().trim()).toEqual('View ORA in Studio');
expect($($buttons[3]).text().trim()).toEqual('View ORA in Studio');
});
});

Expand Down
19 changes: 19 additions & 0 deletions openassessment/xblock/test/test_staff_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,25 @@ def test_staff_area_esg(self, xblock, is_esg_enabled, mock_esg_flag):
block_id=context['xblock_id']
))

@override_settings(
ORA_GRADING_MICROFRONTEND_URL=None
)
@patch(
'openassessment.xblock.config_mixin.ConfigMixin.is_enhanced_staff_grader_enabled',
new_callable=PropertyMock
)
@scenario('data/staff_grade_scenario.xml', user_id='Bob')
def test_staff_area_esg_no_url(self, xblock, mock_esg_flag):
"""
If there is a staff step, enhanced_staff_grader_url should be None
if ORA_GRADING_MICROFRONTEND_URL is not set
"""
mock_esg_flag.return_value = True
_, context = xblock.get_staff_path_and_context()
self._verify_staff_assessment_context(context, True, 0, 0)
self.assertEqual(context['is_enhanced_staff_grader_enabled'], True)
self.assertIsNone(context['enhanced_staff_grader_url'])

@log_capture()
@patch('openassessment.xblock.config_mixin.ConfigMixin.user_state_upload_data_enabled')
@scenario('data/file_upload_missing_scenario.xml', user_id='Bob')
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.5.1",
"version": "6.6.2",
"repository": "https://github.com/openedx/edx-ora2.git",
"dependencies": {
"@edx/frontend-build": "8.0.6",
Expand Down

0 comments on commit ce3c271

Please sign in to comment.