mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'MDL-75596-master' of https://github.com/sh-csg/moodle
This commit is contained in:
commit
be95fb2581
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
@ -146,7 +146,12 @@ const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
}
|
||||
|
||||
// Apply the section id to all the module instance links.
|
||||
const builtModuleData = sectionIdMapper(data, caller.dataset.sectionid, caller.dataset.sectionreturnid);
|
||||
const builtModuleData = sectionIdMapper(
|
||||
data,
|
||||
caller.dataset.sectionid,
|
||||
caller.dataset.sectionreturnid,
|
||||
caller.dataset.beforemod
|
||||
);
|
||||
|
||||
ChooserDialogue.displayChooser(
|
||||
sectionModal,
|
||||
@ -172,13 +177,14 @@ const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
* @param {Object} webServiceData Our original data from the Web service call
|
||||
* @param {Number} id The ID of the section we need to append to the links
|
||||
* @param {Number|null} sectionreturnid The ID of the section return we need to append to the links
|
||||
* @param {Number|null} beforemod The ID of the cm we need to append to the links
|
||||
* @return {Array} [modules] with URL's built
|
||||
*/
|
||||
const sectionIdMapper = (webServiceData, id, sectionreturnid) => {
|
||||
const sectionIdMapper = (webServiceData, id, sectionreturnid, beforemod) => {
|
||||
// We need to take a fresh deep copy of the original data as an object is a reference type.
|
||||
const newData = JSON.parse(JSON.stringify(webServiceData));
|
||||
newData.content_items.forEach((module) => {
|
||||
module.link += '§ion=' + id + '&sr=' + (sectionreturnid ?? 0);
|
||||
module.link += '§ion=' + id + '&sr=' + (sectionreturnid ?? 0) + '&beforemod=' + (beforemod ?? 0);
|
||||
});
|
||||
return newData.content_items;
|
||||
};
|
||||
|
@ -56,6 +56,11 @@
|
||||
"modstealth": true
|
||||
}
|
||||
}}
|
||||
{{#editing}}
|
||||
<div class="divider divider-plus" data-action="insert-before-{{activityname}}">
|
||||
{{> core_course/activitychooserbuttonactivity}}
|
||||
</div>
|
||||
{{/editing}}
|
||||
<div class="activity-item {{#modstealth}}hiddenactivity{{/modstealth}}{{!
|
||||
}}{{#modhiddenfromstudents}}hiddenactivity{{/modhiddenfromstudents}}{{!
|
||||
}}{{#modinline}}activityinline{{/modinline}}" data-activityname="{{activityname}}">
|
||||
|
37
course/templates/activitychooserbuttonactivity.mustache
Normal file
37
course/templates/activitychooserbuttonactivity.mustache
Normal file
@ -0,0 +1,37 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_course/activitychooserbuttonactivity
|
||||
|
||||
Displays a add activity or resource button.
|
||||
|
||||
Context variables required for this template:
|
||||
* id - Which activity we want to add the new activity before.
|
||||
* num - Relative section number (field course_sections.section).
|
||||
* sectionreturn - The section to link back to.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"id": 0,
|
||||
"num": 1,
|
||||
"sectionreturn": 5
|
||||
}
|
||||
}}
|
||||
<button class="btn btn-link text-decoration-none section-modchooser section-modchooser-link activity-add d-flex align-items-center p-3 mb-3 activitychooser-button"
|
||||
data-action="open-chooser" data-sectionid="{{num}}" data-sectionreturnid="{{sectionreturn}}" data-beforemod="{{id}}" aria-label="{{#str}}insertresourceoractivitybefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}" tabindex="0">
|
||||
{{#pix}} t/add, core {{/pix}}
|
||||
</button>
|
42
course/tests/behat/activity_chooser_plus.feature
Normal file
42
course/tests/behat/activity_chooser_plus.feature
Normal file
@ -0,0 +1,42 @@
|
||||
@core @core_course @javascript
|
||||
Feature: Use the activity chooser to insert activities anywhere in a section
|
||||
In order to add activities to a course
|
||||
As a teacher
|
||||
I should be able to add an activity anywhere in a section.
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher | Teacher | 1 | teacher@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course | C | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher | C | editingteacher |
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | intro | name | section |
|
||||
| page | C | p1 | x | Test Page | 1 |
|
||||
| forum | C | f1 | x | Test Forum | 1 |
|
||||
| label | C | l1 | x | Test Label | 1 |
|
||||
And I log in as "teacher"
|
||||
And I am on "Course" course homepage with editing mode on
|
||||
|
||||
Scenario: The activity chooser icon is hidden by default and be made visible on hover
|
||||
Given I hover ".navbar-brand" "css_element"
|
||||
And "[data-action='insert-before-Test Forum'] button" "css_element" should not be visible
|
||||
When I hover "[data-action='insert-before-Test Forum']" "css_element"
|
||||
Then "[data-action='insert-before-Test Forum'] button" "css_element" should be visible
|
||||
|
||||
Scenario: The activity chooser can be used to insert modules before existing modules
|
||||
Given I hover "[data-action='insert-before-Test Forum']" "css_element"
|
||||
And I click on "[data-action='insert-before-Test Forum'] button" "css_element"
|
||||
And I should see "Add an activity or resource" in the ".modal-title" "css_element"
|
||||
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
|
||||
And I set the following fields to these values:
|
||||
| Assignment name | Test Assignment |
|
||||
And I press "Save and return to course"
|
||||
And I should see "Test Assignment" in the "Topic 1" "section"
|
||||
# Ensure the new assignment is in the middle of the two existing modules.
|
||||
Then "Test Page" "text" should appear before "Test Assignment" "text"
|
||||
And "Test Assignment" "text" should appear before "Test Forum" "text"
|
@ -215,8 +215,8 @@ class behat_course extends behat_base {
|
||||
// Clicks add activity or resource section link.
|
||||
$sectionnode = $this->find('xpath', $sectionxpath);
|
||||
$this->execute('behat_general::i_click_on_in_the', [
|
||||
get_string('addresourceoractivity', 'moodle'),
|
||||
'button',
|
||||
"//button[@data-action='open-chooser' and not(@data-beforemod)]",
|
||||
'xpath',
|
||||
$sectionnode,
|
||||
'NodeElement',
|
||||
]);
|
||||
|
@ -1150,6 +1150,7 @@ $string['indicator:userforumstracking'] = 'User is tracking forums';
|
||||
$string['indicator:userforumstracking_help'] = 'This indicator represents whether or not the student has tracking turned on in the forums.';
|
||||
$string['info'] = 'Information';
|
||||
$string['inprogress'] = 'In progress';
|
||||
$string['insertresourceoractivitybefore'] = 'Insert an activity or resource before \'{$a->activityname}\'';
|
||||
$string['institution'] = 'Institution';
|
||||
$string['instudentview'] = 'in student view';
|
||||
$string['interests'] = 'Interests';
|
||||
|
@ -1530,3 +1530,47 @@ $activity-add-hover: theme-color-level('primary', -10) !default;
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.activity:focus-within + .activity div.divider button,
|
||||
.course-section-header:focus-within + .content .section .activity:first-child div.divider button,
|
||||
.content .section .activity:focus-within div.divider button {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.activity {
|
||||
div.divider {
|
||||
height: 2rem;
|
||||
margin-top: -1.25rem;
|
||||
margin-bottom: -0.75rem;
|
||||
z-index: 5;
|
||||
button {
|
||||
border-radius: 100%;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
position: relative;
|
||||
left: calc(50% - 1rem);
|
||||
top: calc(50% - 1rem);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: visibility 0.1s;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
i.icon {
|
||||
height: 1.5rem;
|
||||
width: 1.5rem;
|
||||
font-size: 1.5rem;
|
||||
position: absolute;
|
||||
left: 0.25rem;
|
||||
top: 0.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
&:not(.dragging) div.divider {
|
||||
&:hover button,
|
||||
&:focus button,
|
||||
&:focus-within button {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14967,6 +14967,42 @@ span.editinstructions {
|
||||
.automatic-completion-conditions .badge:first-child {
|
||||
margin-top: 0; }
|
||||
|
||||
.activity:focus-within + .activity div.divider button,
|
||||
.course-section-header:focus-within + .content .section .activity:first-child div.divider button,
|
||||
.content .section .activity:focus-within div.divider button {
|
||||
visibility: visible; }
|
||||
|
||||
.activity div.divider {
|
||||
height: 2rem;
|
||||
margin-top: -1.25rem;
|
||||
margin-bottom: -0.75rem;
|
||||
z-index: 5; }
|
||||
.activity div.divider button {
|
||||
border-radius: 100%;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
position: relative;
|
||||
left: calc(50% - 1rem);
|
||||
top: calc(50% - 1rem);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: visibility 0.1s;
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
.activity div.divider button i.icon {
|
||||
height: 1.5rem;
|
||||
width: 1.5rem;
|
||||
font-size: 1.5rem;
|
||||
position: absolute;
|
||||
left: 0.25rem;
|
||||
top: 0.25rem; }
|
||||
|
||||
.activity:not(.dragging) div.divider:hover button,
|
||||
.activity:not(.dragging) div.divider:focus button,
|
||||
.activity:not(.dragging) div.divider:focus-within button {
|
||||
opacity: 1;
|
||||
visibility: visible; }
|
||||
|
||||
/* Anchor link offset fix. This makes hash links scroll 60px down to account for the fixed header. */
|
||||
:target {
|
||||
scroll-margin-top: 70px; }
|
||||
|
@ -14967,6 +14967,42 @@ span.editinstructions {
|
||||
.automatic-completion-conditions .badge:first-child {
|
||||
margin-top: 0; }
|
||||
|
||||
.activity:focus-within + .activity div.divider button,
|
||||
.course-section-header:focus-within + .content .section .activity:first-child div.divider button,
|
||||
.content .section .activity:focus-within div.divider button {
|
||||
visibility: visible; }
|
||||
|
||||
.activity div.divider {
|
||||
height: 2rem;
|
||||
margin-top: -1.25rem;
|
||||
margin-bottom: -0.75rem;
|
||||
z-index: 5; }
|
||||
.activity div.divider button {
|
||||
border-radius: 100%;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
position: relative;
|
||||
left: calc(50% - 1rem);
|
||||
top: calc(50% - 1rem);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: visibility 0.1s;
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
.activity div.divider button i.icon {
|
||||
height: 1.5rem;
|
||||
width: 1.5rem;
|
||||
font-size: 1.5rem;
|
||||
position: absolute;
|
||||
left: 0.25rem;
|
||||
top: 0.25rem; }
|
||||
|
||||
.activity:not(.dragging) div.divider:hover button,
|
||||
.activity:not(.dragging) div.divider:focus button,
|
||||
.activity:not(.dragging) div.divider:focus-within button {
|
||||
opacity: 1;
|
||||
visibility: visible; }
|
||||
|
||||
/* Anchor link offset fix. This makes hash links scroll 60px down to account for the fixed header. */
|
||||
:target {
|
||||
scroll-margin-top: 60px; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user