/** * This function does the cron process within the time range according to settings. */ function local_qeupgradehelper_process($settings) { global $CFG; require_once dirname(__FILE__) . '/locallib.php'; if (!local_qeupgradehelper_is_upgraded()) { mtrace('qeupgradehelper: site not yet upgraded. Doing nothing.'); return; } require_once dirname(__FILE__) . '/afterupgradelib.php'; $hour = (int) date('H'); if ($hour < $settings->starthour || $hour >= $settings->stophour) { mtrace('qeupgradehelper: not between starthour and stophour, so doing nothing (hour = ' . $hour . ').'); return; } $stoptime = time() + $settings->procesingtime; mtrace('qeupgradehelper: processing ...'); while (time() < $stoptime) { $quiz = local_qeupgradehelper_get_quiz_for_upgrade(); if (!$quiz) { mtrace('qeupgradehelper: No more quizzes to process. You should probably disable the qeupgradehelper cron settings now.'); break; // No more to do; } $quizid = $quiz->id; $quizsummary = local_qeupgradehelper_get_quiz($quizid); if ($quizsummary) { mtrace(' starting upgrade of attempts at quiz ' . $quizid); $upgrader = new local_qeupgradehelper_attempt_upgrader($quizsummary->id, $quizsummary->numtoconvert); $upgrader->convert_all_quiz_attempts(); mtrace(' upgrade of quiz ' . $quizid . ' complete.'); } } mtrace('qeupgradehelper: Done.'); return; }
/** * This function does the cron process within the time range according to settings. */ function local_qeupgradehelper_process($settings) { if (!local_qeupgradehelper_is_upgraded()) { mtrace('qeupgradehelper: site not yet upgraded. Doing nothing.'); return; } $hour = (int) date('H'); if ($hour < $settings->starthour || $hour >= $settings->stophour) { mtrace('qeupgradehelper: not between starthour and stophour, so doing nothing (hour = ' . $hour . ').'); return; } $stoptime = time() + $settings->procesingtime; while (time() < $stoptime) { mtrace('qeupgradehelper: processing ...'); // TODO mtrace('qeupgradehelper: sorry, not implemented yet.'); return; } }
function local_qeupgradehelper_load_question($questionid, $quizid) { global $CFG, $DB; $question = $DB->get_record_sql(' SELECT q.*, qqi.grade AS maxmark FROM {question} q JOIN {quiz_question_instances} qqi ON qqi.question = q.id WHERE q.id = :questionid AND qqi.quiz = :quizid', array('questionid' => $questionid, 'quizid' => $quizid)); if (local_qeupgradehelper_is_upgraded()) { require_once $CFG->dirroot . '/question/engine/bank.php'; $qtype = question_bank::get_qtype($question->qtype, false); } else { global $QTYPES; if (!array_key_exists($question->qtype, $QTYPES)) { $question->qtype = 'missingtype'; $question->questiontext = '<p>' . get_string('warningmissingtype', 'quiz') . '</p>' . $question->questiontext; } $qtype = $QTYPES[$question->qtype]; } $qtype->get_question_options($question); return $question; }
* from Moodle 2.0 to 2.1. * * This screen is the main entry-point to the plugin, it gives the admin a list * of options available to them. * * @package local * @subpackage qeupgradehelper * @copyright 2010 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../../config.php'; require_once dirname(__FILE__) . '/locallib.php'; require_once $CFG->libdir . '/adminlib.php'; require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); admin_externalpage_setup('qeupgradehelper'); $renderer = $PAGE->get_renderer('local_qeupgradehelper'); $actions = array(); if (local_qeupgradehelper_is_upgraded()) { $detected = get_string('upgradedsitedetected', 'local_qeupgradehelper'); $actions[] = local_qeupgradehelper_action::make('listtodo'); $actions[] = local_qeupgradehelper_action::make('listupgraded'); $actions[] = local_qeupgradehelper_action::make('extracttestcase'); $actions[] = local_qeupgradehelper_action::make('cronsetup'); } else { $detected = get_string('oldsitedetected', 'local_qeupgradehelper'); $actions[] = local_qeupgradehelper_action::make('listpreupgrade'); $actions[] = local_qeupgradehelper_action::make('extracttestcase'); $actions[] = local_qeupgradehelper_action::make('cronsetup'); } echo $renderer->index_page($detected, $actions);