ndunand / moodle-mod_opencast

OpenCast module for Moodle
8 stars 6 forks source link

Fix reset of course module #15

Closed OdyX closed 3 years ago

OdyX commented 3 years ago

When resetting mod_opencast instances through the API, sometimes this error can occur:

Unknown column 'timeopen' in 'where clause'
UPDATE mdl_opencast
                          SET timeopen = timeopen + ?
                        WHERE course=? AND timeopen<>0
[array (
  0 => 3600,
  1 => 3311,
)]

This is because this line will ask Moodle to update fields that don't exist: https://github.com/ndunand/moodle-mod_opencast/blob/master/lib.php#L225

    // updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('opencast', ['timeopen', 'timeclose'], $data->timeshift, $data->courseid);
        $status[] = ['component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false];
    }

My proposal is to completely remove all references to these fields that are not installed in the DB (not present in db/install.xml).

ndunand commented 3 years ago

Thanks for spotting this and for providing a fix!