Browse Source

Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

jmontoyaa 8 years ago
parent
commit
ada86b0a90

+ 8 - 11
main/exercise/exercise_show.php

@@ -74,8 +74,10 @@ if (empty($id)) {
     api_not_allowed(true);
 }
 
+$current_user_id = api_get_user_id();
+
 if (api_is_course_session_coach(
-    api_get_user_id(),
+    $current_user_id,
     api_get_course_int_id(),
     api_get_session_id()
 )) {
@@ -105,7 +107,6 @@ $student_id = $track_exercise_info['exe_user_id'];
 $learnpath_id = $track_exercise_info['orig_lp_id'];
 $learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
 $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
-$current_user_id = api_get_user_id();
 
 if (api_is_excluded_user_type(true, $student_id)) {
     api_not_allowed(true);
@@ -214,17 +215,13 @@ if (!empty($track_exercise_info)) {
             $show_results = false;
             $show_only_total_score = true;
             if ($origin != 'learnpath') {
-                echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
-                      <tr>
-                        <td colspan="2">';
-                Display::display_warning_message(get_lang('ThankYouForPassingTheTest'), false);
-                echo '</td>
-                </tr>
-                </table>';
+                if ($current_user_id == $student_id) {
+                    echo Display::return_message(get_lang('ThankYouForPassingTheTest'), 'warning', false);
+                }
             }
         } elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
             $attempts = Event::getExerciseResultsByUser(
-                api_get_user_id(),
+                $current_user_id,
                 $objExercise->id,
                 api_get_course_int_id(),
                 api_get_session_id(),
@@ -902,7 +899,7 @@ if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress
     $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.api_get_session_id();
 
     $content = ExerciseLib::getEmailNotification(
-        api_get_user_id(),
+        $current_user_id,
         api_get_course_info(),
         $track_exercise_info['title'],
         $track_exercise_info['orig_lp_id'],

+ 1 - 1
main/exercise/fill_blanks.class.php

@@ -305,7 +305,7 @@ class FillBlanks extends Question
         // answer
         $form->addLabel(
             null,
-            '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')
+            get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')
         );
         $form->addElement(
             'html_editor',

+ 4 - 3
main/inc/lib/events.lib.php

@@ -1918,9 +1918,10 @@ class Event
         // format returned by SQL for a subtraction of two datetime values
         // @todo make sure this is portable between DBMSes
         if (preg_match('/:/', $virtualTime)) {
-            $virtualTime = preg_replace('/:/', '', $virtualTime);
+            list($h, $m, $s) = preg_split('/:/', $virtualTime);
+            $virtualTime = $h * 3600 + $m * 60 + $s;
         } else {
-            $virtualTime *= 10000;
+            $virtualTime *= 3600;
         }
 
         // Get the current latest course connection register. We need that
@@ -1932,7 +1933,7 @@ class Event
                             c_id = $courseId  AND
                             session_id  = $sessionId AND
                             counter = 0 AND
-                            logout_course_date - login_course_date = '$virtualTime'
+                            (UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) = '$virtualTime'
                         ORDER BY login_course_date DESC LIMIT 0,1";
         $result = Database::query($sql);
 

+ 4 - 3
main/inc/lib/pear/HTML/QuickForm/advanced_settings.php

@@ -49,9 +49,10 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
         return '<div class="form-group">
                     <label class="col-sm-2 control-label"></label>
                     <div class="col-sm-10">
-                        <a id="'.$name.'" class="btn btn-default advanced_options" href="#">
-                        <em class="fa fa-bars"></em>  '.$text.'
-                        </a>
+                        <button id="' . $name . '" type="button" class="btn btn-default advanced_options"
+                                data-toggle="button" aria-pressed="false" autocomplete="off">
+                            <em class="fa fa-bars"></em> '.$text.'
+                        </button>
                     </div>
                  </div>';
     }

+ 0 - 1
main/template/default/layout/footer.js.tpl

@@ -38,7 +38,6 @@
             event.preventDefault();
             var id = $(this).attr('id') + '_options';
             var button = $(this);
-            button.toggleClass('active');
             $("#" + id).toggle();
         });
 

+ 41 - 25
main/work/work.lib.php

@@ -3828,11 +3828,11 @@ function processWorkForm(
             // connection to the platform to hand the work in.
             $consideredWorkingTime = api_get_configuration_value('considered_working_time');
 
-            if ($consideredWorkingTime) {
+            if (!empty($consideredWorkingTime)) {
                 // Get the "considered work time" defined for this work
                 $fieldValue = new ExtraFieldValue('work');
                 $resultExtra = $fieldValue->getAllValuesForAnItem(
-                    $workId,
+                    $workInfo['iid'], //the ID of the work *folder*, not the document uploaded by the student
                     true
                 );
 
@@ -4298,41 +4298,57 @@ function deleteWorkItem($item_id, $courseInfo)
                 WHERE c_id = $course_id AND id = $item_id";
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
+        $count = Database::num_rows($result);
 
-        if (Database::num_rows($result) > 0) {
+        if ($count > 0) {
 
             // If the "considered_working_time" option is enabled, check
             // whether some time should be removed from track_e_course_access
             $consideredWorkingTime = api_get_configuration_value('considered_working_time');
             if ($consideredWorkingTime) {
-                // Get the "considered work time" defined for this work
-                $fieldValue = new ExtraFieldValue('work');
-                $resultExtra = $fieldValue->getAllValuesForAnItem(
+                $userWorks = get_work_user_list(
+                    0,
+                    100,
+                    null,
+                    null,
                     $row['parent_id'],
-                    true
+                    null,
+                    $row['user_id'],
+                    false,
+                    $course_id,
+                    $row['session_id']
                 );
+                // We're only interested in deleting the time if this is the latest work sent
+                if (count($userWorks) == 1) {
+                    // Get the "considered work time" defined for this work
+                    $fieldValue = new ExtraFieldValue('work');
+                    $resultExtra = $fieldValue->getAllValuesForAnItem(
+                        $row['parent_id'],
+                        true
+                    );
 
-                $workingTime = null;
-                foreach ($resultExtra as $field) {
-                    $field = $field['value'];
+                    $workingTime = null;
+                    foreach ($resultExtra as $field) {
+                        $field = $field['value'];
 
-                    if ($consideredWorkingTime == $field->getField()->getVariable()) {
-                        $workingTime = $field->getValue();
+                        if ($consideredWorkingTime == $field->getField()->getVariable()) {
+                            $workingTime = $field->getValue();
+                        }
+                    }
+                    // If no time was defined, or a time of "0" was set, do nothing
+                    if (!empty($workingTime)) {
+                        $sessionId = empty($row['session_id']) ? 0 : $row['session_id'];
+                        // Getting false from the following call would mean the
+                        // time record
+                        $removalResult = Event::eventRemoveVirtualCourseTime(
+                            $course_id,
+                            $row['user_id'],
+                            $sessionId,
+                            $workingTime
+                        );
                     }
                 }
-                // If no time was defined, or a time of "0" was set, do nothing
-                if (!empty($workingTime)) {
-                    $sessionId = empty($row['session_id']) ? 0 : $row['session_id'];
-                    // Getting false from the following call would mean the
-                    // time record
-                    $removalResult = Event::eventRemoveVirtualCourseTime(
-                        $course_id,
-                        $row['user_id'],
-                        $sessionId,
-                        $workingTime
-                    );
-                }
-            } // fin de sección sobre considered_working_time
+            } // end of considered_working_time check section
 
             $sql = "UPDATE $work_table SET active = 2
                     WHERE c_id = $course_id AND id = $item_id";