Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/course/reset.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00030 require('../config.php');
00031 require_once('reset_form.php');
00032 
00033 $id = required_param('id', PARAM_INT);
00034 
00035 if (!$course = $DB->get_record('course', array('id'=>$id))) {
00036     print_error("invalidcourseid");
00037 }
00038 
00039 $PAGE->set_url('/course/reset.php', array('id'=>$id));
00040 
00041 require_login($course);
00042 require_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id));
00043 
00044 $strreset       = get_string('reset');
00045 $strresetcourse = get_string('resetcourse');
00046 $strremove      = get_string('remove');
00047 
00048 $PAGE->navbar->add($strresetcourse);
00049 $PAGE->set_title($course->fullname.': '.$strresetcourse);
00050 $PAGE->set_heading($course->fullname.': '.$strresetcourse);
00051 
00052 $mform = new course_reset_form();
00053 
00054 if ($mform->is_cancelled()) {
00055     redirect($CFG->wwwroot.'/course/view.php?id='.$id);
00056 
00057 } else if ($data = $mform->get_data()) { // no magic quotes
00058 
00059     if (isset($data->selectdefault)) {
00060         $_POST = array();
00061         $mform = new course_reset_form();
00062         $mform->load_defaults();
00063 
00064     } else if (isset($data->deselectall)) {
00065         $_POST = array();
00066         $mform = new course_reset_form();
00067 
00068     } else {
00069         echo $OUTPUT->header();
00070         echo $OUTPUT->heading($strresetcourse);
00071 
00072         $data->reset_start_date_old = $course->startdate;
00073         $status = reset_course_userdata($data);
00074 
00075         $data = array();;
00076         foreach ($status as $item) {
00077             $line = array();
00078             $line[] = $item['component'];
00079             $line[] = $item['item'];
00080             $line[] = ($item['error']===false) ? get_string('ok') : '<div class="notifyproblem">'.$item['error'].'</div>';
00081             $data[] = $line;
00082         }
00083 
00084         $table = new html_table();
00085         $table->head  = array(get_string('resetcomponent'), get_string('resettask'), get_string('resetstatus'));
00086         $table->size  = array('20%', '40%', '40%');
00087         $table->align = array('left', 'left', 'left');
00088         $table->width = '80%';
00089         $table->data  = $data;
00090         echo html_writer::table($table);
00091 
00092         echo $OUTPUT->continue_button('view.php?id='.$course->id);  // Back to course page
00093         echo $OUTPUT->footer();
00094         exit;
00095     }
00096 }
00097 
00098 echo $OUTPUT->header();
00099 echo $OUTPUT->heading($strresetcourse);
00100 
00101 echo $OUTPUT->box(get_string('resetinfo'));
00102 
00103 $mform->display();
00104 echo $OUTPUT->footer();
00105 
00106 
 All Data Structures Namespaces Files Functions Variables Enumerations