Browse Source

Added courses test filler

Yannick Warnier 14 years ago
parent
commit
a8a440a68a
3 changed files with 15 additions and 4 deletions
  1. 13 2
      main/admin/filler.php
  2. 0 1
      tests/datafiller/data_courses.php
  3. 2 1
      tests/datafiller/fill_courses.php

+ 13 - 2
main/admin/filler.php

@@ -30,8 +30,18 @@ $nameTools = get_lang('DataFiller');
 
 $output = array();
 if (!empty($_GET['fill'])) {
-	require api_get_path('SYS_TEST_PATH').'datafiller/fill_users.php';
-	$output = fill_users();
+    switch ($_GET['fill']) {
+    	case 'users':
+        	require api_get_path('SYS_TEST_PATH').'datafiller/fill_users.php';
+            $output = fill_users();
+            break;
+        case 'courses':
+            require api_get_path('SYS_TEST_PATH').'datafiller/fill_courses.php';
+            $output = fill_courses();
+            break;
+        default:
+            break;
+    }
 }
 
 // Displaying the header
@@ -57,6 +67,7 @@ if (count($output)>0) {
   <div><?php echo get_lang('ThisSectionIsOnlyVisibleOnSourceInstalls');?></div>
   <ul>
     <li><a href="filler.php?fill=users"><?php echo get_lang('FillUsers');?></a></li>
+    <li><a href="filler.php?fill=courses"><?php echo get_lang('FillCourses');?></a></li>
   </ul>
 </div>
 <?php

+ 0 - 1
tests/datafiller/data_courses.php

@@ -17,7 +17,6 @@ $courses[] = array(
     'category' => 'PROJ',
     'language' => 'english',
     'admin_id' => 1,
-    'db_prefix' => $_configuration['db_prefix'],
     'expires' => '2020-09-01 00:00:00',
     'fill' => true,
 );

+ 2 - 1
tests/datafiller/fill_courses.php

@@ -9,6 +9,7 @@
  */
 //require_once '../../main/inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
+require_once api_get_path(LIBRARY_PATH).'database.lib.php';
 /**
  * Loads the data and injects it into the Chamilo database, using the Chamilo
  * internal functions.
@@ -24,7 +25,7 @@ function fill_courses() {
     foreach ($courses as $i => $course) {
         //first check that the first item doesn't exist already
     	$output[$i]['line-init'] = $course['title'];
-    	$output[$i]['line-info'] = (create_course($course[)?$res:get_lang('NotInserted'));
+    	$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'));
     	$i++;
     }
     return $output;