Pārlūkot izejas kodu

Merge pull request #1842 from chamilo/scrutinizer-patch-1

Scrutinizer Auto-Fixes
Julio Montoya 8 gadi atpakaļ
vecāks
revīzija
43fbc9d492

+ 1 - 1
main/auth/categories_list.php

@@ -16,7 +16,7 @@ $stok = Security::get_token();
 <!-- Actions: The menu with the different options in cathe course management -->
 <div id="actions" class="actions">
     <a href="<?php echo api_get_self() ?>?action=sortmycourses">
-        <?php echo Display::return_icon('back.png', get_lang('Back'),'','32'); ?>
+        <?php echo Display::return_icon('back.png', get_lang('Back'), '', '32'); ?>
     </a>
 </div>
 

+ 6 - 6
main/auth/courses.php

@@ -195,7 +195,7 @@ switch ($action) {
         if (!$user_can_view_page) {
             api_not_allowed(true);
         }
-        header('Location: ' . api_get_self());
+        header('Location: '.api_get_self());
         exit;
         /* if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
             $courses_controller->courses_categories(
@@ -283,7 +283,7 @@ switch ($action) {
                 $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);
 
                 if (!$continueWithSubscription) {
-                    header('Location: ' .  api_get_path(WEB_CODE_PATH) . 'auth/courses.php');
+                    header('Location: '.api_get_path(WEB_CODE_PATH).'auth/courses.php');
                     exit;
                 }
             }
@@ -301,16 +301,16 @@ switch ($action) {
 
             if ($count <= 0) {
                 // no course in session -> return to catalog
-                $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php';
+                $url = api_get_path(WEB_CODE_PATH).'auth/courses.php';
             } elseif ($count == 1) {
                 // only one course, so redirect directly to this course
                 foreach ($coursesList as $course) {
-                    $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']);
+                    $url = api_get_path(WEB_COURSE_PATH).$course['directory'].'/index.php?id_session='.intval($_GET['session_id']);
                 }
             } else {
-                $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']);
+                $url = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.intval($_GET['session_id']);
             }
-            header('Location: ' . $url);
+            header('Location: '.$url);
             exit;
         }
         //else show error message?

+ 10 - 10
main/coursecopy/import_backup.php

@@ -98,21 +98,21 @@ if (Security::check_token('post') && (
         $cr->set_file_option($_POST['same_file_name_option']);
         $cr->restore();
         Display::addFlash(Display::return_message(get_lang('ImportFinished')));
-        echo '<a class="btn btn-default" href="' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/index.php">' . get_lang('CourseHomepage') . '</a>';
+        echo '<a class="btn btn-default" href="'.api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php">'.get_lang('CourseHomepage').'</a>';
     } else {
         if (!$error) {
             Display::addFlash(Display::return_message(get_lang('NoResourcesInBackupFile'), 'warning'));
-            echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+            echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
         } elseif ($filename === false) {
             Display::addFlash(Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'error'));
-            echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+            echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
         } else {
             if ($filename == '') {
                 Display::addFlash(Display::return_message(get_lang('SelectBackupFile'), 'error'));
-                echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+                echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
             } else {
                 Display::addFlash(Display::return_message(get_lang('UploadError'), 'error'));
-                echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+                echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
             }
         }
     }
@@ -142,10 +142,10 @@ if (Security::check_token('post') && (
         CourseSelectForm::display_form($course, $hiddenFields);
     } elseif ($filename === false) {
         Display::addFlash(Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'error'));
-        echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+        echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
     } else {
         Display::addFlash(Display::return_message(get_lang('NoResourcesInBackupFile'), 'warning'));
-        echo '<a class="btn btn-default" href="import_backup.php?' . api_get_cidreq() . '">' . get_lang('TryAgain') . '</a>';
+        echo '<a class="btn btn-default" href="import_backup.php?'.api_get_cidreq().'">'.get_lang('TryAgain').'</a>';
     }
 } else {
     $user = api_get_user_info();
@@ -157,7 +157,7 @@ if (Security::check_token('post') && (
     $form = new FormValidator(
         'import_backup_form',
         'post',
-        api_get_path(WEB_CODE_PATH) . 'coursecopy/import_backup.php?' . api_get_cidreq(),
+        api_get_path(WEB_CODE_PATH).'coursecopy/import_backup.php?'.api_get_cidreq(),
         '',
         array('enctype' => 'multipart/form-data')
     );
@@ -189,7 +189,7 @@ if (Security::check_token('post') && (
         );
         $options['null'] = '-';
         foreach ($backups as $index => $backup) {
-            $options[$backup['file']] = $backup['course_code'] . ' (' . $backup['date'] . ')';
+            $options[$backup['file']] = $backup['course_code'].' ('.$backup['date'].')';
         }
         $form->addElement(
             'select',
@@ -207,7 +207,7 @@ if (Security::check_token('post') && (
             'radio',
             '',
             '',
-            '<i>' . get_lang('NoBackupsAvailable') . '</i>',
+            '<i>'.get_lang('NoBackupsAvailable').'</i>',
             '',
             'disabled="true"'
         );

+ 14 - 14
main/exercise/MatchingDraggable.php

@@ -66,12 +66,12 @@ class MatchingDraggable extends Question
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                     if ($answer->isCorrect($i)) {
                         $nb_matches++;
-                        $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
-                        $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
-                        $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
+                        $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i);
+                        $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1);
+                        $defaults['matches['.$nb_matches.']'] = $answer->correct[$i];
                     } else {
                         $nb_options++;
-                        $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
+                        $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i);
                     }
                 }
             }
@@ -102,10 +102,10 @@ class MatchingDraggable extends Question
         $html = '<table class="table table-striped table-hover">
             <thead>
                 <tr>
-                    <th width="10">' . get_lang('Number') . '</th>
-                    <th width="85%">' . get_lang('Answer') . '</th>
-                    <th width="15%">' . get_lang('MatchesTo') . '</th>
-                    <th width="10">' . get_lang('Weighting') . '</th>
+                    <th width="10">' . get_lang('Number').'</th>
+                    <th width="85%">' . get_lang('Answer').'</th>
+                    <th width="15%">' . get_lang('MatchesTo').'</th>
+                    <th width="10">' . get_lang('Weighting').'</th>
                 </tr>
             </thead>
             <tbody>';
@@ -164,8 +164,8 @@ class MatchingDraggable extends Question
         $html = '<table class="table table-striped table-hover">
             <thead>
                 <tr>
-                    <th width="15%">' . get_lang('Number') . '</th>
-                    <th width="85%">' . get_lang('Answer') . '</th>
+                    <th width="15%">' . get_lang('Number').'</th>
+                    <th width="85%">' . get_lang('Answer').'</th>
                 </tr>
             </thead>
             <tbody>';
@@ -186,7 +186,7 @@ class MatchingDraggable extends Question
             );
 
             $form->addHtml('<tr>');
-            $form->addHtml('<td>' . chr(64 + $i) . '</td>');
+            $form->addHtml('<td>'.chr(64 + $i).'</td>');
             //$form->addText("option[$i]", null);
             $form->addHtmlEditor(
                 "option[$i]",
@@ -273,10 +273,10 @@ class MatchingDraggable extends Question
     public function return_header($feedback_type = null, $counter = null, $score = null)
     {
         $header = parent::return_header($feedback_type, $counter, $score);
-        $header .= '<table class="' . $this->question_table_class . '">
+        $header .= '<table class="'.$this->question_table_class.'">
                 <tr>
-                    <th>' . get_lang('ElementList') . '</th>
-                    <th>' . get_lang('CorrespondsTo') . '</th>
+                    <th>' . get_lang('ElementList').'</th>
+                    <th>' . get_lang('CorrespondsTo').'</th>
                 </tr>';
 
         return $header;

+ 43 - 43
main/exercise/UniqueAnswerImage.php

@@ -45,22 +45,22 @@ class UniqueAnswerImage extends UniqueAnswer
 
         if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
             //Scenario
-            $commentTitle = '<th>' . get_lang('Comment') . '</th>';
-            $feedbackTitle = '<th>' . get_lang('Scenario') . '</th>';
+            $commentTitle = '<th>'.get_lang('Comment').'</th>';
+            $feedbackTitle = '<th>'.get_lang('Scenario').'</th>';
         } else {
-            $commentTitle = '<th >' . get_lang('Comment') . '</th>';
+            $commentTitle = '<th >'.get_lang('Comment').'</th>';
         }
 
         $html = '<div class="alert alert-success" role="alert">'.get_lang('UniqueAnswerImagePreferredSize200x150').'</div>';
         $html .= '<table class="table table-striped table-hover">
             <thead>
                 <tr style="text-align: center;">
-                    <th width="10">' . get_lang('Number') . '</th>
-                    <th>' . get_lang('True') . '</th>
-                    <th>' . get_lang('Answer') . '</th>
-                        ' . $commentTitle . '
-                        ' . $feedbackTitle . '
-                    <th width="15">' . get_lang('Weighting') . '</th>
+                    <th width="10">' . get_lang('Number').'</th>
+                    <th>' . get_lang('True').'</th>
+                    <th>' . get_lang('Answer').'</th>
+                        ' . $commentTitle.'
+                        ' . $feedbackTitle.'
+                    <th width="15">' . get_lang('Weighting').'</th>
                 </tr>
             </thead>
             <tbody>';
@@ -95,7 +95,7 @@ class UniqueAnswerImage extends UniqueAnswer
                 }
 
                 $question = Question::read($questionid);
-                $selectQuestion[$questionid] = 'Q' . $key . ' :' . cut(
+                $selectQuestion[$questionid] = 'Q'.$key.' :'.cut(
                     $question->selectTitle(), 20
                 );
             }
@@ -152,18 +152,18 @@ class UniqueAnswerImage extends UniqueAnswer
                     $urlResult = $url;
                 }
 
-                $tempScenario['url' . $i] = $urlResult;
-                $tempScenario['try' . $i] = $tryResult;
-                $tempScenario['lp' . $i] = $lp;
-                $tempScenario['destination' . $i] = $listDestination;
+                $tempScenario['url'.$i] = $urlResult;
+                $tempScenario['try'.$i] = $tryResult;
+                $tempScenario['lp'.$i] = $lp;
+                $tempScenario['destination'.$i] = $listDestination;
             } else {
                 $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1');
                 $defaults['weighting[1]'] = 10;
                 $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2');
                 $defaults['weighting[2]'] = 0;
 
-                $tempScenario['destination' . $i] = array('0');
-                $tempScenario['lp' . $i] = array('0');
+                $tempScenario['destination'.$i] = array('0');
+                $tempScenario['lp'.$i] = array('0');
             }
 
             $defaults['scenario'] = $tempScenario;
@@ -174,28 +174,28 @@ class UniqueAnswerImage extends UniqueAnswer
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'counter[' . $i . ']'
+                'counter['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'answer[' . $i . ']'
+                'answer['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'comment[' . $i . ']'
+                'comment['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'weighting[' . $i . ']'
+                'weighting['.$i.']'
             );
 
-            $answerNumber = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"');
+            $answerNumber = $form->addElement('text', 'counter['.$i.']', null, ' value = "'.$i.'"');
             $answerNumber->freeze();
 
             $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox"');
-            $form->addHtmlEditor('answer[' . $i . ']', null, null, true, $editorConfig);
+            $form->addHtmlEditor('answer['.$i.']', null, null, true, $editorConfig);
 
-            $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
+            $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
 
             if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
                 $form->addHtmlEditor(
@@ -208,22 +208,22 @@ class UniqueAnswerImage extends UniqueAnswer
                 // Direct feedback
                 // Adding extra feedback fields
                 $group = array();
-                $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain'));
-                $group['lp' . $i] = $form->createElement(
+                $group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
+                $group['lp'.$i] = $form->createElement(
                     'select',
-                    'lp' . $i,
-                    get_lang('SeeTheory') . ': ',
+                    'lp'.$i,
+                    get_lang('SeeTheory').': ',
                     $selectLpId
                 );
-                $group['destination' . $i] = $form->createElement(
+                $group['destination'.$i] = $form->createElement(
                     'select',
-                    'destination' . $i,
-                    get_lang('GoToQuestion') . ': ',
+                    'destination'.$i,
+                    get_lang('GoToQuestion').': ',
                     $selectQuestion
                 );
-                $group['url' . $i] = $form->createElement(
-                    'text', 'url' . $i,
-                    get_lang('Other') . ': ',
+                $group['url'.$i] = $form->createElement(
+                    'text', 'url'.$i,
+                    get_lang('Other').': ',
                     array(
                         'class' => 'col-md-2',
                         'placeholder' => get_lang('Other')
@@ -236,9 +236,9 @@ class UniqueAnswerImage extends UniqueAnswer
                     'scenario'
                 );
             } else {
-                $form->addHtmlEditor('comment[' . $i . ']', null, null, false, $editorConfig);
+                $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
             }
-            $form->addText('weighting[' . $i . ']', null, null, array('class' => "col-md-1", 'value' => '0'));
+            $form->addText('weighting['.$i.']', null, null, array('class' => "col-md-1", 'value' => '0'));
             $form->addHtml('</tr>');
         }
 
@@ -284,19 +284,19 @@ class UniqueAnswerImage extends UniqueAnswer
         $numberAnswers = $form->getSubmitValue('nb_answers');
 
         for ($i = 1; $i <= $numberAnswers; $i++) {
-            $answer = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('answer[' . $i . ']')));
-            $comment = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('comment[' . $i . ']')));
-            $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
+            $answer = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('answer['.$i.']')));
+            $comment = trim(str_replace(['<p>', '</p>'], '', $form->getSubmitValue('comment['.$i.']')));
+            $weighting = trim($form->getSubmitValue('weighting['.$i.']'));
 
             $scenario = $form->getSubmitValue('scenario');
 
             //$listDestination = $form -> getSubmitValue('destination'.$i);
             //$destinationStr = $form -> getSubmitValue('destination'.$i);
 
-            $try = $scenario['try' . $i];
-            $lp = $scenario['lp' . $i];
-            $destination = $scenario['destination' . $i];
-            $url = trim($scenario['url' . $i]);
+            $try = $scenario['try'.$i];
+            $lp = $scenario['lp'.$i];
+            $destination = $scenario['destination'.$i];
+            $url = trim($scenario['url'.$i]);
 
             /*
               How we are going to parse the destination value
@@ -344,7 +344,7 @@ class UniqueAnswerImage extends UniqueAnswer
             }
 
             //1@@1;2;@@2;4;4;@@http://www.chamilo.org
-            $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
+            $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
 
             $objAnswer->createAnswer(
                 $answer,

+ 20 - 20
main/exercise/admin.php

@@ -48,7 +48,7 @@ use ChamiloSession as Session;
  */
 
 require_once __DIR__.'/../inc/global.inc.php';
-$current_course_tool  = TOOL_QUIZ;
+$current_course_tool = TOOL_QUIZ;
 $this_section = SECTION_COURSES;
 
 // Access control
@@ -76,7 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
 }
 
 if (empty($exerciseId)) {
-    $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0';
+    $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']) : '0';
 }
 
 $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0;
@@ -149,7 +149,7 @@ $aType = array(
 if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
     require_once 'export/qti2/qti2_export.php';
     $export = export_question_qti($_GET['questionId'], true);
-    $qid = (int)$_GET['questionId'];
+    $qid = (int) $_GET['questionId'];
     $archive_path = api_get_path(SYS_ARCHIVE_PATH);
     $temp_dir_short = uniqid();
     $temp_zip_dir = $archive_path."/".$temp_dir_short;
@@ -193,7 +193,7 @@ if ($objExercise->sessionId != $sessionId) {
 if (!$fromExercise) {
     // gets the right exercise ID, and if 0 creates a new exercise
     if (!$exerciseId = $objExercise->selectId()) {
-        $modifyExercise='yes';
+        $modifyExercise = 'yes';
     }
 }
 
@@ -243,7 +243,7 @@ if ($cancelQuestion) {
     } else {
         // goes back to the question viewing
         $editQuestion = $modifyQuestion;
-        unset($newQuestion,$modifyQuestion);
+        unset($newQuestion, $modifyQuestion);
     }
 }
 
@@ -283,14 +283,14 @@ if (isset($_SESSION['gradebook'])) {
     $gradebook = $_SESSION['gradebook'];
 }
 
-if (!empty($gradebook) && $gradebook=='view') {
-    $interbreadcrumb[]= array(
+if (!empty($gradebook) && $gradebook == 'view') {
+    $interbreadcrumb[] = array(
         'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
         'name' => get_lang('ToolGradebook')
     );
 }
 
-$interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises'));
+$interbreadcrumb[] = array("url" => "exercise.php", "name" => get_lang('Exercises'));
 if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) {
     $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name);
 } else {
@@ -299,7 +299,7 @@ if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) {
 
 // shows a link to go back to the question pool
 if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')) {
-    $interbreadcrumb[]=array(
+    $interbreadcrumb[] = array(
         "url" => api_get_path(WEB_CODE_PATH)."exercise/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(),
         "name" => get_lang('QuestionPool')
     );
@@ -341,8 +341,8 @@ $template = new Template();
 $templateName = $template->get_template('exercise/submit.js.tpl');
 $htmlHeadXtra[] = $template->fetch($templateName);
 $htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js');
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
 
 Display::display_header($nameTools, 'Exercise');
 /*
@@ -361,22 +361,22 @@ if ($inATest) {
     echo '<div class="actions">';
     if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidreq().'">'.
-            Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
 
-    if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) &&  !isset($_GET['editQuestion'])) {
+    if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq().'">'.
-            Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
+            Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).'</a>';
     }
     echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'.
-        Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>';
+        Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM).'</a>';
 
     echo Display::url(
-        Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM),
+        Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM),
         api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id
     );
 
     echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
-        Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
+        Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
 
     $maxScoreAllQuestions = 0;
     //$questionList = $objExercise->getQuestionList();
@@ -404,7 +404,7 @@ if ($inATest) {
     );
 
     if ($objExercise->random > 0) {
-        echo '<br />' .
+        echo '<br />'.
             sprintf(get_lang('OnlyXQuestionsPickedRandomly'), $objExercise->random);
     }
     echo '</div>';
@@ -413,13 +413,13 @@ if ($inATest) {
     // we are in create a new question from question pool not in a test
     echo '<div class="actions">';
     echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'">'.
-        Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'', ICON_SIZE_MEDIUM).'</a>';
+        Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
     echo '</div>';
 } else {
     // If we are in question_pool but not in an test, go back to question create in pool
     echo '<div class="actions">';
     echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/question_pool.php?'.api_get_cidreq().'">'.
-        Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).
+        Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).
         '</a>';
     echo '</div>';
 }

+ 6 - 7
main/exercise/calculated_answer.class.php

@@ -129,8 +129,8 @@ class CalculatedAnswer extends Question
             ),
             array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
 
-        $form->addRule('answer', get_lang('GiveText'),'required');
-        $form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/');
+        $form->addRule('answer', get_lang('GiveText'), 'required');
+        $form->addRule('answer', get_lang('DefineBlanks'), 'regex', '/\[.*\]/');
 
         $form->addElement('label', null, get_lang('IfYouWantOnlyIntegerValuesWriteBothLimitsWithoutDecimals'));
         $form->addElement('html', '<div id="blanks_weighting"></div>');
@@ -215,10 +215,9 @@ class CalculatedAnswer extends Question
                         $newBlankItem = "[".trim($newBlankItem)."]";
                         // take random float values when one or both edge values have a decimal point
                         $randomValue =
-                            (strpos($lowestValues[$i],'.') !== false ||
-                            strpos($highestValues[$i],'.') !== false) ?
-                            mt_rand($lowestValues[$i]*100,$highestValues[$i]*100)/100 :
-                            mt_rand($lowestValues[$i],$highestValues[$i]);
+                            (strpos($lowestValues[$i], '.') !== false ||
+                            strpos($highestValues[$i], '.') !== false) ?
+                            mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]);
                         $auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer);
                         $auxFormula = str_replace($blankItem, $randomValue, $auxFormula);
                     }
@@ -252,7 +251,7 @@ class CalculatedAnswer extends Question
     public function return_header($feedback_type = null, $counter = null, $score = null)
     {
         $header = parent::return_header($feedback_type, $counter, $score);
-        $header .= '<table class="'.$this->question_table_class .'">
+        $header .= '<table class="'.$this->question_table_class.'">
             <tr>
                 <th>'.get_lang("Answer").'</th>
             </tr>';

+ 8 - 8
main/exercise/exercise_result.php

@@ -58,9 +58,9 @@ if (empty($objExercise)) {
 
 $gradebook = '';
 if (isset($_SESSION['gradebook'])) {
-	$gradebook=	$_SESSION['gradebook'];
+	$gradebook = $_SESSION['gradebook'];
 }
-if (!empty($gradebook) && $gradebook=='view') {
+if (!empty($gradebook) && $gradebook == 'view') {
     $interbreadcrumb[] = array(
         'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
         'name' => get_lang('ToolGradebook'),
@@ -74,9 +74,9 @@ $interbreadcrumb[] = array(
     "name" => get_lang('Exercises'),
 );
 
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'annotation/js/annotation.js"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
 
 if ($origin != 'learnpath') {
 	// So we are not in learnpath tool
@@ -152,7 +152,7 @@ if ($objExercise->selectAttempts() > 0) {
         if ($remainingAttempts) {
             $attemptButton = Display::toolbarButton(
                 get_lang('AnotherAttempt'),
-                api_get_path(WEB_CODE_PATH) . 'exercise/overview.php?' . api_get_cidreq() . '&' . http_build_query([
+                api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&'.http_build_query([
                     'exerciseId' => $objExercise->id,
                     'learnpath_id' => $learnpath_id,
                     'learnpath_item_id' => $learnpath_item_id
@@ -173,7 +173,7 @@ if (!empty($exercise_stat_info)) {
 
 $max_score = $objExercise->get_max_score();
 
-Display::display_normal_message(get_lang('Saved').'<br />',false);
+Display::display_normal_message(get_lang('Saved').'<br />', false);
 
 // Display and save questions
 ExerciseLib::display_question_list_by_attempt(
@@ -209,7 +209,7 @@ if ($origin != 'learnpath') {
 } else {
 	$lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null;
 	$url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id;
-	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"';
+	$href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
 
     if (api_is_allowed_to_session_edit()) {
         Session::erase('objExercise');

+ 61 - 61
main/exercise/exercise_show.php

@@ -34,7 +34,7 @@ $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
 // General parameters passed via POST/GET
 if ($debug) {
-    error_log('Entered exercise_result.php: ' . print_r($_POST, 1));
+    error_log('Entered exercise_result.php: '.print_r($_POST, 1));
 }
 
 if (empty($formSent)) {
@@ -133,20 +133,20 @@ if (isset($_SESSION['gradebook'])) {
 }
 
 if (!empty($gradebook) && $gradebook == 'view') {
-    $interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
+    $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
 }
 
 $fromlink = '';
 
-$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
-$interbreadcrumb[] = array("url" => "overview.php?exerciseId=" . $exercise_id . '&' . api_get_cidreq(), "name" => $objExercise->name);
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
+$interbreadcrumb[] = array("url" => "overview.php?exerciseId=".$exercise_id.'&'.api_get_cidreq(), "name" => $objExercise->name);
 $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
 
 $this_section = SECTION_COURSES;
 
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'annotation/js/annotation.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
 
 if ($origin != 'learnpath') {
     Display::display_header('');
@@ -272,29 +272,29 @@ if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLa
 $i = $totalScore = $totalWeighting = 0;
 
 if ($debug > 0) {
-    error_log("ExerciseResult: " . print_r($exerciseResult, 1));
-    error_log("QuestionList: " . print_r($questionList, 1));
+    error_log("ExerciseResult: ".print_r($exerciseResult, 1));
+    error_log("QuestionList: ".print_r($questionList, 1));
 }
 
 $arrques = array();
 $arrans = array();
 
-$user_restriction = $is_allowedToEdit ? '' : "AND user_id=" . intval($student_id) . " ";
+$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
 $sql = "SELECT attempts.question_id, answer
         FROM $TBL_TRACK_ATTEMPT as attempts
-        INNER JOIN " . $TBL_TRACK_EXERCISES . " AS stats_exercises
+        INNER JOIN ".$TBL_TRACK_EXERCISES." AS stats_exercises
         ON stats_exercises.exe_id=attempts.exe_id
         INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions
         ON
             quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND
             quizz_rel_questions.question_id = attempts.question_id AND
-            quizz_rel_questions.c_id=" . api_get_course_int_id() . "
-        INNER JOIN " . $TBL_QUESTIONS . " AS questions
+            quizz_rel_questions.c_id=".api_get_course_int_id()."
+        INNER JOIN " . $TBL_QUESTIONS." AS questions
         ON
             questions.id=quizz_rel_questions.question_id AND
-            questions.c_id = " . api_get_course_int_id() . "
+            questions.c_id = " . api_get_course_int_id()."
         WHERE
-            attempts.exe_id = " . intval($id) . " $user_restriction
+            attempts.exe_id = " . intval($id)." $user_restriction
 		GROUP BY quizz_rel_questions.question_order, attempts.question_id";
 
 $result = Database::query($sql);
@@ -526,26 +526,26 @@ foreach ($questionList as $questionId) {
                 $table_resume = '<table class="data_table">
                     <tr class="row_odd" >
                     <td></td>
-                    <td ><b>' . get_lang('Requirements') . '</b></td>
-                    <td><b>' . get_lang('YourAnswer') . '</b></td>
+                    <td ><b>' . get_lang('Requirements').'</b></td>
+                    <td><b>' . get_lang('YourAnswer').'</b></td>
                     </tr>
         
                     <tr class="row_even">
-                    <td><b>' . get_lang('Overlap') . '</b></td>
-                    <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
-                        <td><div style="color:' . $overlap_color . '">' . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '</div></td>
+                    <td><b>' . get_lang('Overlap').'</b></td>
+                    <td>' . get_lang('Min').' '.$threadhold1.'</td>
+                        <td><div style="color:' . $overlap_color.'">'.(($final_overlap < 0) ? 0 : intval($final_overlap)).'</div></td>
                     </tr>
         
                     <tr>
-                        <td><b>' . get_lang('Excess') . '</b></td>
-                        <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
-                        <td><div style="color:' . $excess_color . '">' . (($final_excess < 0) ? 0 : intval($final_excess)) . '</div></td>
+                        <td><b>' . get_lang('Excess').'</b></td>
+                        <td>' . get_lang('Max').' '.$threadhold2.'</td>
+                        <td><div style="color:' . $excess_color.'">'.(($final_excess < 0) ? 0 : intval($final_excess)).'</div></td>
                     </tr>
         
                     <tr class="row_even">
-                        <td><b>' . get_lang('Missing') . '</b></td>
-                        <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
-                        <td><div style="color:' . $missing_color . '">' . (($final_missing < 0) ? 0 : intval($final_missing)) . '</div></td>
+                        <td><b>' . get_lang('Missing').'</b></td>
+                        <td>' . get_lang('Max').' '.$threadhold3.'</td>
+                        <td><div style="color:' . $missing_color.'">'.(($final_missing < 0) ? 0 : intval($final_missing)).'</div></td>
                     </tr></table>';
 
                 if ($answerType != HOT_SPOT_DELINEATION) {
@@ -569,25 +569,25 @@ foreach ($questionList as $questionId) {
                     }
                 }
 
-                echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>';
+                echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
                 if ($answerType == HOT_SPOT_DELINEATION) {
                     if ($organs_at_risk_hit > 0) {
-                        $message = '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
-                        $message .= '<p style="color:#DC0A0A;"><b>' . get_lang('OARHit') . '</b></p>';
+                        $message = '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
+                        $message .= '<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
                     } else {
-                        $message = '<p>' . get_lang('YourDelineation') . '</p>';
+                        $message = '<p>'.get_lang('YourDelineation').'</p>';
                         $message .= $table_resume;
-                        $message .= '<br />' . get_lang('ResultIs') . ' <b>' . $result_comment . '</b><br />';
+                        $message .= '<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
                     }
-                    $message .= '<p>' . $comment . '</p>';
+                    $message .= '<p>'.$comment.'</p>';
                     echo $message;
                 } else {
-                    echo '<p>' . $comment . '</p>';
+                    echo '<p>'.$comment.'</p>';
                 }
 
                 //showing the score
-                $queryfree = "SELECT marks from " . $TBL_TRACK_ATTEMPT . " 
-                              WHERE exe_id = " . intval($id) . " AND question_id= " . intval($questionId) . "";
+                $queryfree = "SELECT marks from ".$TBL_TRACK_ATTEMPT." 
+                              WHERE exe_id = " . intval($id)." AND question_id= ".intval($questionId)."";
                 $resfree = Database::query($queryfree);
                 $questionScore = Database::result($resfree, 0, "marks");
                 $totalScore += $questionScore;
@@ -673,8 +673,8 @@ foreach ($questionList as $questionId) {
         $marksname = '';
 
         if ($isFeedbackAllowed) {
-            $name = "fckdiv" . $questionId;
-            $marksname = "marksName" . $questionId;
+            $name = "fckdiv".$questionId;
+            $marksname = "marksName".$questionId;
             if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION))) {
                 $url_name = get_lang('EditCommentsAndMarks');
             } else {
@@ -685,32 +685,32 @@ foreach ($questionList as $questionId) {
                 }
             }
             echo '<br />';
-            echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('" . $name . "', '" . $marksname . "');"));
+            echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick' => "showfck('".$name."', '".$marksname."');"));
             echo '<br />';
 
-            echo '<div id="feedback_' . $name . '" style="width:100%">';
+            echo '<div id="feedback_'.$name.'" style="width:100%">';
             $comnt = trim(Event::get_comments($id, $questionId));
             if (empty($comnt)) {
                 echo '<br />';
             } else {
-                echo '<div id="question_feedback">' . $comnt . '</div>';
+                echo '<div id="question_feedback">'.$comnt.'</div>';
             }
             echo '</div>';
 
-            echo '<div id="' . $name . '" style="display:none">';
+            echo '<div id="'.$name.'" style="display:none">';
             $arrid[] = $questionId;
-            $feedback_form = new FormValidator('frmcomments' . $questionId, 'post', '');
+            $feedback_form = new FormValidator('frmcomments'.$questionId, 'post', '');
             $feedback_form->addElement('html', '<br>');
-            $renderer =& $feedback_form->defaultRenderer();
+            $renderer = & $feedback_form->defaultRenderer();
             $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>');
             $renderer->setCustomElementTemplate('<div align="left">{element}</div>');
             $comnt = Event::get_comments($id, $questionId);
-            $default = array('comments_' . $questionId => $comnt);
+            $default = array('comments_'.$questionId => $comnt);
 
             if ($useAdvancedEditor) {
                 $feedback_form->addElement(
                     'html_editor',
-                    'comments_' . $questionId,
+                    'comments_'.$questionId,
                     null,
                     null,
                     array(
@@ -720,7 +720,7 @@ foreach ($questionList as $questionId) {
                     )
                 );
             } else {
-                $feedback_form->addElement('textarea', 'comments_' . $questionId);
+                $feedback_form->addElement('textarea', 'comments_'.$questionId);
             }
             $feedback_form->addElement('html', '<br>');
             $feedback_form->setDefaults($default);
@@ -731,21 +731,21 @@ foreach ($questionList as $questionId) {
             $comnt = Event::get_comments($id, $questionId);
             echo '<br />';
             if (!empty($comnt)) {
-                echo '<b>' . get_lang('Feedback') . '</b>';
-                echo '<div id="question_feedback">' . $comnt . '</div>';
+                echo '<b>'.get_lang('Feedback').'</b>';
+                echo '<div id="question_feedback">'.$comnt.'</div>';
             }
         }
 
         if ($is_allowedToEdit && $isFeedbackAllowed) {
             if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION, ANNOTATION))) {
-                $marksname = "marksName" . $questionId;
-                echo '<div id="' . $marksname . '" style="display:none">';
-                echo '<form name="marksform_' . $questionId . '" method="post" action="">';
+                $marksname = "marksName".$questionId;
+                echo '<div id="'.$marksname.'" style="display:none">';
+                echo '<form name="marksform_'.$questionId.'" method="post" action="">';
                 $arrmarks[] = $questionId;
                 echo get_lang("AssignMarks");
                 echo "&nbsp;<select name='marks' id='marks'>";
                 for ($i = 0; $i <= $questionWeighting; $i++) {
-                    echo '<option ' . (($i == $questionScore) ? "selected='selected'" : '') . '>' . $i . '</option>';
+                    echo '<option '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$i.'</option>';
                 }
                 echo '</select>';
                 echo '</form><br /></div>';
@@ -756,8 +756,8 @@ foreach ($questionList as $questionId) {
                 }
             } else {
                 $arrmarks[] = $questionId;
-                echo '<div id="' . $marksname . '" style="display:none"><form name="marksform_' . $questionId . '" method="post" action="">
-					  <select name="marks" id="marks" style="display:none;"><option>' . $questionScore . '</option></select></form><br/ ></div>';
+                echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action="">
+					  <select name="marks" id="marks" style="display:none;"><option>' . $questionScore.'</option></select></form><br/ ></div>';
             }
         } else {
             if ($questionScore == -1) {
@@ -813,7 +813,7 @@ foreach ($questionList as $questionId) {
 
     $score = array();
     if ($show_results) {
-        $score['result'] = get_lang('Score') . " : " . ExerciseLib::show_score(
+        $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score(
             $my_total_score,
             $my_total_weight,
             false,
@@ -885,7 +885,7 @@ if ($isFeedbackAllowed) {
 
 if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress') {
     if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
-        $formUrl = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_report.php?' . api_get_cidreq() . '&';
+        $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
         $formUrl .= http_build_query([
             'exerciseId' => $exercise_id,
             'filter' => 2,
@@ -904,7 +904,7 @@ if ($isFeedbackAllowed && $origin != 'learnpath' && $origin != 'student_progress
         $emailForm->addHidden('total_score', $totalScore);
         $emailForm->addHidden('my_exe_exo_id', $exercise_id);
     } else {
-        $formUrl = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_report.php?' . api_get_cidreq() . '&';
+        $formUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidreq().'&';
         $formUrl .= http_build_query([
             'exerciseId' => $exercise_id,
             'filter' => 1,
@@ -974,7 +974,7 @@ if ($origin != 'learnpath') {
 } else {
     if (!isset($_GET['fb_type'])) {
         $lp_mode = $_SESSION['lp_mode'];
-        $url = '../lp/lp_controller.php?' . api_get_cidreq() . '&';
+        $url = '../lp/lp_controller.php?'.api_get_cidreq().'&';
         $url .= http_build_url([
             'action' => 'view',
             'lp_id' => $learnpath_id,
@@ -982,13 +982,13 @@ if ($origin != 'learnpath') {
             'exeId' => $exeId,
             'fb_type' => $feedback_type
         ]);
-        $href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" ';
-        echo '<script type="text/javascript">' . $href . '</script>';
+        $href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'" ';
+        echo '<script type="text/javascript">'.$href.'</script>';
         // Record the results in the learning path, using the SCORM interface (API)
         echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>";
         echo '</body></html>';
     } else {
-        Display::display_normal_message(get_lang('ExerciseFinished') . ' ' . get_lang('ToContinueUseMenu'));
+        Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));
         echo '<br />';
     }
 }

+ 66 - 66
main/exercise/exercise_submit.php

@@ -29,7 +29,7 @@ use ChamiloSession as Session;
 */
 
 require_once __DIR__.'/../inc/global.inc.php';
-$current_course_tool  = TOOL_QUIZ;
+$current_course_tool = TOOL_QUIZ;
 $this_section = SECTION_COURSES;
 $debug = false;
 
@@ -60,15 +60,15 @@ $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epicloc
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
 $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
 $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'annotation/js/annotation.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
 
 if (api_get_setting('enable_record_audio') === 'true') {
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'rtc/RecordRTC.js"></script>';
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/recorder.js"></script>';
-    $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'wami-recorder/gui.js"></script>';
-    $htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'swfobject/swfobject.js"></script>';
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
+    $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
+    $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
 }
 
 $template = new Template();
@@ -76,7 +76,7 @@ $template = new Template();
 // General parameters passed via POST/GET
 $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : 0;
 $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : 0;
-$learnpath_item_view_id	= isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
+$learnpath_item_view_id = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : 0;
 
 $reminder = isset($_REQUEST['reminder']) ? intval($_REQUEST['reminder']) : 0;
 $remind_question_id = isset($_REQUEST['remind_question_id']) ? intval($_REQUEST['remind_question_id']) : 0;
@@ -179,7 +179,7 @@ $_SESSION['duration_time'][$current_expired_time_key] = $current_timestamp;
 
 if ($time_control) {
     // Get the expired time of the current exercise in track_e_exercises
-    $total_seconds = $objExercise->expired_time*60;
+    $total_seconds = $objExercise->expired_time * 60;
 }
 
 $show_clock = true;
@@ -327,12 +327,12 @@ if (empty($exercise_stat_info)) {
 		if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp);
 		if ($debug) error_log('5.2. $expected_time '.$expected_time);
 
-		$clock_expired_time 	= api_get_utc_datetime($expected_time);
+		$clock_expired_time = api_get_utc_datetime($expected_time);
 		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
 
 		//Sessions  that contain the expired time
-		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
+		$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
+		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
 	}
 
     $exe_id = $objExercise->save_stat_track_exercise_info(
@@ -447,22 +447,22 @@ if ($time_control) {
 	    	   the track_et_attempt see #2069 */
 	    	if (empty($last_attempt_date)) {
 	    		$diff = $current_timestamp - api_strtotime($exercise_stat_info['start_date'], 'UTC');
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'],'UTC') + $diff);
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($exercise_stat_info['start_date'], 'UTC') + $diff);
 	    	} else {
 	    		//Recalculate the time control due #2069
-	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
-	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
+	    		$diff = $current_timestamp - api_strtotime($last_attempt_date, 'UTC');
+	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff);
 	    	}
 	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
 
 	        //New expired time - it is due to the possible closure of session
-	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
+	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC');
 	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }
 
-	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
+	        $expected_time = $current_timestamp + $new_expired_time_in_seconds;
 	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
 
-	        $clock_expired_time  = api_get_utc_datetime($expected_time);
+	        $clock_expired_time = api_get_utc_datetime($expected_time);
 	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
 
 			// First we update the attempt to today
@@ -478,7 +478,7 @@ if ($time_control) {
 
 	        //Sessions  that contain the expired time
 	        $_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
+	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
         }
     } else {
         $clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
@@ -488,7 +488,7 @@ if ($time_control) {
 }
 
 // Get time left for expiring time
-$time_left = api_strtotime($clock_expired_time,'UTC') - time();
+$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
 
 /*
  * The time control feature is enable here - this feature is enable for a jquery plugin called epiclock
@@ -540,7 +540,7 @@ if ($formSent && isset($_POST)) {
 
     //Only for hotspot
     if (!isset($choice) && isset($_REQUEST['hidden_hotspot_id'])) {
-        $hotspot_id = (int)($_REQUEST['hidden_hotspot_id']);
+        $hotspot_id = (int) ($_REQUEST['hidden_hotspot_id']);
         $choice     = array($hotspot_id => '');
     }
 
@@ -574,7 +574,7 @@ if ($formSent && isset($_POST)) {
                     if (isset($exe_id)) {
                     	// Manage the question and answer attempts
                         if ($debug) {
-                            error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1));
+                            error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice, 1));
                         }
                         $objExercise->manage_answer(
                             $exe_id,
@@ -594,13 +594,13 @@ if ($formSent && isset($_POST)) {
             }
         }
         if ($debug) { error_log('9.3.  $choice is an array - end'); }
-        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult,1)); }
+        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult, 1)); }
     }
 
     // the script "exercise_result.php" will take the variable $exerciseResult from the session
     Session::write('exerciseResult', $exerciseResult);
 //    Session::write('remind_list', $remind_list);
-    Session::write('exerciseResultCoordinates',$exerciseResultCoordinates);
+    Session::write('exerciseResultCoordinates', $exerciseResultCoordinates);
 
     // if all questions on one page OR if it is the last question (only for an exercise with one question per page)
     if ($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count) {
@@ -727,15 +727,15 @@ if (!empty ($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
 }
 
 if (!empty ($gradebook) && $gradebook == 'view') {
-    $interbreadcrumb[] = array ('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
+    $interbreadcrumb[] = array('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('ToolGradebook'));
 }
 
-$interbreadcrumb[] = array ("url" => "exercise.php?".api_get_cidreq(),	"name" => get_lang('Exercises'));
-$interbreadcrumb[] = array ("url" => "#", "name" => $objExercise->name);
+$interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(), "name" => get_lang('Exercises'));
+$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
 
 if ($origin != 'learnpath') { //so we are not in learnpath tool
-    Display :: display_header(null,'Exercises');
-    if (!api_is_allowed_to_session_edit() ) {
+    Display :: display_header(null, 'Exercises');
+    if (!api_is_allowed_to_session_edit()) {
         Display :: display_warning_message(get_lang('SessionIsReadOnly'));
     }
 } else {
@@ -754,9 +754,9 @@ $show_quiz_edition = $objExercise->added_in_lp();
 if (api_is_course_admin() && $origin != 'learnpath') {
     echo '<div class="actions">';
     if ($show_quiz_edition == false) {
-    	echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
+    	echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
     } else {
-    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
+    	echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';
     }
     echo '</div>';
 }
@@ -795,7 +795,7 @@ if ($limit_time_exists) {
     }
 
     if (!$permission_to_start || $exercise_timeover) {
-        if (!api_is_allowed_to_edit(null,true)) {
+        if (!api_is_allowed_to_edit(null, true)) {
             $message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
             Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
             if ($origin != 'learnpath') {
@@ -838,7 +838,7 @@ if ($origin != 'learnpath') {
    echo '<div id="highlight-plugin" class="glossary-content">';
 }
 
-if ($reminder == 2)  {
+if ($reminder == 2) {
     if ($debug) { error_log(' $reminder == 2'); }
 
     $data_tracking  = $exercise_stat_info['data_tracking'];
@@ -848,14 +848,14 @@ if ($reminder == 2)  {
     if (!empty($my_remind_list)) {
     	//Checking which questions we are going to call from the remind list
 		for ($i = 0; $i < count($data_tracking); $i++) {
-			for($j = 0; $j < count($my_remind_list); $j++) {
+			for ($j = 0; $j < count($my_remind_list); $j++) {
 
 				if (!empty($remind_question_id)) {
 					if ($remind_question_id == $my_remind_list[$j]) {
 
 			        	if ($remind_question_id == $data_tracking[$i]) {
-			        		if (isset($my_remind_list[$j+1])) {
-			        			$remind_question_id = $my_remind_list[$j+1];
+			        		if (isset($my_remind_list[$j + 1])) {
+			        			$remind_question_id = $my_remind_list[$j + 1];
 			        			$current_question = $i + 1;
 			        		} else {
                                 // We end the remind list we go to the exercise_reminder.php please
@@ -867,8 +867,8 @@ if ($reminder == 2)  {
 					}
 				} else {
 					if ($my_remind_list[$j] == $data_tracking[$i]) {
-						if (isset($my_remind_list[$j+1])) {
-							$remind_question_id = $my_remind_list[$j+1];
+						if (isset($my_remind_list[$j + 1])) {
+							$remind_question_id = $my_remind_list[$j + 1];
 							$current_question = $i + 1; // last question
 						} else {
                             // We end the remind list we go to the exercise_reminder.php please
@@ -899,7 +899,7 @@ if (!empty($error)) {
     Display::addFlash(Display::return_message($error, 'error', false));
 } else {
     if (!empty ($exercise_sound)) {
-        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . Security::remove_XSS($exercise_sound) . "\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound') . "\" /></a>";
+        echo "<a href=\"../document/download.php?doc_url=%2Faudio%2F".Security::remove_XSS($exercise_sound)."\" target=\"_blank\">", "<img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=", get_lang('Sound')."\" /></a>";
     }
     // Get number of hotspot questions for javascript validation
     $number_of_hotspot_questions = 0;
@@ -930,7 +930,7 @@ if (!empty($error)) {
     }
 
     if ($number_of_hotspot_questions > 0) {
-        $onsubmit = "onsubmit=\"return validateFlashVar('" . $number_of_hotspot_questions . "', '" . get_lang('HotspotValidateError1') . "', '" . get_lang('HotspotValidateError2') . "');\"";
+        $onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
     }
 
     echo '<script>
@@ -944,7 +944,7 @@ if (!empty($error)) {
                 ICON_SIZE_SMALL,
                 false,
                 true
-            ) . '\';
+            ).'\';
 
             // Block form submition on enter
             $(".block_on_enter").keypress(function(event) {
@@ -1040,7 +1040,7 @@ if (!empty($error)) {
             } else {
                 url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
             }
-            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
+            //$("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
             window.location = url;
         }
 
@@ -1072,7 +1072,7 @@ if (!empty($error)) {
 
             // Only for the first time
 
-            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin') . '\');
+            $("#save_for_now_"+question_id).html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
             $.ajax({
                 type:"post",
                 async: false,
@@ -1080,9 +1080,9 @@ if (!empty($error)) {
                 data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
                 success: function(return_value) {
                     if (return_value == "ok") {
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
                     } else if (return_value == "error") {
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
                     } else if (return_value == "one_per_page") {
                         var url = "";
                         if ('.$reminder.' == 1 ) {
@@ -1097,13 +1097,13 @@ if (!empty($error)) {
                             url = url_extra;
                         }
 
-                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL) . '\');
+                        $("#save_for_now_"+question_id).html(\'' . Display::return_icon('save.png', get_lang('Saved'), array(), ICON_SIZE_SMALL).'\');
 
                         window.location = url;
                     }
                 },
                 error: function() {
-                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL) . '\');
+                    $("#save_for_now_"+question_id).html(\'' . Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL).'\');
                 }
             });
         }
@@ -1135,7 +1135,7 @@ if (!empty($error)) {
 
             free_answers = $.param(free_answers);
 
-            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin') . '\');
+            $("#save_all_reponse").html(\'' . Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
 
             $.ajax({
                 type:"post",
@@ -1144,14 +1144,14 @@ if (!empty($error)) {
                 data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
                 success: function(return_value) {
                     if (return_value == "ok") {
-                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
+                        //$("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
                         if (validate == "validate") {
                             window.location = "'.$script_php.'?'.$params.'";
                         } else {
-                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png') . '\');
+                            $("#save_all_reponse").html(\'' . Display::return_icon('accept.png').'\');
                         }
                     } else {
-                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif') . '\');
+                        $("#save_all_reponse").html(\'' . Display::return_icon('wrong.gif').'\');
                     }
                 }
             });
@@ -1163,16 +1163,16 @@ if (!empty($error)) {
         }
     </script>';
 
-    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId .'" name="frm_exercise" '.$onsubmit.'>
+    echo '<form id="exercise_form" method="post" action="'.api_get_self().'?'.api_get_cidreq().'&autocomplete=off&&exerciseId='.$exerciseId.'" name="frm_exercise" '.$onsubmit.'>
          <input type="hidden" name="formSent"				value="1" />
-         <input type="hidden" name="exerciseId" 			value="'.$exerciseId . '" />
+         <input type="hidden" name="exerciseId" 			value="'.$exerciseId.'" />
          <input type="hidden" name="num" 					value="'.$current_question.'" id="num_current_id" />
          <input type="hidden" name="num_answer"             value="'.$currentAnswer.'" id="num_current_answer_id" />
-         <input type="hidden" name="exe_id" 				value="'.$exe_id . '" />
-         <input type="hidden" name="origin" 				value="'.$origin . '" />
-         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id . '" />
-         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id . '" />
-         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id . '" />';
+         <input type="hidden" name="exe_id" 				value="'.$exe_id.'" />
+         <input type="hidden" name="origin" 				value="'.$origin.'" />
+         <input type="hidden" name="learnpath_id" 			value="'.$learnpath_id.'" />
+         <input type="hidden" name="learnpath_item_id" 		value="'.$learnpath_item_id.'" />
+         <input type="hidden" name="learnpath_item_view_id" value="'.$learnpath_item_view_id.'" />';
 
 	// Show list of questions
     $i = 1;
@@ -1229,7 +1229,7 @@ if (!empty($error)) {
             $remind_highlight = 'no_remind_highlight';
         }
 
-        $exercise_actions  = '';
+        $exercise_actions = '';
         $is_remind_on = false;
 
         $attributes = array('id' =>'remind_list['.$questionId.']');
@@ -1242,7 +1242,7 @@ if (!empty($error)) {
 
         // Showing the exercise description
         if (!empty($objExercise->description)) {
-            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i==1)) {
+            if ($objExercise->type == ONE_PER_PAGE || ($objExercise->type != ONE_PER_PAGE && $i == 1)) {
                 echo Display::panelCollapse('<span>'.
                     get_lang('ExerciseDescriptionLabel').'</span>',
                     $objExercise->description,
@@ -1284,7 +1284,7 @@ if (!empty($error)) {
                     ),
                     '<span id="save_for_now_'.$questionId.'"></span>&nbsp;'
                 ];
-                $exercise_actions  .= Display::div(
+                $exercise_actions .= Display::div(
                     implode(PHP_EOL, $button),
                     array('class'=>'exercise_save_now_button')
                 );
@@ -1297,13 +1297,13 @@ if (!empty($error)) {
                 'label',
                 Display::input(
                     'checkbox',
-                    'remind_list[' . $questionId . ']',
+                    'remind_list['.$questionId.']',
                     '',
                     $attributes
-                ) . get_lang('ReviewQuestionLater'),
+                ).get_lang('ReviewQuestionLater'),
                 array(
                     'class' => 'checkbox',
-                    'for' => 'remind_list[' . $questionId . ']'
+                    'for' => 'remind_list['.$questionId.']'
                 )
             );
             $exercise_actions .= Display::div($remind_question_div, array('class'=>'exercise_save_now_button'));
@@ -1320,7 +1320,7 @@ if (!empty($error)) {
     }
     // end foreach()
     if ($objExercise->type == ALL_ON_ONE_PAGE) {
-    	$exercise_actions =  $objExercise->show_button($questionId, $current_question);
+    	$exercise_actions = $objExercise->show_button($questionId, $current_question);
     	echo Display::div($exercise_actions, array('class'=>'exercise_actions'));
         echo '<br>';
     }

+ 8 - 8
main/exercise/export/exercise_import.php

@@ -30,21 +30,21 @@ $nameTools = get_lang('ImportExercise');
 $interbredcrump[] = array('url' => '../exercise.php', 'name' => get_lang('Exercises'));
 
 // EXECUTE COMMAND
-$cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import');
+$cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import');
 
 switch ($cmd) {
     case 'show_import':
         $display = '<p>'
-            .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.') . '<br>'
+            .            get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'<br>'
             .            '</p>'
             .            '<form enctype="multipart/form-data" action="" method="post">'
             .            '<input name="cmd" type="hidden" value="import" />'
             .            '<input name="uploadedExercise" type="file" /><br><br>'
-            .            get_lang('Import exercise') . ' : '
-            .            '<input value="' . get_lang('Ok') . '" type="submit" /> '
-            .            claro_html_button( $_SERVER['PHP_SELF'], get_lang('Cancel'))
+            .            get_lang('Import exercise').' : '
+            .            '<input value="'.get_lang('Ok').'" type="submit" /> '
+            .            claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
             .            '<br><br>'
-            .            '<small>' . get_lang('Max file size') . ' :  2&nbsp;MB</small>'
+            .            '<small>'.get_lang('Max file size').' :  2&nbsp;MB</small>'
             .            '</form>';
         break;
     case 'import':
@@ -60,7 +60,7 @@ switch ($cmd) {
 
 
 // DISPLAY
-include api_get_path(SYS_INC_PATH) . '/header.inc.php';
+include api_get_path(SYS_INC_PATH).'/header.inc.php';
 
 // Tool introduction
 // TODO: These settings to be checked when it is possible.
@@ -82,4 +82,4 @@ if (isset($display)) {
     echo $display;
 }
 
-include api_get_path(SYS_INC_PATH) . '/footer.inc.php';
+include api_get_path(SYS_INC_PATH).'/footer.inc.php';

+ 3 - 3
main/exercise/live_stats.php

@@ -41,7 +41,7 @@ $minutes = 60;
 $url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
 
 //The order is important you need to check the the $column variable in the model.ajax.php file
-$columns        = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
+$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
 
 //Column config
 $column_model = array(
@@ -109,8 +109,8 @@ $(function() {
 </script>
 <?php
 
-$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">' .
-    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
+$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'&'.api_get_cidreq().'">'.
+    Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
 echo $actions = Display::div($actions, array('class'=> 'actions'));
 
 echo Display::grid_html('live_stats');

+ 12 - 12
main/exercise/matching.class.php

@@ -69,12 +69,12 @@ class Matching extends Question
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                     if ($answer->isCorrect($i)) {
                         $nb_matches++;
-                        $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
-                        $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
-                        $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
+                        $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i);
+                        $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1);
+                        $defaults['matches['.$nb_matches.']'] = $answer->correct[$i];
                     } else {
                         $nb_options++;
-                        $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
+                        $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i);
                     }
                 }
             }
@@ -105,10 +105,10 @@ class Matching extends Question
         $html = '<table class="table table-striped table-hover">
             <thead>
                 <tr>
-                    <th width="5%">' . get_lang('Number') . '</th>
-                    <th width="70%">' . get_lang('Answer') . '</th>
-                    <th width="15%">' . get_lang('MatchesTo') . '</th>
-                    <th width="10%">' . get_lang('Weighting') . '</th>
+                    <th width="5%">' . get_lang('Number').'</th>
+                    <th width="70%">' . get_lang('Answer').'</th>
+                    <th width="15%">' . get_lang('MatchesTo').'</th>
+                    <th width="10%">' . get_lang('Weighting').'</th>
                 </tr>
             </thead>
             <tbody>';
@@ -177,8 +177,8 @@ class Matching extends Question
         $html = '<table class="table table-striped table-hover">
             <thead>
                 <tr>
-                    <th width="15%">' . get_lang('Number') . '</th>
-                    <th width="85%">' . get_lang('Answer') . '</th>
+                    <th width="15%">' . get_lang('Number').'</th>
+                    <th width="85%">' . get_lang('Answer').'</th>
                 </tr>
             </thead>
             <tbody>';
@@ -200,7 +200,7 @@ class Matching extends Question
             );
 
             $form->addHtml('<tr>');
-            $form->addHtml('<td>' . chr(64 + $i) . '</td>');
+            $form->addHtml('<td>'.chr(64 + $i).'</td>');
             $form->addHtmlEditor(
                 "option[$i]",
                 null,
@@ -286,7 +286,7 @@ class Matching extends Question
     public function return_header($feedback_type = null, $counter = null, $score = null)
     {
         $header = parent::return_header($feedback_type, $counter, $score);
-        $header .= '<table class="'.$this->question_table_class .'">';
+        $header .= '<table class="'.$this->question_table_class.'">';
         $header .= '<tr>
                 <th>'.get_lang('ElementList').'</th>
                 <th>'.get_lang('CorrespondsTo').'</th>

+ 26 - 26
main/exercise/multiple_answer_true_false.class.php

@@ -45,14 +45,14 @@ class MultipleAnswerTrueFalse extends Question
         $html = '<table class="table table-striped table-hover">';
         $html .= '<thead>';
         $html .= '<tr>';
-        $html .= '<th>' . get_lang('Number') . '</th>';
-        $html .= '<th>' . get_lang('True') . '</th>';
-        $html .= '<th>' . get_lang('False') . '</th>';
-        $html .= '<th>' . get_lang('Answer') . '</th>';
+        $html .= '<th>'.get_lang('Number').'</th>';
+        $html .= '<th>'.get_lang('True').'</th>';
+        $html .= '<th>'.get_lang('False').'</th>';
+        $html .= '<th>'.get_lang('Answer').'</th>';
 
         // show column comment when feedback is enable
         if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
-            $html .= '<th>' . get_lang('Comment') . '</th>';
+            $html .= '<th>'.get_lang('Comment').'</th>';
         }
 
         $html .= '</tr>';
@@ -88,19 +88,19 @@ class MultipleAnswerTrueFalse extends Question
 
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'correct[' . $i . ']'
+                'correct['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'counter[' . $i . ']'
+                'counter['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'answer[' . $i . ']'
+                'answer['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'comment[' . $i . ']'
+                'comment['.$i.']'
             );
 
             $answer_number = $form->addElement(
@@ -113,15 +113,15 @@ class MultipleAnswerTrueFalse extends Question
             $answer_number->freeze();
 
             if (is_object($answer)) {
-                $defaults['answer[' . $i . ']'] = $answer->answer[$i];
-                $defaults['comment[' . $i . ']'] = $answer->comment[$i];
+                $defaults['answer['.$i.']'] = $answer->answer[$i];
+                $defaults['comment['.$i.']'] = $answer->comment[$i];
                 $correct = $answer->correct[$i];
-                $defaults['correct[' . $i . ']'] = $correct;
+                $defaults['correct['.$i.']'] = $correct;
 
                 $j = 1;
                 if (!empty($optionData)) {
                     foreach ($optionData as $id => $data) {
-                        $form->addElement('radio', 'correct[' . $i . ']', null, null, $id);
+                        $form->addElement('radio', 'correct['.$i.']', null, null, $id);
                         $j++;
                         if ($j == 3) {
                             break;
@@ -129,12 +129,12 @@ class MultipleAnswerTrueFalse extends Question
                     }
                 }
             } else {
-                $form->addElement('radio', 'correct[' . $i . ']', null, null, 1);
-                $form->addElement('radio', 'correct[' . $i . ']', null, null, 2);
+                $form->addElement('radio', 'correct['.$i.']', null, null, 1);
+                $form->addElement('radio', 'correct['.$i.']', null, null, 2);
 
-                $defaults['answer[' . $i . ']'] = '';
-                $defaults['comment[' . $i . ']'] = '';
-                $defaults['correct[' . $i . ']'] = '';
+                $defaults['answer['.$i.']'] = '';
+                $defaults['comment['.$i.']'] = '';
+                $defaults['correct['.$i.']'] = '';
             }
 
             $form->addHtmlEditor(
@@ -149,7 +149,7 @@ class MultipleAnswerTrueFalse extends Question
             if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
                 $form->addElement(
                     'html_editor',
-                    'comment[' . $i . ']',
+                    'comment['.$i.']',
                     null,
                     array(),
                     array(
@@ -167,22 +167,22 @@ class MultipleAnswerTrueFalse extends Question
 
         $correctInputTemplate = '<div class="form-group">';
         $correctInputTemplate .= '<label class="col-sm-2 control-label">';
-        $correctInputTemplate .= '<span class="form_required">*</span>' . get_lang('Score');
+        $correctInputTemplate .= '<span class="form_required">*</span>'.get_lang('Score');
         $correctInputTemplate .= '</label>';
         $correctInputTemplate .= '<div class="col-sm-8">';
         $correctInputTemplate .= '<table>';
         $correctInputTemplate .= '<tr>';
         $correctInputTemplate .= '<td>';
-        $correctInputTemplate .= get_lang('Correct') . '{element}';
+        $correctInputTemplate .= get_lang('Correct').'{element}';
         $correctInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
         $correctInputTemplate .= '</td>';
 
         $wrongInputTemplate = '<td>';
-        $wrongInputTemplate .= get_lang('Wrong') . '{element}';
+        $wrongInputTemplate .= get_lang('Wrong').'{element}';
         $wrongInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
         $wrongInputTemplate .= '</td>';
 
-        $doubtScoreInputTemplate = '<td>' . get_lang('DoubtScore') . '<br>{element}';
+        $doubtScoreInputTemplate = '<td>'.get_lang('DoubtScore').'<br>{element}';
         $doubtScoreInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
         $doubtScoreInputTemplate .= '</td>';
         $doubtScoreInputTemplate .= '</tr>';
@@ -211,7 +211,7 @@ class MultipleAnswerTrueFalse extends Question
 
             if (!empty($scores)) {
                 for ($i = 1; $i <= 3; $i++) {
-                    $defaults['option[' . $i . ']'] = $scores[$i - 1];
+                    $defaults['option['.$i.']'] = $scores[$i - 1];
                 }
             }
         }
@@ -282,7 +282,7 @@ class MultipleAnswerTrueFalse extends Question
         $extra_values = array();
         for ($i = 1; $i <= 3; $i++) {
             $score = trim($form -> getSubmitValue('option['.$i.']'));
-            $extra_values[]= $score;
+            $extra_values[] = $score;
         }
         $this->setExtra(implode(':', $extra_values));
 
@@ -315,7 +315,7 @@ class MultipleAnswerTrueFalse extends Question
     function return_header($feedback_type = null, $counter = null, $score = null)
     {
         $header = parent::return_header($feedback_type, $counter, $score);
-        $header .= '<table class="'.$this->question_table_class .'">
+        $header .= '<table class="'.$this->question_table_class.'">
         <tr>
             <th>'.get_lang("Choice").'</th>
             <th>'. get_lang("ExpectedChoice").'</th>

+ 14 - 15
main/exercise/question_list_admin.inc.php

@@ -136,7 +136,7 @@ $ajax_url = api_get_path(WEB_AJAX_PATH)."exercise.ajax.php?".api_get_cidreq()."&
             .sortable({
                 cursor: "move", // works?
                 update: function(event, ui) {
-                    var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo intval($_GET['exerciseId']);?>";
+                    var order = $(this).sortable("serialize") + "&a=update_question_order&exercise_id=<?php echo intval($_GET['exerciseId']); ?>";
                     $.post("<?php echo $ajax_url ?>", order, function(reponse){
                         $("#message").html(reponse);
                     });
@@ -172,12 +172,12 @@ if (!$inATest) {
     echo "<div class='table-responsive'>";
     echo "<table class='table table-condensed'>";
     echo "<tr>";
-    echo "<th style=\"width: 40%;\">" .get_lang('Questions'). "</th>";
-    echo "<th style=\"width: 10%;\">" .get_lang('Type'). "</th>";
-    echo "<th style=\"width: 20%;\">" .get_lang('Category'). "</th>";
-    echo "<th style=\"width: 10%;\">" .get_lang('Difficulty'). "</th>";
-    echo "<th style=\"width: 10%;\">" .get_lang('MaximumScore'). "</th>";
-    echo "<th style=\"width: 10%;\">" .get_lang('Actions'). "</th>";
+    echo "<th style=\"width: 40%;\">".get_lang('Questions')."</th>";
+    echo "<th style=\"width: 10%;\">".get_lang('Type')."</th>";
+    echo "<th style=\"width: 20%;\">".get_lang('Category')."</th>";
+    echo "<th style=\"width: 10%;\">".get_lang('Difficulty')."</th>";
+    echo "<th style=\"width: 10%;\">".get_lang('MaximumScore')."</th>";
+    echo "<th style=\"width: 10%;\">".get_lang('Actions')."</th>";
     echo "</tr>";
     echo "</table>";
     echo "</div>";
@@ -227,8 +227,7 @@ if (!$inATest) {
                         get_lang('QuestionEditionNotAvailableBecauseItIsAlreadyAnsweredHoweverYouCanCopyItAndModifyTheCopy'),
                         array(),
                         ICON_SIZE_SMALL
-                    ).'</a>' :
-                    '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.
+                    ).'</a>' : '<a href="'.api_get_self().'?'.api_get_cidreq().'&type='.
                     $objQuestionTmp->selectType().'&myid=1&editQuestion='.$id.'">'.
                     Display::return_icon(
                         'edit.png',
@@ -238,17 +237,17 @@ if (!$inATest) {
                     ).'</a>';
                 $delete_link = null;
                 if ($objExercise->edit_exercise_in_lp == true) {
-                    $delete_link = '<a id="delete_'.$id.'" class="opener"  href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" >'.Display::return_icon('delete.png',get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL).'</a>';
+                    $delete_link = '<a id="delete_'.$id.'" class="opener"  href="'.api_get_self().'?'.api_get_cidreq().'&exerciseId='.$exerciseId.'&deleteQuestion='.$id.'" >'.Display::return_icon('delete.png', get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL).'</a>';
                 }
 
-                $edit_link = Display::tag('span', $edit_link,   array('class'=>'items'));
-                $clone_link = Display::tag('span', $clone_link,  array('class'=>'items'));
+                $edit_link = Display::tag('span', $edit_link, array('class'=>'items'));
+                $clone_link = Display::tag('span', $clone_link, array('class'=>'items'));
                 $delete_link = Display::tag('span', $delete_link, array('class'=>'items'));
-                $btnActions = Display::tag('td',Display::tag(
+                $btnActions = Display::tag('td', Display::tag(
                     'div',
                     $edit_link.$clone_link.$delete_link,
                     array('class'=>'edition')
-                ), array ('class'=>'btn-actions'));
+                ), array('class'=>'btn-actions'));
 
                 $title = Security::remove_XSS($objQuestionTmp->selectTitle());
                 $move = Display::returnFontAwesomeIcon("arrows moved", 'lg');
@@ -285,7 +284,7 @@ if (!$inATest) {
                 $questionScore = Display::tag('td', $objQuestionTmp->selectWeighting(), array('class'=>$styleScore));
 
                 echo '<div id="question_id_list_'.$id.'" >';
-                echo '<div class="header_operations" data-exercise="' . $objExercise->selectId() . '" data-question="' . $id . '">';
+                echo '<div class="header_operations" data-exercise="'.$objExercise->selectId().'" data-question="'.$id.'">';
                 echo "<div class='table-responsive'>";
                 echo "<table class='table'>";
                 echo "<tr>";

+ 4 - 4
main/exercise/result.php

@@ -28,7 +28,7 @@ if (empty($id)) {
     api_not_allowed($show_headers);
 }
 
-$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
+$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor;
 
 // Getting results from the exe_id. This variable also contain all the information about the exercise
 $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
@@ -55,9 +55,9 @@ if (!$is_allowedToEdit) {
     }
 }
 
-$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'annotation/js/annotation.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
 
 if ($show_headers) {
     $interbreadcrumb[] = array(

+ 38 - 38
main/exercise/unique_answer_no_option.class.php

@@ -37,7 +37,7 @@ class UniqueAnswerNoOption extends Question
 
         $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
         //this line define how many question by default appear when creating a choice question
-        $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;  // The previous default value was 2. See task #1759.
+        $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3; // The previous default value was 2. See task #1759.
         $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
 
         /*
@@ -52,20 +52,20 @@ class UniqueAnswerNoOption extends Question
         if ($obj_ex->selectFeedbackType() == 1) {
             $editor_config['Width'] = '250';
             $editor_config['Height'] = '110';
-            $comment_title = '<th width="50%" >' . get_lang('Comment') . '</th>';
-            $feedback_title = '<th width="50%" >' . get_lang('Scenario') . '</th>';
+            $comment_title = '<th width="50%" >'.get_lang('Comment').'</th>';
+            $feedback_title = '<th width="50%" >'.get_lang('Scenario').'</th>';
         } else {
-            $comment_title = '<th width="50%">' . get_lang('Comment') . '</th>';
+            $comment_title = '<th width="50%">'.get_lang('Comment').'</th>';
         }
 
         $html = '<table class="table table-striped table-hover">';
         $html .= '<thead>';
         $html .= '<tr>';
-        $html .= '<th>' . get_lang('Number') . '</th>';
-        $html .= '<th>' . get_lang('True') . '</th>';
-        $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
-        $html .= $comment_title . $feedback_title;
-        $html .= '<th>' . get_lang('Weighting') . '</th>';
+        $html .= '<th>'.get_lang('Number').'</th>';
+        $html .= '<th>'.get_lang('True').'</th>';
+        $html .= '<th width="50%">'.get_lang('Answer').'</th>';
+        $html .= $comment_title.$feedback_title;
+        $html .= '<th>'.get_lang('Weighting').'</th>';
         $html .= '</tr>';
         $html .= '</thead>';
         $html .= '<tbody>';
@@ -130,9 +130,9 @@ class UniqueAnswerNoOption extends Question
                         $weight_result = '0';
                     }
 
-                    $defaults['answer[' . $i . ']'] = $answer_result;
-                    $defaults['comment[' . $i . ']'] = $answer->comment[$i];
-                    $defaults['weighting[' . $i . ']'] = $weight_result;
+                    $defaults['answer['.$i.']'] = $answer_result;
+                    $defaults['comment['.$i.']'] = $answer->comment[$i];
+                    $defaults['weighting['.$i.']'] = $weight_result;
 
                     $item_list = explode('@@', $answer->destination[$i]);
 
@@ -153,10 +153,10 @@ class UniqueAnswerNoOption extends Question
                         $url_result = $url;
                     }
 
-                    $temp_scenario['url' . $i] = $url_result;
-                    $temp_scenario['try' . $i] = $try_result;
-                    $temp_scenario['lp' . $i] = $lp;
-                    $temp_scenario['destination' . $i] = $list_dest;
+                    $temp_scenario['url'.$i] = $url_result;
+                    $temp_scenario['try'.$i] = $try_result;
+                    $temp_scenario['lp'.$i] = $lp;
+                    $temp_scenario['destination'.$i] = $list_dest;
                 }
             }
 
@@ -169,30 +169,30 @@ class UniqueAnswerNoOption extends Question
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'counter[' . $i . ']'
+                'counter['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'answer[' . $i . ']'
+                'answer['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'comment[' . $i . ']'
+                'comment['.$i.']'
             );
             $renderer->setElementTemplate(
                 '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-                'weighting[' . $i . ']'
+                'weighting['.$i.']'
             );
 
-            $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
+            $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
             $answer_number->freeze();
 
 
             $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"');
-            $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), $editor_config);
+            $form->addElement('html_editor', 'answer['.$i.']', null, array(), $editor_config);
 
-            $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), $editor_config);
-            $form->addElement('text', 'weighting[' . $i . ']', null, array('style' => 'width: 60px;', 'value' => '0'));
+            $form->addElement('html_editor', 'comment['.$i.']', null, array(), $editor_config);
+            $form->addElement('text', 'weighting['.$i.']', null, array('style' => 'width: 60px;', 'value' => '0'));
             $form->addElement('html', '</tr>');
             $i++;
         }
@@ -207,8 +207,8 @@ class UniqueAnswerNoOption extends Question
         $form->addHtml('<tr>');
 
         $defaults["counter[$i]"] = '-';
-        $defaults['answer[' . $i . ']'] = get_lang('DontKnow');
-        $defaults['weighting[' . $i . ']'] = '0';
+        $defaults['answer['.$i.']'] = get_lang('DontKnow');
+        $defaults['weighting['.$i.']'] = '0';
         $defaults['scenario'] = $temp_scenario;
         $renderer = & $form->defaultRenderer();
 
@@ -218,32 +218,32 @@ class UniqueAnswerNoOption extends Question
         );
         $renderer->setElementTemplate(
             '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-            'counter[' . $i . ']'
+            'counter['.$i.']'
         );
         $renderer->setElementTemplate(
             '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-            'answer[' . $i . ']'
+            'answer['.$i.']'
         );
         $renderer->setElementTemplate(
             '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-            'comment[' . $i . ']'
+            'comment['.$i.']'
         );
         $renderer->setElementTemplate(
             '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
-            'weighting[' . $i . ']'
+            'weighting['.$i.']'
         );
 
         $form
-            ->addElement('text', 'counter[' . $i . ']', null)
+            ->addElement('text', 'counter['.$i.']', null)
             ->freeze();
 
-        $form->addElement('hidden', 'position[' . $i . ']', '666');
+        $form->addElement('hidden', 'position['.$i.']', '666');
 
         $form->addElement('radio', 'correct', null, null, $i, ['class' => 'checkbox', 'disabled' => true]);
-        $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), $editor_config);
+        $form->addElement('html_editor', 'answer['.$i.']', null, array(), $editor_config);
 
-        $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
-        $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), $editor_config);
+        $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
+        $form->addElement('html_editor', 'comment['.$i.']', null, array(), $editor_config);
 
         //$form->addElement('select', 'destination'.$i, get_lang('SelectQuestion').' : ',$select_question,'multiple');
 
@@ -334,7 +334,7 @@ class UniqueAnswerNoOption extends Question
                 $destination_str.=$destination_id.';';
             }*/
 
-            $goodAnswer= ($correct == $i) ? true : false;
+            $goodAnswer = ($correct == $i) ? true : false;
 
             if ($goodAnswer) {
                 $nbrGoodAnswers++;
@@ -361,7 +361,7 @@ class UniqueAnswerNoOption extends Question
             }
 
             //1@@1;2;@@2;4;4;@@http://www.chamilo.org
-            $dest= $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
+            $dest = $try.'@@'.$lp.'@@'.$destination.'@@'.$url;
             $objAnswer->createAnswer(
                 $answer,
                 $goodAnswer,
@@ -404,7 +404,7 @@ class UniqueAnswerNoOption extends Question
 	function return_header($feedback_type = null, $counter = null, $score = null)
     {
 	    $header = parent::return_header($feedback_type, $counter, $score);
-	    $header .= '<table class="'.$this->question_table_class .'">
+	    $header .= '<table class="'.$this->question_table_class.'">
 			<tr>
 				<th>'.get_lang("Choice").'</th>
 				<th>'. get_lang("ExpectedChoice").'</th>

+ 41 - 41
main/forum/viewforumcategory.php

@@ -57,11 +57,11 @@ $origin = api_get_origin();
 /* Header and Breadcrumbs */
 $gradebook = null;
 if (isset($_SESSION['gradebook'])) {
-    $gradebook=	$_SESSION['gradebook'];
+    $gradebook = $_SESSION['gradebook'];
 }
 
 if (!empty($gradebook) && $gradebook == 'view') {
-    $interbreadcrumb[] = array (
+    $interbreadcrumb[] = array(
         'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
         'name' => get_lang('ToolGradebook')
     );
@@ -71,15 +71,15 @@ $sessionId = api_get_session_id();
 
 $current_forum_category = get_forum_categories($_GET['forumcategory']);
 $interbreadcrumb[] = array(
-    'url' => 'index.php?gradebook=' . $gradebook . '&search='
+    'url' => 'index.php?gradebook='.$gradebook.'&search='
         . Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')),
     'name' => get_lang('Forum')
 );
 
 if (!empty($_GET['action']) && !empty($_GET['content'])) {
-    if ($_GET['action']=='add' && $_GET['content']=='forum' ) {
+    if ($_GET['action'] == 'add' && $_GET['content'] == 'forum') {
         $interbreadcrumb[] = array(
-            'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='. $current_forum_category['cat_id'],
+            'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.$current_forum_category['cat_id'],
             'name' => $current_forum_category['cat_title']
         );
         $interbreadcrumb[] = array(
@@ -109,7 +109,7 @@ $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsn
 // then the user is not allowed here.
 if (
     !api_is_allowed_to_edit(false, true) AND
-    ( $current_forum_category && $current_forum_category['visibility'] == 0)
+    ($current_forum_category && $current_forum_category['visibility'] == 0)
 ) {
     api_not_allowed();
 }
@@ -119,10 +119,10 @@ $html  = '';
 $html .= '<div class="actions">';
 $html .= '<a href="index.php?gradebook='.$gradebook.'&'.api_get_cidreq().'">'.
     Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
-if (api_is_allowed_to_edit(false,true)) {
-    $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
-        . $current_forum_category['cat_id'] . '&action=add&content=forum"> '
-        . Display::return_icon('new_forum.png', get_lang('AddForum'), '', ICON_SIZE_MEDIUM) . '</a>';
+if (api_is_allowed_to_edit(false, true)) {
+    $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
+        . $current_forum_category['cat_id'].'&action=add&content=forum"> '
+        . Display::return_icon('new_forum.png', get_lang('AddForum'), '', ICON_SIZE_MEDIUM).'</a>';
 }
 $html .= search_link();
 $html .= '</div>';
@@ -182,7 +182,7 @@ if ($action_forums != 'add') {
     $forum_categories_list = '';
     $forumId = $forum_category['cat_id'];
     $forumTitle = $forum_category['cat_title'];
-    $linkForumCategory = 'viewforumcategory.php?' . api_get_cidreq() . '&forumcategory=' . strval(intval($forumId));
+    $linkForumCategory = 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.strval(intval($forumId));
     $descriptionCategory = $forum_category['cat_comment'];
     $icoCategory = Display::return_icon(
         'forum_blue.png',
@@ -193,16 +193,16 @@ if ($action_forums != 'add') {
 
     if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && $sessionId != 0)) {
 
-        $iconsEdit = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
-            . Security::remove_XSS($_GET['forumcategory']) . '&action=edit&content=forumcategory&id='
-            . '' . $forumId . '">'
-            . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
-        $iconsEdit .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
+        $iconsEdit = '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
+            . Security::remove_XSS($_GET['forumcategory']).'&action=edit&content=forumcategory&id='
+            . ''.$forumId.'">'
+            . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
+        $iconsEdit .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
             . Security::remove_XSS($_GET['forumcategory'])
-            . '&action=delete&content=forumcategory&id=' . $forumId
+            . '&action=delete&content=forumcategory&id='.$forumId
             . "\" onclick=\"javascript:if(!confirm('"
             . addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES))
-            . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
+            . "')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
             . '</a>';
         $iconsEdit .= return_visible_invisible_icon(
             'forumcategory', $forum_category['cat_id'],
@@ -242,7 +242,7 @@ if ($action_forums != 'add') {
     );
 
 
-    if ($descriptionCategory != '' && trim($descriptionCategory)!= '&nbsp;') {
+    if ($descriptionCategory != '' && trim($descriptionCategory) != '&nbsp;') {
         $html .= '<div class="forum-description">'.$descriptionCategory.'</div>';
     }
 
@@ -333,9 +333,9 @@ if ($action_forums != 'add') {
                         ? $all_groups[$forum['forum_of_group']]['id']
                         : null;
                     $group_title = api_substr($my_all_groups_forum_name, 0, 30);
-                    $forum_title_group_addition = ' (<a href="../group/group_space.php?' . api_get_cidreq()
-                        . '&gidReq=' . $my_all_groups_forum_id . '" class="forum_group_link">'
-                        . get_lang('GoTo') . ' ' . $group_title . '</a>)';
+                    $forum_title_group_addition = ' (<a href="../group/group_space.php?'.api_get_cidreq()
+                        . '&gidReq='.$my_all_groups_forum_id.'" class="forum_group_link">'
+                        . get_lang('GoTo').' '.$group_title.'</a>)';
                 } else {
                     $forum_title_group_addition = '';
                 }
@@ -353,7 +353,7 @@ if ($action_forums != 'add') {
                 $html .= '<div class="row">';
                 $html .= '<div class="col-md-6">';
                 $html .= '<div class="col-md-3">';
-                $html .= '<div class="number-post">'.$forum_image .'<p>' . $my_number_threads . ' ' . get_lang('ForumThreads') . '</p></div>';
+                $html .= '<div class="number-post">'.$forum_image.'<p>'.$my_number_threads.' '.get_lang('ForumThreads').'</p></div>';
                 $html .= '</div>';
 
                 $html .= '<div class="col-md-9">';
@@ -368,7 +368,7 @@ if ($action_forums != 'add') {
                     'a',
                     $forum['forum_title'].$session_displayed,
                     array(
-                        'href' => 'viewforum.php?' . api_get_cidreq()
+                        'href' => 'viewforum.php?'.api_get_cidreq()
                             . "&gidReq={$forum['forum_of_group']}&forum={$forum['forum_id']}&search="
                             . Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')),
                         'class' => empty($forum['visibility']) ? 'text-muted' : null
@@ -376,7 +376,7 @@ if ($action_forums != 'add') {
                 );
                 $html .= Display::tag(
                     'h3',
-                    $linkForum . ' ' . $forum_title_group_addition,
+                    $linkForum.' '.$forum_title_group_addition,
                     array(
                         'class' => 'title'
                     )
@@ -396,7 +396,7 @@ if ($action_forums != 'add') {
                     );
                     if (!empty($waitingCount)) {
                         $html .= Display::label(
-                            get_lang('PostsPendingModeration'). ': '.$waitingCount,
+                            get_lang('PostsPendingModeration').': '.$waitingCount,
                             'warning'
                         );
                     }
@@ -406,19 +406,19 @@ if ($action_forums != 'add') {
                 $html .= '</div>';
                 $html .= '<div class="col-md-6">';
 
-                $iconEmpty='';
+                $iconEmpty = '';
 
                 // The number of topics and posts.
                 if ($forum['forum_of_group'] !== '0') {
                     $newPost = '';
                     if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
-                        $newPost = ' ' . Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
+                        $newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
                     } else {
                         $newPost = $iconEmpty;
                     }
                 } else {
                     if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
-                        $newPost = ' ' . Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
+                        $newPost = ' '.Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
                     } else {
                         $newPost = $iconEmpty;
                     }
@@ -426,7 +426,7 @@ if ($action_forums != 'add') {
 
                 $html .= '<div class="row">';
                 $html .= '<div class="col-md-2">';
-                $html .= $newPost . '</div>';
+                $html .= $newPost.'</div>';
 
                 $poster_id = 0;
                 $name = '';
@@ -441,9 +441,9 @@ if ($action_forums != 'add') {
                 }
                 $html .= '<div class="col-md-6">';
                 if (!empty($forum['last_post_id'])) {
-                    $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ';
+                    $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' ';
                     $html .= api_convert_and_format_date($forum['last_post_date'])
-                        . ' ' . get_lang('By') . ' '
+                        . ' '.get_lang('By').' '
                         . display_user_link($poster_id, $name);
                 }
                 $html .= '</div>';
@@ -453,13 +453,13 @@ if ($action_forums != 'add') {
                     api_is_allowed_to_edit(false, true) &&
                     !($forum['session_id'] == 0 && $sessionId != 0)
                 ) {
-                    $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
+                    $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
                         . Security::remove_XSS($_GET['forumcategory'])
-                        . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">'
-                        . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
-                    $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
+                        . '&action=edit&content=forum&id='.$forum['forum_id'].'">'
+                        . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
+                    $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
                         . Security::remove_XSS($_GET['forumcategory'])
-                        . '&action=delete&content=forum&id=' . $forum['forum_id']
+                        . '&action=delete&content=forum&id='.$forum['forum_id']
                         . "\" onclick=\"javascript:if(!confirm('"
                         . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES))
                         . "')) return false;\">"
@@ -483,15 +483,15 @@ if ($action_forums != 'add') {
                 $iconnotify = 'notification_mail_na.png';
 
                 if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
-                    if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) {
+                    if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) {
                         $iconnotify = 'notification_mail.png';
                     }
                 }
 
                 if (!api_is_anonymous()) {
-                    $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
-                        . Security::remove_XSS($_GET['forumcategory']) . '&action=notify&content=forum&id='
-                        . $forum['forum_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>';
+                    $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='
+                        . Security::remove_XSS($_GET['forumcategory']).'&action=notify&content=forum&id='
+                        . $forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
                 }
                 $html .= '</div>';
                 $html .= '</div>';

+ 86 - 86
main/forum/viewthread_threaded.inc.php

@@ -21,7 +21,7 @@
  * @package chamilo.forum
  */
 
-$forumUrl = api_get_path(WEB_CODE_PATH) . 'forum/';
+$forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
 $_user = api_get_user_info();
 $sortDirection = isset($_GET['posts_order']) && $_GET['posts_order'] === 'desc' ? 'DESC' : 'ASC';
 $rows = getPosts($current_forum, $_GET['thread'], $sortDirection, true);
@@ -44,7 +44,7 @@ $origin = api_get_origin();
 // Delete attachment file.
 if (
     isset($_GET['action']) &&
-    $_GET['action']=='delete_attach' &&
+    $_GET['action'] == 'delete_attach' &&
     isset($_GET['id_attach'])
 ) {
     delete_attachment(0, $_GET['id_attach']);
@@ -55,7 +55,7 @@ if (
 
 // Displaying the thread (structure)
 
-$thread_structure = "<div class=\"structure\">" .get_lang('Structure')."</div>";
+$thread_structure = "<div class=\"structure\">".get_lang('Structure')."</div>";
 $counter = 0;
 $count = 0;
 $prev_next_array = array();
@@ -67,7 +67,7 @@ $groupId = api_get_group_id();
 foreach ($rows as $post) {
     $counter++;
     $indent = $post['indent_cnt'] * '20';
-    $thread_structure .= "<div style=\"margin-left: " . $indent . "px;\">";
+    $thread_structure .= "<div style=\"margin-left: ".$indent."px;\">";
 
     if (
         !empty($whatsnew_post_info[$forumId][$post['thread_id']]) &&
@@ -85,13 +85,13 @@ foreach ($rows as $post) {
             $counter == 1 AND !isset($_GET['post'])
         )
     ) {
-        $thread_structure .= '<strong>' .prepare4display($post['post_title']) . '</strong>';
+        $thread_structure .= '<strong>'.prepare4display($post['post_title']).'</strong>';
         $prev_next_array[] = $post['post_id'];
     } else {
         $count_loop = ($count == 0) ? '&id=1' : '';
         $thread_structure .= Display::url(
             prepare4display($post['post_title']),
-            'viewthread.php?' . api_get_cidreq() . "$count_loop&" . http_build_query([
+            'viewthread.php?'.api_get_cidreq()."$count_loop&".http_build_query([
                 'forum' => $forumId,
                 'thread' => $threadId,
                 'post' => $post['post_id']
@@ -147,43 +147,43 @@ $class_prev = '';
 $class_next = '';
 
 // Links
-$first_href = $forumUrl . 'viewthread.php?' . api_get_cidreq() .
-    '&forum=' . $forumId . '&thread=' . $threadId .
-    '&gradebook=' . $gradebook . '&id=1&post=' . $prev_next_array[0];
-$last_href 	= $forumUrl . 'viewthread.php?' . api_get_cidreq() .
-    '&forum=' . $forumId . '&thread=' . $threadId .
-    '&gradebook=' . $gradebook . '&post=' . $prev_next_array[$max-1];
-$prev_href	= $forumUrl . 'viewthread.php?' . api_get_cidreq() .
-    '&forum=' . $forumId . '&thread=' . $threadId .
-    '&gradebook=' . $gradebook . '&post=' . $prev_next_array[$prev_id];
-$next_href	= $forumUrl . 'viewthread.php?' . api_get_cidreq() .
-    '&forum=' . $forumId . '&thread=' . $threadId .
-    '&post=' . $prev_next_array[$next_id];
+$first_href = $forumUrl.'viewthread.php?'.api_get_cidreq().
+    '&forum='.$forumId.'&thread='.$threadId.
+    '&gradebook='.$gradebook.'&id=1&post='.$prev_next_array[0];
+$last_href 	= $forumUrl.'viewthread.php?'.api_get_cidreq().
+    '&forum='.$forumId.'&thread='.$threadId.
+    '&gradebook='.$gradebook.'&post='.$prev_next_array[$max - 1];
+$prev_href	= $forumUrl.'viewthread.php?'.api_get_cidreq().
+    '&forum='.$forumId.'&thread='.$threadId.
+    '&gradebook='.$gradebook.'&post='.$prev_next_array[$prev_id];
+$next_href	= $forumUrl.'viewthread.php?'.api_get_cidreq().
+    '&forum='.$forumId.'&thread='.$threadId.
+    '&post='.$prev_next_array[$next_id];
 
 echo '<center style="margin-top: 10px; margin-bottom: 10px;">';
 // Go to: first and previous
 if (((int) $current_id) > 0) {
-    echo '<a href="' . $first_href . '" ' . $class . ' title=' .
-        $first_message . '>' . $first_img . ' ' . $first_message .'</a>';
-    echo '<a href="' . $prev_href . '" ' . $class_prev . ' title=' .
-        $prev_message . '>' . $prev_img . ' ' . $prev_message . '</a>';
+    echo '<a href="'.$first_href.'" '.$class.' title='.
+        $first_message.'>'.$first_img.' '.$first_message.'</a>';
+    echo '<a href="'.$prev_href.'" '.$class_prev.' title='.
+        $prev_message.'>'.$prev_img.' '.$prev_message.'</a>';
 } else {
-    echo '<strong class="text-muted">' .
-        $first_img . ' ' . $first_message . '</strong>';
-    echo '<strong class="text-muted">' .
-        $prev_img . ' ' . $prev_message . '</strong>';
+    echo '<strong class="text-muted">'.
+        $first_img.' '.$first_message.'</strong>';
+    echo '<strong class="text-muted">'.
+        $prev_img.' '.$prev_message.'</strong>';
 }
 
 // Current counter
-echo ' [ ' . ($current_id + 1) . ' / ' . $max . ' ] ';
+echo ' [ '.($current_id + 1).' / '.$max.' ] ';
 
 // Go to: next and last
 if (($current_id + 1) < $max) {
-    echo '<a href="' . $next_href . '" ' . $class_next . ' title=' . $next_message . '>' . $next_message . ' ' . $next_img . '</a>';
-    echo '<a href="' . $last_href . '" ' . $class . ' title=' . $last_message . '>' . $last_message . ' ' . $last_img . '</a>';
+    echo '<a href="'.$next_href.'" '.$class_next.' title='.$next_message.'>'.$next_message.' '.$next_img.'</a>';
+    echo '<a href="'.$last_href.'" '.$class.' title='.$last_message.'>'.$last_message.' '.$last_img.'</a>';
 } else {
-    echo '<strong class="text-muted">' . $next_message . ' ' . $next_img . '</strong>';
-    echo '<strong class="text-muted">' . $last_message . ' ' . $last_img . '</strong>';
+    echo '<strong class="text-muted">'.$next_message.' '.$next_img.'</strong>';
+    echo '<strong class="text-muted">'.$last_message.' '.$last_img.'</strong>';
 }
 echo '</center>';
 
@@ -217,18 +217,18 @@ if ($rows[$display_post_id]['user_id'] == '0') {
 }
 
 if (api_get_course_setting('allow_user_image_forum')) {
-    echo '<br />' . display_user_image($rows[$display_post_id]['user_id'], $name, $origin) . '<br />';
+    echo '<br />'.display_user_image($rows[$display_post_id]['user_id'], $name, $origin).'<br />';
 }
 echo display_user_link(
     $rows[$display_post_id]['user_id'],
     $name,
     $origin,
     $username
-) . "<br />";
+)."<br />";
 
 echo api_convert_and_format_date(
     $rows[$display_post_id]['post_date']
-) . '<br /><br />';
+).'<br /><br />';
 // Get attach id
 $attachment_list = get_attachment($display_post_id);
 $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
@@ -248,16 +248,16 @@ if (
     )
 ) {
     if ($locked == false) {
-        echo "<a href=\"editpost.php?" . api_get_cidreq() .
-            "&forum=" . $forumId . "&thread=" . $threadId .
-            "&post=" . $rows[$display_post_id]['post_id'] .
-            "&id_attach=" . $id_attach . "\">" .
+        echo "<a href=\"editpost.php?".api_get_cidreq().
+            "&forum=".$forumId."&thread=".$threadId.
+            "&post=".$rows[$display_post_id]['post_id'].
+            "&id_attach=".$id_attach."\">".
             Display::return_icon(
                 'edit.png',
                 get_lang('Edit'),
                 array(),
                 ICON_SIZE_SMALL
-            ) . '</a>';
+            ).'</a>';
     }
 }
 
@@ -273,7 +273,7 @@ if (!empty($my_post) && is_array($my_post)) {
     sort($id_posts, SORT_NUMERIC);
     reset($id_posts);
     // The post minor
-    $post_minor = (int)$id_posts[0];
+    $post_minor = (int) $id_posts[0];
 }
 
 if (
@@ -282,13 +282,13 @@ if (
     !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)
 ) {
     if ($locked == false) {
-        echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() .
-            "&forum=" . $forumId . "&thread=" . $threadId .
-            "&action=delete&content=post&id=" .
-            $rows[$display_post_id]['post_id'] .
-            "\" onclick=\"javascript:if(!confirm('" .
-            addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) .
-            "')) return false;\">" . Display::return_icon(
+        echo "<a href=\"".api_get_self()."?".api_get_cidreq().
+            "&forum=".$forumId."&thread=".$threadId.
+            "&action=delete&content=post&id=".
+            $rows[$display_post_id]['post_id'].
+            "\" onclick=\"javascript:if(!confirm('".
+            addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)).
+            "')) return false;\">".Display::return_icon(
                 'delete.png',
                 get_lang('Delete'),
                 array(),
@@ -307,16 +307,16 @@ if (
     );
 
     if (!isset($_GET['id']) && $post_id > $post_minor) {
-        echo "<a href=\"viewthread.php?" . api_get_cidreq() .
-            "&forum=" . $forumId . "&thread=" . $threadId .
-            "&action=move&post=" .
-            $rows[$display_post_id]['post_id'] . "\">" .
+        echo "<a href=\"viewthread.php?".api_get_cidreq().
+            "&forum=".$forumId."&thread=".$threadId.
+            "&action=move&post=".
+            $rows[$display_post_id]['post_id']."\">".
             Display::return_icon(
                 'move.png',
                 get_lang('MovePost'),
                 array(),
                 ICON_SIZE_SMALL
-            ) . "</a>";
+            )."</a>";
 
     }
 }
@@ -339,16 +339,16 @@ if ($userCanQualify) {
         );
 
         if ($locked == false) {
-            echo "<a href=\"forumqualify.php?" . api_get_cidreq() .
-                "&forum=" . $forumId . "&thread=" . $threadId .
-                "&action=list&post=" . $rows[$display_post_id]['post_id'] .
-                "&user=" . $rows[$display_post_id]['user_id'] . "&user_id=" .
+            echo "<a href=\"forumqualify.php?".api_get_cidreq().
+                "&forum=".$forumId."&thread=".$threadId.
+                "&action=list&post=".$rows[$display_post_id]['post_id'].
+                "&user=".$rows[$display_post_id]['user_id']."&user_id=".
                 $rows[$display_post_id]['user_id'].
-                "&idtextqualify=" . $current_qualify_thread .
-                "\" >" . Display::return_icon(
+                "&idtextqualify=".$current_qualify_thread.
+                "\" >".Display::return_icon(
                     'quiz.png',
                     get_lang('Qualify')
-                ) . "</a>";
+                )."</a>";
         }
     }
 }
@@ -360,33 +360,33 @@ if (($current_forum_category && $current_forum_category['locked'] == 0) &&
         ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])
     ) {
         if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
-            echo '<a href="reply.php?' . api_get_cidreq() .
-                '&forum=' . $forumId . '&thread=' . $threadId .
-                '&post=' . $rows[$display_post_id]['post_id'] .
-                '&action=replymessage">' .
+            echo '<a href="reply.php?'.api_get_cidreq().
+                '&forum='.$forumId.'&thread='.$threadId.
+                '&post='.$rows[$display_post_id]['post_id'].
+                '&action=replymessage">'.
                 Display::return_icon(
                     'message_reply_forum.png',
                     get_lang('ReplyToMessage')
-                ) . "</a>";
-            echo '<a href="reply.php?' . api_get_cidreq() .
-                '&forum=' . $forumId . '&thread=' . $threadId .
-                '&post=' . $rows[$display_post_id]['post_id'] .
-                '&action=quote">' .
+                )."</a>";
+            echo '<a href="reply.php?'.api_get_cidreq().
+                '&forum='.$forumId.'&thread='.$threadId.
+                '&post='.$rows[$display_post_id]['post_id'].
+                '&action=quote">'.
                 Display::return_icon(
                     'quote.gif',
                     get_lang('QuoteMessage')
-                ) . "</a>";
+                )."</a>";
         }
     }
 } else {
     if ($current_forum_category && $current_forum_category['locked'] == 1) {
-        echo get_lang('ForumcategoryLocked') . '<br />';
+        echo get_lang('ForumcategoryLocked').'<br />';
     }
     if ($current_forum['locked'] == 1) {
-        echo get_lang('ForumLocked') . '<br />';
+        echo get_lang('ForumLocked').'<br />';
     }
     if ($current_thread['locked'] == 1) {
-        echo get_lang('ThreadLocked') . '<br />';
+        echo get_lang('ThreadLocked').'<br />';
     }
 }
 
@@ -405,17 +405,17 @@ if (
     $rows[$display_post_id]['post_notification'] == '1' AND
     $rows[$display_post_id]['poster_id'] == $_user['user_id']
 ) {
-    $post_image .= Display::return_icon('forumnotification.gif',get_lang('YouWillBeNotified'));
+    $post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified'));
 }
 // The post title
-echo "<td class=\"$titleclass\">" .
-    prepare4display($rows[$display_post_id]['post_title']) . "</td>";
+echo "<td class=\"$titleclass\">".
+    prepare4display($rows[$display_post_id]['post_title'])."</td>";
 echo "</tr>";
 
 // The post message
 echo "<tr>";
-echo "<td class=\"$messageclass\">" .
-    prepare4display($rows[$display_post_id]['post_text']) . "</td>";
+echo "<td class=\"$messageclass\">".
+    prepare4display($rows[$display_post_id]['post_text'])."</td>";
 echo "</tr>";
 
 // The check if there is an attachment
@@ -428,21 +428,21 @@ if (!empty($attachment_list) && is_array($attachment_list)) {
         echo Display::return_icon('attachment.gif', get_lang('Attachment'));
         echo '<a href="download.php?file=';
         echo $realname;
-        echo ' "> ' . $user_filename . ' </a>';
-        echo '<span class="forum_attach_comment">' .
-            Security::remove_XSS($attachment['comment'], STUDENT) . '</span>';
+        echo ' "> '.$user_filename.' </a>';
+        echo '<span class="forum_attach_comment">'.
+            Security::remove_XSS($attachment['comment'], STUDENT).'</span>';
 
         if (
-            ($current_forum['allow_edit'] == 1 &&$rows[$display_post_id]['user_id'] == $_user['user_id']) ||
+            ($current_forum['allow_edit'] == 1 && $rows[$display_post_id]['user_id'] == $_user['user_id']) ||
             (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId))
         ) {
-            echo '&nbsp;&nbsp;<a href="' . api_get_self() . '?' .
-                api_get_cidreq() . '&action=delete_attach&id_attach=' .$attachment['id'] . '&forum=' . $forumId .
-                '&thread=' . $threadId .
-                '" onclick="javascript:if(!confirm(\'' .
+            echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.
+                api_get_cidreq().'&action=delete_attach&id_attach='.$attachment['id'].'&forum='.$forumId.
+                '&thread='.$threadId.
+                '" onclick="javascript:if(!confirm(\''.
                 addslashes(api_htmlentities(
                     get_lang('ConfirmYourChoice'), ENT_QUOTES)
-                ) . '\')) return false;">' . Display::return_icon(
+                ).'\')) return false;">'.Display::return_icon(
                     'delete.gif',
                     get_lang('Delete')
                 ).'</a><br />';

+ 14 - 14
main/gradebook/lib/be/abstractlink.class.php

@@ -242,8 +242,8 @@ abstract class AbstractLink implements GradebookItem
         $sql = 'SELECT * FROM '.$tbl_grade_links;
         $paramcount = 0;
         if (isset($id)) {
-            $sql.= ' WHERE id = '.intval($id);
-            $paramcount ++;
+            $sql .= ' WHERE id = '.intval($id);
+            $paramcount++;
         }
         if (isset($type)) {
             if ($paramcount != 0) {
@@ -270,7 +270,7 @@ abstract class AbstractLink implements GradebookItem
                 $sql .= ' WHERE';
             }
             $sql .= ' user_id = '.intval($user_id);
-            $paramcount ++;
+            $paramcount++;
         }
         if (isset($course_code)) {
             if ($paramcount != 0) {
@@ -279,7 +279,7 @@ abstract class AbstractLink implements GradebookItem
                 $sql .= ' WHERE';
             }
             $sql .= " course_code = '".Database::escape_string($course_code)."'";
-            $paramcount ++;
+            $paramcount++;
         }
         if (isset($category_id)) {
             if ($paramcount != 0) {
@@ -288,7 +288,7 @@ abstract class AbstractLink implements GradebookItem
                 $sql .= ' WHERE';
             }
             $sql .= ' category_id = '.intval($category_id);
-            $paramcount ++;
+            $paramcount++;
         }
         if (isset($visible)) {
             if ($paramcount != 0) {
@@ -329,7 +329,7 @@ abstract class AbstractLink implements GradebookItem
             $session_id = api_get_session_id();
 
             $link->set_session_id($session_id);
-            $links[]=$link;
+            $links[] = $link;
         }
         return $links;
     }
@@ -420,12 +420,12 @@ abstract class AbstractLink implements GradebookItem
         $dateobject = self::load($idevaluation, null, null, null, null);
         $current_date_server = api_get_utc_datetime();
         $arreval = get_object_vars($dateobject[0]);
-        $description_log = isset($arreval['description']) ? $arreval['description']:'';
+        $description_log = isset($arreval['description']) ? $arreval['description'] : '';
         if (empty($nameLog)) {
             if (isset($_POST['name_link'])) {
                 $name_log = isset($_POST['name_link']) ? $_POST['name_link'] : $arreval['course_code'];
-            } elseif (isset($_POST['link_' . $idevaluation]) && $_POST['link_' . $idevaluation]) {
-                $name_log = $_POST['link_' . $idevaluation];
+            } elseif (isset($_POST['link_'.$idevaluation]) && $_POST['link_'.$idevaluation]) {
+                $name_log = $_POST['link_'.$idevaluation];
             } else {
                 $name_log = $arreval['course_code'];
             }
@@ -472,8 +472,8 @@ abstract class AbstractLink implements GradebookItem
 
         $crscats = Category::load(null, null, $this->get_course_code(), 0);
         foreach ($crscats as $cat) {
-            $targets[] = array($cat->get_id(), $cat->get_name(), $level+1);
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
         }
 
         return $targets;
@@ -487,8 +487,8 @@ abstract class AbstractLink implements GradebookItem
     {
         $subcats = Category::load(null, null, null, $catid);
         foreach ($subcats as $cat) {
-            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
         }
         return $targets;
     }
@@ -513,7 +513,7 @@ abstract class AbstractLink implements GradebookItem
      * @todo can be written more efficiently using a new (but very complex) sql query
      * @param string $name_mask
      */
-    public function find_links ($name_mask,$selectcat)
+    public function find_links($name_mask, $selectcat)
     {
         $rootcat = Category::load($selectcat);
         $links = $rootcat[0]->get_links((api_is_allowed_to_edit() ? null : api_get_user_id()), true);

+ 26 - 26
main/gradebook/lib/be/evaluation.class.php

@@ -226,36 +226,36 @@ class Evaluation implements GradebookItem
         $paramcount = 0;
 
         if (isset ($id)) {
-            $sql.= ' WHERE id = '.intval($id);
-            $paramcount ++;
+            $sql .= ' WHERE id = '.intval($id);
+            $paramcount++;
         }
 
         if (isset($user_id)) {
             if ($paramcount != 0) $sql .= ' AND';
             else $sql .= ' WHERE';
             $sql .= ' user_id = '.intval($user_id);
-            $paramcount ++;
+            $paramcount++;
         }
 
         if (isset($course_code) && $course_code <> '-1') {
             if ($paramcount != 0) $sql .= ' AND';
             else $sql .= ' WHERE';
             $sql .= " course_code = '".Database::escape_string($course_code)."'";
-            $paramcount ++;
+            $paramcount++;
         }
 
         if (isset($category_id)) {
             if ($paramcount != 0) $sql .= ' AND';
             else $sql .= ' WHERE';
             $sql .= ' category_id = '.intval($category_id);
-            $paramcount ++;
+            $paramcount++;
         }
 
         if (isset($visible)) {
             if ($paramcount != 0) $sql .= ' AND';
             else $sql .= ' WHERE';
             $sql .= ' visible = '.intval($visible);
-            $paramcount ++;
+            $paramcount++;
         }
 
         if (isset($locked)) {
@@ -279,7 +279,7 @@ class Evaluation implements GradebookItem
         $alleval = array();
         if (Database::num_rows($result)) {
             while ($data = Database::fetch_array($result)) {
-                $eval= new Evaluation();
+                $eval = new Evaluation();
                 $eval->set_id($data['id']);
                 $eval->set_name($data['name']);
                 $eval->set_description($data['description']);
@@ -365,7 +365,7 @@ class Evaluation implements GradebookItem
             $tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
             $tbl_grade_linkeval_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
             $eval = new Evaluation();
-            $dateobject = $eval->load($idevaluation,null,null,null,null);
+            $dateobject = $eval->load($idevaluation, null, null, null, null);
             $arreval = get_object_vars($dateobject[0]);
             if (!empty($arreval['id'])) {
                 $sql = 'SELECT weight from '.$tbl_grade_evaluations.'
@@ -399,7 +399,7 @@ class Evaluation implements GradebookItem
             .', description = ';
         if (isset($this->description)) {
             $sql .= "'".Database::escape_string($this->get_description())."'";
-        }else {
+        } else {
             $sql .= 'null';
         }
         $sql .= ', user_id = '.intval($this->get_user_id())
@@ -474,12 +474,12 @@ class Evaluation implements GradebookItem
         }
 
         if (!isset($parent)) {
-            $sql.= ' AND category_id is null';
+            $sql .= ' AND category_id is null';
         } else {
-            $sql.= ' AND category_id = '.intval($parent);
+            $sql .= ' AND category_id = '.intval($parent);
         }
         $result = Database::query($sql);
-        $number=Database::fetch_row($result);
+        $number = Database::fetch_row($result);
 
         return $number[0] != 0;
     }
@@ -495,7 +495,7 @@ class Evaluation implements GradebookItem
                 FROM '.$tbl_grade_results.'
                 WHERE evaluation_id = '.intval($this->id);
         $result = Database::query($sql);
-        $number=Database::fetch_row($result);
+        $number = Database::fetch_row($result);
 
         return ($number[0] != 0);
     }
@@ -545,7 +545,7 @@ class Evaluation implements GradebookItem
             $results = isset($data[$key]) ? $data[$key] : null;
 
             if ($useSession == false) {
-                $results  = null;
+                $results = null;
             }
             if (empty($results)) {
                 $results = Result::load(null, $stud_id, $this->id);
@@ -571,7 +571,7 @@ class Evaluation implements GradebookItem
             $data = Session::read('calc_score');
             $allResults = isset($data[$key]) ? $data[$key] : null;
             if ($useSession == false) {
-                $allResults  = null;
+                $allResults = null;
             }
             if (empty($allResults)) {
                 $allResults = Result::load(null, null, $this->id);
@@ -603,7 +603,7 @@ class Evaluation implements GradebookItem
                     return array($bestResult, $weight);
                     break;
                 case 'average':
-                    return array($sumResult/$count, $weight);
+                    return array($sumResult / $count, $weight);
                     break;
                 case 'ranking':
                     $students = array();
@@ -641,17 +641,17 @@ class Evaluation implements GradebookItem
         $targets[] = $root;
 
         if (isset($this->course_code) && !empty($this->course_code)) {
-            $crscats = Category::load(null,null,$this->course_code,0);
+            $crscats = Category::load(null, null, $this->course_code, 0);
             foreach ($crscats as $cat) {
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+                $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
             }
         }
 
-        $indcats = Category::load(null,$user,0,0);
+        $indcats = Category::load(null, $user, 0, 0);
         foreach ($indcats as $cat) {
-            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
         }
 
         return $targets;
@@ -665,10 +665,10 @@ class Evaluation implements GradebookItem
      */
     private function add_target_subcategories($targets, $level, $catid)
     {
-        $subcats = Category::load(null,null,null,$catid);
+        $subcats = Category::load(null, null, null, $catid);
         foreach ($subcats as $cat) {
-            $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
-            $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
+            $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
+            $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
         }
         return $targets;
     }
@@ -747,7 +747,7 @@ class Evaluation implements GradebookItem
      * @return array evaluation objects matching the search criterium
      * @todo can be written more efficiently using a new (but very complex) sql query
      */
-    public function find_evaluations($name_mask,$selectcat)
+    public function find_evaluations($name_mask, $selectcat)
     {
         $rootcat = Category::load($selectcat);
         $evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);

+ 10 - 10
main/gradebook/lib/be/forumthreadlink.class.php

@@ -86,8 +86,8 @@ class ForumThreadLink extends AbstractLink
 			return [];
 		}
 
-		$tbl_grade_links 	= Database::get_course_table(TABLE_FORUM_THREAD);
-		$tbl_item_property	= Database::get_course_table(TABLE_ITEM_PROPERTY);
+		$tbl_grade_links = Database::get_course_table(TABLE_FORUM_THREAD);
+		$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
 		$session_id = api_get_session_id();
 
 		if ($session_id) {
@@ -211,11 +211,11 @@ class ForumThreadLink extends AbstractLink
                 if (empty($counter) || $counter <= 2) {
                     return array(0, $assignment['thread_qualify_max']);
                 }
-                return [$score/$counter, $assignment['thread_qualify_max']];
+                return [$score / $counter, $assignment['thread_qualify_max']];
             }
         } else {
             // All students -> get average
-            $students = array();  // user list, needed to make sure we only
+            $students = array(); // user list, needed to make sure we only
             // take first attempts into account
             $counter = 0;
             $sum = 0;
@@ -246,7 +246,7 @@ class ForumThreadLink extends AbstractLink
                         return array($bestResult, $weight);
                         break;
                     case 'average':
-                        return array($sumResult/$counter, $weight);
+                        return array($sumResult / $counter, $weight);
                         break;
                     case 'ranking':
                         return AbstractLink::getCurrentUserRanking($stud_id, $students);
@@ -288,8 +288,8 @@ class ForumThreadLink extends AbstractLink
     public function get_name()
     {
         $this->get_exercise_data();
-        $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
-        $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
+        $thread_title = isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : '';
+        $thread_title_qualify = isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : '';
         if (isset($thread_title_qualify) && $thread_title_qualify != '') {
             return $this->exercise_data['thread_title_qualify'];
         } else {
@@ -302,7 +302,7 @@ class ForumThreadLink extends AbstractLink
      */
     public function get_description()
     {
-        return '';//$this->exercise_data['description'];
+        return ''; //$this->exercise_data['description'];
     }
 
     /**
@@ -329,8 +329,8 @@ class ForumThreadLink extends AbstractLink
         $sql = 'SELECT * FROM '.$this->get_forum_thread_table()."
                 WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId."";
         $result = Database::query($sql);
-        $row    = Database::fetch_array($result,'ASSOC');
-        $forum_id=$row['forum_id'];
+        $row    = Database::fetch_array($result, 'ASSOC');
+        $forum_id = $row['forum_id'];
 
         $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id;
         return $url;

+ 27 - 27
main/gradebook/lib/be/result.class.php

@@ -96,23 +96,23 @@ class Result
         if (is_null($id) && is_null($user_id) && !is_null($evaluation_id)) {
             // Verified_if_exist_evaluation
             $sql = 'SELECT COUNT(*) AS count
-                    FROM ' . $tbl_grade_results . '
-                    WHERE evaluation_id="' . Database::escape_string($evaluation_id) . '";';
+                    FROM ' . $tbl_grade_results.'
+                    WHERE evaluation_id="' . Database::escape_string($evaluation_id).'";';
             $result = Database::query($sql);
             $existEvaluation = Database::result($result, 0, 0);
 
             if ($existEvaluation != 0) {
                 if ($sessionId) {
                     $sql = 'SELECT c_id, user_id as user_id, status
-                            FROM ' . $tbl_session_rel_course_user . '
+                            FROM ' . $tbl_session_rel_course_user.'
 							WHERE
 							    status= 0 AND
-							    c_id = "' . api_get_course_int_id() . '" AND
+							    c_id = "' . api_get_course_int_id().'" AND
 							    session_id = ' . $sessionId;
                 } else {
                     $sql = 'SELECT c_id, user_id, status
-                            FROM ' . $tbl_course_rel_course . '
-                            WHERE status ="' . STUDENT . '" AND c_id = "' . api_get_course_int_id() . '" ';
+                            FROM ' . $tbl_course_rel_course.'
+                            WHERE status ="' . STUDENT.'" AND c_id = "'.api_get_course_int_id().'" ';
                 }
 
                 $res_course_rel_user = Database::query($sql);
@@ -122,15 +122,15 @@ class Result
                 $current_date = api_get_utc_datetime();
                 for ($i = 0; $i < count($list_user_course_list); $i++) {
                     $sql_verified = 'SELECT COUNT(*) AS count
-                                    FROM ' . $tbl_grade_results . '
+                                    FROM ' . $tbl_grade_results.'
                                     WHERE
-                                        user_id="' . intval($list_user_course_list[$i]['user_id']) . '" AND
-                                        evaluation_id="' . intval($evaluation_id) . '";';
+                                        user_id="' . intval($list_user_course_list[$i]['user_id']).'" AND
+                                        evaluation_id="' . intval($evaluation_id).'";';
                     $res_verified = Database::query($sql_verified);
                     $info_verified = Database::result($res_verified, 0, 0);
                     if ($info_verified == 0) {
-                        $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score)
-									   VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);';
+                        $sql_insert = 'INSERT INTO '.$tbl_grade_results.'(user_id,evaluation_id,created_at,score)
+									   VALUES ("' . intval($list_user_course_list[$i]['user_id']).'","'.intval($evaluation_id).'","'.$current_date.'",0);';
                         Database::query($sql_insert);
                     }
                 }
@@ -154,8 +154,8 @@ class Result
 
         $paramcount = 0;
         if (!empty($id)) {
-            $sql.= ' WHERE gr.id = ' . intval($id);
-            $paramcount ++;
+            $sql .= ' WHERE gr.id = '.intval($id);
+            $paramcount++;
         }
         if (!empty($user_id)) {
             if ($paramcount != 0) {
@@ -172,8 +172,8 @@ class Result
             } else {
                 $sql .= ' WHERE';
             }
-            $sql .= ' gr.evaluation_id = ' . intval($evaluation_id);
-            $paramcount ++;
+            $sql .= ' gr.evaluation_id = '.intval($evaluation_id);
+            $paramcount++;
         }
         $sql .= ' ORDER BY u.lastname, u.firstname';
         $result = Database::query($sql);
@@ -198,17 +198,17 @@ class Result
     {
         if (isset($this->user_id) && isset($this->evaluation)) {
             $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
-            $sql = "INSERT INTO " . $tbl_grade_results
+            $sql = "INSERT INTO ".$tbl_grade_results
                 . " (user_id, evaluation_id,
 					created_at";
             if (isset($this->score)) {
                 $sql .= ",score";
             }
             $sql .= ") VALUES
-					(" . (int) $this->get_user_id() . ", " . (int) $this->get_evaluation_id()
-                . ", '" . $this->get_date() . "' ";
+					(" . (int) $this->get_user_id().", ".(int) $this->get_evaluation_id()
+                . ", '".$this->get_date()."' ";
             if (isset($this->score)) {
-                $sql .= ", " . $this->get_score();
+                $sql .= ", ".$this->get_score();
             }
             $sql .= ")";
             Database::query($sql);
@@ -229,16 +229,16 @@ class Result
             $arr_result = $result->load(null, $userid, $evaluationid);
             $arr = get_object_vars($arr_result[0]);
 
-            $sql = 'INSERT INTO ' . $tbl_grade_results_log
+            $sql = 'INSERT INTO '.$tbl_grade_results_log
                 . ' (id_result,user_id, evaluation_id,created_at';
             if (isset($arr['score'])) {
                 $sql .= ',score';
             }
             $sql .= ') VALUES
-					(' . (int) $arr['id'] . ',' . (int) $arr['user_id'] . ', ' . (int) $arr['evaluation']
-                . ", '" . api_get_utc_datetime() . "'";
+					(' . (int) $arr['id'].','.(int) $arr['user_id'].', '.(int) $arr['evaluation']
+                . ", '".api_get_utc_datetime()."'";
             if (isset($arr['score'])) {
-                $sql .= ', ' . $arr['score'];
+                $sql .= ', '.$arr['score'];
             }
             $sql .= ')';
 
@@ -254,16 +254,16 @@ class Result
     public function save()
     {
         $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
-        $sql = 'UPDATE ' . $tbl_grade_results . '
+        $sql = 'UPDATE '.$tbl_grade_results.'
                 SET user_id = ' . $this->get_user_id()
-            . ', evaluation_id = ' . $this->get_evaluation_id()
+            . ', evaluation_id = '.$this->get_evaluation_id()
             . ', score = ';
         if (isset($this->score)) {
             $sql .= $this->get_score();
         } else {
             $sql .= 'null';
         }
-        $sql .= ' WHERE id = ' . $this->id;
+        $sql .= ' WHERE id = '.$this->id;
         // no need to update creation date
         Database::query($sql);
     }
@@ -274,7 +274,7 @@ class Result
     public function delete()
     {
         $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
-        $sql = 'DELETE FROM ' . $tbl_grade_results . ' WHERE id = ' . $this->id;
+        $sql = 'DELETE FROM '.$tbl_grade_results.' WHERE id = '.$this->id;
         Database::query($sql);
     }
 }

+ 87 - 87
main/gradebook/lib/fe/displaygradebook.php

@@ -20,37 +20,37 @@ class DisplayGradebook
         if (api_is_allowed_to_edit(null, true)) {
             $header = '<div class="actions">';
             if ($page != 'statistics') {
-                $header .= '<a href="' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $selectcat . '&'.api_get_cidreq().'">' .
-                    Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM) . '</a>';
+                $header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat.'&'.api_get_cidreq().'">'.
+                    Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
                 if ($evalobj->get_course_code() == null) {
 
                 } elseif (!$evalobj->has_results()) {
-                    $header .= '<a href="gradebook_add_result.php?'.api_get_cidreq().'&selectcat=' . $selectcat . '&selecteval=' . $evalobj->get_id() . '">
-    				' . Display::return_icon('evaluation_rate.png', get_lang('AddResult'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $header .= '<a href="gradebook_add_result.php?'.api_get_cidreq().'&selectcat='.$selectcat.'&selecteval='.$evalobj->get_id().'">
+    				' . Display::return_icon('evaluation_rate.png', get_lang('AddResult'), '', ICON_SIZE_MEDIUM).'</a>';
                 }
 
                 if (api_is_platform_admin() || $evalobj->is_locked() == false) {
-                    $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&import=">' .
-                        Display::return_icon('import_evaluation.png', get_lang('ImportResult'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&selecteval='.$evalobj->get_id().'&import=">'.
+                        Display::return_icon('import_evaluation.png', get_lang('ImportResult'), '', ICON_SIZE_MEDIUM).'</a>';
                 }
 
                 if ($evalobj->has_results()) {
-                    $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&export=">' .
-                        Display::return_icon('export_evaluation.png', get_lang('ExportResult'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&selecteval='.$evalobj->get_id().'&export=">'.
+                        Display::return_icon('export_evaluation.png', get_lang('ExportResult'), '', ICON_SIZE_MEDIUM).'</a>';
 
                     if (api_is_platform_admin() || $evalobj->is_locked() == false) {
-                        $header .= '<a href="gradebook_edit_result.php?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '">' .
-                            Display::return_icon('edit.png', get_lang('EditResult'), '', ICON_SIZE_MEDIUM) . '</a>';
-                        $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&selecteval=' . $evalobj->get_id() . '&deleteall=" onclick="return confirmationall();">' .
-                            Display::return_icon('delete.png', get_lang('DeleteResult'), '', ICON_SIZE_MEDIUM) . '</a>';
+                        $header .= '<a href="gradebook_edit_result.php?'.api_get_cidreq().'&selecteval='.$evalobj->get_id().'">'.
+                            Display::return_icon('edit.png', get_lang('EditResult'), '', ICON_SIZE_MEDIUM).'</a>';
+                        $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&selecteval='.$evalobj->get_id().'&deleteall=" onclick="return confirmationall();">'.
+                            Display::return_icon('delete.png', get_lang('DeleteResult'), '', ICON_SIZE_MEDIUM).'</a>';
                     }
                 }
 
-                $header .= '<a href="' . api_get_self() . '?'.api_get_cidreq().'&print=&selecteval=' . $evalobj->get_id() . '" target="_blank">' .
-                    Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM) . '</a>';
+                $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&print=&selecteval='.$evalobj->get_id().'" target="_blank">'.
+                    Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
             } else {
-                $header .= '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval=' . Security::remove_XSS($_GET['selecteval']) . '"> ' .
-                    Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM) . '</a>';
+                $header .= '<a href="gradebook_view_result.php?'.api_get_cidreq().'&selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.
+                    Display::return_icon(('back.png'), get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
             }
             $header .= '</div>';
         }
@@ -68,17 +68,17 @@ class DisplayGradebook
             // TODO this check needed ?
             $score = $evalobj->calc_score();
             if ($score != null) {
-                $average = get_lang('Average') . ' :<b> ' . $scoredisplay->display_score($score, SCORE_AVERAGE) . '</b>';
+                $average = get_lang('Average').' :<b> '.$scoredisplay->display_score($score, SCORE_AVERAGE).'</b>';
                 $student_score = $evalobj->calc_score(api_get_user_id());
                 $student_score = Display::tag(
                     'h3',
-                    get_lang('Score') . ': ' . $scoredisplay->display_score($student_score, SCORE_DIV_PERCENT)
+                    get_lang('Score').': '.$scoredisplay->display_score($student_score, SCORE_DIV_PERCENT)
                 );
             }
         }
         $description = "";
         if (!$evalobj->get_description() == '') {
-            $description = get_lang('Description') . ' :<b> ' . $evalobj->get_description() . '</b><br>';
+            $description = get_lang('Description').' :<b> '.$evalobj->get_description().'</b><br>';
         }
 
         if ($evalobj->get_course_code() == null) {
@@ -88,17 +88,17 @@ class DisplayGradebook
         }
 
         $evalinfo = '<table width="100%" border="0"><tr><td>';
-        $evalinfo .= '<h2>' . $evalobj->get_name() . '</h2><hr>';
+        $evalinfo .= '<h2>'.$evalobj->get_name().'</h2><hr>';
         $evalinfo .= $description;
-        $evalinfo .= get_lang('Course') . ' :<b> ' . $course . '</b><br />';
-        $evalinfo .= get_lang('QualificationNumeric') . ' :<b> ' . $evalobj->get_max() . '</b><br>' . $average;
+        $evalinfo .= get_lang('Course').' :<b> '.$course.'</b><br />';
+        $evalinfo .= get_lang('QualificationNumeric').' :<b> '.$evalobj->get_max().'</b><br>'.$average;
 
         if (!api_is_allowed_to_edit()) {
             $evalinfo .= $student_score;
         }
 
         if (!$evalobj->has_results()) {
-            $evalinfo .= '<br /><i>' . get_lang('NoResultsInEvaluation') . '</i>';
+            $evalinfo .= '<br /><i>'.get_lang('NoResultsInEvaluation').'</i>';
         } elseif ($scoredisplay->is_custom() && api_get_self() != '/main/gradebook/gradebook_statistics.php') {
             if (api_is_allowed_to_edit(null, true)) {
                 if ($page != 'statistics') {
@@ -108,8 +108,8 @@ class DisplayGradebook
         }
         if ($page != 'statistics') {
             if (api_is_allowed_to_edit(null, true)) {
-                $evalinfo .= '<br /><a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . Security::remove_XSS($_GET['selecteval']) . '"> ' .
-                    Display::return_icon('statistics.png', get_lang('ViewStatistics'), '', ICON_SIZE_MEDIUM) . '</a>';
+                $evalinfo .= '<br /><a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.
+                    Display::return_icon('statistics.png', get_lang('ViewStatistics'), '', ICON_SIZE_MEDIUM).'</a>';
             }
         }
         $evalinfo .= '</td><td>'.Display::return_icon('tutorial.gif', '', ['style' => 'float:right; position:relative;']).'</td></table>';
@@ -134,14 +134,14 @@ class DisplayGradebook
             $select_cat = $catobj->get_parent_id();
             $url = 'gradebook_flatview.php';
         }
-        $header .= '<a href="' . $url . '?' . api_get_cidreq() . '&selectcat=' . $select_cat . '">' .
-            Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM) . '</a>';
+        $header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'.
+            Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM).'</a>';
 
         $pageNum = isset($_GET['flatviewlist_page_nr']) ? intval($_GET['flatviewlist_page_nr']) : null;
         $perPage = isset($_GET['flatviewlist_per_page']) ? intval($_GET['flatviewlist_per_page']) : null;
         $offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
 
-        $exportCsvUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
+        $exportCsvUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
             'export_format' => 'csv',
             'export_report' => 'export_report',
             'selectcat' => $catobj->get_id()
@@ -152,7 +152,7 @@ class DisplayGradebook
             $exportCsvUrl
         );
 
-        $exportXlsUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
+        $exportXlsUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
             'export_format' => 'xls',
             'export_report' => 'export_report',
             'selectcat' => $catobj->get_id()
@@ -163,7 +163,7 @@ class DisplayGradebook
             $exportXlsUrl
         );
 
-        $exportDocUrl = api_get_self() . '?' .  api_get_cidreq() . '&' . http_build_query([
+        $exportDocUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
             'export_format' => 'doc',
             'export_report' => 'export_report',
             'selectcat' => $catobj->get_id()
@@ -174,7 +174,7 @@ class DisplayGradebook
             $exportDocUrl
         );
 
-        $exportPrintUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
+        $exportPrintUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
                 'print' => '',
                 'selectcat' => $catobj->get_id(),
             ]);
@@ -185,7 +185,7 @@ class DisplayGradebook
             ['target' => '_blank']
         );
 
-        $exportPdfUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([
+        $exportPdfUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
             'exportpdf' => '',
             'selectcat' => $catobj->get_id(),
             'offset' => $offset,
@@ -293,7 +293,7 @@ class DisplayGradebook
                     $aditionalButtons .= isset($certificateLinkInfo['badge_link']) ? $certificateLinkInfo['badge_link'] : '';
                     $aditionalButtons .= '</div>';
                 }
-                $scoreinfo .= '<strong>' . sprintf(get_lang('TotalX'), $scorecourse_display . $aditionalButtons). '</strong>';
+                $scoreinfo .= '<strong>'.sprintf(get_lang('TotalX'), $scorecourse_display.$aditionalButtons).'</strong>';
 
             }
             Display::display_normal_message($scoreinfo, false);
@@ -304,10 +304,10 @@ class DisplayGradebook
             $header = '<div class="actions"><table>';
             $header .= '<tr>';
             if (!$selectcat == '0') {
-                $header .= '<td><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' .
-                    Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>';
+                $header .= '<td><a href="'.api_get_self().'?selectcat='.$catobj->get_parent_id().'">'.
+                    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('RootCat'), '', ICON_SIZE_MEDIUM).'</a></td>';
             }
-            $header .= '<td>' . get_lang('CurrentCategory') . '</td>' .
+            $header .= '<td>'.get_lang('CurrentCategory').'</td>'.
                     '<td><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
             $cats = Category::load();
 
@@ -320,15 +320,15 @@ class DisplayGradebook
                 }
                 $line = isset($line) ? $line : '';
                 if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
-                    $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
+                    $header .= '<option selected value='.$cat[0].'>'.$line.' '.$cat[1].'</option>';
                 } else {
-                    $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
+                    $header .= '<option value='.$cat[0].'>'.$line.' '.$cat[1].'</option>';
                 }
                 $line = '';
             }
             $header .= '</select></form></td>';
             if (!empty($simple_search_form) && $message_resource === false) {
-                $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
+                $header .= '<td style="vertical-align: top;">'.$simple_search_form->toHtml().'</td>';
             } else {
                 $header .= '<td></td>';
             }
@@ -339,9 +339,9 @@ class DisplayGradebook
             } elseif (!(isset($_GET['studentoverview']))) {
 
             } else {
-                $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">
+                $header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">
 							 '.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
-							' . get_lang('ExportPDF') . '</a>';
+							' . get_lang('ExportPDF').'</a>';
             }
             $header .= '</td></tr>';
             $header .= '</table></div>';
@@ -354,33 +354,33 @@ class DisplayGradebook
 
         if (api_is_allowed_to_edit(null, true)) {
             if (empty($grade_model_id) || $grade_model_id == -1) {
-                $actionsLeft .= '<a href="gradebook_add_cat.php?' . api_get_cidreq() . '&selectcat=' . $catobj->get_id() . '">' .
-                    Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM) . '</a></td>';
+                $actionsLeft .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
+                    Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM).'</a></td>';
             }
             if ($selectcat == '0') {
 
             } else {
                 $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
                 if ($my_api_cidreq == '') {
-                    $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
+                    $my_api_cidreq = 'cidReq='.$my_category['course_code'];
                 }
                 if ($show_add_link && !$message_resource) {
-                    $actionsLeft .= '<a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' .
-                        Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $actionsLeft .= '<a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'" >'.
+                        Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM).'</a>';
                     $cats = Category::load($selectcat);
 
                     if ($cats[0]->get_course_code() != null && !$message_resource) {
-                        $actionsLeft .= '<a href="gradebook_add_link.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                            Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
+                        $actionsLeft .= '<a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                            Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
                     } else {
-                        $actionsLeft .= '<a href="gradebook_add_link_select_course.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                            Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
+                        $actionsLeft .= '<a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                            Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
                     }
                 }
 
                 if (!$message_resource) {
-                    $actionsLeft .= '<a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                        Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                        Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
 
                     if ($my_category['generate_certificates'] == 1) {
                         $actionsLeft .= Display::url(
@@ -390,7 +390,7 @@ class DisplayGradebook
                                 '',
                                 ICON_SIZE_MEDIUM
                             ),
-                            "gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . $selectcat
+                            "gradebook_display_certificate.php?$my_api_cidreq&cat_id=".$selectcat
                         );
                     }
 
@@ -401,29 +401,29 @@ class DisplayGradebook
                             '',
                             ICON_SIZE_MEDIUM
                         ),
-                        "gradebook_display_summary.php?$my_api_cidreq&selectcat=" . $selectcat
+                        "gradebook_display_summary.php?$my_api_cidreq&selectcat=".$selectcat
                     );
 
                     // Right icons
-                    $actionsRight = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
-                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';
-                    $actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&' . $my_api_cidreq . '&origin=gradebook&selectcat=' . $catobj->get_id() . '">' .
-                            Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM) . '</a>';
+                    $actionsRight = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
+                        Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
+                    $actionsRight .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
+                            Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
 
                     if (empty($categories)) {
-                        $actionsRight .= '<a href="gradebook_edit_all.php?id_session=' . api_get_session_id() . '&amp;' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                            Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM) . '</a>';
+                        $actionsRight .= '<a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                            Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM).'</a>';
                     }
                     $score_display_custom = api_get_setting('gradebook_score_display_custom');
                     if (api_get_setting('teachers_can_change_score_settings') == 'true' && $score_display_custom['my_display_custom'] == 'true') {
-                        $actionsRight .= '<a href="gradebook_scoring_system.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                            Display::return_icon('ranking.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM) . '</a>';
+                        $actionsRight .= '<a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                            Display::return_icon('ranking.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
                     }
 
                 }
             }
         } elseif (isset($_GET['search'])) {
-            echo $header = '<b>' . get_lang('SearchResults') . ' :</b>';
+            echo $header = '<b>'.get_lang('SearchResults').' :</b>';
         }
 
         $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@@ -432,26 +432,26 @@ class DisplayGradebook
         );
 
         if ($isDrhOfCourse) {
-            $$actionsLeft .= '<a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
-                Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
+            $$actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
+                Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
         }
 
-        if (api_is_allowed_to_edit(null, true)){
+        if (api_is_allowed_to_edit(null, true)) {
             echo $toolbar = Display::toolbarAction('gradebook-actions', array($actionsLeft, $actionsRight));
         }
 
         if (api_is_allowed_to_edit(null, true)) {
             $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
-            $weight = '<strong>' . get_lang('TotalWeight') . ' : </strong>' . $weight;
+            $weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight;
 
             $min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0);
-            $min_certification = get_lang('CertificateMinScore') . ' : ' . $min_certification;
-            $edit_icon = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
-                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
+            $min_certification = get_lang('CertificateMinScore').' : '.$min_certification;
+            $edit_icon = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'.
+                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
             //$msg = Display::tag('h3', $weight.' - '.$min_certification);
-            $msg = $weight . ' - ' . $min_certification . $edit_icon;
+            $msg = $weight.' - '.$min_certification.$edit_icon;
             //@todo show description
-            $description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>' . get_lang('GradebookDescriptionLog') . '</strong>' . ': ' . $catobj->get_description());
+            $description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
             Display::display_normal_message($msg, false);
             if (!empty($description)) {
                 echo Display::div($description, array());
@@ -485,24 +485,24 @@ class DisplayGradebook
             $cattotal = Category::load(0);
             $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
             $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
-            $scoreinfo = get_lang('StatsStudent') . ' :<b> ' . $user['complete_name']. '</b><br />';
+            $scoreinfo = get_lang('StatsStudent').' :<b> '.$user['complete_name'].'</b><br />';
             if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search'])))
-                $scoreinfo.= '<br />' . get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
-            $scoreinfo.= '<br />' . get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
+                $scoreinfo .= '<br />'.get_lang('TotalForThisCategory').' : <b>'.$scorecourse_display.'</b>';
+            $scoreinfo .= '<br />'.get_lang('Total').' : <b>'.$scoretotal_display.'</b>';
             Display::display_normal_message($scoreinfo, false);
         }
         // show navigation tree and buttons?
         $header = '<div class="actions">';
 
         if ($is_course_admin) {
-            $header .= '<a href="gradebook_flatview.php?' . api_get_cidreq() . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
-            $header .= '<a href="gradebook_scoring_system.php?' . api_get_cidreq() . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM) . '</a>';
+            $header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
+            $header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
         } elseif (!(isset($_GET['studentoverview']))) {
-            $header .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('view_list.gif', get_lang('FlatView')) . ' ' . get_lang('FlatView') . '</a>';
+            $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat='.$catobj->get_id().'">'.Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').'</a>';
         } else {
-            $header .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">' . Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM) . '</a>';
+            $header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">'.Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).'</a>';
         }
-        $header.='</div>';
+        $header .= '</div>';
         echo $header;
     }
 
@@ -531,25 +531,25 @@ class DisplayGradebook
             $item = $evals_links[$count];
             $score = $item->calc_score($userId);
             $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
-            $item_value+=$score[0] / $my_score_denom * $item->get_weight();
-            $item_total+=$item->get_weight();
+            $item_value += $score[0] / $my_score_denom * $item->get_weight();
+            $item_total += $item->get_weight();
         }
         $item_value = api_number_format($item_value, 2);
         $total_score = array($item_value, $item_total);
         $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
 
         $info = '<div class="row"><div class="col-md-3">';
-        $info .= '<div class="thumbnail"><img src="' . $user['avatar'] . '" /></div>';
+        $info .= '<div class="thumbnail"><img src="'.$user['avatar'].'" /></div>';
         $info .= '</div>';
         $info .= '<div class="col-md-6">';
-        $info .= get_lang('Name') . ' :  <a target="_blank" href="' . api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $userId . '"> ' .
-            $user['complete_name'] . '</a><br />';
+        $info .= get_lang('Name').' :  <a target="_blank" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$userId.'"> '.
+            $user['complete_name'].'</a><br />';
 
         if (api_get_setting('show_email_addresses') == 'true') {
-            $info .= get_lang('Email') . ' : <a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a><br />';
+            $info .= get_lang('Email').' : <a href="mailto:'.$user['email'].'">'.$user['email'].'</a><br />';
         }
 
-        $info .= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b>';
+        $info .= get_lang('TotalUser').' : <b>'.$scorecourse_display.'</b>';
         $info .= '</div>';
         $info .= '</div>';
         echo $info;

+ 21 - 21
main/gradebook/lib/user_data_generator.class.php

@@ -50,9 +50,9 @@ class UserDataGenerator
 
         }
         if (count($result) == 0) {
-            $evals_filtered=$evals;
+            $evals_filtered = $evals;
         } else {
-            $evals_filtered=$evals_filtered_copy;
+            $evals_filtered = $evals_filtered_copy;
         }
         $this->items = array_merge($evals_filtered, $links);
 
@@ -85,7 +85,7 @@ class UserDataGenerator
     {
         // do some checks on count, redefine if invalid value
         if (!isset($count)) {
-            $count = count ($this->items) - $start;
+            $count = count($this->items) - $start;
         }
         if ($count < 0) {
             $count = 0;
@@ -104,20 +104,20 @@ class UserDataGenerator
         } elseif ($sorting & self::UDG_SORT_AVERAGE) {
             // if user sorts on average scores, first calculate them and cache them
             foreach ($allitems as $item) {
-                $this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
+                $this->avgcache[$item->get_item_type().$item->get_id()] = $item->calc_score();
             }
             usort($allitems, array('UserDataGenerator', 'sort_by_average'));
         } elseif ($sorting & self::UDG_SORT_SCORE) {
             // if user sorts on student's scores, first calculate them and cache them
             foreach ($allitems as $item) {
-                $this->scorecache[$item->get_item_type() . $item->get_id()]
+                $this->scorecache[$item->get_item_type().$item->get_id()]
                     = $item->calc_score($this->userid);
             }
             usort($allitems, array('UserDataGenerator', 'sort_by_score'));
         } elseif ($sorting & self::UDG_SORT_MASK) {
             // if user sorts on student's masks, first calculate scores and cache them
             foreach ($allitems as $item) {
-                $this->scorecache[$item->get_item_type() . $item->get_id()]
+                $this->scorecache[$item->get_item_type().$item->get_id()]
                     = $item->calc_score($this->userid);
             }
             usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
@@ -132,7 +132,7 @@ class UserDataGenerator
         // fill score cache if not done yet
         if (!isset ($this->scorecache)) {
             foreach ($visibleitems as $item) {
-                $this->scorecache[$item->get_item_type() . $item->get_id()]
+                $this->scorecache[$item->get_item_type().$item->get_id()]
                     = $item->calc_score($this->userid);
             }
 
@@ -141,7 +141,7 @@ class UserDataGenerator
         $scoredisplay = ScoreDisplay::instance();
         $data = array();
         foreach ($visibleitems as $item) {
-            $row = array ();
+            $row = array();
             $row[] = $item;
             $row[] = $item->get_name();
             $row[] = $this->build_course_name($item);
@@ -163,7 +163,7 @@ class UserDataGenerator
     function sort_by_type($item1, $item2)
     {
         if ($item1->get_item_type() == $item2->get_item_type()) {
-            return $this->sort_by_name($item1,$item2);
+            return $this->sort_by_name($item1, $item2);
         } else {
             return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
         }
@@ -203,7 +203,7 @@ class UserDataGenerator
      */
     function sort_by_name($item1, $item2)
     {
-        return api_strnatcmp($item1->get_name(),$item2->get_name());
+        return api_strnatcmp($item1->get_name(), $item2->get_name());
     }
 
     /**
@@ -213,8 +213,8 @@ class UserDataGenerator
      */
     function sort_by_average($item1, $item2)
     {
-        $score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
-        $score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
+        $score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()];
+        $score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()];
 
         return $this->compare_scores($score1, $score2);
     }
@@ -226,8 +226,8 @@ class UserDataGenerator
      */
     function sort_by_score($item1, $item2)
     {
-        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
-        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
+        $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
+        $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
 
         return $this->compare_scores($score1, $score2);
     }
@@ -239,8 +239,8 @@ class UserDataGenerator
      */
     function sort_by_mask($item1, $item2)
     {
-        $score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
-        $score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
+        $score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
+        $score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
 
         return ScoreDisplay::compare_scores_by_custom_display($score1, $score2);
     }
@@ -256,10 +256,10 @@ class UserDataGenerator
             return (isset($score2) ? 1 : 0);
         } elseif (!isset($score2)) {
             return -1;
-        } elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
+        } elseif (($score1[0] / $score1[1]) == ($score2[0] / $score2[1])) {
             return 0;
         } else {
-            return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
+            return (($score1[0] / $score1[1]) < ($score2[0] / $score2[1]) ? -1 : 1);
         }
     }
 
@@ -291,7 +291,7 @@ class UserDataGenerator
     private function build_average_column($item, $ignore_score_color)
     {
         if (isset($this->avgcache)) {
-            $avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
+            $avgscore = $this->avgcache[$item->get_item_type().$item->get_id()];
         } else {
             $avgscore = $item->calc_score();
         }
@@ -311,7 +311,7 @@ class UserDataGenerator
      */
     private function build_result_column($item, $ignore_score_color)
     {
-        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
+        $studscore = $this->scorecache[$item->get_item_type().$item->get_id()];
         $scoredisplay = ScoreDisplay::instance();
         $displaytype = SCORE_DIV_PERCENT;
         if ($ignore_score_color) {
@@ -328,7 +328,7 @@ class UserDataGenerator
      */
     private function build_mask_column($item, $ignore_score_color)
     {
-        $studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
+        $studscore = $this->scorecache[$item->get_item_type().$item->get_id()];
         $scoredisplay = ScoreDisplay::instance();
         $displaytype = SCORE_DIV_PERCENT;
         if ($ignore_score_color) {

+ 58 - 58
main/inc/lib/attendance.lib.php

@@ -73,7 +73,7 @@ class Attendance
             $course_id = intval($course_id);
         }
 
-        $session_id = isset($session_id)?intval($session_id):api_get_session_id();
+        $session_id = isset($session_id) ? intval($session_id) : api_get_session_id();
         $condition_session = api_get_session_condition($session_id);
 
         // Get attendance data
@@ -108,7 +108,7 @@ class Attendance
         $from = intval($from);
         $number_of_items = intval($number_of_items);
 
-        if (!in_array($direction, array('ASC','DESC'))) {
+        if (!in_array($direction, array('ASC', 'DESC'))) {
             $direction = 'ASC';
         }
 
@@ -135,7 +135,7 @@ class Attendance
                 LIMIT $from,$number_of_items ";
 
         $res = Database::query($sql);
-        $attendances = array ();
+        $attendances = array();
         $user_info = api_get_user_info();
         $allowDelete = api_get_setting('allow_delete_attendance');
 
@@ -190,8 +190,8 @@ class Attendance
                         $attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
                     }
                     if ($allowDelete === 'true') {
-                        $actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0]. '">' .
-                            Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
+                        $actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
+                            Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
                     }
                 } else {
                     $is_locked_attendance = self::is_locked_attendance($attendance[0]);
@@ -211,8 +211,8 @@ class Attendance
                             $attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
                         }
                         if ($allowDelete === 'true') {
-                            $actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0].'">' .
-                                Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
+                            $actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
+                                Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
                         }
                     }
                 }
@@ -221,7 +221,7 @@ class Attendance
                 $is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]);
 
                 if ($is_done_all_calendar) {
-                    $locked   = $attendance[4];
+                    $locked = $attendance[4];
                     if ($locked == 0) {
                         if (api_is_platform_admin()) {
                             $message_alert = get_lang('AreYouSureToLockTheAttendance');
@@ -241,7 +241,7 @@ class Attendance
                 }
                 $actions .= '</center>';
 
-                $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3],$actions);
+                $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions);
             } else {
                 $attendance[0] = '&nbsp;';
                 $attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]);
@@ -282,13 +282,13 @@ class Attendance
     public function attendance_add($link_to_gradebook = false)
     {
         $_course = api_get_course_info();
-        $tbl_attendance	= Database::get_course_table(TABLE_ATTENDANCE);
+        $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
         $table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
         $session_id = api_get_session_id();
         $user_id = api_get_user_id();
         $course_code = $_course['code'];
         $course_id = $_course['real_id'];
-        $title_gradebook= $this->attendance_qualify_title;
+        $title_gradebook = $this->attendance_qualify_title;
         $value_calification = 0;
         $weight_calification = api_float_val($this->attendance_weight);
 
@@ -433,12 +433,12 @@ class Attendance
     public function attendance_restore($attendance_id)
     {
         $_course = api_get_course_info();
-        $tbl_attendance	= Database::get_course_table(TABLE_ATTENDANCE);
+        $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
         $user_id = api_get_user_id();
         $course_id = $_course['real_id'];
         if (is_array($attendance_id)) {
             foreach ($attendance_id as $id) {
-                $id	= intval($id);
+                $id = intval($id);
                 $sql = "UPDATE $tbl_attendance SET active = 1
                         WHERE c_id = $course_id AND id = '$id'";
                 $result = Database::query($sql);
@@ -454,8 +454,8 @@ class Attendance
                     );
                 }
             }
-        } else  {
-            $attendance_id	= intval($attendance_id);
+        } else {
+            $attendance_id = intval($attendance_id);
             $sql = "UPDATE $tbl_attendance SET active = 1
                     WHERE c_id = $course_id AND id = '$attendance_id'";
             $result = Database::query($sql);
@@ -483,13 +483,13 @@ class Attendance
     public function attendance_delete($attendance_id)
     {
         $_course = api_get_course_info();
-        $tbl_attendance	= Database::get_course_table(TABLE_ATTENDANCE);
+        $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
         $user_id = api_get_user_id();
         $course_id = $_course['real_id'];
 
         if (is_array($attendance_id)) {
             foreach ($attendance_id as $id) {
-                $id	= intval($id);
+                $id = intval($id);
                 $sql = "UPDATE $tbl_attendance SET active = 2
                         WHERE c_id = $course_id AND id = '$id'";
                 $result = Database::query($sql);
@@ -505,8 +505,8 @@ class Attendance
                     );
                 }
             }
-        } else  {
-            $attendance_id= intval($attendance_id);
+        } else {
+            $attendance_id = intval($attendance_id);
             $sql = "UPDATE $tbl_attendance SET active = 2
                     WHERE c_id = $course_id AND id = '$attendance_id'";
 
@@ -537,7 +537,7 @@ class Attendance
     public function changeVisibility($attendanceId, $status = 1)
     {
         $_course = api_get_course_info();
-        $tbl_attendance	= Database::get_course_table(TABLE_ATTENDANCE);
+        $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
         $user_id = api_get_user_id();
         $course_id = $_course['real_id'];
         $status = intval($status);
@@ -549,7 +549,7 @@ class Attendance
 
         if (is_array($attendanceId)) {
             foreach ($attendanceId as $id) {
-                $id	= intval($id);
+                $id = intval($id);
                 $sql = "UPDATE $tbl_attendance SET active = $status
                         WHERE c_id = $course_id AND id = '$id'";
                 $result = Database::query($sql);
@@ -559,8 +559,8 @@ class Attendance
                     api_item_property_update($_course, TOOL_ATTENDANCE, $id, $action, $user_id);
                 }
             }
-        } else  {
-            $attendanceId	= intval($attendanceId);
+        } else {
+            $attendanceId = intval($attendanceId);
             $sql = "UPDATE $tbl_attendance SET active = $status
                     WHERE c_id = $course_id AND id = '$attendanceId'";
             $result = Database::query($sql);
@@ -590,7 +590,7 @@ class Attendance
         $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
         $course_id = api_get_course_int_id();
         $attendance_id = intval($attendance_id);
-        $locked = ($lock)?1:0;
+        $locked = ($lock) ? 1 : 0;
         $upd = "UPDATE $tbl_attendance SET locked = $locked
                 WHERE c_id = $course_id AND id = $attendance_id";
         $result = Database::query($upd);
@@ -720,8 +720,8 @@ class Attendance
      */
     public function attendance_sheet_add($calendar_id, $users_present, $attendance_id)
     {
-        $tbl_attendance_sheet 	= Database::get_course_table(TABLE_ATTENDANCE_SHEET);
-        $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
+        $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
+        $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
 
         $calendar_id = intval($calendar_id);
         $attendance_id = intval($attendance_id);
@@ -729,7 +729,7 @@ class Attendance
         $course_id = api_get_course_int_id();
 
         $user_ids = array_keys($users);
-        $users_absent = array_diff($user_ids,$users_present);
+        $users_absent = array_diff($user_ids, $users_present);
         $affected_rows = 0;
 
         // get last edit type
@@ -1012,7 +1012,7 @@ class Attendance
         }
 
         $faults = $faults > 0 ? $faults : 0;
-        $faults_porcent = $calendar_count > 0 ?round(($faults*100)/$calendar_count,0):0;
+        $faults_porcent = $calendar_count > 0 ? round(($faults * 100) / $calendar_count, 0) : 0;
         $results['faults'] = $faults;
         $results['total'] = $calendar_count;
         $results['faults_porcent'] = $faults_porcent;
@@ -1046,13 +1046,13 @@ class Attendance
             //$course_code = $course['code'];
             //$course_info = api_get_course_info($course_code);
             $course_id = $course['real_id'];
-            $tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
+            $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
 
             $attendances_by_course = $this->get_attendances_list($course_id);
 
             foreach ($attendances_by_course as $attendance) {
                 // get total faults and total weight
-                $total_done_attendance 	= $attendance['attendance_qualify_max'];
+                $total_done_attendance = $attendance['attendance_qualify_max'];
                 $sql = "SELECT score
                         FROM $tbl_attendance_result
                         WHERE
@@ -1065,16 +1065,16 @@ class Attendance
                     $row = Database::fetch_array($rs);
                     $score = $row['score'];
                 }
-                $faults = $total_done_attendance-$score;
-                $faults = $faults > 0 ? $faults:0;
+                $faults = $total_done_attendance - $score;
+                $faults = $faults > 0 ? $faults : 0;
                 $total_faults += $faults;
                 $total_weight += $total_done_attendance;
             }
         }
 
-        $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
+        $porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
         $results['faults'] 	= $total_faults;
-        $results['total']	= $total_weight;
+        $results['total'] = $total_weight;
         $results['porcent'] = $porcent;
 
         return $results;
@@ -1092,7 +1092,7 @@ class Attendance
     {
         // Database tables and variables
         $course_info = api_get_course_info($course_code);
-        $tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
+        $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
         $user_id = intval($user_id);
         $results = array();
         $total_faults = $total_weight = $porcent = 0;
@@ -1100,7 +1100,7 @@ class Attendance
 
         foreach ($attendances_by_course as $attendance) {
             // Get total faults and total weight
-            $total_done_attendance 	= $attendance['attendance_qualify_max'];
+            $total_done_attendance = $attendance['attendance_qualify_max'];
             $sql = "SELECT score FROM $tbl_attendance_result
                     WHERE
                         c_id = {$course_info['real_id']} AND
@@ -1112,15 +1112,15 @@ class Attendance
                 $row = Database::fetch_array($rs);
                 $score = $row['score'];
             }
-            $faults = $total_done_attendance-$score;
-            $faults = $faults > 0 ? $faults:0;
+            $faults = $total_done_attendance - $score;
+            $faults = $faults > 0 ? $faults : 0;
             $total_faults += $faults;
             $total_weight += $total_done_attendance;
         }
 
-        $porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
+        $porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
         $results['faults'] 	= $total_faults;
-        $results['total']	= $total_weight;
+        $results['total'] = $total_weight;
         $results['porcent'] = $porcent;
 
         return $results;
@@ -1134,8 +1134,8 @@ class Attendance
      */
     public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null)
     {
-        $tbl_attendance_sheet 	= Database::get_course_table(TABLE_ATTENDANCE_SHEET);
-        $tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
+        $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
+        $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
 
         $attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId);
         $calendar_ids = array();
@@ -1157,7 +1157,7 @@ class Attendance
                             WHERE
                                 c_id = $course_id AND
                                 user_id = '$uid' AND
-                                attendance_calendar_id IN(".implode(',',$calendar_ids).")
+                                attendance_calendar_id IN(".implode(',', $calendar_ids).")
                             ";
                     $res = Database::query($sql);
                     if (Database::num_rows($res) > 0) {
@@ -1179,7 +1179,7 @@ class Attendance
                             att.c_id = $course_id AND
                             cal.c_id =  $course_id AND
                             att.user_id = '$user_id' AND
-                            att.attendance_calendar_id IN (".implode(',',$calendar_ids).")
+                            att.attendance_calendar_id IN (".implode(',', $calendar_ids).")
                         ORDER BY date_time";
                 $res = Database::query($sql);
                 if (Database::num_rows($res) > 0) {
@@ -1257,7 +1257,7 @@ class Attendance
      */
     public function get_user_score($user_id, $attendance_id, $groupId = null)
     {
-        $tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
+        $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
         $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
         $tbl_attendance_cal_rel_group = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP);
         $tbl_attendance_cal = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
@@ -1370,7 +1370,7 @@ class Attendance
                    ";
         }
 
-        if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) {
+        if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done', 'calendar_id'))) {
             $type = 'all';
         }
 
@@ -1378,7 +1378,7 @@ class Attendance
             case 'calendar_id':
                 $calendar_id = intval($calendar_id);
                 if (!empty($calendar_id)) {
-                    $sql.= " AND c.id = $calendar_id";
+                    $sql .= " AND c.id = $calendar_id";
                 }
                 break;
             case 'today':
@@ -1399,7 +1399,7 @@ class Attendance
         $rs = Database::query($sql);
         $data = array();
         if (Database::num_rows($rs) > 0) {
-            while ($row = Database::fetch_array($rs,'ASSOC')) {
+            while ($row = Database::fetch_array($rs, 'ASSOC')) {
                 $row['db_date_time'] = $row['date_time'];
                 $row['date_time'] = api_get_local_time($row['date_time']);
                 $row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT);
@@ -1764,14 +1764,14 @@ class Attendance
      * @param   int     The number of years to add
      * @return  int     The new timestamp
      */
-    private function add_month($timestamp, $num=1)
+    private function add_month($timestamp, $num = 1)
     {
         $values = api_get_utc_datetime($timestamp);
-        $values = str_replace(array(':','-',' '), '/', $values);
-        list($y, $m, $d, $h, $n, $s) = split('/',$values);
-        if($m+$num>12) {
-            $y += floor($num/12);
-            $m += $num%12;
+        $values = str_replace(array(':', '-', ' '), '/', $values);
+        list($y, $m, $d, $h, $n, $s) = split('/', $values);
+        if ($m + $num > 12) {
+            $y += floor($num / 12);
+            $m += $num % 12;
         } else {
             $m += $num;
         }
@@ -1829,7 +1829,7 @@ class Attendance
      * @param	bool	true for removing all calendar inside current attendance, false for removing by calendar id
      * @return	int affected rows
      */
-    public function attendance_calendar_delete($calendar_id, $attendance_id , $all_delete = false)
+    public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false)
     {
         $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
         $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
@@ -1987,7 +1987,7 @@ class Attendance
 
         $dateTimeStartOriginal = new DateTime($startDate);
         $dateTimeStart = new DateTime($startDate);
-        $dateTimeEnd= new DateTime($endDate);
+        $dateTimeEnd = new DateTime($endDate);
         $interval = $dateTimeStart->diff($dateTimeEnd);
         $days = intval($interval->format('%a'));
 
@@ -2060,7 +2060,7 @@ class Attendance
                 0,
                 $user['lastname'].' '.$user['firstname'].' ('.$user['username'].')'
             );
-            $row ++;
+            $row++;
         }
 
         $column = 1;
@@ -2137,7 +2137,7 @@ class Attendance
         $tableToString = $table->toHtml();
 
         $params = array(
-            'filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(),
+            'filename' => get_lang('Attendance').'_'.api_get_utc_datetime(),
             'pdf_title' => get_lang('Attendance'),
             'course_code' => api_get_course_id(),
             'show_real_course_teachers' => true

+ 8 - 8
main/inc/lib/certificate.lib.php

@@ -204,7 +204,7 @@ class Certificate extends Model
                             // Creating new name
                             $name = md5($this->user_id.$this->certificate_data['cat_id']).'.html';
                             $my_path_certificate = $this->certification_user_path.$name;
-                            $path_certificate    ='/'.$name;
+                            $path_certificate    = '/'.$name;
 
                             // Getting QR filename
                             $file_info = pathinfo($path_certificate);
@@ -351,11 +351,11 @@ class Certificate extends Model
             $final_content['gradebook_institution'].' - '.
             $final_content['gradebook_sitename'].' - '.
             get_lang('Certification').$break_space.
-            get_lang('Student'). ': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space.
-            get_lang('Teacher'). ': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space.
-            get_lang('Date'). ': '.$final_content['date_certificate'].$break_space.
-            get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space.
-            'URL'. ': '.$final_content['certificate_link'];
+            get_lang('Student').': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space.
+            get_lang('Teacher').': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space.
+            get_lang('Date').': '.$final_content['date_certificate'].$break_space.
+            get_lang('Score').': '.$final_content['gradebook_grade'].$break_space.
+            'URL'.': '.$final_content['certificate_link'];
 
         return $text;
     }
@@ -408,7 +408,7 @@ class Certificate extends Model
             return false;
         }
 
-        $user_certificate = $this->certification_user_path . basename($this->certificate_data['path_certificate']);
+        $user_certificate = $this->certification_user_path.basename($this->certificate_data['path_certificate']);
 
         if (!file_exists($user_certificate)) {
             return false;
@@ -422,7 +422,7 @@ class Certificate extends Model
     */
     public function show()
     {
-        header('Content-Type: text/html; charset='. api_get_system_encoding());
+        header('Content-Type: text/html; charset='.api_get_system_encoding());
 
         $user_certificate = $this->certification_user_path.basename($this->certificate_data['path_certificate']);
         if (file_exists($user_certificate)) {

+ 22 - 22
main/inc/lib/diagnoser.lib.php

@@ -15,7 +15,7 @@ class Diagnoser
 {
     const STATUS_OK = 1;
     const STATUS_WARNING = 2;
-    const STATUS_ERROR 	= 3;
+    const STATUS_ERROR = 3;
     const STATUS_INFORMATION = 4;
 
     /**
@@ -45,12 +45,12 @@ class Diagnoser
                 $html .= '<li>';
             }
             $params['section'] = $section;
-            $html .='<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>';
+            $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>';
         }
 
         $html .= '</ul><div class="tab-pane">';
 
-        $data = call_user_func(array($this, 'get_' . $currentSection . '_data'));
+        $data = call_user_func(array($this, 'get_'.$currentSection.'_data'));
         echo $html;
 
         if ($currentSection != 'paths') {
@@ -117,11 +117,11 @@ class Diagnoser
     {
         $array = array();
         $writable_folders = array(
-            api_get_path(SYS_APP_PATH) .'cache',
+            api_get_path(SYS_APP_PATH).'cache',
             api_get_path(SYS_COURSE_PATH),
-            api_get_path(SYS_APP_PATH) .'home',
-            api_get_path(SYS_APP_PATH) .'upload/users/',
-            api_get_path(SYS_PATH) .'main/default_course_document/images/',
+            api_get_path(SYS_APP_PATH).'home',
+            api_get_path(SYS_APP_PATH).'upload/users/',
+            api_get_path(SYS_PATH).'main/default_course_document/images/',
         );
         foreach ($writable_folders as $index => $folder) {
             $writable = is_writable($folder);
@@ -140,10 +140,10 @@ class Diagnoser
 
         $exists = file_exists(api_get_path(SYS_CODE_PATH).'install');
         $status = $exists ? self::STATUS_WARNING : self::STATUS_OK;
-        $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved'));
+        $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists').': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved'));
 
         $app_version = api_get_setting('chamilo_database_version');
-        $array[] = $this->build_setting(self::STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null,  'Chamilo DB version');
+        $array[] = $this->build_setting(self::STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version');
 
         $access_url_id = api_get_current_access_url_id();
 
@@ -155,7 +155,7 @@ class Diagnoser
                     $message2 .= get_lang('SpaceUsedOnSystemCannotBeMeasuredOnWindows');
                 } else {
                     $dir = api_get_path(SYS_PATH);
-                    $du = exec('du -sh ' . $dir, $err);
+                    $du = exec('du -sh '.$dir, $err);
                     list($size, $none) = explode("\t", $du);
                     $limit = $_configuration[$access_url_id]['hosting_limit_disk_space'];
                     $message2 .= sprintf(get_lang('TotalSpaceUsedByPortalXLimitIsYMB'), $size, $limit);
@@ -239,33 +239,33 @@ class Diagnoser
         $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo'));
 
         $setting = ini_get('max_execution_time');
-        $req_setting = '300 (' . get_lang('Minimum') . ')';
+        $req_setting = '300 ('.get_lang('Minimum').')';
         $status = $setting >= 300 ? self::STATUS_OK : self::STATUS_WARNING;
         $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo'));
 
         $setting = ini_get('max_input_time');
-        $req_setting = '300 (' . get_lang('Minimum') . ')';
+        $req_setting = '300 ('.get_lang('Minimum').')';
         $status = $setting >= 300 ? self::STATUS_OK : self::STATUS_WARNING;
         $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo'));
 
         $setting = ini_get('memory_limit');
         $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M';
         $status = self::STATUS_ERROR;
-        if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT)
+        if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT)
             $status = self::STATUS_OK;
         $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo'));
 
         $setting = ini_get('post_max_size');
         $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M';
         $status = self::STATUS_ERROR;
-        if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE)
+        if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE)
             $status = self::STATUS_OK;
         $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo'));
 
         $setting = ini_get('upload_max_filesize');
         $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M';
         $status = self::STATUS_ERROR;
-        if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE)
+        if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE)
             $status = self::STATUS_OK;
         $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo'));
 
@@ -279,7 +279,7 @@ class Diagnoser
         $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
         $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo'));
 
-        if (api_check_browscap()){$setting = true;}else{$setting=false;}
+        if (api_check_browscap()) {$setting = true; } else {$setting = false; }
         $req_setting = true;
         $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
         $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo'));
@@ -345,7 +345,7 @@ class Diagnoser
 
             $loaded = extension_loaded($extension);
             $status = $loaded ? self::STATUS_OK : self::STATUS_ERROR;
-            $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension') . ': ' . $extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment);
+            $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment);
         }
 
         return $array;
@@ -470,9 +470,9 @@ class Diagnoser
         $formatted_expected_value = $expected_value;
 
         if ($formatter) {
-            if (method_exists($this, 'format_' . $formatter)) {
-                $formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value);
-                $formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value);
+            if (method_exists($this, 'format_'.$formatter)) {
+                $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value);
+                $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value);
             }
         }
 
@@ -487,13 +487,13 @@ class Diagnoser
      */
     public function get_link($title, $url)
     {
-        return '<a href="' . $url . '" target="about:bank">' . $title . '</a>';
+        return '<a href="'.$url.'" target="about:bank">'.$title.'</a>';
     }
 
     public function format_yes_no_optional($value)
     {
     	$return = '';
-    	switch($value) {
+    	switch ($value) {
      		case 0:
      			$return = get_lang('No');
      			break;

+ 68 - 68
main/inc/lib/text.lib.php

@@ -60,10 +60,10 @@ function api_set_encoding_html(&$string, $encoding)
     if (@preg_match('/(.*<head.*)(<meta[^>]*content=[^>]*>)(.*<\/head>.*)/si', $string, $matches)) {
         $meta = $matches[2];
         if (@preg_match("/(<meta[^>]*charset=)(.*)([\"';][^>]*>)/si", $meta, $matches1)) {
-            $meta = $matches1[1] . $encoding . $matches1[3];
-            $string = $matches[1] . $meta . $matches[3];
+            $meta = $matches1[1].$encoding.$matches1[3];
+            $string = $matches[1].$meta.$matches[3];
         } else {
-            $string = $matches[1] . '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>' . $matches[3];
+            $string = $matches[1].'<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/>'.$matches[3];
         }
     } else {
         $count = 1;
@@ -171,9 +171,9 @@ function _api_convert_encoding_xml(&$string, $to_encoding, $from_encoding) {
     if (!preg_match(_PCRE_XML_ENCODING, $string)) {
         if (strpos($matches[0], 'standalone') !== false) {
             // The encoding option should precede the standalone option, othewise DOMDocument fails to load the document.
-            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone' , $matches[0]);
+            $replace = str_replace('standalone', ' encoding="'.$to_encoding.'" standalone', $matches[0]);
         } else {
-            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>' , $matches[0]);
+            $replace = str_replace('?>', ' encoding="'.$to_encoding.'"?>', $matches[0]);
         }
         return api_convert_encoding(str_replace($matches[0], $replace, $string), $to_encoding, $from_encoding);
     }
@@ -344,7 +344,7 @@ function domesticate($input)
 function _make_url_clickable_cb($matches) {
     $url = $matches[2];
 
-    if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
+    if (')' == $matches[3] && strpos($url, '(')) {
         // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.
         // Then we can let the parenthesis balancer do its thing below.
         $url .= $matches[3];
@@ -354,16 +354,16 @@ function _make_url_clickable_cb($matches) {
     }
 
     // Include parentheses in the URL only if paired
-    while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
-        $suffix = strrchr( $url, ')' ) . $suffix;
-        $url = substr( $url, 0, strrpos( $url, ')' ) );
+    while (substr_count($url, '(') < substr_count($url, ')')) {
+        $suffix = strrchr($url, ')').$suffix;
+        $url = substr($url, 0, strrpos($url, ')'));
     }
 
     $url = esc_url($url);
-    if ( empty($url) )
+    if (empty($url))
         return $matches[0];
 
-    return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
+    return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix;
 }
 
 /**
@@ -383,10 +383,10 @@ function _make_url_clickable_cb($matches) {
  * @param string $_context Private. Use esc_url_raw() for database usage.
  * @return string The cleaned $url after the 'clean_url' filter is applied.
  */
-function esc_url( $url, $protocols = null, $_context = 'display' ) {
+function esc_url($url, $protocols = null, $_context = 'display') {
     //$original_url = $url;
 
-    if ( '' == $url )
+    if ('' == $url)
         return $url;
     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
     $strip = array('%0d', '%0a', '%0D', '%0A');
@@ -396,9 +396,9 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
      * presume it needs http:// appended (unless a relative
      * link starting with /, # or ? or a php file).
      */
-    if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
-        ! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
-        $url = 'http://' . $url;
+    if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) &&
+        !preg_match('/^[a-z0-9-]+?\.php/i', $url))
+        $url = 'http://'.$url;
 
     return Security::remove_XSS($url);
 
@@ -446,12 +446,12 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
  * @return string The string with the replaced svalues.
  */
-function _deep_replace( $search, $subject ) {
+function _deep_replace($search, $subject) {
     $subject = (string) $subject;
 
     $count = 1;
-    while ( $count ) {
-        $subject = str_replace( $search, '', $subject, $count );
+    while ($count) {
+        $subject = str_replace($search, '', $subject, $count);
     }
 
     return $subject;
@@ -473,17 +473,17 @@ function _deep_replace( $search, $subject ) {
 function _make_web_ftp_clickable_cb($matches) {
     $ret = '';
     $dest = $matches[2];
-    $dest = 'http://' . $dest;
+    $dest = 'http://'.$dest;
     $dest = esc_url($dest);
-    if ( empty($dest) )
+    if (empty($dest))
         return $matches[0];
 
     // removed trailing [.,;:)] from URL
-    if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
+    if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) {
         $ret = substr($dest, -1);
-        $dest = substr($dest, 0, strlen($dest)-1);
+        $dest = substr($dest, 0, strlen($dest) - 1);
     }
-    return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
+    return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
 }
 
 /**
@@ -499,8 +499,8 @@ function _make_web_ftp_clickable_cb($matches) {
  * @return string HTML A element with email address.
  */
 function _make_email_clickable_cb($matches) {
-    $email = $matches[2] . '@' . $matches[3];
-    return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
+    $email = $matches[2].'@'.$matches[3];
+    return $matches[1]."<a href=\"mailto:$email\">$email</a>";
 }
 
 /**
@@ -514,30 +514,30 @@ function _make_email_clickable_cb($matches) {
  * @param string $text Content to convert URIs.
  * @return string Content with converted URIs.
  */
-function make_clickable( $text ) {
+function make_clickable($text) {
     $r = '';
-    $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
+    $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags
     $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>
-    foreach ( $textarr as $piece ) {
+    foreach ($textarr as $piece) {
 
-        if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) )
+        if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece))
             $nested_code_pre++;
-        elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre )
+        elseif (('</code>' === strtolower($piece) || '</pre>' === strtolower($piece)) && $nested_code_pre)
             $nested_code_pre--;
 
-        if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
+        if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && !preg_match('|^<\s*[\w]{1,20}+://|', $piece))) {
             $r .= $piece;
             continue;
         }
 
         // Long strings might contain expensive edge cases ...
-        if ( 10000 < strlen( $piece ) ) {
+        if (10000 < strlen($piece)) {
             // ... break it up
-            foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
-                if ( 2101 < strlen( $chunk ) ) {
+            foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses
+                if (2101 < strlen($chunk)) {
                     $r .= $chunk; // Too big, no whitespace: bail.
                 } else {
-                    $r .= make_clickable( $chunk );
+                    $r .= make_clickable($chunk);
                 }
             }
         } else {
@@ -558,18 +558,18 @@ function make_clickable( $text ) {
 			~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
             // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
 
-            $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
+            $ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret);
 
-            $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
-            $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
+            $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
+            $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
 
-            $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
+            $ret = substr($ret, 1, -1); // Remove our whitespace padding.
             $r .= $ret;
         }
     }
 
     // Cleanup of accidental links within links
-    $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
+    $r = preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r);
     return $r;
 }
 
@@ -604,27 +604,27 @@ function make_clickable( $text ) {
  * @param int $goal The desired chunk length.
  * @return array Numeric array of chunks.
  */
-function _split_str_by_whitespace( $string, $goal ) {
+function _split_str_by_whitespace($string, $goal) {
     $chunks = array();
 
-    $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
+    $string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000");
 
-    while ( $goal < strlen( $string_nullspace ) ) {
-        $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
+    while ($goal < strlen($string_nullspace)) {
+        $pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000");
 
-        if ( false === $pos ) {
-            $pos = strpos( $string_nullspace, "\000", $goal + 1 );
-            if ( false === $pos ) {
+        if (false === $pos) {
+            $pos = strpos($string_nullspace, "\000", $goal + 1);
+            if (false === $pos) {
                 break;
             }
         }
 
-        $chunks[] = substr( $string, 0, $pos + 1 );
-        $string = substr( $string, $pos + 1 );
-        $string_nullspace = substr( $string_nullspace, $pos + 1 );
+        $chunks[] = substr($string, 0, $pos + 1);
+        $string = substr($string, $pos + 1);
+        $string_nullspace = substr($string_nullspace, $pos + 1);
     }
 
-    if ( $string ) {
+    if ($string) {
         $chunks[] = $string;
     }
 
@@ -702,7 +702,7 @@ function get_last_week() {
  */
 function get_week_from_day($date) {
     if (!empty($date)) {
-       $time = api_strtotime($date,'UTC');
+       $time = api_strtotime($date, 'UTC');
        return date('W', $time);
     } else {
         return date('W');
@@ -719,7 +719,7 @@ function get_week_from_day($date) {
  * @return a reduce string
  */
 
-function substrwords($text,$maxchar,$end='...')
+function substrwords($text, $maxchar, $end = '...')
 {
     if (strlen($text) > $maxchar) {
         $words = explode(" ", $text);
@@ -747,7 +747,7 @@ function implode_with_key($glue, $array)
 {
     if (!empty($array)) {
         $string = '';
-        foreach($array as $key => $value) {
+        foreach ($array as $key => $value) {
             if (empty($value)) {
                 $value = 'null';
             }
@@ -769,13 +769,13 @@ function format_file_size($file_size)
 {
     $file_size = intval($file_size);
     if ($file_size >= 1073741824) {
-        $file_size = round($file_size / 1073741824 * 100) / 100 . 'G';
-    } elseif($file_size >= 1048576) {
-        $file_size = round($file_size / 1048576 * 100) / 100 . 'M';
-    } elseif($file_size >= 1024) {
-        $file_size = round($file_size / 1024 * 100) / 100 . 'k';
+        $file_size = round($file_size / 1073741824 * 100) / 100.'G';
+    } elseif ($file_size >= 1048576) {
+        $file_size = round($file_size / 1048576 * 100) / 100.'M';
+    } elseif ($file_size >= 1024) {
+        $file_size = round($file_size / 1024 * 100) / 100.'k';
     } else {
-        $file_size = $file_size . 'B';
+        $file_size = $file_size.'B';
     }
     return $file_size;
 }
@@ -784,18 +784,18 @@ function return_datetime_from_array($array)
 {
     $year	 = '0000';
     $month = $day = $hours = $minutes = $seconds = '00';
-    if (isset($array['Y']) && (isset($array['F']) || isset($array['M']))  && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
+    if (isset($array['Y']) && (isset($array['F']) || isset($array['M'])) && isset($array['d']) && isset($array['H']) && isset($array['i'])) {
         $year = $array['Y'];
-        $month = isset($array['F'])?$array['F']:$array['M'];
-        if (intval($month) < 10 ) $month = '0'.$month;
+        $month = isset($array['F']) ? $array['F'] : $array['M'];
+        if (intval($month) < 10) $month = '0'.$month;
         $day = $array['d'];
-        if (intval($day) < 10 ) $day = '0'.$day;
+        if (intval($day) < 10) $day = '0'.$day;
         $hours = $array['H'];
-        if (intval($hours) < 10 ) $hours = '0'.$hours;
+        if (intval($hours) < 10) $hours = '0'.$hours;
         $minutes = $array['i'];
-        if (intval($minutes) < 10 ) $minutes = '0'.$minutes;
+        if (intval($minutes) < 10) $minutes = '0'.$minutes;
     }
-    if (checkdate($month,$day,$year)) {
+    if (checkdate($month, $day, $year)) {
         $datetime = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.':'.$seconds;
     }
     return $datetime;

+ 21 - 21
main/lp/lp_view.php

@@ -21,7 +21,7 @@ $_SESSION['whereami'] = 'lp/view';
 $this_section = SECTION_COURSES;
 
 if ($lp_controller_touched != 1) {
-    header('location: lp_controller.php?action=view&item_id=' . intval($_REQUEST['item_id']));
+    header('location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id']));
     exit;
 }
 
@@ -119,7 +119,7 @@ if ($_SESSION['oLP']->mode == 'embedframe' || $_SESSION['oLP']->get_hide_toc_fra
 // Impress js
 if ($_SESSION['oLP']->mode == 'impress') {
     $lp_id = $_SESSION['oLP']->get_id();
-    $url = api_get_path(WEB_CODE_PATH) . "lp/lp_impress.php?lp_id=$lp_id&" . api_get_cidreq();
+    $url = api_get_path(WEB_CODE_PATH)."lp/lp_impress.php?lp_id=$lp_id&".api_get_cidreq();
     header("Location: $url");
     exit;
 }
@@ -137,15 +137,15 @@ if (isset($exerciseResult) || isset($_SESSION['exerciseResult'])) {
 
 // additional APIs
 $htmlHeadXtra[] = '<script>
-chamilo_courseCode = "' . $course_code . '";
+chamilo_courseCode = "' . $course_code.'";
 </script>';
 // Document API
 $htmlHeadXtra[] = '<script src="js/documentapi.js" type="text/javascript" language="javascript"></script>';
 // Storage API
 $htmlHeadXtra[] = '<script>
-var sv_user = \'' . api_get_user_id() . '\';
+var sv_user = \'' . api_get_user_id().'\';
 var sv_course = chamilo_courseCode;
-var sv_sco = \'' . $lp_id . '\';
+var sv_sco = \'' . $lp_id.'\';
 </script>'; // FIXME fetch sco and userid from a more reliable source directly in sotrageapi.js
 $htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
 
@@ -216,7 +216,7 @@ if (!isset($src)) {
         case 3:
             // aicc
             $_SESSION['oLP']->stop_previous_item(); // save status manually if asset
-            $htmlHeadXtra[] = '<script src="' . $_SESSION['oLP']->get_js_lib().'" type="text/javascript" language="javascript"></script>';
+            $htmlHeadXtra[] = '<script src="'.$_SESSION['oLP']->get_js_lib().'" type="text/javascript" language="javascript"></script>';
             $preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
             if ($preReqCheck === true) {
                 $src = $_SESSION['oLP']->get_link(
@@ -238,10 +238,10 @@ $autostart = 'true';
 // Update status, total_time from lp_item_view table when you finish the exercises in learning path.
 
 if ($debug) {
-    error_log('$type_quiz: ' . $type_quiz);
-    error_log('$_REQUEST[exeId]: ' . intval($_REQUEST['exeId']));
-    error_log('$lp_id: ' . $lp_id);
-    error_log('$_GET[lp_item_id]: ' . intval($_GET['lp_item_id']));
+    error_log('$type_quiz: '.$type_quiz);
+    error_log('$_REQUEST[exeId]: '.intval($_REQUEST['exeId']));
+    error_log('$lp_id: '.$lp_id);
+    error_log('$_GET[lp_item_id]: '.intval($_GET['lp_item_id']));
 }
 
 if (!empty($_REQUEST['exeId']) &&
@@ -262,7 +262,7 @@ if (!empty($_REQUEST['exeId']) &&
         $safe_item_id == strval(intval($safe_item_id))
     ) {
         $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id
-                FROM ' . $TBL_TRACK_EXERCICES . '
+                FROM ' . $TBL_TRACK_EXERCICES.'
                 WHERE exe_id = ' . $safe_exe_id;
         $res = Database::query($sql);
         $row_dates = Database::fetch_array($res);
@@ -276,14 +276,14 @@ if (!empty($_REQUEST['exeId']) &&
 
         $sql = "UPDATE $TBL_LP_ITEM SET
                     max_score = '$max_score'
-                WHERE c_id = $course_id AND id = '" . $safe_item_id . "'";
+                WHERE c_id = $course_id AND id = '".$safe_item_id."'";
         Database::query($sql);
 
         $sql = "SELECT id FROM $TBL_LP_ITEM_VIEW
                 WHERE
                     c_id = $course_id AND
                     lp_item_id = '$safe_item_id' AND
-                    lp_view_id = '" . $_SESSION['oLP']->lp_view_id . "'
+                    lp_view_id = '".$_SESSION['oLP']->lp_view_id."'
                 ORDER BY id DESC
                 LIMIT 1";
         $res_last_attempt = Database::query($sql);
@@ -312,7 +312,7 @@ if (!empty($_REQUEST['exeId']) &&
                         status = '$status',
                         score = $score,
                         total_time = $mytime
-                    WHERE id='" . $lp_item_view_id . "' AND c_id = $course_id ";
+                    WHERE id='".$lp_item_view_id."' AND c_id = $course_id ";
 
             if ($debug) {
                 error_log($sql);
@@ -322,7 +322,7 @@ if (!empty($_REQUEST['exeId']) &&
 
             $sql = "UPDATE $TBL_TRACK_EXERCICES SET
                         orig_lp_item_view_id = $lp_item_view_id
-                    WHERE exe_id = " . $safe_exe_id;
+                    WHERE exe_id = ".$safe_exe_id;
             Database::query($sql);
         }
     }
@@ -331,7 +331,7 @@ if (!empty($_REQUEST['exeId']) &&
     } else {
         $src = api_get_path(WEB_CODE_PATH).'exercise/result.php?origin=learnpath&id='.$safe_exe_id.'&'.api_get_cidreq();
         if ($debug) {
-            error_log('Calling URL: ' . $src);
+            error_log('Calling URL: '.$src);
         }
     }
     $autostart = 'false';
@@ -387,8 +387,8 @@ $mediaplayer = $_SESSION['oLP']->get_mediaplayer($_SESSION['oLP']->current, $aut
 $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 $show_audioplayer = false;
 // Getting all the information about the item.
-$sql = "SELECT audio FROM " . $tbl_lp_item . "
-        WHERE c_id = $course_id AND lp_id = '" . $_SESSION['oLP']->lp_id . "'";
+$sql = "SELECT audio FROM ".$tbl_lp_item."
+        WHERE c_id = $course_id AND lp_id = '".$_SESSION['oLP']->lp_id."'";
 $res_media = Database::query($sql);
 
 if (Database::num_rows($res_media) > 0) {
@@ -409,7 +409,7 @@ if ($is_allowed_to_edit) {
         'name' => get_lang('LearningPaths')
     );
     $interbreadcrumb[] = array(
-        'url' => api_get_self() . "?action=add_item&type=step&lp_id={$_SESSION['oLP']->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
+        'url' => api_get_self()."?action=add_item&type=step&lp_id={$_SESSION['oLP']->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
         'name' => $_SESSION['oLP']->get_name()
     );
 
@@ -421,12 +421,12 @@ if ($is_allowed_to_edit) {
 
 // Return to course home.
 if ($is_allowed_to_edit) {
-    $buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq(true, true, 'course') . '&' . http_build_query([
+    $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
         'isStudentView' => 'false',
         'action' => 'return_to_course_homepage'
     ]);
 } else {
-    $buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq(true, true, 'course') . '&' . http_build_query([
+    $buttonHomeUrl = 'lp_controller.php?'.api_get_cidreq(true, true, 'course').'&'.http_build_query([
         'action' => 'return_to_course_homepage'
     ]);
 }

+ 11 - 11
main/survey/survey.lib.php

@@ -35,7 +35,7 @@ class SurveyManager
             $result = Database::query($sql);
             if (Database::num_rows($result)) {
                 $num++;
-                $new_code = $code . $num;
+                $new_code = $code.$num;
             } else {
                 break;
             }
@@ -130,7 +130,7 @@ class SurveyManager
         $table_survey = Database::get_course_table(TABLE_SURVEY);
 
         if ($shared != 0) {
-            $table_survey	= Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
+            $table_survey = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION);
             $sql = "SELECT * FROM $table_survey
                     WHERE survey_id='".intval($survey_id)."' ";
         } else {
@@ -143,7 +143,7 @@ class SurveyManager
         $result = Database::query($sql);
         $return = array();
 
-        if (Database::num_rows($result)> 0) {
+        if (Database::num_rows($result) > 0) {
             $return = Database::fetch_array($result, 'ASSOC');
             if ($simple_return) {
                 return $return;
@@ -234,7 +234,7 @@ class SurveyManager
                             if ($values[$field] == '') {
                                 $values[$field] = 0;
                             }
-                            $field_values.= $field.':'.$values[$field].'@';
+                            $field_values .= $field.':'.$values[$field].'@';
                         }
                     }
                     $extraParams['form_fields'] = $field_values;
@@ -394,7 +394,7 @@ class SurveyManager
                             ) {
                                 $values[$field] = 0;
                             }
-                            $field_values.= $field.':'.$values[$field].'@';
+                            $field_values .= $field.':'.$values[$field].'@';
                         }
                     }
                     $extraParams['form_fields'] = $field_values;
@@ -526,7 +526,7 @@ class SurveyManager
         $_course = api_get_course_info();
 
         // Table definitions
-        $table_survey	= Database::get_main_table(TABLE_MAIN_SHARED_SURVEY);
+        $table_survey = Database::get_main_table(TABLE_MAIN_SHARED_SURVEY);
 
         if (!$values['survey_id'] ||
             !is_numeric($values['survey_id']) ||
@@ -544,7 +544,7 @@ class SurveyManager
                     '".api_get_utc_datetime()."',
                     '".$_course['id']."')";
             Database::query($sql);
-            $return	= Database::insert_id();
+            $return = Database::insert_id();
 
             $sql = "UPDATE $table_survey SET survey_id = $return WHERE iid = $return";
             Database::query($sql);
@@ -561,7 +561,7 @@ class SurveyManager
                         surveythanks	= '".Database::escape_string($values['survey_thanks'])."'
 					WHERE survey_id = '".Database::escape_string($values['survey_share']['survey_share'])."'";
             Database::query($sql);
-            $return	= $values['survey_share']['survey_share'];
+            $return = $values['survey_share']['survey_share'];
         }
 
         return $return;
@@ -662,7 +662,7 @@ class SurveyManager
             $params['c_id'] = $targetCourseId;
             unset($params['survey_id']);
             $params['session_id'] = api_get_session_id();
-            $params['title'] = $params['title'] . ' ' . get_lang('Copy');
+            $params['title'] = $params['title'].' '.get_lang('Copy');
             unset($params['iid']);
             Database::insert($table_survey, $params);
             $new_survey_id = Database::insert_id();
@@ -900,7 +900,7 @@ class SurveyManager
     {
         // Table definitions
         $tbl_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
-        $table_survey_question_option 	= Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
+        $table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
         $course_id = api_get_course_int_id();
 
         $sql = "SELECT * FROM $tbl_survey_question
@@ -1220,7 +1220,7 @@ class SurveyManager
                     '".Database::escape_string($form_content['question_comment'])."',
                     '".Database::escape_string($form_content['type'])."',
                     '".Database::escape_string($form_content['horizontalvertical'])."',
-                    '".Database::escape_string($max_sort+1)."',
+                    '".Database::escape_string($max_sort + 1)."',
                     '".Database::escape_string($_course['id'])."')";
             Database::query($sql);
             $shared_question_id = Database::insert_id();