Skip to content

Commit

Permalink
Add a feature flag for the sync grade side of auto grading
Browse files Browse the repository at this point in the history
This will allow us to expose the configuring and calculating side of
auto grading while we work on the syncing part.
  • Loading branch information
marcospri committed Sep 19, 2024
1 parent 5ee0a24 commit a02651c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lms/js_config_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ class User(TypedDict):
class DashboardConfig(TypedDict):
user: User
routes: DashboardRoutes

auto_grading_sync_enabled: bool
"""Whether or nor the opotion to sync grades back to the LMS is enabled."""
1 change: 1 addition & 0 deletions lms/models/application_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ApplicationSettings(JSONSettings):
JSONSetting("hypothesis", "instructor_email_digests_enabled", asbool),
JSONSetting("hypothesis", "lti_13_sourcedid_for_grading", asbool),
JSONSetting("hypothesis", "auto_grading_enabled", asbool),
JSONSetting("hypothesis", "auto_grading_sync_enabled", asbool),
)


Expand Down
4 changes: 4 additions & 0 deletions lms/resources/_js_config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def enable_dashboard_mode(self, token_lifetime_seconds: int) -> None:
"api.dashboard.assignments.grading.sync"
),
),
auto_grading_sync_enabled=self._lti_user
and self._application_instance.settings.get(
"hypothesis", "auto_grading_sync_enabled", False
),
),
}
)
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 @@ -115,6 +115,7 @@
{{ settings_checkbox('Enable instructor email digests', 'hypothesis', 'instructor_email_digests_enabled') }}
{{ settings_checkbox("Use alternative parameter for LTI1.3 grading", "hypothesis", "lti_13_sourcedid_for_grading", default=False) }}
{{ settings_checkbox("Enable auto-grading", "hypothesis", "auto_grading_enabled", default=False) }}
{{ settings_checkbox("Enable auto-grading grade sync", "hypothesis", "auto_grading_sync_enabled", default=False) }}
</fieldset>
<fieldset class="box">
<legend class="label has-text-centered">Canvas settings</legend>
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/lms/resources/_js_config/__init___test.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,18 @@ def LTIEvent(self, patch):


class TestEnableDashboardMode:
def test_it(self, js_config, lti_user, bearer_token_schema):
@pytest.mark.parametrize("auto_grading_sync_setting", [True, False])
def test_it(
self,
js_config,
lti_user,
bearer_token_schema,
auto_grading_sync_setting,
application_instance,
):
application_instance.settings.set(
"hypothesis", "auto_grading_sync_enabled", auto_grading_sync_setting
)
js_config.enable_dashboard_mode(token_lifetime_seconds=100)
config = js_config.asdict()

Expand All @@ -737,6 +748,7 @@ def test_it(self, js_config, lti_user, bearer_token_schema):
"students": "/api/dashboard/students",
"assignment_grades_sync": "/api/dashboard/assignments/:assignment_id/grading/sync",
},
"auto_grading_sync_enabled": auto_grading_sync_setting,
}

def test_user_when_staff(self, js_config, pyramid_request_staff_member, context):
Expand All @@ -748,6 +760,8 @@ def test_user_when_staff(self, js_config, pyramid_request_staff_member, context)
"is_staff": True,
"display_name": "[email protected]",
}
# Grade syncing always disabled for staff
assert not config["dashboard"]["auto_grading_sync_enabled"]

@pytest.fixture
def pyramid_request_staff_member(self, pyramid_config, pyramid_request):
Expand Down

0 comments on commit a02651c

Please sign in to comment.