fill_courses.php 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php //$id$
  2. /**
  3. * This script contains a data filling procedure for users
  4. * @author Yannick Warnier <yannick.warnier@beeznest.com>
  5. *
  6. */
  7. /**
  8. * Initialisation section
  9. */
  10. //require_once '../../main/inc/global.inc.php';
  11. require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'database.lib.php';
  13. /**
  14. * Loads the data and injects it into the Chamilo database, using the Chamilo
  15. * internal functions.
  16. * @return array List of user IDs for the users that have just been inserted
  17. */
  18. function fill_courses() {
  19. $eol = PHP_EOL;
  20. $courses = array(); //declare only to avoid parsing notice
  21. require_once 'data_courses.php'; //fill the $users array
  22. $output = array();
  23. $output[] = array('title'=>'Courses Filling Report:');
  24. $i = 1;
  25. foreach ($courses as $i => $course) {
  26. //first check that the first item doesn't exist already
  27. $output[$i]['line-init'] = $course['title'];
  28. $output[$i]['line-info'] = ($res = create_course($course['code'],$course['title'],$course['tutor'],$course['category'],$course['language'],$course['admin_id'],Database::get_database_name_prefix(),$course['expires'],$course['fill'])?$res:get_lang('NotInserted'));
  29. $i++;
  30. }
  31. return $output;
  32. }