Browse Source

Fixing command chamilo:install in order to update the user admin and portal settings see BT#5572

Julio Montoya 12 years ago
parent
commit
cbd4f5db0f

+ 2 - 2
composer.json

@@ -57,8 +57,8 @@
         "silex/web-profiler": "~1.0"
     },
     "scripts": {
-        "post-install-cmd": "ChamiloLMS\\Composer\\Script::install",
-        "post-update-cmd": "ChamiloLMS\\Composer\\Script::install"
+        "post-install-cmd": "ChamiloLMS\\Composer\\Script::postInstall",
+        "post-update-cmd": "ChamiloLMS\\Composer\\Script::postUpdate"
     },
     "minimum-stability": "stable"
 }

+ 5 - 6
main/inc/global.inc.php

@@ -336,6 +336,7 @@ if (is_writable($app['cache.path'])) {
 
 //Setting Doctrine service provider (DBAL)
 if (isset($_configuration['main_database'])) {
+
     $app->register(new Silex\Provider\DoctrineServiceProvider(), array(
         'db.options' => array(
             'driver' => 'pdo_mysql',
@@ -467,9 +468,6 @@ require_once $libPath.'array.lib.php';
 require_once $libPath.'events.lib.inc.php';
 require_once $libPath.'online.inc.php';
 
-/*  Database connection (for backward compatibility) */
-global $database_connection;
-
 // Connect to the server database and select the main chamilo database.
 if (!($conn_return = @Database::connect(
     array(
@@ -514,7 +512,8 @@ if (isset($_configuration['main_database'])) {
     // The system has not been designed to use special SQL modes that were introduced since MySQL 5.
     Database::query("set session sql_mode='';");
 
-    $checkConnection = @Database::select_db($_configuration['main_database'], $database_connection);
+    $checkConnection = @Database::select_db($_configuration['main_database'], $conn_return);
+
     if ($checkConnection) {
 
         // Initialization of the database encoding to be used.
@@ -604,12 +603,12 @@ if ($alreadyInstalled) {
 //Adding web profiler
 if (is_writable($app['cache.path'])) {
     //if ($app['debug']) {
-    //if (api_get_setting('allow_web_profiler') == 'true') {
+    if (api_get_setting('allow_web_profiler') == 'true') {
         $app->register($p = new Silex\Provider\WebProfilerServiceProvider(), array(
                 'profiler.cache_dir' => $app['profiler.cache_dir'],
             ));
         $app->mount('/_profiler', $p);
-    //}
+    }
     //}
 }
 

+ 0 - 1
main/inc/lib/database.lib.php

@@ -36,7 +36,6 @@ class Database
     public static function get_main_database()
     {
         global $_configuration;
-
         return isset($_configuration['main_database']) ? $_configuration['main_database'] : null;
     }
 

+ 4 - 4
main/install/1.10.0/db_course.sql

@@ -847,7 +847,7 @@ CREATE TABLE c_group_info (
   iid int(10) unsigned NOT NULL AUTO_INCREMENT,
   PRIMARY KEY (iid),
   KEY session_id (session_id)
-) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -909,7 +909,7 @@ CREATE TABLE c_item_property (
   id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   PRIMARY KEY (id),
   KEY idx_item_property_toolref (tool,ref)
-) ENGINE=MyISAM AUTO_INCREMENT=582 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -1012,7 +1012,7 @@ CREATE TABLE c_lp_category (
   name varchar(255) DEFAULT NULL,
   position int(11) DEFAULT NULL,
   PRIMARY KEY (id)
-) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -1348,7 +1348,7 @@ CREATE TABLE c_quiz_order (
   exercise_id int(11) NOT NULL,
   exercise_order int(11) NOT NULL,
   PRIMARY KEY (id)
-) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=latin1;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --

+ 375 - 0
main/install/1.10.0/db_main.sql

@@ -3086,5 +3086,380 @@ CREATE TABLE branch_transaction (
     PRIMARY KEY (id, transaction_id, branch_id)
 );
 
+-- Stats database
+
+
+
+DROP TABLE IF EXISTS track_c_browsers;
+CREATE TABLE track_c_browsers (
+  id int NOT NULL auto_increment,
+  browser varchar(255) NOT NULL default '',
+  counter int NOT NULL default 0,
+  PRIMARY KEY  (id)
+);
+
+DROP TABLE IF EXISTS track_c_countries;
+CREATE TABLE track_c_countries (
+  id int NOT NULL auto_increment,
+  code varchar(40) NOT NULL default '',
+  country varchar(50) NOT NULL default '',
+  counter int NOT NULL default 0,
+  PRIMARY KEY  (id)
+);
+
+DROP TABLE IF EXISTS track_c_os;
+CREATE TABLE track_c_os (
+  id int NOT NULL auto_increment,
+  os varchar(255) NOT NULL default '',
+  counter int NOT NULL default 0,
+  PRIMARY KEY  (id)
+);
+
+DROP TABLE IF EXISTS track_c_providers;
+CREATE TABLE track_c_providers (
+  id int NOT NULL auto_increment,
+  provider varchar(255) NOT NULL default '',
+  counter int NOT NULL default 0,
+  PRIMARY KEY  (id)
+);
+
+DROP TABLE IF EXISTS track_c_referers;
+CREATE TABLE track_c_referers (
+  id int NOT NULL auto_increment,
+  referer varchar(255) NOT NULL default '',
+  counter int NOT NULL default 0,
+  PRIMARY KEY  (id)
+);
+
+DROP TABLE IF EXISTS track_e_access;
+CREATE TABLE track_e_access (
+  access_id int NOT NULL auto_increment,
+  access_user_id int unsigned default NULL,
+  access_date datetime NOT NULL default '0000-00-00 00:00:00',
+  access_cours_code varchar(40) NOT NULL default '',
+  access_tool varchar(30) default NULL,
+  access_session_id int NOT NULL default 0,
+  PRIMARY KEY  (access_id),
+  KEY access_user_id (access_user_id),
+  KEY access_cours_code (access_cours_code)
+);
+
+DROP TABLE IF EXISTS track_e_lastaccess;
+CREATE TABLE track_e_lastaccess (
+  access_id bigint NOT NULL auto_increment,
+  access_user_id int unsigned default NULL,
+  access_date datetime NOT NULL default '0000-00-00 00:00:00',
+  access_cours_code varchar(40) NOT NULL,
+  access_tool varchar(30) default NULL,
+  access_session_id int unsigned default NULL,
+  PRIMARY KEY  (access_id),
+  KEY access_user_id (access_user_id),
+  KEY access_cours_code (access_cours_code),
+  KEY access_session_id (access_session_id)
+);
+
+DROP TABLE IF EXISTS track_e_default;
+CREATE TABLE track_e_default (
+  default_id int NOT NULL auto_increment,
+  default_user_id int unsigned NOT NULL default 0,
+  default_cours_code varchar(40) NOT NULL default '',
+  default_date datetime NOT NULL default '0000-00-00 00:00:00',
+  default_event_type varchar(20) NOT NULL default '',
+  default_value_type varchar(20) NOT NULL default '',
+  default_value text NOT NULL,
+  c_id int unsigned default NULL,
+  session_id int unsigned default 0,
+  PRIMARY KEY  (default_id)
+);
+
+DROP TABLE IF EXISTS track_e_downloads;
+CREATE TABLE track_e_downloads (
+  down_id int NOT NULL auto_increment,
+  down_user_id int unsigned default NULL,
+  down_date datetime NOT NULL default '0000-00-00 00:00:00',
+  down_cours_id varchar(40) NOT NULL default '',
+  down_doc_path varchar(255) NOT NULL default '',
+  down_session_id INT NOT NULL DEFAULT 0,
+  PRIMARY KEY  (down_id),
+  KEY down_user_id (down_user_id),
+  KEY down_cours_id (down_cours_id)
+);
+
+DROP TABLE IF EXISTS track_e_exercices;
+CREATE TABLE track_e_exercices (
+  exe_id int NOT NULL auto_increment,
+  exe_user_id int unsigned default NULL,
+  exe_date datetime NOT NULL default '0000-00-00 00:00:00',
+  exe_cours_id varchar(40) NOT NULL default '',
+  exe_exo_id int unsigned NOT NULL default 0,
+  exe_result float(6,2) NOT NULL default 0,
+  exe_weighting float(6,2) NOT NULL default 0,
+  PRIMARY KEY  (exe_id),
+  KEY exe_user_id (exe_user_id),
+  KEY exe_cours_id (exe_cours_id)
+);
+
+ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
+ALTER TABLE track_e_exercices ADD data_tracking text NOT NULL default '';
+ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercices ADD session_id INT UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
+ALTER TABLE track_e_exercices ADD orig_lp_id int  NOT NULL default 0;
+ALTER TABLE track_e_exercices ADD orig_lp_item_id int  NOT NULL default 0;
+ALTER TABLE track_e_exercices ADD exe_duration int UNSIGNED NOT NULL default 0;
+ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
+ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
+ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT  NOT NULL DEFAULT '';
+
+DROP TABLE IF EXISTS track_e_attempt;
+CREATE TABLE track_e_attempt (
+    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+    exe_id int default NULL,
+    user_id int NOT NULL default 0,
+    question_id int NOT NULL default 0,
+    answer text NOT NULL,
+    teacher_comment text NOT NULL,
+    marks float(6,2) NOT NULL default 0,
+    course_code varchar(40) NOT NULL default '',
+    position int default 0,
+    tms datetime NOT NULL default '0000-00-00 00:00:00',
+    session_id INT NOT NULL DEFAULT 0,
+    filename VARCHAR(255) DEFAULT NULL
+);
+ALTER TABLE track_e_attempt ADD INDEX (exe_id);
+ALTER TABLE track_e_attempt ADD INDEX (user_id);
+ALTER TABLE track_e_attempt ADD INDEX (question_id);
+ALTER TABLE track_e_attempt ADD INDEX (session_id);
+
+DROP TABLE IF EXISTS track_e_attempt_recording;
+CREATE TABLE track_e_attempt_recording (
+    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+    exe_id int unsigned NOT NULL,
+    question_id int unsigned NOT NULL,
+    marks int NOT NULL,
+    insert_date datetime NOT NULL default '0000-00-00 00:00:00',
+    author int unsigned NOT NULL,
+    teacher_comment text NOT NULL,
+    session_id INT NOT NULL DEFAULT 0
+);
+ALTER TABLE track_e_attempt_recording ADD INDEX (exe_id);
+ALTER TABLE track_e_attempt_recording ADD INDEX (question_id);
+ALTER TABLE track_e_attempt_recording ADD INDEX (session_id);
+
+DROP TABLE IF EXISTS track_e_hotpotatoes;
+CREATE TABLE track_e_hotpotatoes (
+    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+    exe_name VARCHAR( 255 ) NOT NULL ,
+    exe_user_id int unsigned DEFAULT NULL ,
+    exe_date DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL ,
+    exe_cours_id varchar(40) NOT NULL ,
+    exe_result smallint default 0 NOT NULL ,
+    exe_weighting smallint default 0 NOT NULL,
+    KEY exe_user_id (exe_user_id),
+    KEY exe_cours_id (exe_cours_id)
+);
+
+DROP TABLE IF EXISTS track_e_links;
+CREATE TABLE track_e_links (
+  links_id int NOT NULL auto_increment,
+  links_user_id int unsigned default NULL,
+  links_date datetime NOT NULL default '0000-00-00 00:00:00',
+  links_cours_id varchar(40) NOT NULL default '' ,
+  links_link_id int NOT NULL default 0,
+  links_session_id INT NOT NULL DEFAULT 0,
+  PRIMARY KEY  (links_id),
+  KEY links_cours_id (links_cours_id),
+  KEY links_user_id (links_user_id)
+);
+
+DROP TABLE IF EXISTS track_e_login;
+CREATE TABLE track_e_login (
+  login_id int NOT NULL auto_increment,
+  login_user_id int unsigned NOT NULL default 0,
+  login_date datetime NOT NULL default '0000-00-00 00:00:00',
+  login_ip varchar(39) NOT NULL default '',
+  logout_date datetime NULL default NULL,
+  PRIMARY KEY  (login_id),
+  KEY login_user_id (login_user_id)
+);
+
+DROP TABLE IF EXISTS track_e_online;
+CREATE TABLE track_e_online (
+  login_id int NOT NULL auto_increment,
+  login_user_id int unsigned NOT NULL default 0,
+  login_date datetime NOT NULL default '0000-00-00 00:00:00',
+  login_ip varchar(39) NOT NULL default '',
+  course varchar(40) default NULL,
+  session_id INT NOT NULL DEFAULT 0,
+  access_url_id INT NOT NULL DEFAULT 1,
+  PRIMARY KEY  (login_id),
+  KEY login_user_id (login_user_id)
+);
+DROP TABLE IF EXISTS track_e_open;
+CREATE TABLE track_e_open (
+  open_id int NOT NULL auto_increment,
+  open_remote_host tinytext NOT NULL,
+  open_agent tinytext NOT NULL,
+  open_referer tinytext NOT NULL,
+  open_date datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (open_id)
+);
+
+DROP TABLE IF EXISTS track_e_uploads;
+CREATE TABLE track_e_uploads (
+  upload_id int NOT NULL auto_increment,
+  upload_user_id int unsigned default NULL,
+  upload_date datetime NOT NULL default '0000-00-00 00:00:00',
+  upload_cours_id varchar(40) NOT NULL default '',
+  upload_work_id int NOT NULL default 0,
+  upload_session_id INT NOT NULL DEFAULT 0,
+  PRIMARY KEY  (upload_id),
+  KEY upload_user_id (upload_user_id),
+  KEY upload_cours_id (upload_cours_id)
+);
+
+DROP TABLE IF EXISTS track_e_course_access;
+CREATE TABLE track_e_course_access (
+  course_access_id int NOT NULL auto_increment,
+  course_code varchar(40) NOT NULL,
+  user_id int NOT NULL,
+  login_course_date datetime NOT NULL default '0000-00-00 00:00:00',
+  logout_course_date datetime default NULL,
+  counter int NOT NULL,
+  session_id int NOT NULL default 0,
+  c_id int NOT NULL default 0,
+  PRIMARY KEY  (course_access_id)
+);
+
+DROP TABLE IF EXISTS track_e_hotspot;
+CREATE TABLE track_e_hotspot (
+  hotspot_id int NOT NULL auto_increment,
+  hotspot_user_id int NOT NULL,
+  hotspot_course_code varchar(50) NOT NULL,
+  hotspot_exe_id int NOT NULL,
+  hotspot_question_id int NOT NULL,
+  hotspot_answer_id int NOT NULL,
+  hotspot_correct tinyint(3) unsigned NOT NULL,
+  hotspot_coordinate text NOT NULL,
+  PRIMARY KEY  (hotspot_id),
+  KEY hotspot_course_code (hotspot_course_code),
+  KEY hotspot_user_id (hotspot_user_id),
+  KEY hotspot_exe_id (hotspot_exe_id),
+  KEY hotspot_question_id (hotspot_question_id)
+);
+
+DROP TABLE IF EXISTS track_e_item_property;
+
+CREATE TABLE track_e_item_property (
+  id int NOT NULL auto_increment PRIMARY KEY,
+  course_id int NOT NULL,
+  item_property_id int NOT NULL,
+  title varchar(255),
+  content text,
+  progress int NOT NULL default 0,
+  lastedit_date datetime NOT NULL default '0000-00-00 00:00:00',
+  lastedit_user_id int  NOT NULL,
+  session_id int NOT NULL default 0
+);
+
+ALTER TABLE track_e_course_access ADD INDEX (user_id);
+ALTER TABLE track_e_course_access ADD INDEX (login_course_date);
+ALTER TABLE track_e_course_access ADD INDEX (course_code);
+ALTER TABLE track_e_course_access ADD INDEX (session_id);
+ALTER TABLE track_e_access ADD INDEX (access_session_id);
+
+ALTER TABLE track_e_online ADD INDEX (course);
+ALTER TABLE track_e_online ADD INDEX (session_id);
+ALTER TABLE track_e_online ADD INDEX idx_trackonline_uat (login_user_id, access_url_id, login_date);
+
+ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
+ALTER TABLE track_e_downloads ADD INDEX (down_session_id);
+ALTER TABLE track_e_links ADD INDEX (links_session_id);
+ALTER TABLE track_e_uploads ADD INDEX (upload_session_id);
+
+--
+-- Table structure for LP custom storage API
+--
+DROP TABLE IF EXISTS track_stored_values;
+CREATE TABLE IF NOT EXISTS track_stored_values (
+    id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
+	user_id INT NOT NULL,
+	sco_id INT NOT NULL,
+	course_id CHAR(40) NOT NULL,
+	sv_key CHAR(64) NOT NULL,
+	sv_value TEXT NOT NULL
+);
+ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
+ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
+
+DROP TABLE IF EXISTS track_stored_value_stack;
+CREATE TABLE IF NOT EXISTS track_stored_values_stack (
+    id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
+	user_id INT NOT NULL,
+	sco_id INT NOT NULL,
+	stack_order INT NOT NULL,
+	course_id CHAR(40) NOT NULL,
+	sv_key CHAR(64) NOT NULL,
+	sv_value TEXT NOT NULL
+);
+ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
+ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
+
+DROP TABLE IF EXISTS track_e_attempt_coeff;
+CREATE TABLE track_e_attempt_coeff (
+    id int unsigned not null auto_increment primary key,
+    attempt_id INT NOT NULL,
+    marks_coeff float(6,2)
+);
+
+
+-- User database
+
+
+DROP TABLE IF EXISTS personal_agenda;
+CREATE TABLE personal_agenda (
+  id int NOT NULL auto_increment,
+  user int unsigned,
+  title text,
+  `text` text,
+  `date` datetime DEFAULT NULL,
+  enddate datetime DEFAULT NULL,
+  course varchar(255),
+  parent_event_id int NULL,
+  all_day int NOT NULL DEFAULT 0,
+  PRIMARY KEY id (id)
+);
+
+DROP TABLE IF EXISTS personal_agenda_repeat;
+CREATE TABLE personal_agenda_repeat (
+  cal_id INT DEFAULT 0 NOT NULL,
+  cal_type VARCHAR(20),
+  cal_end INT,
+  cal_frequency INT DEFAULT 1,
+  cal_days CHAR(7),
+  PRIMARY KEY (cal_id)
+);
+
+DROP TABLE IF EXISTS personal_agenda_repeat_not;
+CREATE TABLE personal_agenda_repeat_not (
+  cal_id INT NOT NULL,
+  cal_date INT NOT NULL,
+  PRIMARY KEY ( cal_id, cal_date )
+);
+
+DROP TABLE IF EXISTS user_course_category;
+CREATE TABLE user_course_category (
+  id int unsigned NOT NULL auto_increment,
+  user_id int unsigned NOT NULL default 0,
+  title text NOT NULL,
+  sort int,
+  PRIMARY KEY  (id)
+);
+
+ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_user (user);
+ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_parent (parent_event_id);
+ALTER TABLE user_course_category ADD INDEX idx_user_c_cat_uid (user_id);
+
 -- Do not move this
 UPDATE settings_current SET selected_value = '1.10.0.21694' WHERE variable = 'chamilo_database_version';

+ 0 - 332
main/install/1.10.0/db_stats.sql

@@ -1,332 +0,0 @@
--- MySQL dump
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-
-DROP TABLE IF EXISTS track_c_browsers;
-CREATE TABLE track_c_browsers (
-  id int NOT NULL auto_increment,
-  browser varchar(255) NOT NULL default '',
-  counter int NOT NULL default 0,
-  PRIMARY KEY  (id)
-);
-
-DROP TABLE IF EXISTS track_c_countries;
-CREATE TABLE track_c_countries (
-  id int NOT NULL auto_increment,
-  code varchar(40) NOT NULL default '',
-  country varchar(50) NOT NULL default '',
-  counter int NOT NULL default 0,
-  PRIMARY KEY  (id)
-);
-
-DROP TABLE IF EXISTS track_c_os;
-CREATE TABLE track_c_os (
-  id int NOT NULL auto_increment,
-  os varchar(255) NOT NULL default '',
-  counter int NOT NULL default 0,
-  PRIMARY KEY  (id)
-);
-
-DROP TABLE IF EXISTS track_c_providers;
-CREATE TABLE track_c_providers (
-  id int NOT NULL auto_increment,
-  provider varchar(255) NOT NULL default '',
-  counter int NOT NULL default 0,
-  PRIMARY KEY  (id)
-);
-
-DROP TABLE IF EXISTS track_c_referers;
-CREATE TABLE track_c_referers (
-  id int NOT NULL auto_increment,
-  referer varchar(255) NOT NULL default '',
-  counter int NOT NULL default 0,
-  PRIMARY KEY  (id)
-);
-
-DROP TABLE IF EXISTS track_e_access;
-CREATE TABLE track_e_access (
-  access_id int NOT NULL auto_increment,
-  access_user_id int unsigned default NULL,
-  access_date datetime NOT NULL default '0000-00-00 00:00:00',
-  access_cours_code varchar(40) NOT NULL default '',
-  access_tool varchar(30) default NULL,
-  access_session_id int NOT NULL default 0,
-  PRIMARY KEY  (access_id),
-  KEY access_user_id (access_user_id),
-  KEY access_cours_code (access_cours_code)
-);
-
-DROP TABLE IF EXISTS track_e_lastaccess;
-CREATE TABLE track_e_lastaccess (
-  access_id bigint NOT NULL auto_increment,
-  access_user_id int unsigned default NULL,
-  access_date datetime NOT NULL default '0000-00-00 00:00:00',
-  access_cours_code varchar(40) NOT NULL,
-  access_tool varchar(30) default NULL,
-  access_session_id int unsigned default NULL,
-  PRIMARY KEY  (access_id),
-  KEY access_user_id (access_user_id),
-  KEY access_cours_code (access_cours_code),
-  KEY access_session_id (access_session_id)
-);
-
-DROP TABLE IF EXISTS track_e_default;
-CREATE TABLE track_e_default (
-  default_id int NOT NULL auto_increment,
-  default_user_id int unsigned NOT NULL default 0,
-  default_cours_code varchar(40) NOT NULL default '',
-  default_date datetime NOT NULL default '0000-00-00 00:00:00',
-  default_event_type varchar(20) NOT NULL default '',
-  default_value_type varchar(20) NOT NULL default '',
-  default_value text NOT NULL,
-  c_id int unsigned default NULL,
-  session_id int unsigned default 0,
-  PRIMARY KEY  (default_id)
-);
-
-DROP TABLE IF EXISTS track_e_downloads;
-CREATE TABLE track_e_downloads (
-  down_id int NOT NULL auto_increment,
-  down_user_id int unsigned default NULL,
-  down_date datetime NOT NULL default '0000-00-00 00:00:00',
-  down_cours_id varchar(40) NOT NULL default '',
-  down_doc_path varchar(255) NOT NULL default '',
-  down_session_id INT NOT NULL DEFAULT 0,
-  PRIMARY KEY  (down_id),
-  KEY down_user_id (down_user_id),
-  KEY down_cours_id (down_cours_id)
-);
-
-DROP TABLE IF EXISTS track_e_exercices;
-CREATE TABLE track_e_exercices (
-  exe_id int NOT NULL auto_increment,
-  exe_user_id int unsigned default NULL,
-  exe_date datetime NOT NULL default '0000-00-00 00:00:00',
-  exe_cours_id varchar(40) NOT NULL default '',
-  exe_exo_id int unsigned NOT NULL default 0,
-  exe_result float(6,2) NOT NULL default 0,
-  exe_weighting float(6,2) NOT NULL default 0,
-  PRIMARY KEY  (exe_id),
-  KEY exe_user_id (exe_user_id),
-  KEY exe_cours_id (exe_cours_id)
-);
-
-ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
-ALTER TABLE track_e_exercices ADD data_tracking text NOT NULL default '';
-ALTER TABLE track_e_exercices ADD start_date datetime NOT NULL default '0000-00-00 00:00:00';
-ALTER TABLE track_e_exercices ADD steps_counter SMALLINT UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD session_id INT UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD INDEX ( session_id ) ;
-ALTER TABLE track_e_exercices ADD orig_lp_id int  NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD orig_lp_item_id int  NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD exe_duration int UNSIGNED NOT NULL default 0;
-ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
-ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;
-ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT  NOT NULL DEFAULT '';
-
-DROP TABLE IF EXISTS track_e_attempt;
-CREATE TABLE track_e_attempt (
-    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-    exe_id int default NULL,
-    user_id int NOT NULL default 0,
-    question_id int NOT NULL default 0,
-    answer text NOT NULL,
-    teacher_comment text NOT NULL,
-    marks float(6,2) NOT NULL default 0,
-    course_code varchar(40) NOT NULL default '',
-    position int default 0,
-    tms datetime NOT NULL default '0000-00-00 00:00:00',
-    session_id INT NOT NULL DEFAULT 0,
-    filename VARCHAR(255) DEFAULT NULL
-);
-ALTER TABLE track_e_attempt ADD INDEX (exe_id);
-ALTER TABLE track_e_attempt ADD INDEX (user_id);
-ALTER TABLE track_e_attempt ADD INDEX (question_id);
-ALTER TABLE track_e_attempt ADD INDEX (session_id);
-
-DROP TABLE IF EXISTS track_e_attempt_recording;
-CREATE TABLE track_e_attempt_recording (
-    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-    exe_id int unsigned NOT NULL,
-    question_id int unsigned NOT NULL,
-    marks int NOT NULL,
-    insert_date datetime NOT NULL default '0000-00-00 00:00:00',
-    author int unsigned NOT NULL,
-    teacher_comment text NOT NULL,
-    session_id INT NOT NULL DEFAULT 0
-);
-ALTER TABLE track_e_attempt_recording ADD INDEX (exe_id);
-ALTER TABLE track_e_attempt_recording ADD INDEX (question_id);
-ALTER TABLE track_e_attempt_recording ADD INDEX (session_id);
-
-DROP TABLE IF EXISTS track_e_hotpotatoes;
-CREATE TABLE track_e_hotpotatoes (
-    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-    exe_name VARCHAR( 255 ) NOT NULL ,
-    exe_user_id int unsigned DEFAULT NULL ,
-    exe_date DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL ,
-    exe_cours_id varchar(40) NOT NULL ,
-    exe_result smallint default 0 NOT NULL ,
-    exe_weighting smallint default 0 NOT NULL,
-    KEY exe_user_id (exe_user_id),
-    KEY exe_cours_id (exe_cours_id)
-);
-
-DROP TABLE IF EXISTS track_e_links;
-CREATE TABLE track_e_links (
-  links_id int NOT NULL auto_increment,
-  links_user_id int unsigned default NULL,
-  links_date datetime NOT NULL default '0000-00-00 00:00:00',
-  links_cours_id varchar(40) NOT NULL default '' ,
-  links_link_id int NOT NULL default 0,
-  links_session_id INT NOT NULL DEFAULT 0,
-  PRIMARY KEY  (links_id),
-  KEY links_cours_id (links_cours_id),
-  KEY links_user_id (links_user_id)
-);
-
-DROP TABLE IF EXISTS track_e_login;
-CREATE TABLE track_e_login (
-  login_id int NOT NULL auto_increment,
-  login_user_id int unsigned NOT NULL default 0,
-  login_date datetime NOT NULL default '0000-00-00 00:00:00',
-  login_ip varchar(39) NOT NULL default '',
-  logout_date datetime NULL default NULL,
-  PRIMARY KEY  (login_id),
-  KEY login_user_id (login_user_id)
-);
-
-DROP TABLE IF EXISTS track_e_online;
-CREATE TABLE track_e_online (
-  login_id int NOT NULL auto_increment,
-  login_user_id int unsigned NOT NULL default 0,
-  login_date datetime NOT NULL default '0000-00-00 00:00:00',
-  login_ip varchar(39) NOT NULL default '',
-  course varchar(40) default NULL,
-  session_id INT NOT NULL DEFAULT 0,
-  access_url_id INT NOT NULL DEFAULT 1,
-  PRIMARY KEY  (login_id),
-  KEY login_user_id (login_user_id)
-);
-DROP TABLE IF EXISTS track_e_open;
-CREATE TABLE track_e_open (
-  open_id int NOT NULL auto_increment,
-  open_remote_host tinytext NOT NULL,
-  open_agent tinytext NOT NULL,
-  open_referer tinytext NOT NULL,
-  open_date datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY  (open_id)
-);
-
-DROP TABLE IF EXISTS track_e_uploads;
-CREATE TABLE track_e_uploads (
-  upload_id int NOT NULL auto_increment,
-  upload_user_id int unsigned default NULL,
-  upload_date datetime NOT NULL default '0000-00-00 00:00:00',
-  upload_cours_id varchar(40) NOT NULL default '',
-  upload_work_id int NOT NULL default 0,
-  upload_session_id INT NOT NULL DEFAULT 0,
-  PRIMARY KEY  (upload_id),
-  KEY upload_user_id (upload_user_id),
-  KEY upload_cours_id (upload_cours_id)
-);
-
-DROP TABLE IF EXISTS track_e_course_access;
-CREATE TABLE track_e_course_access (
-  course_access_id int NOT NULL auto_increment,
-  course_code varchar(40) NOT NULL,
-  user_id int NOT NULL,
-  login_course_date datetime NOT NULL default '0000-00-00 00:00:00',
-  logout_course_date datetime default NULL,
-  counter int NOT NULL,
-  session_id int NOT NULL default 0,
-  c_id int NOT NULL default 0,
-  PRIMARY KEY  (course_access_id)
-);
-
-DROP TABLE IF EXISTS track_e_hotspot;
-CREATE TABLE track_e_hotspot (
-  hotspot_id int NOT NULL auto_increment,
-  hotspot_user_id int NOT NULL,
-  hotspot_course_code varchar(50) NOT NULL,
-  hotspot_exe_id int NOT NULL,
-  hotspot_question_id int NOT NULL,
-  hotspot_answer_id int NOT NULL,
-  hotspot_correct tinyint(3) unsigned NOT NULL,
-  hotspot_coordinate text NOT NULL,
-  PRIMARY KEY  (hotspot_id),
-  KEY hotspot_course_code (hotspot_course_code),
-  KEY hotspot_user_id (hotspot_user_id),
-  KEY hotspot_exe_id (hotspot_exe_id),
-  KEY hotspot_question_id (hotspot_question_id)
-);
-
-DROP TABLE IF EXISTS track_e_item_property;
-
-CREATE TABLE track_e_item_property (
-  id int NOT NULL auto_increment PRIMARY KEY,
-  course_id int NOT NULL,
-  item_property_id int NOT NULL,
-  title varchar(255),
-  content text,
-  progress int NOT NULL default 0,
-  lastedit_date datetime NOT NULL default '0000-00-00 00:00:00',
-  lastedit_user_id int  NOT NULL,
-  session_id int NOT NULL default 0
-);
-
-ALTER TABLE track_e_course_access ADD INDEX (user_id);
-ALTER TABLE track_e_course_access ADD INDEX (login_course_date);
-ALTER TABLE track_e_course_access ADD INDEX (course_code);
-ALTER TABLE track_e_course_access ADD INDEX (session_id);
-ALTER TABLE track_e_access ADD INDEX (access_session_id);
-
-ALTER TABLE track_e_online ADD INDEX (course);
-ALTER TABLE track_e_online ADD INDEX (session_id);
-ALTER TABLE track_e_online ADD INDEX idx_trackonline_uat (login_user_id, access_url_id, login_date);
-
-ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
-ALTER TABLE track_e_downloads ADD INDEX (down_session_id);
-ALTER TABLE track_e_links ADD INDEX (links_session_id);
-ALTER TABLE track_e_uploads ADD INDEX (upload_session_id);
-
---
--- Table structure for LP custom storage API
---
-DROP TABLE IF EXISTS track_stored_values;
-CREATE TABLE IF NOT EXISTS track_stored_values (
-    id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
-	user_id INT NOT NULL,
-	sco_id INT NOT NULL,
-	course_id CHAR(40) NOT NULL,
-	sv_key CHAR(64) NOT NULL,
-	sv_value TEXT NOT NULL
-);
-ALTER TABLE track_stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
-ALTER TABLE track_stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
-
-DROP TABLE IF EXISTS track_stored_value_stack;
-CREATE TABLE IF NOT EXISTS track_stored_values_stack (
-    id int unsigned not null AUTO_INCREMENT PRIMARY KEY,
-	user_id INT NOT NULL,
-	sco_id INT NOT NULL,
-	stack_order INT NOT NULL,
-	course_id CHAR(40) NOT NULL,
-	sv_key CHAR(64) NOT NULL,
-	sv_value TEXT NOT NULL
-);
-ALTER TABLE track_stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
-ALTER TABLE track_stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
-
-DROP TABLE IF EXISTS track_e_attempt_coeff;
-CREATE TABLE track_e_attempt_coeff (
-    id int unsigned not null auto_increment primary key,
-    attempt_id INT NOT NULL,
-    marks_coeff float(6,2)
-);

+ 0 - 53
main/install/1.10.0/db_user.sql

@@ -1,53 +0,0 @@
--- MySQL dump
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-
-DROP TABLE IF EXISTS personal_agenda;
-CREATE TABLE personal_agenda (
-  id int NOT NULL auto_increment,
-  user int unsigned,
-  title text,
-  `text` text,
-  `date` datetime DEFAULT NULL,
-  enddate datetime DEFAULT NULL,
-  course varchar(255),
-  parent_event_id int NULL,
-  all_day int NOT NULL DEFAULT 0,
-  PRIMARY KEY id (id)
-);
-
-DROP TABLE IF EXISTS personal_agenda_repeat;
-CREATE TABLE personal_agenda_repeat (
-  cal_id INT DEFAULT 0 NOT NULL,
-  cal_type VARCHAR(20),
-  cal_end INT,
-  cal_frequency INT DEFAULT 1,
-  cal_days CHAR(7),
-  PRIMARY KEY (cal_id)
-);
-
-DROP TABLE IF EXISTS personal_agenda_repeat_not;
-CREATE TABLE personal_agenda_repeat_not (
-  cal_id INT NOT NULL,
-  cal_date INT NOT NULL,
-  PRIMARY KEY ( cal_id, cal_date )
-);
-
-DROP TABLE IF EXISTS user_course_category;
-CREATE TABLE user_course_category (
-  id int unsigned NOT NULL auto_increment,
-  user_id int unsigned NOT NULL default 0,
-  title text NOT NULL,
-  sort int, 
-  PRIMARY KEY  (id)
-);
-
-ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_user (user);
-ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_parent (parent_event_id);
-ALTER TABLE user_course_category ADD INDEX idx_user_c_cat_uid (user_id);

+ 1 - 1
main/install/configuration.dist.yml.php

@@ -33,7 +33,7 @@ $_configuration['db_host']     = 'localhost';
 // Your MySQL username
 $_configuration['db_user']     = 'root';
 // Your MySQL password
-$_configuration['db_password'] = 'dokeosla';
+$_configuration['db_password'] = 'root';
 
 /**
  * Database settings

+ 53 - 39
src/ChamiloLMS/Command/Database/InstallCommand.php

@@ -80,9 +80,8 @@ class InstallCommand extends CommonCommand
                         array(
                             'name' => 'chamilo',
                             'sql' => array(
-                                'db_main.sql',
-                                'db_stats.sql',
-                                'db_user.sql'
+                                'db_course.sql',
+                                'db_main.sql'
                             ),
                         ),
                     ),
@@ -94,9 +93,8 @@ class InstallCommand extends CommonCommand
                         array(
                             'name' => 'chamilo',
                             'sql' => array(
-                                'db_main.sql',
-                                'db_stats.sql',
-                                'db_user.sql'
+                                'db_course.sql',
+                                'db_main.sql'
                             ),
                         ),
                     ),
@@ -234,25 +232,38 @@ class InstallCommand extends CommonCommand
             $result = $this->install($version, $newConfigurationArray, $output);
 
             if ($result) {
+                $this->setDatabaseSettings($newConfigurationArray, $newConfigurationArray['main_database']);
+
+                global $_configuration;
+                $_configuration = $newConfigurationArray;
+
                 $this->createAdminUser($newConfigurationArray, $output);
 
+                //@todo ask this during installation
+
+                $adminInfo = $this->getDefaultAdminUser();
+
+                api_set_setting('Institution', 'Portal');
+                api_set_setting('InstitutionUrl', 'Portal');
+                api_set_setting('siteName', 'Campus');
+                api_set_setting('emailAdministrator', $adminInfo['email']);
+                api_set_setting('administratorSurname', $adminInfo['lastname']);
+                api_set_setting('administratorName', $adminInfo['firstname']);
+                api_set_setting('platformLanguage', $adminInfo['language']);
+                api_set_setting('allow_registration', '1');
+                api_set_setting('allow_registration_as_teacher', '1');
+
                 $output->writeln("<comment>Chamilo was successfully installed. Go to your browser and enter:</comment> <info>".$newConfigurationArray['root_web']);
             }
         }
     }
 
     /**
-     *
-     * @param $newConfigurationArray
-     * @param $output
-     *
-     * @return bool
+     * Default admin info
+     * @return array
      */
-    public function createAdminUser($newConfigurationArray, $output)
+    public function getDefaultAdminUser()
     {
-        $dialog = $this->getHelperSet()->get('dialog');
-
-        //Creating admin user
         $adminUser = array(
             'lastname' => 'Julio',
             'firstname' => 'M',
@@ -262,6 +273,22 @@ class InstallCommand extends CommonCommand
             'language' => 'english',
             'phone' => '6666666'
         );
+        return $adminUser;
+    }
+
+    /**
+     *
+     * @param $newConfigurationArray
+     * @param $output
+     *
+     * @return bool
+     */
+    public function createAdminUser($newConfigurationArray, $output)
+    {
+        $dialog = $this->getHelperSet()->get('dialog');
+
+        //Creating admin user
+        $adminUser = $this->getDefaultAdminUser();
 
         $output->writeln("<comment>Creating an admin User</comment>");
         $userInfo = array();
@@ -273,6 +300,7 @@ class InstallCommand extends CommonCommand
             );
             $userInfo[$key] = $data;
         }
+
         //By default admin is = 1 so we update it
         $userId = $userInfo['user_id'] = 1;
         $userInfo['auth_source'] = 'platform';
@@ -318,16 +346,15 @@ class InstallCommand extends CommonCommand
         return file_exists($newConfigurationFile);
     }
 
-    private function setDatabaseSettings($_configuration, $databaseName)
+    private function setDatabaseSettings($configuration, $databaseName)
     {
         global $config;
-
         $defaultConnection = array(
             'driver'    => 'pdo_mysql',
             'dbname'    => $databaseName,
-            'user'      => $_configuration['db_user'],
-            'password'  => $_configuration['db_password'],
-            'host'      => $_configuration['db_host'],
+            'user'      => $configuration['db_user'],
+            'password'  => $configuration['db_password'],
+            'host'      => $configuration['db_host'],
         );
 
         $em = \Doctrine\ORM\EntityManager::create($defaultConnection, $config);
@@ -346,14 +373,12 @@ class InstallCommand extends CommonCommand
             $this->getApplication()->getHelperSet()->set($helper, $name);
         }
 
-        $conn_return = @\Database::connect(array(
-            'server' => $_configuration['db_host'],
-            'username' => $_configuration['db_user'],
-            'password' => $_configuration['db_password']
+        $conn_return = \Database::connect(array(
+            'server' => $configuration['db_host'],
+            'username' => $configuration['db_user'],
+            'password' => $configuration['db_password']
         ));
-
-        global $database_connection;
-        $checkConnection = @\Database::select_db($databaseName, $database_connection);
+        $checkConnection = \Database::select_db($databaseName, $conn_return);
     }
 
     /**
@@ -412,18 +437,6 @@ class InstallCommand extends CommonCommand
                         $input = new ArrayInput($arguments);
                         $command->run($input, $output);
 
-                        if ($databaseName == 'chamilo') {
-                            api_set_setting('Institution', 'Portal');
-                            api_set_setting('InstitutionUrl', 'Portal');
-                            api_set_setting('siteName', 'Campus');
-                            api_set_setting('emailAdministrator', 'admin@example.org');
-                            api_set_setting('administratorSurname', 'M');
-                            api_set_setting('administratorName', 'Julio');
-                            api_set_setting('platformLanguage', 'english');
-                            api_set_setting('allow_registration', '1');
-                            api_set_setting('allow_registration_as_teacher', '1');
-                        }
-
                         //Getting extra information about the installation
                         //$value = api_get_setting('chamilo_database_version');
                         //$output->writeln("<comment>Showing chamilo_database_version value:</comment> ".$value);
@@ -441,6 +454,7 @@ class InstallCommand extends CommonCommand
                     $this->createCourse($databaseName);
                 }
             }
+
             $output->writeln("<comment>Check your installation status with </comment><info>chamilo:status</info>");
 
             return true;

+ 6 - 1
src/ChamiloLMS/Composer/Script.php

@@ -4,7 +4,7 @@ namespace ChamiloLMS\Composer;
 
 class Script
 {
-    public static function install()
+    public static function postInstall()
     {
         /*chmod('resources/cache', 0777);
         chmod('resources/log', 0777);
@@ -13,4 +13,9 @@ class Script
         exec('php console assetic:dump');*/
         //echo 'Execting ChamiloLMS\Composer\Script::install';
     }
+
+    public static function postUpdate()
+    {
+
+    }
 }

+ 2 - 3
tests/main/inc/lib/database.lib.test.php

@@ -129,9 +129,8 @@ class TestDatabase extends UnitTestCase {
 	}
 
 	function testGetCourseChatConnectedTable() {
-		$database_name='dokeosla';
-		$res=$this->dbase->get_course_chat_connected_table($database_name);
-		$this->assertTrue(is_string($res));
+		//$res=$this->dbase->get_course_chat_connected_table($database_name);
+		//$this->assertTrue(is_string($res));
 	}
 
 	function testGetCourseInfo() {