Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/qeupgradehelper/resetquiz.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00026 require_once(dirname(__FILE__) . '/../../../config.php');
00027 require_once(dirname(__FILE__) . '/locallib.php');
00028 require_once(dirname(__FILE__) . '/afterupgradelib.php');
00029 require_once($CFG->libdir . '/adminlib.php');
00030 
00031 $quizid = required_param('quizid', PARAM_INT);
00032 $confirmed = optional_param('confirmed', false, PARAM_BOOL);
00033 
00034 require_login();
00035 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
00036 tool_qeupgradehelper_require_upgraded();
00037 
00038 admin_externalpage_setup('qeupgradehelper', '', array(),
00039         tool_qeupgradehelper_url('resetquiz', array('quizid' => $quizid)));
00040 $PAGE->navbar->add(get_string('listupgraded', 'tool_qeupgradehelper'),
00041         tool_qeupgradehelper_url('listtodo'));
00042 $PAGE->navbar->add(get_string('resetquiz', 'tool_qeupgradehelper'));
00043 
00044 $renderer = $PAGE->get_renderer('tool_qeupgradehelper');
00045 
00046 $quizsummary = tool_qeupgradehelper_get_resettable_quiz($quizid);
00047 if (!$quizsummary) {
00048     print_error('invalidquizid', 'tool_qeupgradehelper',
00049             tool_qeupgradehelper_url('listupgraded'));
00050 }
00051 
00052 $quizsummary->name = format_string($quizsummary->name);
00053 
00054 if ($confirmed && data_submitted() && confirm_sesskey()) {
00055     // Actually do the conversion.
00056     echo $renderer->header();
00057     echo $renderer->heading(get_string(
00058             'resettingquizattempts', 'tool_qeupgradehelper', $quizsummary));
00059 
00060     $upgrader = new tool_qeupgradehelper_attempt_upgrader(
00061             $quizsummary->id, $quizsummary->resettableattempts);
00062     $upgrader->reset_all_resettable_attempts();
00063 
00064     echo $renderer->heading(get_string('resetcomplete', 'tool_qeupgradehelper'));
00065     echo $renderer->end_of_page_link(tool_qeupgradehelper_url('listupgraded'),
00066             get_string('listupgraded', 'tool_qeupgradehelper'));
00067 
00068     echo $renderer->footer();
00069     exit;
00070 }
00071 
00072 echo $renderer->reset_quiz_are_you_sure($quizsummary);
 All Data Structures Namespaces Files Functions Variables Enumerations