예제 #1
0
require_once __DIR__ . '/locallib.php';
require_once __DIR__ . '/stack/utils.class.php';
require_once __DIR__ . '/stack/bulktester.class.php';
// Get the parameters from the URL.
$contextid = required_param('contextid', PARAM_INT);
// Login and check permissions.
$context = context::instance_by_id($contextid);
require_login();
require_capability('qtype/stack:usediagnostictools', $context);
$PAGE->set_url('/question/type/stack/bulktest.php', array('contextid' => $context->id));
$PAGE->set_context($context);
$title = stack_string('bulktesttitle', $context->get_context_name());
$PAGE->set_title($title);
if ($context->contextlevel == CONTEXT_MODULE) {
    // Calling $PAGE->set_context should be enough, but it seems that it is not.
    // Therefore, we get the right $cm and $course, and set things up ourselves.
    $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
    $PAGE->set_cm($cm, $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST));
}
// Create the helper class.
$bulktester = new stack_bulk_tester();
// Release the session, so the user can do other things while this runs.
\core\session\manager::write_close();
// Display.
echo $OUTPUT->header();
echo $OUTPUT->heading($title);
// Run the tests.
list($allpassed, $failingtests) = $bulktester->run_all_tests_for_context($context);
// Display the final summary.
$bulktester->print_overall_result($allpassed, $failingtests);
echo $OUTPUT->footer();
예제 #2
0
 *
 * @package   qtype_stack
 * @copyright 2013 the Open University
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once __DIR__ . '/../../../config.php';
require_once $CFG->libdir . '/questionlib.php';
require_once __DIR__ . '/locallib.php';
require_once __DIR__ . '/stack/utils.class.php';
require_once __DIR__ . '/stack/bulktester.class.php';
// Login and check permissions.
$context = context_system::instance();
require_login();
require_capability('qtype/stack:usediagnostictools', $context);
$PAGE->set_url('/question/type/stack/bulktestindex.php');
$PAGE->set_context($context);
$PAGE->set_title(stack_string('bulktestindextitle'));
// Create the helper class.
$bulktester = new stack_bulk_tester();
// Display.
echo $OUTPUT->header();
echo $OUTPUT->heading(stack_string('replacedollarsindex'));
echo html_writer::start_tag('ul');
foreach ($bulktester->get_stack_questions_by_context() as $contextid => $numstackquestions) {
    echo html_writer::tag('li', html_writer::link(new moodle_url('/question/type/stack/bulktest.php', array('contextid' => $contextid)), context::instance_by_id($contextid)->get_context_name(true, true) . ' (' . $numstackquestions . ')'));
}
echo html_writer::end_tag('ul');
if (has_capability('moodle/site:config', context_system::instance())) {
    echo html_writer::tag('p', html_writer::link(new moodle_url('/question/type/stack/bulktestall.php'), stack_string('bulktestrun')));
}
echo $OUTPUT->footer();
예제 #3
0
require_once __DIR__ . '/locallib.php';
require_once __DIR__ . '/stack/utils.class.php';
require_once __DIR__ . '/stack/bulktester.class.php';
// Get the parameters from the URL. This is an option to restart the process
// in the middle. Useful if it crashes.
$startfromcontextid = optional_param('startfromcontextid', 0, PARAM_INT);
// Login and check permissions.
$context = context_system::instance();
require_login();
require_capability('moodle/site:config', $context);
$PAGE->set_url('/question/type/stack/bulktestall.php', array('startfromcontextid' => $startfromcontextid));
$PAGE->set_context($context);
$title = stack_string('bulktesttitle', $context->get_context_name());
$PAGE->set_title($title);
// Create the helper class.
$bulktester = new stack_bulk_tester();
$allpassed = true;
$allfailingtests = array();
$skipping = $startfromcontextid != 0;
// Release the session, so the user can do other things while this runs.
\core\session\manager::write_close();
// Display.
echo $OUTPUT->header();
echo $OUTPUT->heading($title, 1);
// Run the tests.
foreach ($bulktester->get_stack_questions_by_context() as $contextid => $numstackquestions) {
    if ($skipping && $contextid != $startfromcontextid) {
        continue;
    }
    $skipping = false;
    $testcontext = context::instance_by_id($contextid);