Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
 
-
 
3
// This file is part of Moodle - http://moodle.org/
2
// This file is part of Moodle - http://moodle.org/
4
//
3
//
5
// Moodle is free software: you can redistribute it and/or modify
4
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
5
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
6
// the Free Software Foundation, either version 3 of the License, or
Línea 20... Línea 19...
20
 * in order to make it available for a new semester.  This feature can handle the removal
19
 * in order to make it available for a new semester.  This feature can handle the removal
21
 * of general course data like students, teachers, logs, events and groups as well as module
20
 * of general course data like students, teachers, logs, events and groups as well as module
22
 * specific data.  Each module must be modified to take advantage of this new feature.
21
 * specific data.  Each module must be modified to take advantage of this new feature.
23
 * The feature will also reset the start date of the course if necessary.
22
 * The feature will also reset the start date of the course if necessary.
24
 *
23
 *
-
 
24
 * @package   core_course
25
 * @copyright Mark Flach and moodle.com
25
 * @copyright Mark Flach and moodle.com
26
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @package course
-
 
28
 */
27
 */
Línea 29... Línea 28...
29
 
28
 
30
require('../config.php');
29
require('../config.php');
31
require_once('reset_form.php');
30
require_once('reset_form.php');
32
require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php');
31
require_once($CFG->dirroot . '/backup/util/interfaces/checksumable.class.php');
33
require_once($CFG->dirroot . '/backup/backup.class.php');
32
require_once($CFG->dirroot . '/backup/backup.class.php');
Línea 34... Línea 33...
34
require_once($CFG->dirroot . '/backup/util/helper/backup_helper.class.php');
33
require_once($CFG->dirroot . '/backup/util/helper/backup_helper.class.php');
Línea 35... Línea 34...
35
 
34
 
36
$id = required_param('id', PARAM_INT);
35
$id = required_param('id', PARAM_INT);
37
 
36
 
Línea 38... Línea 37...
38
if (!$course = $DB->get_record('course', array('id'=>$id))) {
37
if (!$course = $DB->get_record('course', ['id' => $id])) {
39
    throw new \moodle_exception("invalidcourseid");
38
    throw new \moodle_exception('invalidcourseid');
Línea 40... Línea 39...
40
}
39
}
41
 
40
 
Línea 42... Línea 41...
42
$PAGE->set_url('/course/reset.php', array('id'=>$id));
41
$PAGE->set_url('/course/reset.php', ['id' => $id]);
Línea 54... Línea 53...
54
$PAGE->set_secondary_active_tab('coursereuse');
53
$PAGE->set_secondary_active_tab('coursereuse');
Línea 55... Línea 54...
55
 
54
 
Línea 56... Línea 55...
56
$mform = new course_reset_form();
55
$mform = new course_reset_form();
57
 
56
 
Línea 58... Línea 57...
58
if ($mform->is_cancelled()) {
57
if ($mform->is_cancelled()) {
Línea 59... Línea 58...
59
    redirect($CFG->wwwroot.'/course/view.php?id='.$id);
58
    redirect($CFG->wwwroot . '/course/view.php?id='.$id);
60
 
59
 
61
} else if ($data = $mform->get_data()) { // no magic quotes
60
} else if ($data = $mform->get_data()) { // No magic quotes.
62
 
61
 
Línea 63... Línea 62...
63
    if (isset($data->selectdefault)) {
62
    if (isset($data->selectdefault)) {
64
        $_POST = array();
63
        $_POST = [];
65
        $mform = new course_reset_form();
64
        $mform = new course_reset_form();
Línea 66... Línea 65...
66
        $mform->load_defaults();
65
        $mform->load_defaults();
67
 
66
 
68
    } else if (isset($data->deselectall)) {
67
    } else if (isset($data->deselectall)) {
Línea 69... Línea 68...
69
        $_POST = array();
68
        $_POST = [];
70
        $mform = new course_reset_form();
69
        $mform = new course_reset_form();
71
 
70
 
Línea 72... Línea 71...
72
    } else {
71
    } else {
73
        echo $OUTPUT->header();
72
        echo $OUTPUT->header();
74
        \backup_helper::print_coursereuse_selector('reset');
73
        \backup_helper::print_coursereuse_selector('reset');
75
 
74
 
76
        $data->reset_start_date_old = $course->startdate;
75
        $data->reset_start_date_old = $course->startdate;
-
 
76
        $data->reset_end_date_old = $course->enddate;
-
 
77
        $status = reset_course_userdata($data);
-
 
78
 
-
 
79
        $data = [];
77
        $data->reset_end_date_old = $course->enddate;
80
        foreach ($status as $item) {
-
 
81
            $line = [];
-
 
82
            $line[] = $item['component'];
78
        $status = reset_course_userdata($data);
83
            $line[] = $item['item'];
79
 
84
            if ($item['error'] === false) {
Línea 80... Línea 85...
80
        $data = array();
85
                $line[] = get_string('statusdone');
81
        foreach ($status as $item) {
86
            } else {
82
            $line = array();
87
                $line[] = html_writer::div(
83
            $line[] = $item['component'];
88
                    $OUTPUT->pix_icon('i/invalid', get_string('error')) . $item['error'],
84
            $line[] = $item['item'];
89
                );
85
            $line[] = ($item['error'] === false) ? get_string('statusok') : '<div class="notifyproblem">'.$item['error'].'</div>';
90
            }
86
            $data[] = $line;
91
            $data[] = $line;
Línea 87... Línea 92...
87
        }
92
        }
88
 
93
 
89
        $table = new html_table();
94
        $table = new html_table();
90
        $table->head  = array(get_string('resetcomponent'), get_string('resettask'), get_string('resetstatus'));
95
        $table->head  = [get_string('resetcomponent'), get_string('resettask'), get_string('resetstatus')];
-
 
96
        $table->size  = ['20%', '40%', '40%'];
-
 
97
        $table->align = ['left', 'left', 'left'];
-
 
98
        $table->width = '80%';
91
        $table->size  = array('20%', '40%', '40%');
99
        $table->data  = $data;
Línea -... Línea 100...
-
 
100
        echo html_writer::table($table);
92
        $table->align = array('left', 'left', 'left');
101
 
93
        $table->width = '80%';
102
        echo $OUTPUT->continue_button('view.php?id=' . $course->id);  // Back to course page.
Línea 94... Línea 103...
94
        $table->data  = $data;
103
        echo $OUTPUT->footer();
-
 
104
        exit;
Línea 95... Línea 105...
95
        echo html_writer::table($table);
105
    }
96
 
106
} else {