Skip to content

Commit

Permalink
Enable dashboard for all instructors
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Aug 19, 2024
1 parent bc9eab5 commit d5bf709
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 28 deletions.
7 changes: 1 addition & 6 deletions lms/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,7 @@ def identity(self, request) -> Identity | None:
if lti_user.is_instructor:
permissions.append(Permissions.LTI_CONFIGURE_ASSIGNMENT)
permissions.append(Permissions.GRADE_ASSIGNMENT)

if lti_user.application_instance.settings.get(
"hypothesis", "instructor_dashboard"
):
# Only include this permission if the feature is enabled
permissions.append(Permissions.DASHBOARD_VIEW)
permissions.append(Permissions.DASHBOARD_VIEW)

return Identity(self._get_userid(lti_user), permissions, lti_user)

Expand Down
1 change: 0 additions & 1 deletion lms/templates/admin/application_instance/show.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
<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 instructor dashboard', 'hypothesis', 'instructor_dashboard') }}
{{ settings_checkbox("Use alternative parameter for LTI1.3 grading", "hypothesis", "lti_13_sourcedid_for_grading", default=False) }}
</fieldset>
<fieldset class="box">
Expand Down
6 changes: 1 addition & 5 deletions lms/views/lti/basic_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,11 @@ def _show_document(self, assignment):
self.request.lti_params.get("lis_outcome_service_url"),
)

application_instance = self.request.lti_user.application_instance

# Set up the JS config for the front-end
self.context.js_config.add_document_url(assignment.document_url)
self.context.js_config.enable_lti_launch_mode(self.course, assignment)

if self.request.lti_user.is_instructor and application_instance.settings.get(
"hypothesis", "instructor_dashboard"
):
if self.request.lti_user.is_instructor:
self.context.js_config.enable_instructor_dashboard_entry_point(assignment)

# If there are any Hypothesis client feature flags that need to be
Expand Down
11 changes: 1 addition & 10 deletions tests/unit/lms/security_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pyramid.interfaces import ISecurityPolicy
from pyramid.security import Allowed, Denied

from lms.models import ApplicationSettings
from lms.security import (
CookiesBearerTokenLTIUserPolicy,
DeniedWithException,
Expand Down Expand Up @@ -277,26 +276,19 @@ def test_identity_when_theres_an_lti_user_with_no_roles(
assert not identity.permissions
assert identity.userid

@pytest.mark.parametrize(
"settings",
[{}, {"hypothesis": {"instructor_dashboard": True}}],
)
@pytest.mark.parametrize("is_instructor", [True, False])
def test_identity_when_theres_an_lti_user(
self,
request,
pyramid_request,
is_instructor,
application_instance,
settings,
policy,
get_lti_user,
):
if is_instructor:
_ = request.getfixturevalue("user_is_instructor")
else:
_ = request.getfixturevalue("user_is_learner")
settings = application_instance.settings = ApplicationSettings(settings)
get_lti_user.return_value = pyramid_request.lti_user

identity = policy.identity(pyramid_request)
Expand All @@ -313,10 +305,9 @@ def test_identity_when_theres_an_lti_user(
[
Permissions.LTI_CONFIGURE_ASSIGNMENT,
Permissions.GRADE_ASSIGNMENT,
Permissions.DASHBOARD_VIEW,
]
)
if settings.get("hypothesis", "instructor_dashboard"):
expected_permissions.append(Permissions.DASHBOARD_VIEW)

assert identity.permissions == expected_permissions

Expand Down
7 changes: 1 addition & 6 deletions tests/unit/lms/views/lti/basic_launch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def test__show_document(

@pytest.mark.parametrize("use_toolbar_editing", [True, False])
@pytest.mark.parametrize("use_toolbar_grading", [True, False])
@pytest.mark.parametrize("instructor_dashboard_enabled", [True, False])
@pytest.mark.parametrize("is_gradable", [True, False])
@pytest.mark.parametrize("is_instructor", [True, False])
def test__show_document_configures_toolbar(
Expand All @@ -286,7 +285,6 @@ def test__show_document_configures_toolbar(
lti_user,
use_toolbar_editing,
use_toolbar_grading,
instructor_dashboard_enabled,
is_gradable,
is_instructor,
grading_info_service,
Expand All @@ -297,9 +295,6 @@ def test__show_document_configures_toolbar(
request.getfixturevalue("user_is_instructor")
pyramid_request.product.use_toolbar_grading = use_toolbar_grading
pyramid_request.product.use_toolbar_editing = use_toolbar_editing
lti_user.application_instance.settings.set(
"hypothesis", "instructor_dashboard", instructor_dashboard_enabled
)

result = svc._show_document(assignment) # noqa: SLF001

Expand All @@ -309,7 +304,7 @@ def test__show_document_configures_toolbar(
else:
context.js_config.enable_toolbar_editing.assert_not_called()

if instructor_dashboard_enabled and is_instructor:
if is_instructor:
context.js_config.enable_instructor_dashboard_entry_point.assert_called_once()
else:
context.js_config.enable_instructor_dashboard_entry_point.assert_not_called()
Expand Down

0 comments on commit d5bf709

Please sign in to comment.