Skip to content

Commit 84d2200

Browse files
feeat: feature flag, application instance
1 parent 17a9a47 commit 84d2200

5 files changed

Lines changed: 58 additions & 0 deletions

File tree

lms/models/application_instance.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Settings(StrEnum):
7070
HYPOTHESIS_MENTIONS = "hypothesis.mentions"
7171
HYPOTHESIS_PDF_IMAGE_ANNOTATION = "hypothesis.pdf_image_annotation"
7272
HYPOTHESIS_PROMPT_FOR_GRADABLE = "hypothesis.prompt_for_gradable"
73+
HYPOTHESIS_HIDE_AND_REVEAL = "hypothesis.hide_and_reveal"
7374

7475
fields: Mapping[Settings, JSONSetting] = {
7576
Settings.BLACKBOARD_FILES_ENABLED: JSONSetting(
@@ -182,6 +183,11 @@ class Settings(StrEnum):
182183
SettingFormat.TRI_STATE,
183184
default=True,
184185
),
186+
Settings.HYPOTHESIS_HIDE_AND_REVEAL: JSONSetting(
187+
Settings.HYPOTHESIS_HIDE_AND_REVEAL,
188+
SettingFormat.TRI_STATE,
189+
default=False,
190+
),
185191
}
186192

187193

lms/resources/_js_config/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ def enable_file_picker_mode( # noqa: PLR0913
402402
"formFields": form_fields,
403403
"promptForTitle": prompt_for_title,
404404
"promptForGradable": prompt_for_gradable,
405+
# Assignment types the instructor can choose from. Gated by
406+
# the per-install "hide_and_reveal" feature flag.
407+
"assignmentTypes": self._get_assignment_types(),
405408
# Enable auto grading everywhere except in Sakai
406409
"autoGradingEnabled": self._application_instance.tool_consumer_info_product_family_code
407410
!= "sakai",
@@ -430,6 +433,23 @@ def enable_file_picker_mode( # noqa: PLR0913
430433
)
431434
return self._config
432435

436+
def _get_assignment_types(self) -> list[str]:
437+
"""Return the assignment types the instructor can choose from.
438+
439+
`reading` is always available. The "Hide & Reveal" (Guided Social
440+
annotation) type is gated by the per-install `hypothesis.hide_and_reveal`
441+
feature flag.
442+
"""
443+
settings = self._application_instance.settings
444+
types = ["reading"]
445+
446+
if settings.get_setting(
447+
settings.fields[settings.Settings.HYPOTHESIS_HIDE_AND_REVEAL]
448+
):
449+
types.append("hide_and_reveal")
450+
451+
return types
452+
433453
def add_deep_linking_api(self):
434454
"""
435455
Add the details of the "DeepLinking API" in LMS where we support deep linking.

lms/templates/admin/application_instance/show.html.jinja2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
{{ tri_state_settings_checkbox("Collect student emails", fields[Settings.HYPOTHESIS_COLLECT_STUDENT_EMAILS]) }}
131131
{{ tri_state_settings_checkbox("Mentions", fields[Settings.HYPOTHESIS_MENTIONS]) }}
132132
{{ tri_state_settings_checkbox("PDF image annotation", fields[Settings.HYPOTHESIS_PDF_IMAGE_ANNOTATION]) }}
133+
{{ tri_state_settings_checkbox("Hide & Reveal (Guided Social annotation)", fields[Settings.HYPOTHESIS_HIDE_AND_REVEAL]) }}
133134
</fieldset>
134135
<fieldset class="box">
135136
<legend class="label has-text-centered">Grading settings</legend>

tests/unit/lms/models/application_instance_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ def test_it(self):
194194
"hypothesis.pdf_image_annotation",
195195
SettingFormat.TRI_STATE,
196196
),
197+
(
198+
"hypothesis",
199+
"hide_and_reveal",
200+
"hypothesis.hide_and_reveal",
201+
SettingFormat.TRI_STATE,
202+
),
197203
]
198204

199205

tests/unit/lms/resources/_js_config/__init___test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,31 @@ def test_it(
6666
}
6767
)
6868

69+
@pytest.mark.parametrize(
70+
"hide_and_reveal,expected_types",
71+
[
72+
# Flag explicitly on.
73+
(True, ["reading", "hide_and_reveal"]),
74+
# Flag explicitly off.
75+
(False, ["reading"]),
76+
# Flag unset: defaults to off.
77+
(None, ["reading"]),
78+
],
79+
)
80+
def test_it_sets_assignment_types(
81+
self, js_config, course, application_instance, hide_and_reveal, expected_types
82+
):
83+
if hide_and_reveal is not None:
84+
application_instance.settings.set(
85+
"hypothesis", "hide_and_reveal", hide_and_reveal
86+
)
87+
88+
js_config.enable_file_picker_mode(
89+
sentinel.form_action, sentinel.form_fields, course
90+
)
91+
92+
assert js_config.asdict()["filePicker"]["assignmentTypes"] == expected_types
93+
6994
@pytest.mark.parametrize(
7095
"config_function,key",
7196
(

0 commit comments

Comments
 (0)