mirror of
https://github.com/moodle/moodle.git
synced 2025-02-13 12:34:28 +01:00
MDL-31124 reinstroduce accidentally removed restore code for 1.9 backups
This commit is contained in:
parent
7a00d6cbc6
commit
a75386fba6
@ -26,8 +26,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/mod/workshop/form/accumulative/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* Conversion handler for the accumulative grading strategy data
|
||||
*/
|
||||
@ -171,3 +169,46 @@ class moodle1_workshopform_accumulative_handler extends moodle1_workshopform_han
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a given record from workshop_elements_old into an object to be saved into workshopform_accumulative
|
||||
*
|
||||
* @param stdClass $old legacy record from workshop_elements_old
|
||||
* @param array $newscaleids mapping from old scale types into new standard ones
|
||||
* @param int $newworkshopid id of the new workshop instance that replaced the previous one
|
||||
* @return stdclass to be saved in workshopform_accumulative
|
||||
*/
|
||||
function workshopform_accumulative_upgrade_element(stdclass $old, array $newscaleids, $newworkshopid) {
|
||||
$new = new stdclass();
|
||||
$new->workshopid = $newworkshopid;
|
||||
$new->sort = $old->elementno;
|
||||
$new->description = $old->description;
|
||||
$new->descriptionformat = FORMAT_HTML;
|
||||
// calculate new grade/scale of the element
|
||||
if ($old->scale >= 0 and $old->scale <= 6 and isset($newscaleids[$old->scale])) {
|
||||
$new->grade = -$newscaleids[$old->scale];
|
||||
} elseif ($old->scale == 7) {
|
||||
$new->grade = 10;
|
||||
} elseif ($old->scale == 8) {
|
||||
$new->grade = 20;
|
||||
} elseif ($old->scale == 9) {
|
||||
$new->grade = 100;
|
||||
} else {
|
||||
$new->grade = 0; // something is wrong
|
||||
}
|
||||
// calculate new weight of the element. Negative weights are not supported any more and
|
||||
// are replaced with weight = 0. Legacy workshop did not store the raw weight but the index
|
||||
// in the array of weights (see $WORKSHOP_EWEIGHTS in workshop 1.x)
|
||||
// workshop 2.0 uses integer weights only (0-16) so all previous weights are multiplied by 4.
|
||||
switch ($old->weight) {
|
||||
case 8: $new->weight = 1; break;
|
||||
case 9: $new->weight = 2; break;
|
||||
case 10: $new->weight = 3; break;
|
||||
case 11: $new->weight = 4; break;
|
||||
case 12: $new->weight = 6; break;
|
||||
case 13: $new->weight = 8; break;
|
||||
case 14: $new->weight = 16; break;
|
||||
default: $new->weight = 0;
|
||||
}
|
||||
return $new;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/mod/workshop/form/comments/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* Conversion handler for the comments grading strategy data
|
||||
*/
|
||||
@ -48,3 +46,19 @@ class moodle1_workshopform_comments_handler extends moodle1_workshopform_handler
|
||||
return $converted;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a given record from workshop_elements_old into an object to be saved into workshopform_comments
|
||||
*
|
||||
* @param stdClass $old legacy record from workshop_elements_old
|
||||
* @param int $newworkshopid id of the new workshop instance that replaced the previous one
|
||||
* @return stdclass to be saved in workshopform_comments
|
||||
*/
|
||||
function workshopform_comments_upgrade_element(stdclass $old, $newworkshopid) {
|
||||
$new = new stdclass();
|
||||
$new->workshopid = $newworkshopid;
|
||||
$new->sort = $old->elementno;
|
||||
$new->description = $old->description;
|
||||
$new->descriptionformat = FORMAT_HTML;
|
||||
return $new;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/mod/workshop/form/numerrors/db/upgradelib.php');
|
||||
require_once($CFG->libdir.'/gradelib.php'); // grade_floatval() called here
|
||||
|
||||
/**
|
||||
@ -96,3 +95,35 @@ class moodle1_workshopform_numerrors_handler extends moodle1_workshopform_handle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a given record from workshop_elements_old into an object to be saved into workshopform_numerrors
|
||||
*
|
||||
* @param stdClass $old legacy record from workshop_elements_old
|
||||
* @param int $newworkshopid id of the new workshop instance that replaced the previous one
|
||||
* @return stdclass to be saved in workshopform_numerrors
|
||||
*/
|
||||
function workshopform_numerrors_upgrade_element(stdclass $old, $newworkshopid) {
|
||||
$new = new stdclass();
|
||||
$new->workshopid = $newworkshopid;
|
||||
$new->sort = $old->elementno;
|
||||
$new->description = $old->description;
|
||||
$new->descriptionformat = FORMAT_HTML;
|
||||
$new->grade0 = get_string('grade0default', 'workshopform_numerrors');
|
||||
$new->grade1 = get_string('grade1default', 'workshopform_numerrors');
|
||||
// calculate new weight of the element. Negative weights are not supported any more and
|
||||
// are replaced with weight = 0. Legacy workshop did not store the raw weight but the index
|
||||
// in the array of weights (see $WORKSHOP_EWEIGHTS in workshop 1.x)
|
||||
// workshop 2.0 uses integer weights only (0-16) so all previous weights are multiplied by 4.
|
||||
switch ($old->weight) {
|
||||
case 8: $new->weight = 1; break;
|
||||
case 9: $new->weight = 2; break;
|
||||
case 10: $new->weight = 3; break;
|
||||
case 11: $new->weight = 4; break;
|
||||
case 12: $new->weight = 6; break;
|
||||
case 13: $new->weight = 8; break;
|
||||
case 14: $new->weight = 16; break;
|
||||
default: $new->weight = 0;
|
||||
}
|
||||
return $new;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot.'/mod/workshop/form/rubric/db/upgradelib.php');
|
||||
|
||||
/**
|
||||
* Conversion handler for the rubric grading strategy data
|
||||
*/
|
||||
@ -141,3 +139,21 @@ class moodle1_workshopform_rubric_handler extends moodle1_workshopform_handler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms given record into an object to be saved into workshopform_rubric_levels
|
||||
*
|
||||
* This is used during Rubric 1.9 -> Rubric 2.0 conversion
|
||||
*
|
||||
* @param stdClass $old legacy record from joined workshop_elements_old + workshop_rubrics_old
|
||||
* @param int $newdimensionid id of the new workshopform_rubric dimension record to be linked to
|
||||
* @return stdclass to be saved in workshopform_rubric_levels
|
||||
*/
|
||||
function workshopform_rubric_upgrade_rubric_level(stdclass $old, $newdimensionid) {
|
||||
$new = new stdclass();
|
||||
$new->dimensionid = $newdimensionid;
|
||||
$new->grade = $old->rgrade * workshopform_rubric_upgrade_weight($old->eweight);
|
||||
$new->definition = $old->rdesc;
|
||||
$new->definitionformat = FORMAT_HTML;
|
||||
return $new;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user