mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-32895: Improvements to assignment upgrade tool for large numbers of assignments.
* Form to control the perpage variable for the upgradable assignments table. * Set timeout and increase memory limit for batch upgrades * Output/renderer pages to the upgrade progress is progressively displayed * Cleanup of relative includes in assignmentupgrade tool * More verbose errors reported for failed upgrades
This commit is contained in:
parent
71d7bc34a8
commit
5b12114476
13 changed files with 168 additions and 116 deletions
|
@ -170,54 +170,33 @@ function tool_assignmentupgrade_load_all_upgradable_assignmentids() {
|
|||
|
||||
|
||||
/**
|
||||
* Convert a list of assignments from the old format to the new one.
|
||||
* @param bool $upgradeall - Upgrade all possible assignments
|
||||
* @param array $assignmentids An array of assignment ids to upgrade
|
||||
* @return array of $entry['assignmentsummary' => (result from tool_assignmentupgrade_get_assignment)
|
||||
* $entry['success'] => boolean
|
||||
* $entry['log'] => string - upgrade log
|
||||
* Upgrade a single assignment. This is used by both upgrade single and upgrade batch
|
||||
*
|
||||
* @param int $assignmentid - The assignment id to upgrade
|
||||
* @return array(string, boolean, string) -
|
||||
* The array contains
|
||||
* - the assignment summary (returned by tool_assignmentupgrade_get_assignment)
|
||||
* - success
|
||||
* - the upgrade log
|
||||
*/
|
||||
function tool_assignmentupgrade_upgrade_multiple_assignments($upgradeall, $assignmentids) {
|
||||
function tool_assignmentupgrade_upgrade_assignment($assignmentid) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/assign/upgradelib.php');
|
||||
$upgrades = array();
|
||||
|
||||
if ($upgradeall) {
|
||||
$assignmentids = tool_assignmentupgrade_load_all_upgradable_assignmentids();
|
||||
}
|
||||
|
||||
$assignment_upgrader = new assign_upgrade_manager();
|
||||
foreach ($assignmentids as $assignmentid) {
|
||||
$info = tool_assignmentupgrade_get_assignment($assignmentid);
|
||||
if ($info) {
|
||||
$log = '';
|
||||
$success = $assignment_upgrader->upgrade_assignment($assignmentid, $log);
|
||||
} else {
|
||||
$success = false;
|
||||
$log = get_string('assignmentnotfound', 'tool_assignmentupgrade', $assignmentid);
|
||||
$info = new stdClass();
|
||||
$info->name = get_string('unknown', 'tool_assignmentupgrade');
|
||||
$info->shortname = get_string('unknown', 'tool_assignmentupgrade');
|
||||
}
|
||||
|
||||
$upgrades[] = array('assignmentsummary'=>$info, 'success'=>$success, 'log'=>$log);
|
||||
$info = tool_assignmentupgrade_get_assignment($assignmentid);
|
||||
if ($info) {
|
||||
$log = '';
|
||||
$success = $assignment_upgrader->upgrade_assignment($assignmentid, $log);
|
||||
} else {
|
||||
$success = false;
|
||||
$log = get_string('assignmentnotfound', 'tool_assignmentupgrade', $assignmentid);
|
||||
$info = new stdClass();
|
||||
$info->name = get_string('unknown', 'tool_assignmentupgrade');
|
||||
$info->shortname = get_string('unknown', 'tool_assignmentupgrade');
|
||||
}
|
||||
return $upgrades;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a single assignment from the old format to the new one.
|
||||
* @param stdClass $assignmentinfo An object containing information about this class
|
||||
* @param string $log This gets appended to with the details of the conversion process
|
||||
* @return boolean This is the overall result (true/false)
|
||||
*/
|
||||
function tool_assignmentupgrade_upgrade_assignment($assignmentinfo, &$log) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/assign/upgradelib.php');
|
||||
$assignment_upgrader = new assign_upgrade_manager();
|
||||
return $assignment_upgrader->upgrade_assignment($assignmentinfo->id, $log);
|
||||
return array($info, $success, $log);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue