fill_courses.php 967 B

1234567891011121314151617181920212223242526272829303132
  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. $eol = PHP_EOL;
  16. $courses = array(); //declare only to avoid parsing notice
  17. require_once 'data_courses.php'; //fill the $users array
  18. $output = array();
  19. $output[] = array('title'=>'Courses Filling Report: ');
  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. $res = CourseManager::create_course($course);
  25. $output[$i]['line-info'] = $res ? get_lang('Added') : get_lang('NotInserted');
  26. $i++;
  27. }
  28. return $output;
  29. }