Hi experts,
is it possible to import activities and resources from one course to multiple courses in moodle?
Hi experts,
is it possible to import activities and resources from one course to multiple courses in moodle?
$token = 'Tokan goes here';
$domainname = 'https://my.Moodle.url';
$functionname = 'core_course_import_course';
$params = array('importfrom' => 1736,
'importto'=> 1739,
'deletecontent'=>0,
'options'=>array(array('name'=>'blocks', 'value'=>'0'),
array('name'=>'activities', 'value'=>'1'),
array('name'=>'filters', 'value'=>'0'))
);
/// REST CALL
header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname;
require_once('./curl.php');
$curl = new curl;
$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:'';
$resp = $curl->post($serverurl . $restformat, $params);
print_r($resp);
?>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I am successfully able to import the activity now my situation is I have multiple course Id's I am trying to figure out what would be the best possible way to import it to all the remaining courses.
moosh (cli only) has a restore command.
https://moosh-online.com/commands/
course-restore
Restore course from path/to/backup.mbz to category or existig course.
Example 1: Restore backup.mbz into category with id=1
moosh course-restore backup.mbz 1
Example 2: Restore backup.mbz into existing course with id=3
moosh course-restore -e backup.mbz 3
one could create a looping bash shell script for the changing course ID numbers and get a lot done in a short time frame ... that's after testing one or two restores to see if it 'fits'.
'SoS', Ken