Auto creating courses (best practices?)

Re: Auto creating courses (best practices?)

by Clinton Graham -
Number of replies: 0
We opted to write our own course database synchronization script which queries on two views (courses and metacourses) in an external database to create courses in Moodle. We use the view data for such mdl_course elements such as name, category, startdate, etc., and a Moodle backup file [without user data] for structuring of the course layout.

I've attached the script, in case it is helpful.

We placed this script, the backup file, and the caller script in the "course" directory.

The caller is simply the stub below:
<?php

if(!empty($_SERVER['GATEWAY_INTERFACE'])){
error_log("should not be called from apache!");
exit;
}
error_reporting(E_ALL);

require_once('../config.php'); // global moodle config file.

require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/lib/blocklib.php');
require_once($CFG->dirroot . "/course/database_import.php");

// ensure errors are well explained
$CFG->debug=E_ALL;
// create instance of importer class
$importer = new course_database_import();

if (!$importer->course_database_synchronize()) {
error_log('Sync Failed!');
}

?>