Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Dynamic course items not updating properly based on course ro…
Browse files Browse the repository at this point in the history
…le assignments. resolves #749
prasanna-lmsace committed Jan 25, 2025
1 parent 296ea1a commit ce842c8
Showing 4 changed files with 46 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@ moodle-theme_boost_union

Changes
-------
### Unreleased

* 2025-01-25 - Bugfix: Fix dynamic course items not updating properly based on course role assignments. resolves #749.

### v4.5-r5

6 changes: 6 additions & 0 deletions classes/eventobservers.php
Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@ public static function role_assigned(\core\event\base $event) {

// Purge the cached menus for the user with the assigned role.
smartmenu_helper::purge_cache_session_roles($event->objectid, $event->relateduserid);
// Purge the related user cache.
smartmenu_helper::set_user_purgecache($event->relateduserid);
}

/**
@@ -144,6 +146,8 @@ public static function role_unassigned(\core\event\base $event) {

// Purge the cached menus for the user with the unassigned role.
smartmenu_helper::purge_cache_session_roles($event->objectid, $event->relateduserid);
// Purge the related user cache.
smartmenu_helper::set_user_purgecache($event->relateduserid);
}

/**
@@ -159,6 +163,8 @@ public static function role_deleted(\core\event\base $event) {

// Purge the cached menus for all users with the deleted role.
smartmenu_helper::purge_cache_deleted_roles($event->objectid);
// Purge all the dynamic course items cache.
smartmenu_helper::purge_cache_dynamic_courseitems();
}

/**
Original file line number Diff line number Diff line change
@@ -316,3 +316,39 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, usi
| teacher, editingteacher | teacher | should | Course 01 | Inline | smart menu item |
| student | student1 | should | Course 01 | Inline | smart menu item |
| student | teacher | should not | Course 01 | Inline | smart menu item |

@javascript
Scenario: Smartmenus: Menu items: Dynamic courses - User role assignments in future courses
Given the following "theme_boost_union > smart menu" exists:
| title | Future Courses Menu |
| location | Main navigation, Menu bar, User menu, Bottom bar |
And the following "theme_boost_union > smart menu item" exists:
| menu | Future Courses Menu |
| title | Future Courses |
| itemtype | Dynamic courses |
| daterange | Future |
| enrolmentrole | student |
And I am logged in as "admin"
And I am on the "Future Courses Menu > Future Courses" "theme_boost_union > smart menu item" page
And the following "courses" exist:
| fullname | shortname | category | enablecompletion | startdate | enddate |
| Future 01 | F1 | CAT1 | 1 | ## +10 days ##| ## +20 days ## |
| Future 02 | F2 | CAT1 | 1 | ## +15 days ##| ## +25 days ## |
And the following "course enrolments" exist:
| user | course | role |
| student1 | F1 | student |
When I log in as "student1"
Then "Future 01" "theme_boost_union > Smart menu item" should exist in the "Future Courses Menu" "theme_boost_union > Main menu smart menu"
And "Future 02" "theme_boost_union > Smart menu item" should not exist in the "Future Courses Menu" "theme_boost_union > Main menu smart menu"
And the following "course enrolments" exist:
| user | course | role |
| student1 | F2 | student |
And I log in as "student1"
And "Future 02" "theme_boost_union > Smart menu item" should exist in the "Future Courses Menu" "theme_boost_union > Main menu smart menu"
Then I am on the "Future 02" "enrolled users" page logged in as "admin"
And I click on "Unenrol" "icon" in the "student1" "table_row"
And I click on "Unenrol" "button" in the "Unenrol" "dialogue"
And I log out
When I log in as "student1"
Then "Future 01" "theme_boost_union > Smart menu item" should exist in the "Future Courses Menu" "theme_boost_union > Main menu smart menu"
And "Future 02" "theme_boost_union > Smart menu item" should not exist in the "Future Courses Menu" "theme_boost_union > Main menu smart menu"
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2024100708;
$plugin->version = 2024100709;
$plugin->release = 'v4.5-r5';
$plugin->requires = 2024100700;
$plugin->supported = [405, 405];

0 comments on commit ce842c8

Please sign in to comment.