public function process_course_completions($data) {
        global $DB;

        $data = (object)$data;

        $data->course = $this->get_courseid();
        $data->userid = $this->get_mappingid('user', $data->userid);

        if (!empty($data->userid)) {
            $params = array(
                'userid' => $data->userid,
                'course' => $data->course,
                'timeenrolled' => $data->timeenrolled,
                'timestarted' => $data->timestarted,
                'timecompleted' => $data->timecompleted,
                'reaggregate' => $data->reaggregate
            );

            $existing = $DB->get_record('course_completions', array(
                'userid' => $data->userid,
                'course' => $data->course
            ));

            // MDL-46651 - If cron writes out a new record before we get to it
            // then we should replace it with the Truth data from the backup.
            // This may be obsolete after MDL-48518 is resolved
            if ($existing) {
                $params['id'] = $existing->id;
                $DB->update_record('course_completions', $params);
            } else {
                $DB->insert_record('course_completions', $params);
            }
        }
    }