Browse Source

Fix DB errors

jmontoyaa 9 years ago
parent
commit
2ce5809df2

+ 4 - 0
app/Migrations/Schema/V111/Version111.php

@@ -76,6 +76,10 @@ class Version111 extends AbstractMigrationChamilo
 
         $this->addSql('ALTER TABLE c_forum_forum CHANGE start_time start_time DATETIME');
         $this->addSql('ALTER TABLE c_forum_forum CHANGE end_time end_time DATETIME');
+
+        $this->addSql('ALTER TABLE track_e_exercises CHANGE expired_time_control expired_time_control DATETIME');
+
+
     }
 
     /**

+ 9 - 8
main/exercice/exercise.class.php

@@ -2840,7 +2840,7 @@ class Exercise
             $safe_lp_item_id = 0;
         }
         if (empty($clock_expired_time)) {
-            $clock_expired_time = 0;
+            $clock_expired_time = null;
         }
 
         $questionList = array_map('intval', $questionList);
@@ -2857,13 +2857,15 @@ class Exercise
             'orig_lp_item_id'  => $safe_lp_item_id,
             'orig_lp_item_view_id'  => $safe_lp_item_view_id,
             'exe_weighting'=> $weight,
-            'user_ip' => api_get_real_ip()
+            'user_ip' => api_get_real_ip(),
+            'exe_date' => api_get_utc_datetime(),
+            'exe_result' => 0,
+            'steps_counter' => 0,
+            'exe_duration' => 0,
+            'expired_time_control' => $clock_expired_time,
+            'questions_to_check' => ''
         );
 
-        if ($this->expired_time != 0) {
-            $params['expired_time_control'] = $clock_expired_time;
-        }
-
         $id = Database::insert($track_exercises, $params);
 
         return $id;
@@ -5085,7 +5087,6 @@ class Exercise
             $sql = 'UPDATE ' . $stat_table . ' SET
                         exe_result = exe_result + ' . floatval($questionScore) . '
                     WHERE exe_id = ' . $exeId;
-            if ($debug) error_log($sql);
             Database::query($sql);
         }
 
@@ -6117,7 +6118,7 @@ class Exercise
             if (empty($exercise_info['questions_to_check'])) {
                 if ($action == 'add') {
                     $sql = "UPDATE $track_exercises SET questions_to_check = '$question_id' WHERE exe_id = $exe_id ";
-                    $result = Database::query($sql);
+                    Database::query($sql);
                 }
             } else {
                 $remind_list = explode(',',$exercise_info['questions_to_check']);

+ 11 - 2
main/inc/lib/events.lib.php

@@ -494,6 +494,8 @@ class Event
                 'position' => $position,
                 'tms' => $now,
                 'filename' => !empty($fileName) ? basename($fileName) : $fileName,
+                'teacher_comment' => '',
+                'course_code' => ''
             );
 
             // Check if attempt exists.
@@ -582,8 +584,15 @@ class Event
      * @return	boolean	Result of the insert query
      * @uses Course code and user_id from global scope $_cid and $_user
      */
-    public static function saveExerciseAttemptHotspot($exe_id, $question_id, $answer_id, $correct, $coords, $updateResults = false, $exerciseId = 0)
-    {
+    public static function saveExerciseAttemptHotspot(
+        $exe_id,
+        $question_id,
+        $answer_id,
+        $correct,
+        $coords,
+        $updateResults = false,
+        $exerciseId = 0
+    ) {
         global $safe_lp_id, $safe_lp_item_id;
 
         if ($updateResults == false) {

+ 1 - 1
src/Chamilo/CoreBundle/Entity/TrackEExercises.php

@@ -120,7 +120,7 @@ class TrackEExercises
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="expired_time_control", type="datetime", nullable=false)
+     * @ORM\Column(name="expired_time_control", type="datetime", nullable=true)
      */
     private $expiredTimeControl;