The information I have is the course id and the module id, what I'm basically missing now is the mapping of the (studentquiz) entries to the course_modules instance.
I would greatly appreciate any input!
The information I have is the course id and the module id, what I'm basically missing now is the mapping of the (studentquiz) entries to the course_modules instance.
I would greatly appreciate any input!
I figured out a way to do it. I feel if Moodle was built a bit better structured, this all wouldn't be such an issue. After everything has been restored, we go in and find the the matching instance in course_modules and add the course_modules id to our table.
protected function after_execute() { global $DB; $courseid = $this->get_courseid(); $moduleid = $DB->get_field('modules', 'id', array('name'=>'studentquiz')); $cms = $DB->get_records('course_modules', array('course'=>$courseid, 'module'=>$moduleid)); foreach ($cms as $cm) { $studentquiz = $DB->get_record('studentquiz', array('id'=>$cm->instance)); $studentquiz->coursemodule = $cm->id; $DB->update_record('studentquiz', $studentquiz); } }