__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?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/>.
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot . '/course/lib.php');
/**
* Defines the course reset settings form.
*
* @package core_course
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_reset_form extends moodleform {
/**
* Form definition.
*/
public function definition() {
global $CFG, $COURSE, $DB;
$mform = $this->_form;
$mform->addElement('header', 'generalheader', get_string('general'));
$mform->addElement('date_time_selector', 'reset_start_date', get_string('startdate'), ['optional' => true]);
$mform->addHelpButton('reset_start_date', 'startdate');
$mform->addElement('date_time_selector', 'reset_end_date', get_string('enddate'), ['optional' => true]);
$mform->addHelpButton('reset_end_date', 'enddate');
$mform->addElement('static', 'generaldelete', get_string('delete'));
$mform->addElement('checkbox', 'reset_events', get_string('deleteevents', 'calendar'));
$mform->addElement('checkbox', 'reset_notes', get_string('deletenotes', 'notes'));
$mform->addElement('checkbox', 'reset_comments', get_string('deleteallcomments', 'moodle'));
$mform->addElement('checkbox', 'reset_completion', get_string('deletecompletiondata', 'completion'));
$mform->addElement('checkbox', 'delete_blog_associations', get_string('deleteblogassociations', 'blog'));
$mform->addHelpButton('delete_blog_associations', 'deleteblogassociations', 'blog');
$mform->addElement('checkbox', 'reset_competency_ratings', get_string('deletecompetencyratings', 'core_competency'));
$mform->addElement('header', 'rolesheader', get_string('roles'));
$roles = get_assignable_roles(context_course::instance($COURSE->id));
$roles[0] = get_string('noroles', 'role');
$roles = array_reverse($roles, true);
$attributes = [
'multiple' => 1,
'size' => min(count($roles), 10),
];
$mform->addElement('select', 'unenrol_users', get_string('unenrolroleusers', 'enrol'), $roles, $attributes);
$mform->addElement('static', 'rolesdelete', get_string('delete'));
$mform->addElement('checkbox', 'reset_roles_local', get_string('deletelocalroles', 'role'));
$mform->addElement('checkbox', 'reset_roles_overrides', get_string('deletecourseoverrides', 'role'));
$mform->addElement('header', 'gradebookheader', get_string('gradebook', 'grades'));
$mform->addElement('static', 'gradebookdelete', get_string('delete'));
$mform->addElement('checkbox', 'reset_gradebook_items', get_string('removeallcourseitems', 'grades'));
$mform->addHelpButton('reset_gradebook_items', 'removeallcourseitems', 'grades');
$mform->addElement('checkbox', 'reset_gradebook_grades', get_string('removeallcoursegrades', 'grades'));
$mform->addHelpButton('reset_gradebook_grades', 'removeallcoursegrades', 'grades');
$mform->disabledIf('reset_gradebook_grades', 'reset_gradebook_items', 'checked');
$mform->addElement('header', 'groupheader', get_string('groups'));
$mform->addElement('static', 'groupdelete', get_string('delete'));
$mform->addElement('checkbox', 'reset_groups_remove', get_string('deleteallgroups', 'group'));
$mform->addElement('checkbox', 'reset_groups_members', get_string('removegroupsmembers', 'group'));
$mform->disabledIf('reset_groups_members', 'reset_groups_remove', 'checked');
$mform->addElement('checkbox', 'reset_groupings_remove', get_string('deleteallgroupings', 'group'));
$mform->addElement('checkbox', 'reset_groupings_members', get_string('removegroupingsmembers', 'group'));
$mform->disabledIf('reset_groupings_members', 'reset_groupings_remove', 'checked');
$unsupportedmods = [];
if ($allmods = $DB->get_records('modules') ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = $CFG->dirroot."/mod/$modname/lib.php";
$modresetcourseformdefinition = $modname.'_reset_course_form_definition';
$modresetuserdata = $modname.'_reset_userdata';
if (file_exists($modfile)) {
if (!$DB->count_records($modname, ['course' => $COURSE->id])) {
continue; // Skip mods with no instances.
}
include_once($modfile);
if (function_exists($modresetcourseformdefinition)) {
$modresetcourseformdefinition($mform);
} else if (!function_exists($modresetuserdata)) {
$unsupportedmods[] = $mod;
}
} else {
debugging('Missing lib.php in '.$modname.' module');
}
}
}
// Mention unsupported mods.
if (!empty($unsupportedmods)) {
$mform->addElement('header', 'unsupportedheader', get_string('resetnotimplemented'));
$mform->addElement('static', 'unsupportedinfo', get_string('resetnotimplementedinfo'));
foreach ($unsupportedmods as $mod) {
$mform->addElement('static', 'unsup'.$mod->name, get_string('modulenameplural', $mod->name));
}
}
$elements = $mform->_elements;
foreach ($elements as $element) {
if (is_a($element, 'HTML_QuickForm_header')) {
$mform->setExpanded($element->getName());
}
}
$mform->addElement('hidden', 'id', $COURSE->id);
$mform->setType('id', PARAM_INT);
$buttonarray = [];
$buttonarray[] = $mform->createElement(
'submit',
'selectdefault',
get_string('selectdefault'),
null,
null,
['customclassoverride' => 'btn-secondary'],
);
$buttonarray[] = $mform->createElement(
'submit',
'deselectall',
get_string('deselectall'),
null,
null,
['customclassoverride' => 'btn-secondary'],
);
$mform->addGroup($buttonarray, 'buttonar', '', [' '], false);
$mform->addElement(
'submit',
'submitbutton',
get_string('resetcourse'),
[
'data-action' => 'resetcourse',
'data-courseid' => $COURSE->id,
'data-coursename' => $COURSE->fullname,
],
null,
['customclassoverride' => 'btn-danger'],
);
$mform->set_sticky_footer('submitbutton');
$mform->closeHeaderBefore('buttonar');
}
/**
* Method to load default values for the reset course form.
*/
public function load_defaults() {
global $CFG, $COURSE, $DB;
$mform = $this->_form;
$defaults = [
'reset_events' => 1,
'reset_roles_local' => 1,
'reset_gradebook_grades' => 1,
'reset_notes' => 1,
];
// Set student as default in unenrol user list, if role with student archetype exist.
if ($studentrole = get_archetype_roles('student')) {
$defaults['unenrol_users'] = array_keys($studentrole);
}
if ($allmods = $DB->get_records('modules') ) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = $CFG->dirroot."/mod/$modname/lib.php";
$modresetcourseformdefaults = $modname.'_reset_course_form_defaults';
if (file_exists($modfile)) {
@include_once($modfile);
if (function_exists($modresetcourseformdefaults)) {
if ($moddefs = $modresetcourseformdefaults($COURSE)) {
$defaults = $defaults + $moddefs;
}
}
}
}
}
foreach ($defaults as $element => $default) {
$mform->setDefault($element, $default);
}
}
/**
* Validation.
*
* @param array $data
* @param array $files
* @return array the errors that were found
*/
public function validation($data, $files) {
$course = get_course($data['id']);
$errors = parent::validation($data, $files);
// We check the values that would be used as start and end.
if ($data['reset_start_date'] != 0) {
$coursedata['startdate'] = $data['reset_start_date'];
} else {
$coursedata['startdate'] = $course->startdate;
}
if ($data['reset_end_date'] != 0) {
// End date set by the user has preference.
$coursedata['enddate'] = $data['reset_end_date'];
} else if ($data['reset_start_date'] > 0 && $course->enddate != 0) {
// Otherwise, if the current course enddate is set, reset_course_userdata will add the start date time shift to it.
$timeshift = $data['reset_start_date'] - usergetmidnight($course->startdate);
$coursedata['enddate'] = $course->enddate + $timeshift;
} else {
$coursedata['enddate'] = $course->enddate;
}
if ($errorcode = course_validate_dates($coursedata)) {
$errors['reset_end_date'] = get_string($errorcode, 'error');
}
return $errors;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ajax | Folder | 0777 |
|
|
| amd | Folder | 0777 |
|
|
| classes | Folder | 0777 |
|
|
| format | Folder | 0777 |
|
|
| report | Folder | 0777 |
|
|
| templates | Folder | 0777 |
|
|
| tests | Folder | 0777 |
|
|
| yui | Folder | 0777 |
|
|
| UPGRADING.md | File | 3.36 KB | 0777 |
|
| admin.php | File | 1.79 KB | 0777 |
|
| bulkcompletion.php | File | 2.66 KB | 0777 |
|
| category.ajax.php | File | 1.24 KB | 0777 |
|
| changenumsections.php | File | 4.23 KB | 0777 |
|
| completion.php | File | 5.95 KB | 0777 |
|
| completion_form.php | File | 14.35 KB | 0777 |
|
| customfield.php | File | 1.3 KB | 0777 |
|
| defaultcompletion.php | File | 3.23 KB | 0777 |
|
| delete.php | File | 4.3 KB | 0777 |
|
| dndupload.js | File | 46.42 KB | 0777 |
|
| dndupload.php | File | 1.54 KB | 0777 |
|
| dnduploadlib.php | File | 25.84 KB | 0777 |
|
| downloadcontent.php | File | 3.56 KB | 0777 |
|
| edit.php | File | 9.9 KB | 0777 |
|
| edit_form.php | File | 26.75 KB | 0777 |
|
| editbulkcompletion.php | File | 2.55 KB | 0777 |
|
| editcategory.php | File | 4.92 KB | 0777 |
|
| editsection.php | File | 6.24 KB | 0777 |
|
| editsection_form.php | File | 5.43 KB | 0777 |
|
| enrol.php | File | 1021 B | 0777 |
|
| externallib.php | File | 209.73 KB | 0777 |
|
| index.php | File | 2.8 KB | 0777 |
|
| info.php | File | 2.74 KB | 0777 |
|
| jumpto.php | File | 1.26 KB | 0777 |
|
| lib.php | File | 183.54 KB | 0777 |
|
| loginas.php | File | 3.04 KB | 0777 |
|
| management.php | File | 23.02 KB | 0777 |
|
| mod.php | File | 12.15 KB | 0777 |
|
| modduplicate.php | File | 1.89 KB | 0777 |
|
| modedit.php | File | 8.38 KB | 0777 |
|
| modlib.php | File | 39.18 KB | 0777 |
|
| modregrade.php | File | 2.25 KB | 0777 |
|
| moodleform_mod.php | File | 50.92 KB | 0777 |
|
| pending.php | File | 7.01 KB | 0777 |
|
| recent.php | File | 8.32 KB | 0777 |
|
| recent_form.php | File | 6.94 KB | 0777 |
|
| recommendations.php | File | 1.98 KB | 0777 |
|
| renderer.php | File | 86.02 KB | 0777 |
|
| report.php | File | 1.34 KB | 0777 |
|
| request.php | File | 3.55 KB | 0777 |
|
| request_form.php | File | 6.6 KB | 0777 |
|
| reset.php | File | 4.1 KB | 0777 |
|
| reset_form.php | File | 10.05 KB | 0777 |
|
| resources.php | File | 4.96 KB | 0777 |
|
| rest.php | File | 3.28 KB | 0777 |
|
| scales.php | File | 5 KB | 0777 |
|
| search.php | File | 4.05 KB | 0777 |
|
| section.php | File | 8.23 KB | 0777 |
|
| switchrole.php | File | 3.65 KB | 0777 |
|
| switchrole_form.php | File | 3.19 KB | 0777 |
|
| tags.php | File | 2.36 KB | 0777 |
|
| tags_form.php | File | 1.51 KB | 0777 |
|
| togglecompletion.php | File | 6.14 KB | 0777 |
|
| upgrade.txt | File | 19.7 KB | 0777 |
|
| user.php | File | 8.74 KB | 0777 |
|
| view.php | File | 13.24 KB | 0777 |
|