fix moodle inserting/updating