Trying to modify some code, to reassign the assignment default value on restoring of a course to a new value but have ran into an error?
If i don't do this it seems that the course always defaults to the older value no matter what the site or course settings are?
Old 2.2.1 Moodle code
$sql = 'SELECT * '.
'FROM '.$CFG->prefix.'assignment'.
'WHERE course= '.$newid;
$params = array();
if ($assignments = $DB->get_records_sql($sql,$params)) {
foreach ($assignments as $assignment) {
if ($assignment->maxbytes != '25600000') {
$assignment->maxbytes = '25600000';
if (!$DB->update_record('assignment', $assignment)) {
echo "The assignment did not update";
}
}
}
}
Newer 2.6.2
$sql = 'SELECT * '.
'FROM '.$CFG->prefix.'assign_plugin_config'.
'WHERE course= '.$newid;
$params = array();
if ($assignments = $DB->get_records_sql($sql,$params)) {
foreach ($assignments as $assignment) {
if ($assignment->maxsubmissionsizebytes != '25600000') {
$assignment->maxsubmissionsizebytes = '25600000';
if (!$DB->update_record('assign_plugin_config', $assignment)) {
echo "The assignment did not update";
}
}
}
}
Error