mirror of
https://github.com/moodle/moodle.git
synced 2025-05-02 22:45:03 +02:00
85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
// 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/>.
|
|
|
|
/**
|
|
* Bulk edit activity completion form
|
|
*
|
|
* @package core_completion
|
|
* @copyright 2017 Marina Glancy
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
defined('MOODLE_INTERNAL') || die;
|
|
|
|
/**
|
|
* Bulk edit activity completion form
|
|
*
|
|
* @package core_completion
|
|
* @copyright 2017 Marina Glancy
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
class core_completion_bulkedit_form extends core_completion_edit_base_form {
|
|
/** @var cm_info[] list of selected course modules */
|
|
protected $cms = [];
|
|
/** @var array Do not use directly, call $this->get_module_names() */
|
|
protected $_modnames = null;
|
|
|
|
/**
|
|
* Returns list of types of selected modules
|
|
*
|
|
* @return array modname=>modfullname
|
|
*/
|
|
protected function get_module_names() {
|
|
if ($this->_modnames !== null) {
|
|
return $this->_modnames;
|
|
}
|
|
$this->_modnames = [];
|
|
foreach ($this->cms as $cm) {
|
|
$this->_modnames[$cm->modname] = $cm->modfullname;
|
|
}
|
|
return $this->_modnames;
|
|
}
|
|
|
|
/**
|
|
* Form definition
|
|
*/
|
|
public function definition() {
|
|
$this->cms = $this->_customdata['cms'];
|
|
$cm = reset($this->cms); // First selected course module.
|
|
$this->course = $cm->get_course();
|
|
|
|
$mform = $this->_form;
|
|
|
|
foreach ($this->cms as $cm) {
|
|
$mform->addElement('hidden', 'cmid['.$cm->id.']', $cm->id);
|
|
$mform->setType('cmid['.$cm->id.']', PARAM_INT);
|
|
}
|
|
|
|
parent::definition();
|
|
|
|
$modform = $this->get_module_form();
|
|
if ($modform) {
|
|
// Pre-fill the form with the current completion rules of the first selected module.
|
|
list($cmrec, $context, $module, $data, $cw) = get_moduleinfo_data($cm->get_course_module_record(), $this->course);
|
|
$data = (array)$data;
|
|
$modform->data_preprocessing($data);
|
|
// Unset fields that will conflict with this form and set data to this form.
|
|
unset($data['cmid']);
|
|
unset($data['id']);
|
|
$this->set_data($data);
|
|
}
|
|
}
|
|
} |