mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
NOMDL workshop more referential integrity checks
As reported by Trudy Koedooder at http://moodle.org/mod/forum/discuss.php?d=161322 there can be some orphaned grade records without the referenced assessment. It threw upgrade error. Such grades are now just ignored during the upgrade.
This commit is contained in:
parent
f4a2817ac5
commit
cdff9eead3
@ -73,6 +73,10 @@ function workshopform_accumulative_upgrade_legacy() {
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
$newassessmentids = workshop_upgrade_assessment_id_mappings();
|
||||
foreach ($rs as $old) {
|
||||
if (!isset($newassessmentids[$old->assessmentid])) {
|
||||
// orphaned grade - the assessment was removed but the grade remained
|
||||
continue;
|
||||
}
|
||||
if (!isset($newelementids[$old->workshopid]) or !isset($newelementids[$old->workshopid][$old->elementno])) {
|
||||
// orphaned grade - the assessment form element has been removed after the grade was recorded
|
||||
continue;
|
||||
|
@ -70,6 +70,10 @@ function workshopform_comments_upgrade_legacy() {
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
$newassessmentids = workshop_upgrade_assessment_id_mappings();
|
||||
foreach ($rs as $old) {
|
||||
if (!isset($newassessmentids[$old->assessmentid])) {
|
||||
// orphaned comment - the assessment was removed but the grade remained
|
||||
continue;
|
||||
}
|
||||
if (!isset($newelementids[$old->workshopid]) or !isset($newelementids[$old->workshopid][$old->elementno])) {
|
||||
// orphaned comment - the assessment form element has been removed after the grade was recorded
|
||||
continue;
|
||||
|
@ -93,6 +93,10 @@ function workshopform_numerrors_upgrade_legacy() {
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
$newassessmentids = workshop_upgrade_assessment_id_mappings();
|
||||
foreach ($rs as $old) {
|
||||
if (!isset($newassessmentids[$old->assessmentid])) {
|
||||
// orphaned grade - the assessment was removed but the grade remained
|
||||
continue;
|
||||
}
|
||||
if (!isset($newelementids[$old->workshopid]) or !isset($newelementids[$old->workshopid][$old->elementno])) {
|
||||
// orphaned grade - the assessment form element has been removed after the grade was recorded
|
||||
continue;
|
||||
|
@ -104,6 +104,10 @@ function workshopform_rubric_upgrade_legacy_criterion() {
|
||||
$newassessmentids = workshop_upgrade_assessment_id_mappings();
|
||||
$newdimensionids = $DB->get_records('workshopform_rubric_levels', array(), '', 'id,dimensionid');
|
||||
foreach ($rs as $old) {
|
||||
if (!isset($newassessmentids[$old->assessmentid])) {
|
||||
// orphaned grade - the assessment was removed but the grade remained
|
||||
continue;
|
||||
}
|
||||
if (!isset($newelementids[$old->workshopid]) or !isset($newelementids[$old->workshopid][$old->elementno])) {
|
||||
// orphaned grade - the assessment form element has been removed after the grade was recorded
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user