Repository navigation
Enforce local context role detection in Learning Style block - #68
Merged
Merged
Conversation
Previously, the block checked for is_siteadmin() and 'moodle/course:viewhiddensections', forcing the teacher dashboard even for admins/managers acting as students. Now it strictly checks 'block/learning_style:viewreports' in the current context to respect local course roles, matching the behavior of other test blocks.
Simplify unauthorized user checks by removing redundant site admin condition.
Updated the can_view_dashboard method to accept an optional user ID parameter, allowing capability checks for specific users. Adjusted related logic to utilize the updated method for determining teacher access and filtering student IDs.
Refactor access checks to streamline permission validation.
Removed redundant admin checks in key views and improved role detection. Added bold formatting to block title for better visibility.
|
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR addresses an issue where the Learning Style block would incorrectly identify a user's role based on global permissions (like Site Admin or
moodle/course:viewhiddensections) rather than their specific enrollment in the current course.Previously, an admin or manager enrolled as a student in a specific course would see the Teacher Dashboard and be unable to take the test.
Changes
can_view_dashboardinblock_learning_style.php.is_siteadmin()and genericmoodle/course:viewhiddensections.has_capability('block/learning_style:viewreports', $context), ensuring the local course context is respected.This aligns the behavior with the other blocks.