Function core_course_duplicate_course

Function core_course_duplicate_course

by María UP Navarra -
Number of replies: 2

Good morning.

First of all, sorry for my bad english.

I am trying to use the "core_course_duplicate_course" function to duplicate a course in moodle.

I have enabled all necessary features and permissions and the process works fine.

My problem arises when I want, for example, to disable the copying/duplicating of users, roles, activities... It doesn't matter how I send the request, it always duplicates the entire course.

I am carrying out the initial tests from Postman, I am attaching a screenshot of my request:

Petición postman - duplicate_course

If I change the options parameter removing the square brackets ([]) it gives me the following error:

Error petición duplicate_course

I think the problem is in the configuration of the parameters of the "options" block.

Could someone please guide me on how I should send these parameters?

I am using php 7.4 and moodle 4.0

Thank you very much for your time and best regards.

Average of ratings: -
In reply to María UP Navarra

Re: Function core_course_duplicate_course

by María UP Navarra -
Hello again!

I have found the solution :D

The request must be sent with this format (attached photo):
ejemplo opciones de la peticion

They needed to add these capacity permissions:

  • moodle/restore:configure
  • moodle/backup:configure

After adding them, the filters work correctly and I can indicate whether or not I want to copy the users, role assignments, activities, etc.

I am not deleting the thread, in case it may be useful to someone in the future.

Have a great day.
Bye!
In reply to María UP Navarra

Re: Function core_course_duplicate_course

by Sean Norrey -
Hi Maria, I have never been able to get core_course_duplicate_course to work. Are you able to share your code so I can see where I might be making a mistake?