MDL-20636 Make extracttestcase.php work after the upgrade too.

This commit is contained in:
Tim Hunt 2011-05-13 11:42:37 +01:00
parent 2d43a02323
commit 1ab31a1b92
3 changed files with 26 additions and 17 deletions

View File

@ -38,7 +38,6 @@ require_once($CFG->libdir . '/adminlib.php');
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
local_qeupgradehelper_require_not_upgraded();
admin_externalpage_setup('qeupgradehelper', '', array(),
local_qeupgradehelper_url('extracttestcase'));

View File

@ -42,6 +42,7 @@ 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 {

View File

@ -463,21 +463,23 @@ function local_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffi
$question = local_qeupgradehelper_load_question($qsession->questionid, $quiz->id);
if (!$quiz->optionflags) {
$quiz->preferredbehaviour = 'deferredfeedback';
} else if (!$quiz->penaltyscheme) {
$quiz->preferredbehaviour = 'adaptive';
} else {
$quiz->preferredbehaviour = 'adaptivenopenalty';
if (!local_qeupgradehelper_is_upgraded()) {
if (!$quiz->optionflags) {
$quiz->preferredbehaviour = 'deferredfeedback';
} else if (!$quiz->penaltyscheme) {
$quiz->preferredbehaviour = 'adaptive';
} else {
$quiz->preferredbehaviour = 'adaptivenopenalty';
}
unset($quiz->optionflags);
unset($quiz->penaltyscheme);
$question->defaultmark = $question->defaultgrade;
unset($question->defaultgrade);
}
unset($quiz->optionflags);
unset($quiz->penaltyscheme);
$attempt->needsupgradetonewqe = 1;
$question->defaultmark = $question->defaultgrade;
unset($question->defaultgrade);
echo "<pre>
public function test_{$question->qtype}_{$quiz->preferredbehaviour}_{$namesuffix}() {
";
@ -560,7 +562,7 @@ function local_qeupgradehelper_display_convert_attempt_input($quiz, $attempt,
}
function local_qeupgradehelper_load_question($questionid, $quizid) {
global $DB, $QTYPES;
global $CFG, $DB;
$question = $DB->get_record_sql('
SELECT q.*, qqi.grade AS maxmark
@ -569,12 +571,19 @@ function local_qeupgradehelper_load_question($questionid, $quizid) {
WHERE q.id = :questionid AND qqi.quiz = :quizid',
array('questionid' => $questionid, 'quizid' => $quizid));
if (!array_key_exists($question->qtype, $QTYPES)) {
$question->qtype = 'missingtype';
$question->questiontext = '<p>' . get_string('warningmissingtype', 'quiz') . '</p>' . $question->questiontext;
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];
}
$QTYPES[$question->qtype]->get_question_options($question);
$qtype->get_question_options($question);
return $question;
}