require_once '../../../config.php'; require_once $CFG->dirroot . '/enrol/enrol.class.php'; require_once $CFG->libdir . '/blocklib.php'; require_once $CFG->dirroot . '/course/lib.php'; require_once $CFG->dirroot . '/course/edit_form.php'; require_once $CFG->dirroot . '/synch/setup.php'; require_once $CFG->dirroot . '/synch/setup.php'; require_once dirname(__FILE__) . '/lib.php'; global $Out; define('ACTION_CREATE_COURSE', 1); define('ACTION_BACKUP_COURSE', 2); $action = optional_param('action', ACTION_CREATE_COURSE, PARAM_INT); // what to do. default = Create a course $categoryId = optional_param('categoryid', 1, PARAM_INT); // what category to create the course in $courseId = optional_param('courseId', 0, PARAM_INT); // what category to create the course in $Out->print_r($action, '$action (1) = '); if ($action & ACTION_CREATE_COURSE) { $Out->append('Creating course'); $course = createCourse($categoryId); if (isset($course->id)) { $courseId = $course->id; } } if ($action & ACTION_BACKUP_COURSE) { $Out->append('Backing up course'); backupCourseByCourseId($courseId); } $Out->flush(); // Output stream to screen.
$course = array('teacher_id' => '', 'course_name' => '', 'school_year_id' => '', 'isCore' => '', 'ed_center' => '', 'SectionID' => ''); foreach ($smsCourses as $SectionID => $courseInfo) { if ($courseInfo['TakesAttendance'] != 1) { continue; } $teacher_id = $q3aitTeachers[$smsTeachers[$courseInfo['username']]['email']]['user_id']; if (!$teacher_id) { continue; } $teacher_fname = $q3aitTeachers[$smsTeachers[$courseInfo['username']]['email']]['first_name']; $teacher_lname = $q3aitTeachers[$smsTeachers[$courseInfo['username']]['email']]['last_name']; if ($SectionID != '' && $courseInfo['username'] != '' && $courseInfo['BuildingID'] != '') { if (!array_key_exists($SectionID, $q3aitCourses)) { $course = array('teacher_id' => $teacher_id, 'course_name' => $courseInfo['tsn'], 'school_year_id' => array_search($courseInfo['SchoolYear'], $schoolYears), 'isCore' => $courseInfo['TakesAttendance'], 'ed_center' => $edCenters[$courseInfo['BuildingID']]['center_id'], 'SectionID' => $courseInfo['SectionID']); foreach ($course as &$cell) { $cell = makeSQLsafe(trim($cell)); } if ($course['teacher_id'] != '' && array_key_exists($smsTeachers[$courseInfo['username']]['email'], $q3aitTeachers)) { //print "Creating course {".$courseInfo['tsn']."} for teacher {".$teacher_fname." ".$teacher_lname."} in building {".$courseInfo['BuildingID']."}<br>"; //continue; $msg = createCourse($course); if ($msg['error']) { $error = true; $msg .= "There was an error creating course {" . $courseInfo['tsn'] . "}<br>" . $msg['message'] . "<br>"; } } } else { //print "Course {".$courseInfo['tsn']."} with CourseID{".$courseInfo['SectionID']."} already exists in Q3<br>"; } } }