Fixing Datafiller due new DB changes see #4056

skala
Julio Montoya 13 years ago
parent 1d3e5abbd9
commit 0b81e85e2b
  1. 32
      main/admin/course_add.php
  2. 8
      main/admin/filler.php
  3. 35
      main/inc/lib/add_course.lib.inc.php
  4. 1
      tests/datafiller/fill_courses.php
  5. 3
      tests/datafiller/fill_users.php

@ -15,6 +15,7 @@ require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
@ -129,12 +130,12 @@ $form->setDefaults($values);
// Validate the form.
if ($form->validate()) {
$course = $form->exportValues();
$code = $course['visual_code'];
$tutor_name = $teachers[$course['tutor_id']];
$teacher_id = $course['tutor_id'];
$course = $form->exportValues();
$code = $course['visual_code'];
$tutor_name = $teachers[$course['tutor_id']];
$teacher_id = $course['tutor_id'];
$course_teachers = $course['course_teachers'];
$test = false;
$test = false;
// The course tutor has been selected in the teachers list so we must remove him to avoid double records in the database.
foreach ($course_teachers as $key => $value){
@ -143,13 +144,14 @@ if ($form->validate()) {
break;
}
}
$title = $course['title'];
$category = $course['category_code'];
$department_name = $course['department_name'];
$department_url = $course['department_url'];
$course_language = $course['course_language'];
$exemplary_content = empty($course['exemplary_content']) ? false : true;
$disk_quota = $course['disk_quota'];
$title = $course['title'];
$category = $course['category_code'];
$department_name = $course['department_name'];
$department_url = $course['department_url'];
$course_language = $course['course_language'];
$exemplary_content = empty($course['exemplary_content']) ? false : true;
$disk_quota = $course['disk_quota'];
if (stripos($department_url, 'http://') === false && stripos($department_url, 'https://') === false) {
$department_url = 'http://'.$department_url;
}
@ -157,14 +159,16 @@ if ($form->validate()) {
$code = generate_course_code(api_substr($title, 0, $maxlength));
}
$keys = define_course_keys($code, '', $_configuration['db_prefix']);
if (count($keys)) {
$current_course_code = $keys['currentCourseCode'];
$current_course_id = $keys['currentCourseId'];
$current_course_repository = $keys['currentCourseRepository'];
//@todo is not set $firstExpirationDelay
$expiration_date = time() + $firstExpirationDelay;
prepare_course_repository($current_course_repository, $current_course_id);
//update_Db_course($current_course_db_name);
$pictures_array = fill_course_repository($current_course_repository, $exemplary_content);
$course_id = register_course($current_course_id, $current_course_code, $current_course_repository, '', $tutor_name, $category, $title, $course_language, $teacher_id, $expiration_date, $course_teachers);
fill_Db_course($course_id, $current_course_repository, $course_language, $pictures_array, $exemplary_content);
@ -172,7 +176,7 @@ if ($form->validate()) {
$sql = "UPDATE $table_course SET disk_quota = '".$disk_quota."', visibility = '".Database::escape_string($course['visibility'])."', subscribe = '".Database::escape_string($course['subscribe'])."', unsubscribe='".Database::escape_string($course['unsubscribe'])."' WHERE code = '".$current_course_id."'";
Database::query($sql);
header('Location: course_list.php');
exit ();
exit;
}
}

@ -1,4 +1,4 @@
<?php // $Id: index.php 22269 2009-07-21 15:06:15Z juliomontoya $
<?php
/* For licensing terms, see /license.txt */
/**
* Index of the admin tools
@ -9,17 +9,17 @@
$language_file=array('admin','tracking');
// resetting the course id
$cidReset=true;
$cidReset = true;
// including some necessary chamilo files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'security.lib.php';
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions
api_protect_admin_script(true);
$nameTools = get_lang('PlatformAdmin');
// setting breadcrumbs

@ -35,19 +35,20 @@ function create_course($wanted_code, $title, $tutor_name, $category_code, $cours
$keys = define_course_keys($wanted_code, '', $db_prefix);
if (count($keys)) {
$visual_code = $keys['currentCourseCode'];
$code = $keys['currentCourseId'];
$current_course_code = $keys['currentCourseCode'];
$current_course_id = $keys['currentCourseId'];
$current_course_repository = $keys['currentCourseRepository'];
$db_name = $keys['currentCourseDbName'];
$directory = $keys['currentCourseRepository'];
$expiration_date = time() + $first_expiration_delay;
prepare_course_repository($directory, $code);
update_Db_course($db_name);
fill_course_repository($directory, $fill_with_exemplary_content);
fill_Db_course($db_name, $directory, $course_language, $fill_with_exemplary_content);
register_course($code, $visual_code, $directory, $db_name, $tutor_name, $category_code, $title, $course_language, $course_admin_id, $expiration_date);
return $code;
$expiration_date = time() + $first_expiration_delay;
prepare_course_repository($current_course_repository, $current_course_id);
$pictures_array = fill_course_repository($current_course_repository, $fill_with_exemplary_content);
$course_id = register_course($current_course_id, $current_course_code, $current_course_repository, '', $tutor_name, $category, $title, $course_language, $course_admin_id, $expiration_date);
fill_Db_course($course_id, $current_course_repository, $course_language, $pictures_array, $fill_with_exemplary_content);
return $course_id;
}
return false;
@ -2391,10 +2392,10 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
-----------------------------------------------------------
*/
Database::query("INSERT INTO $TABLETOOLAGENDA VALUES ($course_id, NULL, '".lang2db(get_lang('AgendaCreationTitle')) . "', '".lang2db(get_lang('AgendaCreationContenu')) . "', now(), now(), NULL, 0)");
Database::query("INSERT INTO $TABLETOOLAGENDA VALUES ($course_id, NULL, '".lang2db(get_lang('AgendaCreationTitle')) . "', '".lang2db(get_lang('AgendaCreationContenu')) . "', now(), now(), NULL, 0, 0)");
// We need to add the item properties too!
$insert_id = Database :: insert_id();
$sql = "INSERT INTO $TABLEITEMPROPERTY ($course_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_CALENDAR_EVENT . "',1,NOW(),NOW(),$insert_id,'AgendaAdded',1,0,NULL,1)";
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id, '" . TOOL_CALENDAR_EVENT . "',1,NOW(),NOW(),$insert_id,'AgendaAdded',1,0,NULL,1)";
Database::query($sql);
/*
@ -2462,7 +2463,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '4', '1', '".lang2db(get_lang('Contradiction')) . "', '1', '".lang2db(get_lang('NotFalse')) . "', '5', '4','','','','')");
$html=Database::escape_string('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="'.api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">'.get_lang('Antique').'</td></tr></table>');
Database::query('INSERT INTO `'.$TABLEQUIZ . '` (c_id, title, description, type, random, random_answers, active, results_disabled )
Database::query('INSERT INTO '.$TABLEQUIZ . ' (c_id, title, description, type, random, random_answers, active, results_disabled )
VALUES ('.$course_id.', "'.lang2db(get_lang('ExerciceEx')) . '", "'.$html.'", "1", "0", "0", "1", "0")');
Database::query("INSERT INTO $TABLEQUIZQUESTIONLIST (c_id, id, question, description, ponderation, position, type, picture, level)
VALUES ( '.$course_id.', '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)");
@ -2479,11 +2480,11 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_category',1,NOW(),NOW(),$insert_id,'ForumCategoryAdded',1,0,NULL,1)");
Database::query("INSERT INTO `$TABLEFORUMS` (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
Database::query("INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
VALUES ($course_id, '".lang2db(get_lang('ExampleForum'))."', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ('$course_id, " . TOOL_FORUM . "',1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
VALUES ($course_id, '".TOOL_FORUM."', 1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max)
VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', 1, 0, 1, '', 0, 1, NOW(), 0, 10)");
@ -2491,7 +2492,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)");
Database::query("INSERT INTO `$TABLEFORUMPOSTS` VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
Database::query("INSERT INTO $TABLEFORUMPOSTS VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
}

@ -9,7 +9,6 @@
*/
//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.

@ -7,8 +7,7 @@
/**
* Initialisation section
*/
//require_once '../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
/**
* Loads the data and injects it into the Chamilo database, using the Chamilo
* internal functions.

Loading…
Cancel
Save