mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-20636 Add warning about very old attempts to listpreupgrade.php.
This commit is contained in:
parent
1ab31a1b92
commit
d02ac70862
@ -45,7 +45,7 @@ $string['gotoresetlink'] = 'Go to the list of quizzes that can be reset';
|
||||
$string['invalidquizid'] = 'Invaid quiz id. Either the quiz does not exist, or it has no attempts to convert.';
|
||||
$string['listpreupgrade'] = 'List quizzes and attempts';
|
||||
$string['listpreupgrade_desc'] = 'This will show a report of all the quizzes on the system and how many attempts they have. This will give you an idea of the scope of the upgrade you have to do.';
|
||||
$string['listpreupgradeintro'] = 'These are the number of quiz attempts that will need to be processed when you upgrade your site. A few tens of thousands is no worry. Much beyond that and you need to think carefully.';
|
||||
$string['listpreupgradeintro'] = 'These are the number of quiz attempts that will need to be processed when you upgrade your site. A few tens of thousands is no worry. Much beyond that and you need to think about how long the upgrade will take.';
|
||||
$string['listtodo'] = 'List quizzes still to upgrade';
|
||||
$string['listtodo_desc'] = 'This will show a report of all the quizzes on the system (if any) that have attempts that still need to be upgraded to the new question engine.';
|
||||
$string['listtodointro'] = 'These are all the quizzes with attempt data that still needs to be converted. You can convert the attempts by clicking the link.';
|
||||
@ -72,4 +72,4 @@ $string['resettingquizattempts'] = 'Resetting quiz attempts';
|
||||
$string['upgradingquizattempts'] = 'Upgrading the attempts for quiz \'{$a->name}\' in course {$a->shortname}';
|
||||
$string['upgradedsitedetected'] = 'This appears to be a site that has been upgraded to include the new question engine.';
|
||||
$string['upgradedsiterequired'] = 'This script can only work after the site has been upgraded.';
|
||||
|
||||
$string['veryoldattemtps'] = 'Your site has {$a} quiz attempts that were never completely updated during the upgrade from Moodle 1.4 to Moodle 1.5. These attempts will be dealt wiht before the main upgrade. You need to to consider the extra time required for this.';
|
||||
|
@ -40,6 +40,7 @@ $PAGE->navbar->add(get_string('listpreupgrade', 'local_qeupgradehelper'));
|
||||
$renderer = $PAGE->get_renderer('local_qeupgradehelper');
|
||||
|
||||
$quizzes = new local_qeupgradehelper_pre_upgrade_quiz_list();
|
||||
$numveryoldattemtps = local_qeupgradehelper_get_num_very_old_attempts();
|
||||
|
||||
if ($quizzes->is_empty()) {
|
||||
echo $renderer->simple_message_page(get_string('noquizattempts', 'local_qeupgradehelper'));
|
||||
@ -47,5 +48,5 @@ if ($quizzes->is_empty()) {
|
||||
} else {
|
||||
// TODO, once we have a way to limit which quizzes will be included in the upgrade,
|
||||
// display that information too.
|
||||
echo $renderer->quiz_list_page($quizzes);
|
||||
echo $renderer->quiz_list_page($quizzes, $numveryoldattemtps);
|
||||
}
|
||||
|
@ -262,26 +262,6 @@ class local_qeupgradehelper_resettable_quiz_list extends local_qeupgradehelper_q
|
||||
}
|
||||
|
||||
|
||||
function local_qeupgradehelper_get_pre_upgrade_quizzes() {
|
||||
global $DB;
|
||||
return $DB->get_records_sql("
|
||||
SELECT
|
||||
quiz.id,
|
||||
quiz.name,
|
||||
c.shortname,
|
||||
c.id AS courseid,
|
||||
COUNT(1) AS attemptcount
|
||||
|
||||
FROM {quiz_attempts} quiza
|
||||
JOIN {quiz} quiz ON quiz.id = quiza.quiz
|
||||
JOIN {course} c ON c.id = quiz.course
|
||||
|
||||
WHERE quiza.preview = 0
|
||||
|
||||
GROUP BY quiz.id, quiz.name, c.shortname, c.id
|
||||
ORDER BY c.shortname, quiz.name, quiz.id");
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of quizzes that still need to be upgraded after the main upgrade.
|
||||
*
|
||||
@ -298,6 +278,24 @@ class local_qeupgradehelper_pre_upgrade_quiz_list extends local_qeupgradehelper_
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List the number of quiz attempts that were never upgraded from 1.4 -> 1.5.
|
||||
* @return int the number of such attempts.
|
||||
*/
|
||||
function local_qeupgradehelper_get_num_very_old_attempts() {
|
||||
global $DB;
|
||||
return $DB->count_records_sql('
|
||||
SELECT COUNT(1)
|
||||
FROM {quiz_attempts} quiza
|
||||
WHERE uniqueid IN (
|
||||
SELECT DISTINCT qst.attempt
|
||||
FROM {question_states} qst
|
||||
LEFT JOIN {question_sessions} qsess ON
|
||||
qst.question = qsess.questionid AND qst.attempt = qsess.attemptid
|
||||
WHERE qsess.id IS NULL)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information about a quiz to be upgraded.
|
||||
* @param integer $quizid the quiz id.
|
||||
|
@ -74,9 +74,11 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Render the list of quizzes that still need to be upgraded page.
|
||||
* @param array $quizzes of data about quizzes.
|
||||
* @param int $numveryoldattemtps only relevant before upgrade.
|
||||
* @return string html to output.
|
||||
*/
|
||||
public function quiz_list_page(local_qeupgradehelper_quiz_list $quizzes) {
|
||||
public function quiz_list_page(local_qeupgradehelper_quiz_list $quizzes,
|
||||
$numveryoldattemtps = null) {
|
||||
$output = '';
|
||||
$output .= $this->header();
|
||||
$output .= $this->heading($quizzes->title);
|
||||
@ -90,6 +92,11 @@ class local_qeupgradehelper_renderer extends plugin_renderer_base {
|
||||
$table->data[] = $quizzes->get_total_row();
|
||||
$output .= html_writer::table($table);
|
||||
|
||||
if ($numveryoldattemtps) {
|
||||
$output .= $this->box(get_string('veryoldattemtps', 'local_qeupgradehelper',
|
||||
$numveryoldattemtps));
|
||||
}
|
||||
|
||||
$output .= $this->back_to_index();
|
||||
$output .= $this->footer();
|
||||
return $output;
|
||||
|
Loading…
x
Reference in New Issue
Block a user