MDL-45958 courselib: Refactor module duplication code to remove duplication
MDL-39883 events: Trigger an event when duplicating a course module