Skip to content

Commit

Permalink
Allow enabling export_formats h FF per instance
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Jan 17, 2024
1 parent 8bf0b29 commit 6de2ff3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
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

0 comments on commit 6de2ff3

Please sign in to comment.