public static function move_annotations_to_final($backupid, $itemname, \core\progress\base $progress) {
        global $DB;
        $progress->start_progress('move_annotations_to_final');
        $rs = $DB->get_recordset('backup_ids_temp', array('backupid' => $backupid, 'itemname' => $itemname));
        $progress->progress();
        foreach($rs as $annotation) {
            // If corresponding 'itemfinal' annotation does not exist, update 'item' to 'itemfinal'
            if (! $DB->record_exists('backup_ids_temp', array('backupid' => $backupid,
                                                              'itemname' => $itemname . 'final',
                                                              'itemid' => $annotation->itemid))) {
                $DB->set_field('backup_ids_temp', 'itemname', $itemname . 'final', array('id' => $annotation->id));
            }
            $progress->progress();
        }
        $rs->close();
        // All the remaining $itemname annotations can be safely deleted
        $DB->delete_records('backup_ids_temp', array('backupid' => $backupid, 'itemname' => $itemname));
        $progress->end_progress();
    }