mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-78201-master' of https://github.com/aanabit/moodle
This commit is contained in:
commit
8c944b217f
2
course/amd/build/actions.min.js
vendored
2
course/amd/build/actions.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
@ -63,6 +63,7 @@ define(
|
||||
const componentActions = [
|
||||
'moveSection', 'moveCm', 'addSection', 'deleteSection', 'cmDelete', 'cmDuplicate', 'sectionHide', 'sectionShow',
|
||||
'cmHide', 'cmShow', 'cmStealth', 'sectionHighlight', 'sectionUnhighlight', 'cmMoveRight', 'cmMoveLeft',
|
||||
'cmNoGroups', 'cmVisibleGroups', 'cmSeparateGroups',
|
||||
];
|
||||
|
||||
// The course reactive instance.
|
||||
|
2
course/format/amd/build/local/content.min.js
vendored
2
course/format/amd/build/local/content.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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -227,6 +227,7 @@ export default class Component extends BaseComponent {
|
||||
{watch: `cm.stealth:updated`, handler: this._reloadCm},
|
||||
{watch: `cm.sectionid:updated`, handler: this._reloadCm},
|
||||
{watch: `cm.indent:updated`, handler: this._reloadCm},
|
||||
{watch: `cm.groupmode:updated`, handler: this._reloadCm},
|
||||
// Update section number and title.
|
||||
{watch: `section.number:updated`, handler: this._refreshSectionNumber},
|
||||
// Collapse and expand sections.
|
||||
|
@ -53,6 +53,9 @@ const directMutations = {
|
||||
cmStealth: 'cmStealth',
|
||||
cmMoveRight: 'cmMoveRight',
|
||||
cmMoveLeft: 'cmMoveLeft',
|
||||
cmNoGroups: 'cmNoGroups',
|
||||
cmSeparateGroups: 'cmSeparateGroups',
|
||||
cmVisibleGroups: 'cmVisibleGroups',
|
||||
};
|
||||
|
||||
export default class extends BaseComponent {
|
||||
|
@ -366,6 +366,33 @@ export default class {
|
||||
await this._cmBasicAction(stateManager, 'cm_moveleft', cmIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cms group mode to NOGROUPS.
|
||||
* @param {StateManager} stateManager the current state manager
|
||||
* @param {array} cmIds the list of cm ids
|
||||
*/
|
||||
async cmNoGroups(stateManager, cmIds) {
|
||||
await this._cmBasicAction(stateManager, 'cm_nogroups', cmIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cms group mode to VISIBLEGROUPS.
|
||||
* @param {StateManager} stateManager the current state manager
|
||||
* @param {array} cmIds the list of cm ids
|
||||
*/
|
||||
async cmVisibleGroups(stateManager, cmIds) {
|
||||
await this._cmBasicAction(stateManager, 'cm_visiblegroups', cmIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cms group mode to SEPARATEGROUPS.
|
||||
* @param {StateManager} stateManager the current state manager
|
||||
* @param {array} cmIds the list of cm ids
|
||||
*/
|
||||
async cmSeparateGroups(stateManager, cmIds) {
|
||||
await this._cmBasicAction(stateManager, 'cm_separategroups', cmIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock or unlock course modules.
|
||||
*
|
||||
|
@ -107,6 +107,7 @@ class cmitem implements named_templatable, renderable {
|
||||
'cmformat' => $item->export_for_template($output),
|
||||
'hasinfo' => $hasinfo,
|
||||
'indent' => ($format->uses_indentation()) ? $mod->indent : 0,
|
||||
'groupmode' => $mod->groupmode,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ class cm implements renderable {
|
||||
'hascmrestrictions' => $this->get_has_restrictions(),
|
||||
'modname' => get_string('pluginname', 'mod_' . $cm->modname),
|
||||
'indent' => ($format->uses_indentation()) ? $cm->indent : 0,
|
||||
'groupmode' => $cm->groupmode,
|
||||
'module' => $cm->modname,
|
||||
'plugin' => 'mod_' . $cm->modname,
|
||||
];
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
namespace core_courseformat;
|
||||
|
||||
use core_courseformat\stateupdates;
|
||||
use core\event\course_module_updated;
|
||||
use cm_info;
|
||||
use section_info;
|
||||
@ -705,6 +704,92 @@ class stateactions {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set NOGROUPS const value to cms groupmode.
|
||||
*
|
||||
* @param stateupdates $updates the affected course elements track
|
||||
* @param stdClass $course the course object
|
||||
* @param int[] $ids cm ids
|
||||
* @param int $targetsectionid not used
|
||||
* @param int $targetcmid not used
|
||||
*/
|
||||
public function cm_nogroups(
|
||||
stateupdates $updates,
|
||||
stdClass $course,
|
||||
array $ids = [],
|
||||
?int $targetsectionid = null,
|
||||
?int $targetcmid = null
|
||||
): void {
|
||||
$this->set_cm_groupmode($updates, $course, $ids, NOGROUPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set VISIBLEGROUPS const value to cms groupmode.
|
||||
*
|
||||
* @param stateupdates $updates the affected course elements track
|
||||
* @param stdClass $course the course object
|
||||
* @param int[] $ids cm ids
|
||||
* @param int $targetsectionid not used
|
||||
* @param int $targetcmid not used
|
||||
*/
|
||||
public function cm_visiblegroups(
|
||||
stateupdates $updates,
|
||||
stdClass $course,
|
||||
array $ids = [],
|
||||
?int $targetsectionid = null,
|
||||
?int $targetcmid = null
|
||||
): void {
|
||||
$this->set_cm_groupmode($updates, $course, $ids, VISIBLEGROUPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SEPARATEGROUPS const value to cms groupmode.
|
||||
*
|
||||
* @param stateupdates $updates the affected course elements track
|
||||
* @param stdClass $course the course object
|
||||
* @param int[] $ids cm ids
|
||||
* @param int $targetsectionid not used
|
||||
* @param int $targetcmid not used
|
||||
*/
|
||||
public function cm_separategroups(
|
||||
stateupdates $updates,
|
||||
stdClass $course,
|
||||
array $ids = [],
|
||||
?int $targetsectionid = null,
|
||||
?int $targetcmid = null
|
||||
): void {
|
||||
$this->set_cm_groupmode($updates, $course, $ids, SEPARATEGROUPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to define the cm groupmode value.
|
||||
*
|
||||
* @param stateupdates $updates the affected course elements track
|
||||
* @param stdClass $course the course object
|
||||
* @param int[] $ids cm ids
|
||||
* @param int $groupmode new value for groupmode: NOGROUPS, SEPARATEGROUPS, VISIBLEGROUPS
|
||||
*/
|
||||
protected function set_cm_groupmode(
|
||||
stateupdates $updates,
|
||||
stdClass $course,
|
||||
array $ids,
|
||||
int $groupmode
|
||||
): void {
|
||||
global $DB;
|
||||
|
||||
$this->validate_cms($course, $ids, __FUNCTION__, ['moodle/course:manageactivities']);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$cms = $this->get_cm_info($modinfo, $ids);
|
||||
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($cms), SQL_PARAMS_NAMED);
|
||||
$DB->set_field_select('course_modules', 'groupmode', $groupmode, "id $insql", $inparams);
|
||||
rebuild_course_cache($course->id, false, true);
|
||||
foreach ($cms as $cm) {
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
course_module_updated::create_from_cm($cm, $modcontext)->trigger();
|
||||
$updates->add_cm_put($cm->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract several cm_info from the course_modinfo.
|
||||
*
|
||||
|
@ -1137,6 +1137,87 @@ class stateactions_test extends \advanced_testcase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cm_nogroups
|
||||
*
|
||||
* @covers ::cm_nogroups
|
||||
* @dataProvider basic_role_provider
|
||||
* @param string $role the user role
|
||||
* @param bool $expectedexception if it will expect an exception.
|
||||
*/
|
||||
public function test_cm_nogroups(
|
||||
string $role = 'editingteacher',
|
||||
bool $expectedexception = false
|
||||
): void {
|
||||
$this->basic_state_text(
|
||||
'cm_nogroups',
|
||||
$role,
|
||||
['cm0', 'cm1', 'cm2', 'cm3'],
|
||||
$expectedexception,
|
||||
['put' => 4],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'groupmode',
|
||||
NOGROUPS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cm_visiblegroups
|
||||
*
|
||||
* @covers ::cm_visiblegroups
|
||||
* @dataProvider basic_role_provider
|
||||
* @param string $role the user role
|
||||
* @param bool $expectedexception if it will expect an exception.
|
||||
*/
|
||||
public function test_cm_visiblegroups(
|
||||
string $role = 'editingteacher',
|
||||
bool $expectedexception = false
|
||||
): void {
|
||||
$this->basic_state_text(
|
||||
'cm_visiblegroups',
|
||||
$role,
|
||||
['cm0', 'cm1', 'cm2', 'cm3'],
|
||||
$expectedexception,
|
||||
['put' => 4],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'groupmode',
|
||||
VISIBLEGROUPS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cm_separategroups
|
||||
*
|
||||
* @covers ::cm_separategroups
|
||||
* @dataProvider basic_role_provider
|
||||
* @param string $role the user role
|
||||
* @param bool $expectedexception if it will expect an exception.
|
||||
*/
|
||||
public function test_cm_separategroups(
|
||||
string $role = 'editingteacher',
|
||||
bool $expectedexception = false
|
||||
): void {
|
||||
$this->basic_state_text(
|
||||
'cm_separategroups',
|
||||
$role,
|
||||
['cm0', 'cm1', 'cm2', 'cm3'],
|
||||
$expectedexception,
|
||||
['put' => 4],
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'groupmode',
|
||||
SEPARATEGROUPS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for section_move_after
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user