mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-70226-master' of https://github.com/sarjona/moodle
This commit is contained in:
commit
d3cdfc645e
@ -190,8 +190,8 @@ class helper {
|
||||
static::add_item($presetid, 'showdataretentionsummary', '0', 'tool_dataprivacy');
|
||||
static::add_item($presetid, 'forum_maxattachments', '3');
|
||||
static::add_item($presetid, 'guestloginbutton', '0');
|
||||
// Set Activity chooser tabs to "Starred, All, Recommended".
|
||||
static::add_item($presetid, 'activitychoosertabmode', '1');
|
||||
// Set Activity chooser tabs to "Starred, Recommended, All".
|
||||
static::add_item($presetid, 'activitychoosertabmode', '4');
|
||||
|
||||
// Modules: Hide chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
|
||||
static::add_plugin($presetid, 'mod', 'chat', false);
|
||||
@ -301,8 +301,8 @@ class helper {
|
||||
static::add_item($presetid, 'showdataretentionsummary', '1', 'tool_dataprivacy');
|
||||
static::add_item($presetid, 'forum_maxattachments', '9');
|
||||
static::add_item($presetid, 'guestloginbutton', '1');
|
||||
// Set Activity chooser tabs to the default value ("Starred, All, Activities, Resources, Recommended").
|
||||
static::add_item($presetid, 'activitychoosertabmode', '0');
|
||||
// Set Activity chooser tabs to the default value ("Starred, Recommended, All, Activities, Resources").
|
||||
static::add_item($presetid, 'activitychoosertabmode', '3');
|
||||
|
||||
// Modules: Enable chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
|
||||
static::add_plugin($presetid, 'mod', 'chat', true);
|
||||
|
@ -260,8 +260,11 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
'activitychoosertabmode',
|
||||
new lang_string('activitychoosertabmode', 'course'),
|
||||
new lang_string('activitychoosertabmode_desc', 'course'),
|
||||
0,
|
||||
3,
|
||||
[
|
||||
3 => new lang_string('activitychoosertabmodefour', 'course'),
|
||||
4 => new lang_string('activitychoosertabmodefive', 'course'),
|
||||
5 => new lang_string('activitychoosertabmodesix', 'course'),
|
||||
0 => new lang_string('activitychoosertabmodeone', 'course'),
|
||||
1 => new lang_string('activitychoosertabmodetwo', 'course'),
|
||||
2 => new lang_string('activitychoosertabmodethree', 'course'),
|
||||
|
2
course/amd/build/activitychooser.min.js
vendored
2
course/amd/build/activitychooser.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -34,8 +34,11 @@ import Pending from 'core/pending';
|
||||
|
||||
// Tab config options.
|
||||
const ALLACTIVITIESRESOURCES = 0;
|
||||
const ONLYALL = 1;
|
||||
const ACTIVITIESRESOURCES = 2;
|
||||
const ALLACTIVITIESRESOURCESREC = 3;
|
||||
const ONLYALLREC = 4;
|
||||
const ACTIVITIESRESOURCESREC = 5;
|
||||
|
||||
|
||||
// Module types.
|
||||
const ACTIVITY = 0;
|
||||
@ -212,8 +215,20 @@ const templateDataBuilder = (data, chooserConfig) => {
|
||||
const favourites = data.filter(mod => mod.favourite === true);
|
||||
const recommended = data.filter(mod => mod.recommended === true);
|
||||
|
||||
// Both of these modes need Activity & Resource tabs.
|
||||
if ((tabMode === ALLACTIVITIESRESOURCES || tabMode === ACTIVITIESRESOURCES) && tabMode !== ONLYALL) {
|
||||
// Whether the activities and resources tabs should be displayed or not.
|
||||
const showActivitiesAndResources = (tabMode) => {
|
||||
const acceptableModes = [
|
||||
ALLACTIVITIESRESOURCES,
|
||||
ALLACTIVITIESRESOURCESREC,
|
||||
ACTIVITIESRESOURCES,
|
||||
ACTIVITIESRESOURCESREC,
|
||||
];
|
||||
|
||||
return acceptableModes.indexOf(tabMode) !== -1;
|
||||
};
|
||||
|
||||
// These modes need Activity & Resource tabs.
|
||||
if (showActivitiesAndResources(tabMode)) {
|
||||
// Filter the incoming data to find activities then resources.
|
||||
activities = data.filter(mod => mod.archetype === ACTIVITY);
|
||||
resources = data.filter(mod => mod.archetype === RESOURCE);
|
||||
@ -221,18 +236,27 @@ const templateDataBuilder = (data, chooserConfig) => {
|
||||
showResources = true;
|
||||
|
||||
// We want all of the previous information but no 'All' tab.
|
||||
if (tabMode === ACTIVITIESRESOURCES) {
|
||||
if (tabMode === ACTIVITIESRESOURCES || tabMode === ACTIVITIESRESOURCESREC) {
|
||||
showAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
const recommendedBeforeTabs = [
|
||||
ALLACTIVITIESRESOURCESREC,
|
||||
ONLYALLREC,
|
||||
ACTIVITIESRESOURCESREC,
|
||||
];
|
||||
// Whether the recommended tab should be displayed before the All/Activities/Resources tabs.
|
||||
const recommendedBeginning = recommendedBeforeTabs.indexOf(tabMode) !== -1;
|
||||
|
||||
// Given the results of the above filters lets figure out what tab to set active.
|
||||
// We have some favourites.
|
||||
const favouritesFirst = !!favourites.length;
|
||||
const recommendedFirst = favouritesFirst === false && recommendedBeginning === true && !!recommended.length;
|
||||
// We are in tabMode 2 without any favourites.
|
||||
const activitiesFirst = showAll === false && favouritesFirst === false;
|
||||
const activitiesFirst = showAll === false && favouritesFirst === false && recommendedFirst === false;
|
||||
// We have nothing fallback to show all modules.
|
||||
const fallback = showAll === true && favouritesFirst === false;
|
||||
const fallback = showAll === true && favouritesFirst === false && recommendedFirst === false;
|
||||
|
||||
return {
|
||||
'default': data,
|
||||
@ -244,6 +268,8 @@ const templateDataBuilder = (data, chooserConfig) => {
|
||||
showResources: showResources,
|
||||
favourites: favourites,
|
||||
recommended: recommended,
|
||||
recommendedFirst: recommendedFirst,
|
||||
recommendedBeginning: recommendedBeginning,
|
||||
favouritesFirst: favouritesFirst,
|
||||
fallback: fallback,
|
||||
};
|
||||
|
@ -15,21 +15,31 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_course/chooser
|
||||
@template core_course/activitychooser
|
||||
|
||||
Chooser dialog template.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"title": "Chooser title",
|
||||
"options": {
|
||||
"label": "Option name",
|
||||
"description": "Option description",
|
||||
"urls": {
|
||||
"addoption": "http://addoptionurl.com"
|
||||
"recommendedBeginning": true,
|
||||
"favouritesFirst": true,
|
||||
"favourites": [
|
||||
{
|
||||
"title": "Option name 1",
|
||||
"description": "Option description 1"
|
||||
},
|
||||
"icon": "<img class='icon' src='http://urltooptionicon'>"
|
||||
}
|
||||
{
|
||||
"title": "Option name 2",
|
||||
"description": "Option description 2"
|
||||
}
|
||||
],
|
||||
"recommended": [
|
||||
{
|
||||
"title": "Option name 3",
|
||||
"description": "Option description 3"
|
||||
}
|
||||
],
|
||||
"showAll": true
|
||||
}
|
||||
}}
|
||||
|
||||
@ -55,6 +65,21 @@
|
||||
>
|
||||
{{#str}} favourites, core {{/str}}
|
||||
</a>
|
||||
{{#recommendedBeginning}}
|
||||
<a class="nav-item nav-link {{#recommendedFirst}}active{{/recommendedFirst}} {{^recommended}}d-none{{/recommended}}"
|
||||
id="recommended-tab-{{uniqid}}"
|
||||
data-region="recommended-tab-nav"
|
||||
data-toggle="tab"
|
||||
href="#recommended-{{uniqid}}"
|
||||
role="tab"
|
||||
aria-label="{{#str}} aria:recommendedtab, core_course {{/str}}"
|
||||
aria-controls="recommended-{{uniqid}}"
|
||||
aria-selected="false"
|
||||
tabindex="-1"
|
||||
>
|
||||
{{#str}} recommended, core {{/str}}
|
||||
</a>
|
||||
{{/recommendedBeginning}}
|
||||
<a class="nav-item nav-link {{#fallback}}active{{/fallback}} {{^showAll}}d-none{{/showAll}}"
|
||||
id="all-tab-{{uniqid}}"
|
||||
data-toggle="tab"
|
||||
@ -94,7 +119,8 @@
|
||||
>
|
||||
{{#str}} resources, core {{/str}}
|
||||
</a>
|
||||
<a class="nav-item nav-link {{^recommended}}d-none{{/recommended}}"
|
||||
{{^recommendedBeginning}}
|
||||
<a class="nav-item nav-link {{#recommendedFirst}}active{{/recommendedFirst}} {{^recommended}}d-none{{/recommended}}"
|
||||
id="recommended-tab-{{uniqid}}"
|
||||
data-region="recommended-tab-nav"
|
||||
data-toggle="tab"
|
||||
@ -107,6 +133,7 @@
|
||||
>
|
||||
{{#str}} recommended, core {{/str}}
|
||||
</a>
|
||||
{{/recommendedBeginning}}
|
||||
</div>
|
||||
<div class="tab-content flex-fill border-left border-right border-bottom bg-light" id="tabbed-activities-{{uniqid}}">
|
||||
<div class="tab-pane {{#favouritesFirst}}active{{/favouritesFirst}}" id="starred-{{uniqid}}" data-region="favourites" role="tabpanel" aria-labelledby="starred-tab-{{uniqid}}">
|
||||
@ -135,7 +162,7 @@
|
||||
{{/resources}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="recommended-{{uniqid}}" data-region="recommended" role="tabpanel" aria-labelledby="recommended-tab-{{uniqid}}">
|
||||
<div class="tab-pane {{#recommendedFirst}}active{{/recommendedFirst}}" id="recommended-{{uniqid}}" data-region="recommended" role="tabpanel" aria-labelledby="recommended-tab-{{uniqid}}">
|
||||
<div class="optionscontainer d-flex flex-wrap p-1 mw-100 position-relative" role="menubar" data-region="chooser-options-container">
|
||||
{{#recommended}}
|
||||
{{>core_course/local/activitychooser/item}}
|
||||
|
@ -189,3 +189,47 @@ Feature: Display and choose from the available activities in course
|
||||
Then I should not see "All" in the "Add an activity or resource" "dialogue"
|
||||
And I should see "Activities" in the "Add an activity or resource" "dialogue"
|
||||
And I should see "Resources" in the "Add an activity or resource" "dialogue"
|
||||
|
||||
Scenario: Recommended tab is displayed in the right position depending on the activitychoosertabmode setting
|
||||
Given I log out
|
||||
And I log in as "admin"
|
||||
And I navigate to "Courses > Activity chooser > Recommended activities" in site administration
|
||||
And I click on ".activity-recommend-checkbox" "css_element" in the "Book" "table_row"
|
||||
And the following config values are set as admin:
|
||||
# 3 = Starred, Recommended, All, Activities, Resources
|
||||
| activitychoosertabmode | 3 |
|
||||
And I log out
|
||||
And I log in as "teacher"
|
||||
And I am on "Course" course homepage with editing mode on
|
||||
When I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
Then "Recommended" "link" should appear before "All" "link" in the "Add an activity or resource" "dialogue"
|
||||
But the following config values are set as admin:
|
||||
# 0 = Starred, All, Activities, Resources, Recommended
|
||||
| activitychoosertabmode | 0 |
|
||||
And I reload the page
|
||||
And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
And "Recommended" "link" should appear after "Resources" "link" in the "Add an activity or resource" "dialogue"
|
||||
But the following config values are set as admin:
|
||||
# 1 = Starred, All, Recommended
|
||||
| activitychoosertabmode | 1 |
|
||||
And I reload the page
|
||||
And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
And "Recommended" "link" should appear after "All" "link" in the "Add an activity or resource" "dialogue"
|
||||
But the following config values are set as admin:
|
||||
# 2 = Starred, Activities, Resources, Recommended
|
||||
| activitychoosertabmode | 2 |
|
||||
And I reload the page
|
||||
And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
And "Recommended" "link" should appear after "Resources" "link" in the "Add an activity or resource" "dialogue"
|
||||
But the following config values are set as admin:
|
||||
# 4 = Starred, Recommended, All
|
||||
| activitychoosertabmode | 4 |
|
||||
And I reload the page
|
||||
And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
And "Recommended" "link" should appear before "All" "link" in the "Add an activity or resource" "dialogue"
|
||||
But the following config values are set as admin:
|
||||
# 5 = Starred, Recommended, Activities, Resources
|
||||
| activitychoosertabmode | 5 |
|
||||
And I reload the page
|
||||
And I click on "Add an activity or resource" "button" in the "Topic 1" "section"
|
||||
And "Recommended" "link" should appear before "Activities" "link" in the "Add an activity or resource" "dialogue"
|
||||
|
@ -29,10 +29,13 @@ $string['activitychooseractivefooter'] = 'Activity chooser footer';
|
||||
$string['activitychooseractivefooter_desc'] = 'The activity chooser can support plugins that add items to the footer.';
|
||||
$string['activitychooserhidefooter'] = 'No footer';
|
||||
$string['activitychoosertabmode'] = 'Activity chooser tabs';
|
||||
$string['activitychoosertabmode_desc'] = "The activity chooser enables a teacher to easily select activities and resources to add to their course. This setting determines which tabs should be displayed in it. Note that the starred tab is only displayed for a user if they have starred one or more activities and the recommended tab is only displayed if a site administrator has specified some recommended activities.";
|
||||
$string['activitychoosertabmode_desc'] = "The activity chooser lists activities and resources for a teacher to add to their course. To add items to the Recommended tab, go to <a href='../course/recommendations.php'>Recommended activities</a>.";
|
||||
$string['activitychoosertabmodeone'] = 'Starred, All, Activities, Resources, Recommended';
|
||||
$string['activitychoosertabmodetwo'] = 'Starred, All, Recommended';
|
||||
$string['activitychoosertabmodethree'] = 'Starred, Activities, Resources, Recommended';
|
||||
$string['activitychoosertabmodefour'] = 'Starred, Recommended, All, Activities, Resources';
|
||||
$string['activitychoosertabmodefive'] = 'Starred, Recommended, All';
|
||||
$string['activitychoosertabmodesix'] = 'Starred, Recommended, Activities, Resources';
|
||||
$string['activitydate:closed'] = 'Closed:';
|
||||
$string['activitydate:closes'] = 'Closes:';
|
||||
$string['activitydate:opened'] = 'Opened:';
|
||||
|
@ -3019,5 +3019,74 @@ privatefiles,moodle|/user/files.php';
|
||||
upgrade_main_savepoint(true, 2023022000.00);
|
||||
}
|
||||
|
||||
if ($oldversion < 2023030300.01) {
|
||||
$sql = "SELECT preset.*
|
||||
FROM {adminpresets} preset
|
||||
INNER JOIN {adminpresets_it} it ON preset.id = it.adminpresetid
|
||||
WHERE it.name = :name AND it.value = :value AND preset.iscore > 0";
|
||||
// Some settings and plugins have been added/removed to the Starter and Full preset. Add them to the core presets if
|
||||
// they haven't been included yet.
|
||||
$params = ['name' => get_string('starterpreset', 'core_adminpresets'), 'iscore' => 1];
|
||||
$starterpreset = $DB->get_record('adminpresets', $params);
|
||||
if (!$starterpreset) {
|
||||
// Starter admin preset might have been created using the English name.
|
||||
$name = get_string_manager()->get_string('starterpreset', 'core_adminpresets', null, 'en');
|
||||
$params['name'] = $name;
|
||||
$starterpreset = $DB->get_record('adminpresets', $params);
|
||||
}
|
||||
if (!$starterpreset) {
|
||||
// We tried, but we didn't find starter by name. Let's find a core preset that sets 'usecomments' setting to 0.
|
||||
$params = ['name' => 'usecomments', 'value' => '0'];
|
||||
$starterpreset = $DB->get_record_sql($sql, $params);
|
||||
}
|
||||
|
||||
$params = ['name' => get_string('fullpreset', 'core_adminpresets')];
|
||||
$fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
|
||||
if (!$fullpreset) {
|
||||
// Full admin preset might have been created using the English name.
|
||||
$name = get_string_manager()->get_string('fullpreset', 'core_adminpresets', null, 'en');
|
||||
$params['name'] = $name;
|
||||
$fullpreset = $DB->get_record_select('adminpresets', 'name = :name and iscore > 0', $params);
|
||||
}
|
||||
if (!$fullpreset) {
|
||||
// We tried, but we didn't find full by name. Let's find a core preset that sets 'usecomments' setting to 1.
|
||||
$params = ['name' => 'usecomments', 'value' => '1'];
|
||||
$fullpreset = $DB->get_record_sql($sql, $params);
|
||||
}
|
||||
|
||||
$settings = [
|
||||
// Settings. Set Activity chooser tabs to "Starred, Recommended, All"(5) for Starter and back it to default(3) for Full.
|
||||
[
|
||||
'presetid' => $starterpreset->id,
|
||||
'plugin' => 'none',
|
||||
'name' => 'activitychoosertabmode',
|
||||
'value' => '4',
|
||||
],
|
||||
[
|
||||
'presetid' => $fullpreset->id,
|
||||
'plugin' => 'none',
|
||||
'name' => 'activitychoosertabmode',
|
||||
'value' => '3',
|
||||
],
|
||||
];
|
||||
foreach ($settings as $notused => $setting) {
|
||||
$params = ['adminpresetid' => $setting['presetid'], 'plugin' => $setting['plugin'], 'name' => $setting['name']];
|
||||
if (!$record = $DB->get_record('adminpresets_it', $params)) {
|
||||
$record = new \stdClass();
|
||||
$record->adminpresetid = $setting['presetid'];
|
||||
$record->plugin = $setting['plugin'];
|
||||
$record->name = $setting['name'];
|
||||
$record->value = $setting['value'];
|
||||
$DB->insert_record('adminpresets_it', $record);
|
||||
} else {
|
||||
$record->value = $setting['value'];
|
||||
$DB->update_record('adminpresets_it', $record);
|
||||
}
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2023030300.01);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2023030300.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2023030300.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.2dev (Build: 20230303)'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user