Added function to hide badges and flow from toolbox. Also respects the enable badges settings in moodle core

This commit is contained in:
PMKuipers 2024-08-08 12:59:34 +02:00
parent b1c6ddd665
commit a9595974bb
7 changed files with 57 additions and 35 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -282,7 +282,7 @@ export default {
toolFinish: 'tool-finish',
toolStart: 'tool-start',
badges: 'badges',
relatedbages: 'relatedbages@badges',
relatedbadges: 'relatedbages@badges', /* [sic] as in badges translation file */
filter: 'filter@core',
sitebadges: 'sitebadges@badges',
}
@ -4402,6 +4402,9 @@ export default {
data() {
return {
toolboxright: !(settings("toolboxleft")),
toolboxcoursesonly: settings("toolboxcoursesonly"),
enablebadges: settings("enablebadges"),
allowcoursebadges: settings("badges_allowcoursebadges"),
text: strings.toolbox,
relatedbadges: [],
systembadges: [],
@ -4525,8 +4528,13 @@ export default {
self.loadingcourses = false;
return;
}).catch(notification.exception);
this.filterSystembadges();
this.filterRelatedbadges();
if (!this.toolboxcoursesonly && this.enablebadges) {
this.filterSystembadges();
if (this.allowcoursebadges) {
this.filterRelatedbadges();
}
}
},
filterSystembadges() {
const self = this;
@ -4594,7 +4602,7 @@ export default {
</div>
</div>
</b-tab>
<b-tab :title="text.flow" class="t-toolbox-tab">
<b-tab :title="text.flow" v-if="!toolboxcoursesonly" class="t-toolbox-tab">
<ul class="t-flow">
<li><drag
:type="filterComponentType"
@ -4619,10 +4627,10 @@ export default {
</drag></li>
</ul>
</b-tab>
<b-tab :title="text.badges" class="t-toolbox-tab">
<b-tab :title="text.badges" v-if="!toolboxcoursesonly && enablebadges" class="t-toolbox-tab">
<b-tabs content-class='mt-2 ml-2' class="t-toolbox-badges">
<b-tab :title="text.relatedbages">
<b-tab :title="text.relatedbadges" v-if="allowcoursebadges">
<div class="t-toolbox-badges-filter">
<input v-model="filters.relatedbadges" @input="filterRelatedbadges" :placeholder="text.filter"></input>
&nbsp;<a @click="resetRelatedbadges" v-if="filters.relatedbadges" href='#'

View File

@ -187,6 +187,9 @@ class utilityservice extends \external_api {
return new \external_single_structure([
"hivizdropslots" => new \external_value(PARAM_BOOL, 'High visibility drop slots for items'),
"toolboxleft" => new \external_value(PARAM_BOOL, 'Start toolbox default on left side'),
"toolboxcoursesonly" => new \external_value(PARAM_BOOL, 'Show only courses in the toolbox'),
"enablebadges" => new \external_value(PARAM_BOOL, 'Badges are enabled in this instance'),
"badges_allowcoursebadges" => new \external_value(PARAM_BOOL, 'Badges are enabled in this instance'),
]);
}
@ -195,12 +198,16 @@ class utilityservice extends \external_api {
* @return array Success/fail structure
*/
public static function getsettings() {
global $CFG;
\external_api::validate_context(\context_system::instance());
require_login(null, false, null);
return [
"hivizdropslots" => get_config("local_treestudyplan", "hivizdropslots"),
"toolboxleft" => get_config("local_treestudyplan", "toolboxleft"),
"toolboxcoursesonly" => get_config("local_treestudyplan", "toolboxcoursesonly"),
"enablebadges" => !empty($CFG->enablebadges),
"badges_allowcoursebadges" => !empty($CFG->badges_allowcoursebadges),
];
}

View File

@ -23,7 +23,8 @@
require_once("../../config.php");
// Since this page is externally accessed and validated in a different way, no login is needed.
// In fact, we need to override the behaviour of require_login to force "guest access" here, even if the configuration says differently
// In fact, we need to override the behaviour of require_login to force "guest access" here, even if the configuration says differently.
// Note that we do not use set_config(...) here, because we do not want to change the settings in the database.
$autologin = $CFG->autologinguests; // Store current guest autologin configuration value.
$CFG->autologinguests = 1; // Override guest autologin configuration value.
require_login(null,true); // Trigger require_login to make sure we have guest access

View File

@ -83,54 +83,57 @@ $string["coaching_plans"] = "Coaching study plans";
$string["settingspage"] = 'Study plan settings';
$string["setting_navigation_heading"] = 'Navigation';
$string["settingdesc_navigation_heading"] = 'Navigation menu configuration';
$string["settingdesc_navigation_heading"] = 'Navigation menu configuration.';
$string["setting_primary_nav_autofill"] = 'Automatically fill <i>custom menu items</i>';
$string["settingdesc_primary_nav_autofill"] = 'To show the studyplan links in the primary navigation menu (especially in moodle 4.x), lines have to be added to the setting <b>Appearance</b>&nbsp;-&nbsp;<b>Theme&nbsp;settings</b>&nbsp;-&nbsp;<b>Custom&nbsp;menu&nbsp;items</b>.<br>Disable this feature here if you do not want this, e.g. if your theme (up to moodle 3.11) uses flat navigation.';
$string["setting_defaulticon"] = 'Default studyplan image';
$string["settingdesc_defaulticon"] = 'Configure default image to show for a study plans if no specific image is set';
$string["settingdesc_defaulticon"] = 'Configure default image to show for a study plans if no specific image is set.';
$string["settingspage_csync"] = 'Synchronize linked cohorts and users to courses';
$string["setting_csync_heading"] = 'Automatically create a cohort sync in all courses linked to a study plan for all cohorts linked to a study plan';
$string["setting_csync_heading"] = 'Automatically create a cohort sync in all courses linked to a study plan for all cohorts linked to a study plan.';
$string["settingdesc_csync_heading"] = '';
$string["setting_csync_enable_field"] = 'Automatic cohort sync';
$string["settingdesc_csync_enable_field"] = 'Enable automatic cohort sync';
$string["settingdesc_csync_enable_field"] = 'Enable automatic cohort sync.';
$string["setting_csync_autoremove_field"] = 'Automatic deletion';
$string["settingdesc_csync_autoremove_field"] = 'Delete synchronization from courses once a cohort is removed from the study plan';
$string["settingdesc_csync_autoremove_field"] = 'Delete synchronization from courses once a cohort is removed from the study plan.';
$string["setting_csync_creategroup_field"] = 'Create groups';
$string["settingdesc_csync_creategroup_field"] = 'Create a group in the course for each cohort sync';
$string["settingdesc_csync_creategroup_field"] = 'Create a group in the course for each cohort sync.';
$string["setting_csync_role_field"] = 'Role';
$string["settingdesc_csync_role_field"] = 'The role to use for automatic cohort sync enrollment created in courses';
$string["settingdesc_csync_role_field"] = 'The role to use for automatic cohort sync enrollment created in courses.';
$string["setting_csync_remember_manual_csync_field"] = 'Remember existing cohort-syncs';
$string["settingdesc_csync_remember_manual_csync_field"] = 'Mark cohort syncs that were manually created earlier, so they won\'t be removed during auto sync if cohorts are removed from the study plan';
$string["settingdesc_csync_remember_manual_csync_field"] = 'Mark cohort syncs that were manually created earlier, so they won\'t be removed during auto sync if cohorts are removed from the study plan.';
$string["setting_csync_users_field"] = 'Enroll linked users';
$string["settingdesc_csync_users_field"] = 'Also enrol all users that are explicitly linked to a study plan in that study plan\'s courses.';
$string["setting_display_heading"] = 'Display';
$string["settingdesc_display_heading"] = 'Study plan display settings';
$string["settingdesc_display_heading"] = 'Study plan display settings.';
$string["setting_display_field"] = 'Course display name';
$string["settingdesc_display_field"] = 'Select the field to use for the display name of a course in the study plan';
$string["settingdesc_display_field"] = 'Select the field to use for the display name of a course in the study plan.';
$string["setting_enableplansharing"] = 'Enable sharing of study plan';
$string["settingdesc_enableplansharing"] = 'Allow students to share access to the study plan with others through a unique link';
$string["settingdesc_enableplansharing"] = 'Allow students to share access to the study plan with others through a unique link.';
$string["setting_limitcourselist"] = 'Limit course list to study plan category';
$string["settingdesc_limitcourselist"] = 'Limit the list of available courses for a study plan to the category the studyplan is located in.';
$string["setting_enablecoach"] = 'Enable coach role';
$string["settingdesc_enablecoach"] = 'The coach role allows one coach specific access to one study plan with limited access to modify it.';
$string["setting_timelessperiods"] = 'Timeless periods and pages';
$string["settingdesc_timelessperiods"] = 'Do not include timing info in periods or pages';
$string["settingdesc_timelessperiods"] = 'Do not include timing info in periods or pages.';
$string["setting_courseprogressbar"] = 'Show progress bar in course';
$string["settingdesc_courseprogressbar"] = 'Show a progress bar in the course pop-up';
$string["settingdesc_courseprogressbar"] = 'Show a progress bar in the course pop-up.';
$string["setting_infofields_heading"] = 'Extra course information fields';
$string["settingdesc_infofields_heading"] = 'Select up to 5 fields or custom fields to add to the course pop-up';
$string["settingdesc_infofields_heading"] = 'Select up to 5 fields or custom fields to add to the course pop-up.';
$string["setting_hivizdropslots"] = 'High visibility drop fields';
$string["settingdesc_hivizdropslots"] = 'Give the drop fields when editing a study plan extra visibility';
$string["settingdesc_hivizdropslots"] = 'Give the drop fields when editing a study plan extra visibility.';
$string["setting_toolboxleft"] = 'Toolbar left side by default';
$string["settingdesc_toolboxleft"] = 'Show the course and component toolbar on the left by default, instead of the right side of the screen';
$string["settingdesc_toolboxleft"] = 'Show the course and component toolbar on the left by default, instead of the right side of the screen.';
$string["setting_toolboxcoursesonly"] = 'Show only the courses in the toolbox';
$string["settingdesc_toolboxcoursesonly"] = 'Hide the badges and flow tabs in the toolbox and show only the courses.';
$string["drophere"] = "Drop here";
$string["infofield_position_above"] = 'Above course results';

View File

@ -83,35 +83,35 @@ $string["coaching_plans"] = "Studieplannen die ik coach";
$string["settingspage"] = 'Studieplan instellingen';
$string["setting_navigation_heading"] = 'Navigatie';
$string["settingdesc_navigation_heading"] = 'Instellingen voor navigatie';
$string["settingdesc_navigation_heading"] = 'Instellingen voor navigatie.';
$string["setting_primary_nav_autofill"] = '<i>Aangepast menu items</i> automatisch aanvullen';
$string["settingdesc_primary_nav_autofill"] = 'Om in het primaire navigatiemenu de studieplan links te tonen (vooral in Moodle 4.x), moeten regels worden toegevoegd in <b>Uiterlijk</b>&nbsp;-&nbsp;<b>Thema&nbsp;instellingen</b>&nbsp;<b>Aangepast&nbsp;menu&nbsp;items</b><br>Zet deze functie hier uit als dat niet gewenst is, b.v. als je Moodle (3.11 of lager) thema flat navigation gebruikt.';
$string["setting_defaulticon"] = 'Standaard afbeelding voor studieplan';
$string["settingdesc_defaulticon"] = 'Stel standaard afbeelding in om weer te geven als een studieplan geen eigen afbeelding heeft ingesteld';
$string["settingdesc_defaulticon"] = 'Stel standaard afbeelding in om weer te geven als een studieplan geen eigen afbeelding heeft ingesteld.';
$string["settingspage_csync"] = 'Site-groepen en gebruikerskoppelingen doorzetten naar cursussen';
$string["setting_csync_heading"] = 'Site-groepen die aan een studieplan gekoppeld zijn automatisch als site-groep synchronisatie koppelen aan alle cursussen in het studieplan.';
$string["settingdesc_csync_heading"] = '';
$string["setting_csync_enable_field"] = 'Automatisch koppelen inschakelen';
$string["settingdesc_csync_enable_field"] = 'Automatische koppelen van site-groep synchronisatie inschakelen';
$string["settingdesc_csync_enable_field"] = 'Automatische koppelen van site-groep synchronisatie inschakelen.';
$string["setting_csync_autoremove_field"] = 'Automatisch verwijderen';
$string["settingdesc_csync_autoremove_field"] = 'Verwijder synchronisaties in cursussen als deze uit het studieplan worden verwijderd';
$string["settingdesc_csync_autoremove_field"] = 'Verwijder synchronisaties in cursussen als deze uit het studieplan worden verwijderd.';
$string["setting_csync_creategroup_field"] = 'Groepen aanmaken';
$string["settingdesc_csync_creategroup_field"] = 'Maak voor elke site-groep synchronisatie een groep aan';
$string["settingdesc_csync_creategroup_field"] = 'Maak voor elke site-groep synchronisatie een groep aan.';
$string["setting_csync_role_field"] = 'Synchronisatierol';
$string["settingdesc_csync_role_field"] = 'Welke rol te gebruiken voor automatische site-groep sync koppelingen';
$string["settingdesc_csync_role_field"] = 'Welke rol te gebruiken voor automatische site-groep sync koppelingen.';
$string["setting_csync_remember_manual_csync_field"] = 'Bewaar bestaande site-group syncs';
$string["settingdesc_csync_remember_manual_csync_field"] = 'Markeer site-group synchronisaties die eerder handmatig zijn aangemaakt, zodat deze niet worden verwijderd als ze uit het studieplan worden gehaald.';
$string["setting_csync_users_field"] = 'Gekoppelde gebruikers automatisch inchrijven';
$string["settingdesc_csync_users_field"] = 'Ook alle gebruikers die expliciet aan een studieplan gekoppeld zijn inschrijven in de cursussen van dat studieplan.';
$string["setting_display_heading"] = 'Weergave';
$string["settingdesc_display_heading"] = 'Configuratie voor de weergave van de studieplannen';
$string["settingdesc_display_heading"] = 'Configuratie voor de weergave van de studieplannen.';
$string["setting_display_field"] = 'Weergavenaam cursus';
$string["settingdesc_display_field"] = 'Kies welk veld gebruikt moet worden als weergavenaam van een cursus';
$string["settingdesc_display_field"] = 'Kies welk veld gebruikt moet worden als weergavenaam van een cursus.';
$string["setting_enableplansharing"] = 'Studieplan delen toestaan';
$string["settingdesc_enableplansharing"] = 'Sta studenten toe om hun studieplannen te delen met anderen via een unieke link';
$string["settingdesc_enableplansharing"] = 'Sta studenten toe om hun studieplannen te delen met anderen via een unieke lin.k';
$string["setting_limitcourselist"] = 'Cursusenlijst beperken tot categorie';
$string["settingdesc_limitcourselist"] = 'Beperk de lijst met beschikbare cursussen om in een studieplan te slepen tot de cateogrie waarin het studieplan zich bevindt.';
@ -121,7 +121,7 @@ $string["setting_timelessperiods"] = 'Tabbladen en periodes zonder tijd';
$string["settingdesc_timelessperiods"] = 'Gebruik geen tijdinformatie in perioden en tabbladen';
$string["setting_courseprogressbar"] = 'Toon voortgangsbalk in cursus';
$string["settingdesc_courseprogressbar"] = 'Laat een voortgangsbalk zien in de cursuspopup';
$string["settingdesc_courseprogressbar"] = 'Laat een voortgangsbalk zien in de cursuspopup.';
$string["setting_infofields_heading"] = 'Extra cursusinformatie in popup';
$string["settingdesc_infofields_heading"] = 'Kies tot 5 extra velden om in het cursuspopupvenster te laten zien.';
@ -132,6 +132,9 @@ $string["settingdesc_hivizdropslots"] = 'Maak de velden waar cursussen heen gesl
$string["setting_toolboxleft"] = 'Toolbox standaard links';
$string["settingdesc_toolboxleft"] = 'Toon de toolbox met cursussen en componenten standaard links in plaats van rechts.';
$string["setting_toolboxcoursesonly"] = 'Toon alleen cursussen in toolbox';
$string["settingdesc_toolboxcoursesonly"] = 'Verberg de tabbladen "flow" en "badges" in de toolbox en toon alleen de cursussen.';
$string["drophere"] = "Sleep hierheen";
$string["infofield_position_above"] = 'Boven cursusresultaten';
$string["infofield_position_below"] = 'Onder cursusresultaten';