fill_courses.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. $languages = SubLanguageManager::getAllLanguages(true);
  20. $i = 1;
  21. foreach ($courses as $i => $course) {
  22. // First check that the first item doesn't exist already
  23. $output[$i]['line-init'] = $course['title'];
  24. // The wanted code is necessary to avoid interpretation
  25. $course['wanted_code'] = $course['code'];
  26. // Make sure the language defaults to English if others are disabled
  27. if (!isset($languages[$course['course_language']])) {
  28. $course['course_language'] = 'english';
  29. }
  30. // Effectively create the course
  31. $res = CourseManager::create_course($course);
  32. $output[$i]['line-info'] = $res ? get_lang('Added') : get_lang('NotInserted');
  33. $i++;
  34. }
  35. return $output;
  36. }