fill_courses.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script contains a data filling procedure for users
  5. * @author Yannick Warnier <yannick.warnier@beeznest.com>
  6. *
  7. */
  8. /**
  9. * Loads the data and injects it into the Chamilo database, using the Chamilo
  10. * internal functions.
  11. * @return array List of user IDs for the users that have just been inserted
  12. */
  13. function fill_courses()
  14. {
  15. $courses = array(); // declare only to avoid parsing notice
  16. require_once 'data_courses.php'; // fill the $courses array
  17. $output = array();
  18. $output[] = array('title'=>'Courses Filling Report: ');
  19. $i = 1;
  20. foreach ($courses as $i => $course) {
  21. // First check that the first item doesn't exist already
  22. $output[$i]['line-init'] = $course['title'];
  23. // The wanted code is necessary to avoid interpretation
  24. $course['wanted_code'] = $course['code'];
  25. $course['course_language'] = !empty($course['course_language']) ? $course['course_language'] : 'en';
  26. $res = CourseManager::create_course($course);
  27. $output[$i]['line-info'] = $res ? get_lang('Added') : get_lang('NotInserted');
  28. $i++;
  29. }
  30. return $output;
  31. }