Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/qeupgradehelper/extracttestcase.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 
00032 require_once(dirname(__FILE__) . '/../../../config.php');
00033 require_once(dirname(__FILE__) . '/locallib.php');
00034 require_once(dirname(__FILE__) . '/extracttestcase_form.php');
00035 require_once($CFG->libdir . '/questionlib.php');
00036 require_once($CFG->libdir . '/adminlib.php');
00037 
00038 
00039 require_login();
00040 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
00041 
00042 admin_externalpage_setup('qeupgradehelper', '', array(),
00043         tool_qeupgradehelper_url('extracttestcase'));
00044 $PAGE->navbar->add(get_string('extracttestcase', 'tool_qeupgradehelper'));
00045 
00046 $renderer = $PAGE->get_renderer('tool_qeupgradehelper');
00047 
00048 $mform = new tool_qeupgradehelper_extract_options_form(
00049         new moodle_url('/admin/tool/qeupgradehelper/extracttestcase.php'), null, 'get');
00050 
00051 echo $OUTPUT->header();
00052 if ($fromform = $mform->get_data()) {
00053     $qsid = null;
00054     if (!empty($fromform->attemptid) && !empty($fromform->questionid)) {
00055         $qsid = tool_qeupgradehelper_get_session_id($fromform->attemptid, $fromform->questionid);
00056         $name = 'qsession' . $qsid;
00057 
00058     } else if (!empty($fromform->statehistory)) {
00059         notify('Searching ...', 'notifysuccess');
00060         flush();
00061         $qsid = tool_qeupgradehelper_find_test_case($fromform->behaviour, $fromform->statehistory,
00062                 $fromform->qtype, $fromform->extratests);
00063         $name = 'history' . $fromform->statehistory;
00064     }
00065 
00066     if ($qsid) {
00067         tool_qeupgradehelper_generate_unit_test($qsid, $name);
00068     } else {
00069         notify('No suitable attempts found.');
00070     }
00071 }
00072 
00073 $mform->display();
00074 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations