Parcourir la source

Add sequence lib and database structure changes see #7615

Julio Montoya il y a 10 ans
Parent
commit
d949647a56

+ 242 - 50
main/inc/lib/SequenceManager.php

@@ -9,7 +9,8 @@ class SequenceManager
      * @param $row_entity_id
      * @return array|bool
      */
-    public static function get_pre_req_id_by_row_entity_id($row_entity_id) {
+    public static function get_pre_req_id_by_row_entity_id($row_entity_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -28,7 +29,8 @@ class SequenceManager
         return false;
     }
 
-    public static function get_next_by_row_id($entity_id, $row_entity_id, $course_id = null) {
+    public static function get_next_by_row_id($entity_id, $row_entity_id, $course_id = null)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -43,9 +45,15 @@ class SequenceManager
 
             $seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
             $row_table = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
-            $sql = "SELECT row.id FROM $row_table row WHERE row.sequence_type_entity_id = $entity_id AND row.row_id = $row_entity_id AND row.c_id = $course_id LIMIT 0, 1";
-            $sql = "SELECT main.sequence_row_entity_id_next FROM $seq_table main WHERE main.sequence_row_entity_id_next IN ($sql)";
-            $sql = "SELECT * FROM $row_table res WHERE res.id IN ($sql)";
+            $sql = "SELECT row.id FROM $row_table row
+                    WHERE
+                        row.sequence_type_entity_id = $entity_id AND
+                         row.row_id = $row_entity_id AND
+                         row.c_id = $course_id LIMIT 0, 1";
+            $sql = "SELECT main.sequence_row_entity_id_next
+                    FROM $seq_table main WHERE main.sequence_row_entity_id_next IN ($sql)";
+            $sql = "SELECT * FROM $row_table res
+                    WHERE res.id IN ($sql)";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while ($temp_next = Database::fetch_array($result, 'ASSOC')){
@@ -57,10 +65,12 @@ class SequenceManager
         return false;
     }
 
-    /*
-     *
+    /**
+     * @param $entity_id
+     * @return array|bool
      */
-    public static function get_entity_by_id($entity_id) {
+    public static function get_entity_by_id($entity_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -80,8 +90,15 @@ class SequenceManager
         return false;
     }
 
-
-    public static function validate_rule_by_row_id($row_entity_id, $user_id = null, $session_id, $rule_id = 1) {
+    /**
+     * @param $row_entity_id
+     * @param null $user_id
+     * @param $session_id
+     * @param int $rule_id
+     * @return bool
+     */
+    public static function validate_rule_by_row_id($row_entity_id, $user_id = null, $session_id, $rule_id = 1)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -108,7 +125,12 @@ class SequenceManager
         return false;
     }
 
-    public static function get_condition_by_rule_id($rule_id = 1) {
+    /**
+     * @param int $rule_id
+     * @return array|bool
+     */
+    public static function get_condition_by_rule_id($rule_id = 1)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -130,7 +152,12 @@ class SequenceManager
         return false;
     }
 
-    public static function get_method_by_rule_id($rule_id =1 ) {
+    /**
+     * @param int $rule_id
+     * @return array|bool
+     */
+    public static function get_method_by_rule_id($rule_id = 1)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -152,7 +179,12 @@ class SequenceManager
         return false;
     }
 
-    public static function get_value_by_row_entity_id($row_entity_id) {
+    /**
+     * @param int $row_entity_id
+     * @return array|bool
+     */
+    public static function get_value_by_row_entity_id($row_entity_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -171,7 +203,12 @@ class SequenceManager
         return false;
     }
 
-    public static function get_variable_by_condition_id($condition_id) {
+    /**
+     * @param int $condition_id
+     * @return array|bool
+     */
+    public static function get_variable_by_condition_id($condition_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -180,7 +217,9 @@ class SequenceManager
             $condition_id = intval($condition_id);
             $var_table = Database::get_main_table(TABLE_SEQUENCE_VARIABLE);
             $vld_table = Database::get_main_table(TABLE_SEQUENCE_VALID);
-            $sql = "SELECT DISTINCT vld.sequence_variable_id FROM $vld_table vld WHERE vld.sequence_condition_id = $condition_id";
+            $sql = "SELECT DISTINCT vld.sequence_variable_id
+                    FROM $vld_table vld
+                    WHERE vld.sequence_condition_id = $condition_id";
             $sql = "SELECT * FROM $var_table var WHERE var.id IN ($sql)";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
@@ -193,7 +232,27 @@ class SequenceManager
         return false;
     }
 
-    public static function execute_formulas_by_user_id($row_entity_id = null ,$user_id = null, $session_id, $met_type = '', $available = 1, $complete_items = 1, $total_items = 1, $available_end_date =null) {
+    /**
+     * @param null $row_entity_id
+     * @param null $user_id
+     * @param $session_id
+     * @param string $met_type
+     * @param int $available
+     * @param int $complete_items
+     * @param int $total_items
+     * @param null $available_end_date
+     * @return bool
+     */
+    public static function execute_formulas_by_user_id(
+        $row_entity_id = null,
+        $user_id = null,
+        $session_id,
+        $met_type = '',
+        $available = 1,
+        $complete_items = 1,
+        $total_items = 1,
+        $available_end_date = null
+    ) {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -216,8 +275,11 @@ class SequenceManager
                 $variable[$temp_var['0']] = $temp_var['1'];
             }
             $sql = "SELECT rul.id FROM $rul_table rul";
-            $sql = "SELECT met.formula, met.assign assign FROM $met_table met, $rul_met_table rm WHERE
-            met.id = rm.sequence_method_id $met_filter ORDER BY rm.method_order";
+            $sql = "SELECT met.formula, met.assign assign
+                    FROM $met_table met, $rul_met_table rm
+                    WHERE
+                        met.id = rm.sequence_method_id $met_filter
+                    ORDER BY rm.method_order";
             $result = Database::query($sql);
             while ($temp_fml = Database::fetch_array($result, 'ASSOC')) {
                 $formula[] = $temp_fml;
@@ -254,7 +316,21 @@ class SequenceManager
         return false;
     }
 
-    public static function get_value_by_user_id($row_entity_id = null, $user_id = null, $session_id = null, $available = -1, $success = -1) {
+    /**
+     * @param null $row_entity_id
+     * @param null $user_id
+     * @param null $session_id
+     * @param int $available
+     * @param int $success
+     * @return array|bool
+     */
+    public static function get_value_by_user_id(
+        $row_entity_id = null,
+        $user_id = null,
+        $session_id = null,
+        $available = -1,
+        $success = -1
+    ) {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -289,7 +365,8 @@ class SequenceManager
                 $session_filter = " AND session_id = $session_id ";
             }
             $val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
-            $sql = "SELECT * FROM $val_table WHERE user_id = $user_id $available_filter $success_filter $row_entity_filter $session_filter";
+            $sql = "SELECT * FROM $val_table
+                    WHERE user_id = $user_id $available_filter $success_filter $row_entity_filter $session_filter";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 while($temp_value = Database::fetch_array($result,'ASSOC')){
@@ -301,7 +378,12 @@ class SequenceManager
         return false;
     }
 
-    public static function find_variables_in_formula($formula) {
+    /**
+     * @param $formula
+     * @return array|bool
+     */
+    public static function find_variables_in_formula($formula)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -318,6 +400,10 @@ class SequenceManager
         return false;
     }
 
+    /**
+     * @param int $row_entity_id
+     * @return array|bool
+     */
     public static function get_user_id_by_row_entity_id($row_entity_id = 0)
     {
         if (self::_debug) {
@@ -341,7 +427,19 @@ class SequenceManager
         return false;
     }
 
-    public static function action_pre_init($row_entity_id, $user_id, $session_id, $available_end_date = null) {
+    /**
+     * @param $row_entity_id
+     * @param $user_id
+     * @param $session_id
+     * @param null $available_end_date
+     * @return bool
+     */
+    public static function action_pre_init(
+        $row_entity_id,
+        $user_id,
+        $session_id,
+        $available_end_date = null
+    ) {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -373,7 +471,14 @@ class SequenceManager
         return false;
     }
 
-    public static function action_post_success_by_user_id($row_entity_id, $user_id, $session_id, $available_end_date = null) {
+    /**
+     * @param $row_entity_id
+     * @param $user_id
+     * @param $session_id
+     * @param null $available_end_date
+     */
+    public static function action_post_success_by_user_id($row_entity_id, $user_id, $session_id, $available_end_date = null)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -383,7 +488,9 @@ class SequenceManager
             //$check_array = []; Update later
             foreach ($value as $val) {
                 $row_entity_id_prev = $val['sequence_row_entity_id'];
-                $sql = "SELECT seq.sequence_row_entity_id_next FROM $seq_table seq WHERE seq.sequence_row_entity_id = $row_entity_id_prev";
+                $sql = "SELECT seq.sequence_row_entity_id_next
+                        FROM $seq_table seq
+                        WHERE seq.sequence_row_entity_id = $row_entity_id_prev";
                 $result = Database::query($sql);
                 while ($temp_next = Database::fetch_array($result, 'ASSOC')) {
                     $next[] = $temp_next['sequence_row_entity_id_next'];
@@ -414,7 +521,9 @@ class SequenceManager
         if ($row_id > 0 && $entity_id > 0 && $c_id > 0) {
             $table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
             $tableRow = Database::get_main_table(TABLE_SEQUENCE_ROW_ENTITY);
-            $sql = "SELECT DISTINCT r.* FROM $table s INNER JOIN $tableRow r ON (r.id = s.sequence_row_entity_id)
+            $sql = "SELECT DISTINCT r.* FROM $table s
+                    INNER JOIN $tableRow r
+                    ON (r.id = s.sequence_row_entity_id)
                     WHERE sequence_row_entity_id_next = $row_entity_id_prev";
 
             $result = Database::query($sql);
@@ -463,7 +572,7 @@ class SequenceManager
      * @param $session_id
      * @return mixed
      */
-    public static function getValIdByRowEntityId ($row_entity_id, $user_id, $session_id)
+    public static function getValIdByRowEntityId($row_entity_id, $user_id, $session_id)
     {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
@@ -478,10 +587,11 @@ class SequenceManager
 
             //check if exists value row
             $sql = "SELECT val.id FROM $val_table val
-                WHERE val.sequence_row_entity_id = $row_entity_id
-                AND val.user_id = $user_id
-                AND val.session_id = $session_id
-                LIMIT 0, 1";
+                    WHERE
+                        val.sequence_row_entity_id = $row_entity_id
+                        AND val.user_id = $user_id
+                        AND val.session_id = $session_id
+                    LIMIT 0, 1";
 
             $result = Database::query($sql);
 
@@ -490,7 +600,7 @@ class SequenceManager
                 return $temp_row_entity['id'];
             } else {
                 $sql = "SELECT sequence_row_entity_id FROM $seq_table
-                    WHERE sequence_row_entity_id_next = $row_entity_id";
+                        WHERE sequence_row_entity_id_next = $row_entity_id";
                 $result = Database::query($sql);
                 $available = 0;
                 if (Database::num_rows($result)) {
@@ -511,8 +621,15 @@ class SequenceManager
         return 0;
     }
 
-
-    public static function get_row_entity_id_by_row_id($entity_id, $row_id, $c_id, $name = '') {
+    /**
+     * @param $entity_id
+     * @param $row_id
+     * @param $c_id
+     * @param string $name
+     * @return int
+     */
+    public static function get_row_entity_id_by_row_id($entity_id, $row_id, $c_id, $name = '')
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
             error_log('......................................');
@@ -544,17 +661,17 @@ class SequenceManager
                 return $row_entity[0]['id'];
             } elseif ($entity_id == 1) {
                 $sql = "SELECT name, prerequisite FROM $clp_table
-                    WHERE c_id = $c_id
-                    AND id = $row_id
-                    LIMIT 0, 1";
+                        WHERE c_id = $c_id
+                        AND id = $row_id
+                        LIMIT 0, 1";
                 $result = Database::query($sql);
                 if (Database::num_rows($result) > 0) {
                     $temp_arr = Database::fetch_array($result, 'ASSOC');
                     $name = $temp_arr['name'];
                     $name = Database::escape_string($name);
                     $pre = ($temp_arr['prerequisite'] > 0)? self::get_row_entity_id_by_row_id($entity_id, $temp_arr['prerequisite'], $c_id) : 0 ;
-                    $sql = "INSERT INTO $row_table (sequence_type_entity_id, c_id, row_id, name) VALUES
-                        ($entity_id, $c_id, $row_id, '$name')";
+                    $sql = "INSERT INTO $row_table (sequence_type_entity_id, c_id, row_id, name)
+                            VALUES ($entity_id, $c_id, $row_id, '$name')";
                     Database::query($sql);
                     $id = Database::insert_id();
                     if ($id != 0) {
@@ -604,7 +721,19 @@ class SequenceManager
         return 0;
     }
 
-    public static function temp_hack_4_update($entity_id, $row_id, $c_id, $session_id, $user_id, $rule_id, $items_completed = 1, $total_items = 1, $available_end_date =null ){
+    /**
+     * @param $entity_id
+     * @param $row_id
+     * @param $c_id
+     * @param $session_id
+     * @param $user_id
+     * @param $rule_id
+     * @param int $items_completed
+     * @param int $total_items
+     * @param null $available_end_date
+     */
+    public static function temp_hack_4_update($entity_id, $row_id, $c_id, $session_id, $user_id, $rule_id, $items_completed = 1, $total_items = 1, $available_end_date =null )
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -617,13 +746,20 @@ class SequenceManager
         }
     }
 
-    public static function get_table_by_entity_name($entity_name){
+    /**
+     * @param $entity_name
+     * @return bool
+     */
+    public static function get_table_by_entity_name($entity_name)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
         $entity_name = Database::escape_string($entity_name);
         $ety_table = Database::get_main_table(TABLE_SEQUENCE_TYPE_ENTITY);
-        $sql = "SELECT ety.ent_table FROM $ety_table ety WHERE ety.name = $entity_name LIMIT 0, 1";
+        $sql = "SELECT ety.ent_table
+                FROM $ety_table ety
+                WHERE ety.name = $entity_name LIMIT 0, 1";
         $result = Database::query($sql);
         if (Database::num_rows($result) > 0) {
             while ($temp_entity = Database::fetch_array($result, 'ASSOC')) {
@@ -631,10 +767,16 @@ class SequenceManager
             }
             return $entity[0]['ent_table'];
         }
+
         return false;
     }
 
-    public static function get_entity_by_entity_name($entity_name){
+    /**
+     * @param $entity_name
+     * @return array|bool
+     */
+    public static function get_entity_by_entity_name($entity_name)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -651,7 +793,15 @@ class SequenceManager
         return false;
     }
 
-    public static function temp_hack_2_insert($entity_id, $row_id, $c_id, $name = '') {
+    /**
+     * @param $entity_id
+     * @param $row_id
+     * @param $c_id
+     * @param string $name
+     * @return bool|string
+     */
+    public static function temp_hack_2_insert($entity_id, $row_id, $c_id, $name = '')
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -671,7 +821,18 @@ class SequenceManager
         }
         return false;
     }
-    public static function temp_hack_3_insert($entity_id_prev, $entity_id_next, $row_id_prev = 0, $row_id_next = 0, $c_id = 1, $is_part = 0) {
+
+    /**
+     * @param $entity_id_prev
+     * @param $entity_id_next
+     * @param int $row_id_prev
+     * @param int $row_id_next
+     * @param int $c_id
+     * @param int $is_part
+     * @return bool|string
+     */
+    public static function temp_hack_3_insert($entity_id_prev, $entity_id_next, $row_id_prev = 0, $row_id_next = 0, $c_id = 1, $is_part = 0)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -690,7 +851,16 @@ class SequenceManager
         return false;
     }
 
-    public static function temp_hack_4_insert($total_items, $row_entity_id, $user_id = 0, $available = -1, $session_id) {
+    /**
+     * @param $total_items
+     * @param $row_entity_id
+     * @param int $user_id
+     * @param int $available
+     * @param $session_id
+     * @return string
+     */
+    public static function temp_hack_4_insert($total_items, $row_entity_id, $user_id = 0, $available = -1, $session_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -711,9 +881,10 @@ class SequenceManager
 
         if (self::get_value_by_user_id($row_entity_id, $user_id, $session_id) === false) {
             $val_table = Database::get_main_table(TABLE_SEQUENCE_VALUE);
-            $sql = "INSERT INTO $val_table (user_id, sequence_row_entity_id, total_items, available, session_id) VALUES
-            ($user_id, $row_entity_id, $total_items, $available, $session_id)";
+            $sql = "INSERT INTO $val_table (user_id, sequence_row_entity_id, total_items, available, session_id)
+                    VALUES ($user_id, $row_entity_id, $total_items, $available, $session_id)";
             Database::query($sql);
+
             return Database::insert_id();
         }
     }
@@ -735,7 +906,22 @@ class SequenceManager
         Database::query($sql);
     }
 
-    public static function temp_hack_3_update($entity_id_prev, $entity_id_next, $row_id_prev = 0, $row_id_next = 0, $c_id = 0, $user_id = 0) {
+    /**
+     * @param $entity_id_prev
+     * @param $entity_id_next
+     * @param int $row_id_prev
+     * @param int $row_id_next
+     * @param int $c_id
+     * @param int $user_id
+     */
+    public static function temp_hack_3_update(
+        $entity_id_prev,
+        $entity_id_next,
+        $row_id_prev = 0,
+        $row_id_next = 0,
+        $c_id = 0,
+        $user_id = 0
+    ) {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -930,7 +1116,12 @@ class SequenceManager
         Database::query($sql);
     }
 
-    public static function get_row_entity_id_by_user_id($user_id) {
+    /**
+     * @param $user_id
+     * @return array|bool
+     */
+    public static function get_row_entity_id_by_user_id($user_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }
@@ -955,7 +1146,8 @@ class SequenceManager
     /**
      * Bool Available for LP
      */
-    public static function get_state_lp_by_row_entity_id ($row_entity_id, $user_id, $session_id) {
+    public static function get_state_lp_by_row_entity_id($row_entity_id, $user_id, $session_id)
+    {
         if (self::_debug) {
             error_log('Entering '.__FUNCTION__.' in '.__FILE__);
         }

+ 70 - 0
main/install/data.sql

@@ -147,6 +147,76 @@ INSERT INTO skill_rel_skill VALUES(1, 1, 0, 0, 0);
 INSERT INTO course_type (id, name) VALUES (1, 'All tools');
 INSERT INTO course_type (id, name) VALUES (2, 'Entry exam');
 
+
+INSERT INTO sequence_rule (description)
+VALUES ('Si el usuario completa un 70% de una entidad o grupo de recursos podrá acceder acceder a otra entidad o grupo de recursos');
+
+INSERT INTO sequence_condition (description, mat_op, param, act_true, act_false) VALUES
+('<= 100%','<=', 100.0, 2, null),
+('>= 70%','>=', 70.0, 0, null);
+
+INSERT INTO sequence_rule_condition VALUES
+  (1,1,1),
+  (2,1,2);
+
+INSERT INTO sequence_method (description,formula, assign, met_type) VALUES
+('Aumenta elemento completado','v#2 + $complete_items;', 2, 'add'),
+('Actualiza Avance por división', 'v#2 / v#3 * 100;', 1, 'div'),
+('Actualiza total de elementos', '$total_items;', 3,'update'),
+('Activa logro', '1;', 4, 'success'),
+('Almacena la fecha de logro', '(empty(v#5))? api_get_utc_datetime() : v#5;', 5, 'success'),
+('Activa disponibilidad', '1;', 6, 'pre'),
+('Almacena la fecha inicio de disponibilidad', '(empty(v#7))? api_get_utc_datetime() : v#7;', 7, 'pre'),
+('Almacena la fecha fin de disponibilidad', '(empty($available_end_date))? api_get_utc_datetime($available_end_date) : "0000-00-00 00:00:00";', 8, 'pre'),
+('Aumenta el total de elementos', 'v#3 + $total_items;', 3,'add'),
+('Actualiza elementos completados', '$complete_items;', 2,'update'),
+('Actualiza Avance', '$complete_items / $total_items * 100;', 1, 'update');
+
+INSERT INTO sequence_rule_method VALUES
+(1,1,1,1),
+(2,1,2,3),
+(3,1,3,0),
+(4,1,4,0),
+(5,1,5,0),
+(6,1,6,0),
+(7,1,7,0),
+(8,1,8,0),
+(9,1,9,2),
+(10,1,10,0),
+(11,1,11,0);
+
+INSERT INTO sequence_variable VALUES
+(1, 'Avance porcentual', 'advance', 0.0),
+(2, 'Elementos completados', 'complete_items', 0),
+(3, 'Total de elementos', 'total_items', 0),
+(4, 'Completado', 'success', 0),
+(5, 'Fecha de completado', 'success_date', '0000-00-00 00:00:00'),
+(6, 'Disponible', 'available', 0),
+(7, 'Fecha de inicio de disponibilidad', 'available_start_date', '0000-00-00 00:00:00'),
+(8, 'Fecha de fin de disponibilidad', 'available_end_date', '0000-00-00 00:00:00');
+
+INSERT INTO sequence_formula VALUES
+(1,1,2),
+(2,2,2),
+(3,2,3),
+(4,2,1),
+(5,3,3),
+(6,4,4),
+(7,5,5),
+(8,6,6),
+(9,7,7),
+(10,8,8),
+(11,9,3),
+(12,10,2),
+(13,11,1);
+INSERT INTO sequence_valid VALUES
+(1,1,1),
+(2,1,2);
+INSERT INTO sequence_type_entity VALUES
+(1,'Lp', 'Learning Path','c_lp'),
+(2,'Quiz', 'Quiz and Tests','c_quiz'),
+(3,'LpItem', 'Items of a Learning Path','c_lp_item');
+
 UPDATE settings_current SET selected_value = '1.10.0.35' WHERE variable = 'chamilo_database_version';
 
 

+ 53 - 0
src/Chamilo/CoreBundle/Entity/Sequence.php

@@ -0,0 +1,53 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class Sequence
+ *
+ * @ORM\Table(name="sequence")
+ * @ORM\Entity
+ */
+class Sequence
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="is_part", type="boolean")
+     */
+    private $part;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceRowEntity")
+     * @ORM\JoinColumn(name="sequence_row_entity_id", referencedColumnName="id")
+     **/
+    private $rowEntity;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceRowEntity")
+     * @ORM\JoinColumn(name="sequence_row_entity_id_next", referencedColumnName="id")
+     **/
+    private $rowEntityNext;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 69 - 0
src/Chamilo/CoreBundle/Entity/SequenceCondition.php

@@ -0,0 +1,69 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceCondition
+ *
+ * @ORM\Table(name="sequence_condition")
+ * @ORM\Entity
+ */
+class SequenceCondition
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=false)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="mat_op", type="integer")
+     */
+    private $mathOperation;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="param", type="float")
+     */
+    private $param;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="act_true", type="integer")
+     */
+    private $actTrue;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="act_false", type="integer")
+     */
+    private $actFalse;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 47 - 0
src/Chamilo/CoreBundle/Entity/SequenceFormula.php

@@ -0,0 +1,47 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceFormula
+ *
+ * @ORM\Table(name="sequence_formula")
+ * @ORM\Entity
+ */
+class SequenceFormula
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceMethod")
+     * @ORM\JoinColumn(name="sequence_method_id", referencedColumnName="id")
+     **/
+    private $method;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceVariable")
+     * @ORM\JoinColumn(name="sequence_variable_id", referencedColumnName="id")
+     **/
+    private $variable;
+
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 69 - 0
src/Chamilo/CoreBundle/Entity/SequenceMethod.php

@@ -0,0 +1,69 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceMethod
+ *
+ * @ORM\Table(name="sequence_method")
+ * @ORM\Entity
+ */
+class SequenceMethod
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=false)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="formula", type="text")
+     */
+    private $formula;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="assign", type="integer")
+     */
+    private $assign;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="met_type", type="integer")
+     */
+    private $metType;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="act_false", type="integer")
+     */
+    private $actFalse;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 68 - 0
src/Chamilo/CoreBundle/Entity/SequenceRowEntity.php

@@ -0,0 +1,68 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceRowEntity
+ *
+ * @ORM\Table(name="sequence_row_entity")
+ * @ORM\Entity
+ */
+class SequenceRowEntity
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="c_id", type="integer")
+     */
+    private $cId;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="session_id", type="integer")
+     */
+    private $sessionId;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="row_id", type="integer")
+     */
+    private $rowId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", length=255, nullable=false)
+     */
+    private $name;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceTypeEntity")
+     * @ORM\JoinColumn(name="sequence_type_entity_id", referencedColumnName="id")
+     **/
+    private $type;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 41 - 0
src/Chamilo/CoreBundle/Entity/SequenceRule.php

@@ -0,0 +1,41 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceRule
+ *
+ * @ORM\Table(name="sequence_rule")
+ * @ORM\Entity
+ */
+class SequenceRule
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=false)
+     */
+    private $description;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 46 - 0
src/Chamilo/CoreBundle/Entity/SequenceRuleCondition.php

@@ -0,0 +1,46 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceRuleCondition
+ *
+ * @ORM\Table(name="sequence_rule_condition")
+ * @ORM\Entity
+ */
+class SequenceRuleCondition
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceRule")
+     * @ORM\JoinColumn(name="sequence_rule_id", referencedColumnName="id")
+     **/
+    private $rule;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceCondition")
+     * @ORM\JoinColumn(name="sequence_condition_id", referencedColumnName="id")
+     **/
+    private $condition;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 53 - 0
src/Chamilo/CoreBundle/Entity/SequenceRuleMethod.php

@@ -0,0 +1,53 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceRuleMethod
+ *
+ * @ORM\Table(name="sequence_rule_method")
+ * @ORM\Entity
+ */
+class SequenceRuleMethod
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="method_order", type="integer")
+     */
+    private $methodOrder;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceRule")
+     * @ORM\JoinColumn(name="sequence_rule_id", referencedColumnName="id")
+     **/
+    private $rule;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceMethod")
+     * @ORM\JoinColumn(name="sequence_method_id", referencedColumnName="id")
+     **/
+    private $method;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 55 - 0
src/Chamilo/CoreBundle/Entity/SequenceTypeEntity.php

@@ -0,0 +1,55 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceTypeEntity
+ *
+ * @ORM\Table(name="sequence_type_entity")
+ * @ORM\Entity
+ */
+class SequenceTypeEntity
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", length=255, nullable=false)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=false)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="ent_table", type="string", length=255, nullable=false)
+     */
+    private $entityTable;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 47 - 0
src/Chamilo/CoreBundle/Entity/SequenceValid.php

@@ -0,0 +1,47 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceRule
+ *
+ * @ORM\Table(name="sequence_valid")
+ * @ORM\Entity
+ */
+class SequenceValid
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceVariable")
+     * @ORM\JoinColumn(name="sequence_variable_id", referencedColumnName="id")
+     **/
+    private $variable;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceCondition")
+     * @ORM\JoinColumn(name="sequence_condition_id", referencedColumnName="id")
+     **/
+    private $condition;
+
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 103 - 0
src/Chamilo/CoreBundle/Entity/SequenceValue.php

@@ -0,0 +1,103 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class Sequence
+ *
+ * @ORM\Table(name="sequence_value")
+ * @ORM\Entity
+ */
+class SequenceValue
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="user_id", type="integer")
+     */
+    private $userId;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="SequenceRowEntity")
+     * @ORM\JoinColumn(name="sequence_row_entity_id", referencedColumnName="id")
+     **/
+    private $entity;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="advance", type="float")
+     */
+    private $advance;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="complete_items", type="integer")
+     */
+    private $completeItems;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="total_items", type="integer")
+     */
+    private $totalItems;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="success", type="boolean")
+     */
+    private $success;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="success_date", type="datetime", nullable=true)
+     */
+    private $successDate;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="available", type="boolean")
+     */
+    private $available;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="available_start_date", type="datetime", nullable=true)
+     */
+    private $availableStartDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="available_end_date", type="datetime", nullable=true)
+     */
+    private $availableEndDate;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 55 - 0
src/Chamilo/CoreBundle/Entity/SequenceVariable.php

@@ -0,0 +1,55 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Class SequenceVariable
+ *
+ * @ORM\Table(name="sequence_variable")
+ * @ORM\Entity
+ */
+class SequenceVariable
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue()
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", nullable=true)
+     */
+    private $name;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=true)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="default_val", type="string", nullable=true)
+     */
+    private $defaultValue;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+}

+ 115 - 0
src/Chamilo/CoreBundle/Migrations/Schema/v1/Version110.php

@@ -30,6 +30,121 @@ class Version110 extends AbstractMigrationChamilo
         $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)");
         $this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)");
 
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_rule (
+            id int unsigned not null auto_increment,
+            description TEXT default '',
+            PRIMARY KEY (id)
+        )";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_condition (
+            id int unsigned not null auto_increment,
+            description TEXT default '',
+            mat_op char(2) not null,
+            param float not null,
+            act_true int unsigned,
+            act_false int unsigned,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_rule_condition (
+            id int unsigned not null auto_increment,
+            sequence_rule_id int unsigned not null,
+            sequence_condition_id int unsigned not null,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_method (
+            id int unsigned not null auto_increment,
+            description TEXT default '',
+            formula TEXT default '',
+            assign int unsigned not null,
+            met_type varchar(50) default '',
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_rule_method (
+            id int unsigned not null auto_increment,
+            sequence_rule_id int unsigned not null,
+            sequence_method_id int unsigned not null,
+            method_order int unsigned not null,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_variable (
+            id int unsigned not null auto_increment,
+            description TEXT default '',
+            name varchar(50),
+            default_val varchar(50) default '',
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_formula (
+            id int unsigned not null auto_increment,
+            sequence_method_id int unsigned not null,
+            sequence_variable_id int unsigned not null,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_valid (
+            id int unsigned not null auto_increment,
+            sequence_variable_id int unsigned not null,
+            sequence_condition_id int unsigned not null,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_type_entity (
+            id int unsigned not null auto_increment,
+            name varchar(50) not null default '',
+            description TEXT default '',
+            ent_table varchar(50) not null,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_row_entity (
+            id int unsigned not null auto_increment,
+            sequence_type_entity_id int unsigned not null,
+            c_id  int unsigned not null,
+            session_id int unsigned not null default 0,
+            row_id int unsigned not null,
+            name varchar(200) not null default '',
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence (
+            id int unsigned not null auto_increment,
+            sequence_row_entity_id int unsigned not null,
+            sequence_row_entity_id_next int unsigned not null,
+            is_part tinyint unsigned not null default 0,
+            PRIMARY KEY (id)
+        );";
+
+        $this->addSql("
+        CREATE TABLE IF NOT EXISTS sequence_value (
+            id int unsigned not null auto_increment,
+            user_id int unsigned not null,
+            sequence_row_entity_id int unsigned not null,
+            advance float not null default 0.0,
+            complete_items int not null default 0,
+            total_items int not null default 1,
+            success tinyint not null default 0,
+            success_date datetime not null,
+            available tinyint not null default 0,
+            available_start_date datetime not null,
+            available_end_date datetime not null,
+            PRIMARY KEY (id)
+        );";
+
         //$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id");
         //$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id");
         //$this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)");