Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enabling h export_formats feature flag per instance #6002

Merged
merged 1 commit into from
Jan 18, 2024
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
1 change: 1 addition & 0 deletions lms/models/application_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ApplicationSettings(JSONSettings):
name="Auto Assigned To Organisation",
),
JSONSetting("hypothesis", "instructor_email_digests_enabled", asbool),
JSONSetting("hypothesis", "export_formats_enabled", asbool),
)


Expand Down
1 change: 1 addition & 0 deletions lms/templates/admin/application_instance/show.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<fieldset class="box">
<legend class="label has-text-centered">General settings</legend>
{{ settings_checkbox('Enable instructor email digests', 'hypothesis', 'instructor_email_digests_enabled') }}
{{ settings_checkbox('Enable export formats', 'hypothesis', 'export_formats_enabled') }}
</fieldset>
<fieldset class="box">
<legend class="label has-text-centered">Canvas settings</legend>
Expand Down
10 changes: 8 additions & 2 deletions lms/views/lti/basic_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,17 @@ def _show_document(self, assignment):
self.context.js_config.add_document_url(assignment.document_url)
self.context.js_config.enable_lti_launch_mode(self.course, assignment)

export_formats_enabled = (
self.request.lti_user.application_instance.settings.get(
"hypothesis", "export_formats_enabled", False
)
)

# If there are any Hypothesis client feature flags that need to be
# enabled based on the current application instance settings, those
# should be enabled here via `self.context.js_config.enable_client_feature`.
#
# There are currently no such features.
if export_formats_enabled:
self.context.js_config.enable_client_feature("export_formats")

# Run any non standard code for the current product
self._misc_plugin.post_launch_assignment_hook(
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/lms/views/lti/basic_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,27 @@ def test__show_document_configures_toolbar(

assert result == {}

@pytest.mark.parametrize("export_formats_feature", [True, False])
def test__show_document_enables_client_features(
self, svc, pyramid_request, context, assignment, export_formats_feature
):
pyramid_request.lti_user.application_instance.settings.set(
"hypothesis", "export_formats_enabled", export_formats_feature
)

# pylint: disable=protected-access
svc._show_document(assignment)

enable_client_feature = context.js_config.enable_client_feature
enabled_features = set(
call.args[0] for call in enable_client_feature.call_args_list
)

if export_formats_feature:
assert "export_formats" in enabled_features
else:
assert "export_formats" not in enabled_features

@pytest.fixture
def assignment(self):
return factories.Assignment(is_gradable=False)
Expand Down