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();