|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00027 require_once(dirname(__FILE__) . '/../../../config.php'); 00028 require_once(dirname(__FILE__) . '/locallib.php'); 00029 require_once(dirname(__FILE__) . '/afterupgradelib.php'); 00030 require_once($CFG->libdir . '/adminlib.php'); 00031 00032 $quizid = required_param('quizid', PARAM_INT); 00033 $confirmed = optional_param('confirmed', false, PARAM_BOOL); 00034 00035 require_login(); 00036 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 00037 tool_qeupgradehelper_require_upgraded(); 00038 00039 admin_externalpage_setup('qeupgradehelper', '', array(), 00040 tool_qeupgradehelper_url('convertquiz', array('quizid' => $quizid))); 00041 $PAGE->navbar->add(get_string('listtodo', 'tool_qeupgradehelper'), 00042 tool_qeupgradehelper_url('listtodo')); 00043 $PAGE->navbar->add(get_string('convertattempts', 'tool_qeupgradehelper')); 00044 00045 $renderer = $PAGE->get_renderer('tool_qeupgradehelper'); 00046 00047 $quizsummary = tool_qeupgradehelper_get_quiz($quizid); 00048 if (!$quizsummary) { 00049 print_error('invalidquizid', 'tool_qeupgradehelper', 00050 tool_qeupgradehelper_url('listtodo')); 00051 } 00052 00053 $quizsummary->name = format_string($quizsummary->name); 00054 00055 if ($confirmed && data_submitted() && confirm_sesskey()) { 00056 // Actually do the conversion. 00057 echo $renderer->header(); 00058 echo $renderer->heading(get_string( 00059 'upgradingquizattempts', 'tool_qeupgradehelper', $quizsummary)); 00060 00061 $upgrader = new tool_qeupgradehelper_attempt_upgrader( 00062 $quizsummary->id, $quizsummary->numtoconvert); 00063 $upgrader->convert_all_quiz_attempts(); 00064 00065 echo $renderer->heading(get_string('conversioncomplete', 'tool_qeupgradehelper')); 00066 echo $renderer->end_of_page_link( 00067 new moodle_url('/mod/quiz/report.php', array('q' => $quizsummary->id)), 00068 get_string('gotoquizreport', 'tool_qeupgradehelper')); 00069 echo $renderer->end_of_page_link(tool_qeupgradehelper_url('listtodo'), 00070 get_string('listtodo', 'tool_qeupgradehelper')); 00071 00072 echo $renderer->footer(); 00073 exit; 00074 } 00075 00076 echo $renderer->convert_quiz_are_you_sure($quizsummary);