Created
May 18, 2017 02:33
-
-
Save FMCorz/f369c7554642dc68c493c1a786323d9c to your computer and use it in GitHub Desktop.
Webservice test for duplicating Moodle courses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
API="http://10.1.1.13/sm/webservice/rest/server.php" # WS entry point. | |
COURSEID=25 # Course to duplicated. | |
CATEGORYID=1 # Category to duplicate to. | |
TOKEN="490b48f8cd71e88a37fa70cc6eff3fb2" # WS Token. | |
# SCRIPT STARTS HERE. | |
SUFFIX=`date +"%s"` | |
echo "Duplicate without user data" | |
SHORTNAME="Duplicated${COURSEID}_NODATA_${SUFFIX}" | |
curl $API\ | |
-d moodlewsrestformat=json\ | |
-d wstoken=$TOKEN\ | |
-d wsfunction=core_course_duplicate_course\ | |
-d courseid=$COURSEID\ | |
-d fullname="Duplicated $COURSEID (without user data) - $SUFFIX"\ | |
-d shortname="$SHORTNAME"\ | |
-d categoryid=$CATEGORYID\ | |
-d 'options[0][name]=users'\ | |
-d 'options[0][value]=0' | |
echo | |
echo "Duplicate with user data" | |
SHORTNAME="Duplicated${COURSEID}_${SUFFIX}" | |
curl $API\ | |
-d moodlewsrestformat=json\ | |
-d wstoken=$TOKEN\ | |
-d wsfunction=core_course_duplicate_course\ | |
-d courseid=$COURSEID\ | |
-d fullname="Duplicated $COURSEID (with user data) - $SUFFIX"\ | |
-d shortname="$SHORTNAME"\ | |
-d categoryid=$CATEGORYID\ | |
-d 'options[0][name]=users'\ | |
-d 'options[0][value]=1' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear FMCorz,
do you have a clue how to pass the roles that should be enroled in the duplicated course?