Pārlūkot izejas kodu

Minor - format code.

Julio Montoya 10 gadi atpakaļ
vecāks
revīzija
29b1bd4175
3 mainītis faili ar 135 papildinājumiem un 98 dzēšanām
  1. 40 29
      main/exercice/exercice.php
  2. 71 49
      main/exercice/exercise.class.php
  3. 24 20
      main/exercice/overview.php

+ 40 - 29
main/exercice/exercice.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * 	Exercise list: This script shows the list of exercises for administrators and students.
  * 	@package chamilo.exercise
@@ -10,9 +11,6 @@
  * Modified by hubert.borderiou (question category)
  */
 
-/**
- * Code
- */
 // name of the language file that needs to be included
 
 use \ChamiloSession as Session;
@@ -56,7 +54,6 @@ $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
 $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
 $TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 
-
 // document path
 $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
 // picture path
@@ -64,7 +61,7 @@ $picturePath = $documentPath.'/images';
 // audio path
 $audioPath = $documentPath.'/audio';
 
-// hotpotatoes
+// hot potatoes
 $uploadPath = DIR_HOTPOTATOES; //defined in main_api
 $exercicePath = api_get_self();
 $exfile = explode('/', $exercicePath);
@@ -221,7 +218,6 @@ if ($is_allowedToEdit) {
                 // list des exercices dans un test
                 // we got variable $course_id $course_info session api_get_session_id()
                 $tab_exercise_list = get_all_exercises_for_course_id($course_info, api_get_session_id(), $course_id, false);
-
                 $quantity_results_deleted = 0;
                 foreach ($tab_exercise_list as $exeItem) {
                     // delete result for test, if not in a gradebook
@@ -239,7 +235,6 @@ if ($is_allowedToEdit) {
 
         // single exercise choice
         // construction of Exercise
-
         $objExerciseTmp = new Exercise();
         $check = Security::check_token('get');
         $exercise_action_locked = api_resource_is_locked_by_gradebook($exerciseId, LINK_EXERCISE);
@@ -247,7 +242,8 @@ if ($is_allowedToEdit) {
         if ($objExerciseTmp->read($exerciseId)) {
             if ($check) {
                 switch ($choice) {
-                    case 'delete' : // deletes an exercise
+                    case 'delete' :
+                        // deletes an exercise
                         if ($exercise_action_locked == false) {
                             $objExerciseTmp->delete();
                             require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
@@ -258,30 +254,35 @@ if ($is_allowedToEdit) {
                             Display :: display_confirmation_message(get_lang('ExerciseDeleted'));
                         }
                         break;
-                    case 'enable' : // enables an exercise
+                    case 'enable' :
+                        // enables an exercise
                         $objExerciseTmp->enable();
                         $objExerciseTmp->save();
                         api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'visible', api_get_user_id());
                         // "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
                         Display :: display_confirmation_message(get_lang('VisibilityChanged'));
                         break;
-                    case 'disable' : // disables an exercise
+                    case 'disable' :
+                        // disables an exercise
                         $objExerciseTmp->disable();
                         $objExerciseTmp->save();
                         api_item_property_update($course_info, TOOL_QUIZ, $objExerciseTmp->id, 'invisible', api_get_user_id());
                         Display :: display_confirmation_message(get_lang('VisibilityChanged'));
                         break;
-                    case 'disable_results' : //disable the results for the learners
+                    case 'disable_results' :
+                        //disable the results for the learners
                         $objExerciseTmp->disable_results();
                         $objExerciseTmp->save();
                         Display :: display_confirmation_message(get_lang('ResultsDisabled'));
                         break;
-                    case 'enable_results' : //disable the results for the learners
+                    case 'enable_results' :
+                        //disable the results for the learners
                         $objExerciseTmp->enable_results();
                         $objExerciseTmp->save();
                         Display :: display_confirmation_message(get_lang('ResultsEnabled'));
                         break;
-                    case 'clean_results' : //clean student results
+                    case 'clean_results' :
+                        //clean student results
                         if ($exercise_action_locked == false) {
                             $quantity_results_deleted = $objExerciseTmp->clean_results(true);
                             Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted));
@@ -322,7 +323,10 @@ if ($is_allowedToEdit) {
                     }
                 }
 
-                // hotpotatoes folder may contains several tests so don't delete folder if not empty : http://support.chamilo.org/issues/2165
+                /* hotpotatoes folder may contains several tests so
+                   don't delete folder if not empty :
+                    http://support.chamilo.org/issues/2165
+                */
 
                 if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath.$uploadPath."/".$fld."/"))) {
                     my_delete($documentPath.$uploadPath."/".$fld."/");
@@ -330,7 +334,8 @@ if ($is_allowedToEdit) {
                 break;
             case 'enable' : // enables an exercise
                 $newVisibilityStatus = "1"; //"visible"
-                $query = "SELECT id FROM $TBL_DOCUMENT WHERE c_id = $course_id AND path='".Database :: escape_string($file)."'";
+                $query = "SELECT id FROM $TBL_DOCUMENT
+                          WHERE c_id = $course_id AND path='".Database :: escape_string($file)."'";
                 $res = Database::query($query);
                 $row = Database :: fetch_array($res, 'ASSOC');
                 api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_user['user_id']);
@@ -339,7 +344,8 @@ if ($is_allowedToEdit) {
                 break;
             case 'disable' : // disables an exercise
                 $newVisibilityStatus = "0"; //"invisible"
-                $query = "SELECT id FROM $TBL_DOCUMENT WHERE c_id = $course_id AND path='".Database :: escape_string($file)."'";
+                $query = "SELECT id FROM $TBL_DOCUMENT
+                          WHERE c_id = $course_id AND path='".Database :: escape_string($file)."'";
                 $res = Database::query($query);
                 $row = Database :: fetch_array($res, 'ASSOC');
                 api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'invisible', $_user['user_id']);
@@ -368,14 +374,17 @@ $course_code = api_get_course_id();
 $session_id = api_get_session_id();
 $condition_session = api_get_session_condition($session_id, true, true);
 
-
 // Only for administrators
 if ($is_allowedToEdit) {
-    $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES WHERE c_id = $course_id AND active<>'-1' $condition_session ";
-    $sql = "SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND active<>'-1' $condition_session ORDER BY title LIMIT ".$from.",".$limit;
+    $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES
+                  WHERE c_id = $course_id AND active<>'-1' $condition_session ";
+    $sql = "SELECT * FROM $TBL_EXERCICES
+            WHERE c_id = $course_id AND active<>'-1' $condition_session
+            ORDER BY title LIMIT ".$from.",".$limit;
 } else {
     // Only for students
-    $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES WHERE c_id = $course_id AND active = '1' $condition_session ";
+    $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES
+                  WHERE c_id = $course_id AND active = '1' $condition_session ";
     $sql = "SELECT * FROM $TBL_EXERCICES
             WHERE c_id = $course_id AND
                   active='1' $condition_session
@@ -395,17 +404,19 @@ if (Database :: num_rows($result_total)) {
 
 //get HotPotatoes files (active and inactive)
 if ($is_allowedToEdit) {
-    $sql = "SELECT * FROM $TBL_DOCUMENT WHERE c_id = $course_id AND path LIKE '".Database :: escape_string($uploadPath)."/%/%'";
+    $sql = "SELECT * FROM $TBL_DOCUMENT
+            WHERE c_id = $course_id AND path LIKE '".Database :: escape_string($uploadPath)."/%/%'";
     $res = Database::query($sql);
     $hp_count = Database :: num_rows($res);
 } else {
     $sql = "SELECT * FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
-            WHERE   d.id = ip.ref AND
-                    ip.tool = '".TOOL_DOCUMENT."' AND
-                    d.path LIKE '".Database :: escape_string($uploadPath)."/%/%' AND
-                    ip.visibility ='1' AND
-                    d.c_id      = ".$course_id." AND
-                    ip.c_id     = ".$course_id;
+            WHERE
+                d.id = ip.ref AND
+                ip.tool = '".TOOL_DOCUMENT."' AND
+                d.path LIKE '".Database :: escape_string($uploadPath)."/%/%' AND
+                ip.visibility ='1' AND
+                d.c_id      = ".$course_id." AND
+                ip.c_id     = ".$course_id;
     $res = Database::query($sql);
     $hp_count = Database :: num_rows($res);
 }
@@ -731,7 +742,6 @@ if (!empty($exercise_list)) {
                 $item .= Display::tag('td', $number_of_questions);
             } else {
                 // Student only
-
                 $visibility = api_get_item_visibility($course_info, TOOL_QUIZ, $my_exercise_id);
 
                 if ($visibility == 0) {
@@ -775,7 +785,7 @@ if (!empty($exercise_list)) {
 
                 //Time limits are on
                 if ($time_limits) {
-                    // Examn is ready to be taken
+                    // Exam is ready to be taken
                     if ($is_actived_time) {
                         //Show results 	697 	$attempt_text = get_lang('LatestAttempt').' : ';
                         if ($my_result_disabled == 0 || $my_result_disabled == 2) {
@@ -865,6 +875,7 @@ if (!empty($exercise_list)) {
         } // end foreach()
     }
 }
+
 // end exercise list
 //Hotpotatoes results
 $hotpotatoes_exist = false;

+ 71 - 49
main/exercice/exercise.class.php

@@ -103,7 +103,8 @@ class Exercise
      * Reads exercise information from the data base
      *
      * @author Olivier Brouckaert
-     * @param integer $id - exercise ID
+     * @param integer $id - exercise Id
+     *
      * @return boolean - true if exercise exists, otherwise false
      */
     public function read($id)
@@ -144,9 +145,9 @@ class Exercise
             $this->pass_percentage          = $object->pass_percentage;
             $this->sessionId = $object->session_id;
 
-            $this->is_gradebook_locked      = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
+            $this->is_gradebook_locked = api_resource_is_locked_by_gradebook($id, LINK_EXERCISE);
 
-            $this->review_answers   = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
+            $this->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;
 
             $sql = "SELECT max_score FROM $table_lp_item
                     WHERE   c_id = {$this->course_id} AND
@@ -192,7 +193,7 @@ class Exercise
 			}*/
             return true;
         }
-        // exercise not found
+
         return false;
     }
 
@@ -248,7 +249,8 @@ class Exercise
     /**
      * returns the time limit
      */
-    function selectTimeLimit() {
+    public function selectTimeLimit()
+    {
         return $this->timeLimit;
     }
 
@@ -258,7 +260,8 @@ class Exercise
      * @author Olivier Brouckaert
      * @return string - exercise description
      */
-    function selectDescription() {
+    public function selectDescription()
+    {
         return $this->description;
     }
 
@@ -293,7 +296,8 @@ class Exercise
         return $this->display_category_name;
     }
 
-    function selectPassPercentage() {
+    public function selectPassPercentage()
+    {
         return $this->pass_percentage;
     }
 
@@ -302,7 +306,8 @@ class Exercise
      * @return : modify object to update the switch display_category_name
      * $in_txt is an integer 0 or 1
      */
-    function updateDisplayCategoryName($in_txt) {
+    public function updateDisplayCategoryName($in_txt)
+    {
         $this->display_category_name = $in_txt;
     }
 
@@ -310,7 +315,8 @@ class Exercise
      * @author hubert borderiou 28-11-11
      * @return html text : the text to display ay the end of the test.
      */
-    function selectTextWhenFinished() {
+    public function selectTextWhenFinished()
+    {
         return $this->text_when_finished;
     }
 
@@ -318,7 +324,8 @@ class Exercise
      * @author hubert borderiou 28-11-11
      * @return html text : update the text to display ay the end of the test.
      */
-    function updateTextWhenFinished($in_txt) {
+    public function updateTextWhenFinished($in_txt)
+    {
         $this->text_when_finished = $in_txt;
     }
 
@@ -327,7 +334,8 @@ class Exercise
      * @author hubert borderiou
      * @return integer - quiz random by category
      */
-    function selectRandomByCat() {
+    public function selectRandomByCat()
+    {
         return $this->randomByCat;
     }
 
@@ -338,7 +346,8 @@ class Exercise
      * @author hubert borderiou
      * @return integer - quiz random by category
      */
-    function isRandomByCat() {
+    public function isRandomByCat()
+    {
         $res = 0;
         if ($this->randomByCat == 1) {
             $res = 1;
@@ -353,7 +362,8 @@ class Exercise
      * update randomByCat value for object
      * @author hubert borderiou
      */
-    function updateRandomByCat($in_randombycat) {
+    public function updateRandomByCat($in_randombycat)
+    {
         if ($in_randombycat == 1) {
             $this->randomByCat = 1;
         } else if ($in_randombycat == 2) {
@@ -380,7 +390,8 @@ class Exercise
      * @author Olivier Brouckaert
      * @return integer - 0 if not random, otherwise the draws
      */
-    function isRandom() {
+    public function isRandom()
+    {
         if($this->random > 0 || $this->random == -1) {
             return true;
         } else {
@@ -393,14 +404,16 @@ class Exercise
      *
      * @author Juan Carlos Rana
      */
-    function selectRandomAnswers() {
+    public function selectRandomAnswers()
+    {
         return $this->random_answers;
     }
 
     /**
      * Same as isRandom() but has a name applied to values different than 0 or 1
      */
-    function getShuffle() {
+    public function getShuffle()
+    {
         return $this->random;
     }
 
@@ -410,7 +423,8 @@ class Exercise
      * @author Olivier Brouckaert
      * @return boolean - true if enabled, otherwise false
      */
-    function selectStatus() {
+    public function selectStatus()
+    {
         return $this->active;
     }
 
@@ -420,7 +434,8 @@ class Exercise
      * @author Olivier Brouckaert
      * @return array - question ID list
      */
-    function selectQuestionList($from_db = false) {
+    public function selectQuestionList($from_db = false)
+    {
         if ($from_db && !empty($this->id)) {
             $TBL_EXERCICE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
             $TBL_QUESTIONS          = Database::get_course_table(TABLE_QUIZ_QUESTION);
@@ -468,11 +483,13 @@ class Exercise
      * @author Olivier Brouckaert
      * @return integer - number of questions
      */
-    function selectNbrQuestions() {
+    public function selectNbrQuestions()
+    {
         return sizeof($this->questionList);
     }
 
-    function selectPropagateNeg() {
+    public function selectPropagateNeg()
+    {
         return $this->propagate_neg;
     }
 
@@ -484,7 +501,8 @@ class Exercise
      *					 without randomizing, otherwise, returns the list with questions selected randomly
      * Modified by Hubert Borderiou 15 nov 2011
      */
-    function selectRandomList() {
+    public function selectRandomList()
+    {
         $nbQuestions	= $this->selectNbrQuestions();
         $temp_list		= $this->questionList;
 
@@ -521,7 +539,8 @@ class Exercise
      * @param integer $questionId - question ID
      * @return boolean - true if in the list, otherwise false
      */
-    function isInList($questionId) {
+    public function isInList($questionId)
+    {
         if (is_array($this->questionList))
             return in_array($questionId,$this->questionList);
         else
@@ -534,7 +553,8 @@ class Exercise
      * @author Olivier Brouckaert
      * @param string $title - exercise title
      */
-    function updateTitle($title) {
+    public function updateTitle($title)
+    {
         $this->exercise=$title;
     }
 
@@ -543,17 +563,17 @@ class Exercise
      *
      * @param int $attempts - exercise max attempts
      */
-    function updateAttempts($attempts) {
+    public function updateAttempts($attempts)
+    {
         $this->attempts=$attempts;
     }
 
-
     /**
      * changes the exercise feedback type
      *
-     * @param int $attempts - exercise max attempts
+     * @param int $feedback_type
      */
-    function updateFeedbackType($feedback_type)
+    public function updateFeedbackType($feedback_type)
     {
         $this->feedback_type=$feedback_type;
     }
@@ -564,7 +584,7 @@ class Exercise
      * @author Olivier Brouckaert
      * @param string $description - exercise description
      */
-    function updateDescription($description)
+    public function updateDescription($description)
     {
         $this->description=$description;
     }
@@ -573,24 +593,24 @@ class Exercise
      * changes the exercise expired_time
      *
      * @author Isaac flores
-     * @param int The expired time of the quiz
+     * @param int $expired_time The expired time of the quiz
      */
-    function updateExpiredTime($expired_time)
+    public function updateExpiredTime($expired_time)
     {
         $this->expired_time = $expired_time;
     }
 
-    function updatePropagateNegative($value)
+    public function updatePropagateNegative($value)
     {
         $this->propagate_neg = $value;
     }
 
-    function updateReviewAnswers($value)
+    public function updateReviewAnswers($value)
     {
         $this->review_answers = (isset($value) && $value) ? true : false;
     }
 
-    function updatePassPercentage($value)
+    public function updatePassPercentage($value)
     {
         $this->pass_percentage = $value;
     }
@@ -602,7 +622,7 @@ class Exercise
      * @param string $sound - exercise sound file
      * @param string $delete - ask to delete the file
      */
-    function updateSound($sound,$delete)
+    public function updateSound($sound,$delete)
     {
         global $audioPath, $documentPath;
         $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
@@ -634,7 +654,7 @@ class Exercise
      * @author Olivier Brouckaert
      * @param integer $type - exercise type
      */
-    function updateType($type)
+    public function updateType($type)
     {
         $this->type=$type;
     }
@@ -646,7 +666,7 @@ class Exercise
      * @author Olivier Brouckaert
      * @param integer $random - 0 if not random, otherwise the draws
      */
-    function setRandom($random)
+    public function setRandom($random)
     {
         /*if ($random == 'all') {
             $random = $this->selectNbrQuestions();
@@ -654,14 +674,13 @@ class Exercise
         $this->random = $random;
     }
 
-
     /**
      * sets to 0 if answers are not selected randomly
      * if answers are selected randomly
      * @author Juan Carlos Rana
      * @param integer $random_answers - random answers
      */
-    function updateRandomAnswers($random_answers)
+    public function updateRandomAnswers($random_answers)
     {
         $this->random_answers = $random_answers;
     }
@@ -671,7 +690,8 @@ class Exercise
      *
      * @author Olivier Brouckaert
      */
-    function enable() {
+    public function enable()
+    {
         $this->active=1;
     }
 
@@ -680,22 +700,22 @@ class Exercise
      *
      * @author Olivier Brouckaert
      */
-    function disable()
+    public function disable()
     {
         $this->active=0;
     }
 
-    function disable_results()
+    public function disable_results()
     {
         $this->results_disabled = true;
     }
 
-    function enable_results()
+    public function enable_results()
     {
         $this->results_disabled = false;
     }
 
-    function updateResultsDisabled($results_disabled)
+    public function updateResultsDisabled($results_disabled)
     {
         $this->results_disabled = intval($results_disabled);
     }
@@ -705,7 +725,7 @@ class Exercise
      *
      * @author Olivier Brouckaert
      */
-    function save($type_e = '')
+    public function save($type_e = '')
     {
         global $_course;
         $TBL_EXERCICES      = Database::get_course_table(TABLE_QUIZ_TEST);
@@ -726,7 +746,6 @@ class Exercise
         $text_when_finished     = $this->text_when_finished;
         $display_category_name  = intval($this->display_category_name);
         $pass_percentage        = intval($this->pass_percentage);
-
         $session_id             = api_get_session_id();
 
         //If direct we do not show results
@@ -864,7 +883,8 @@ class Exercise
      * @param integer $questionId - question ID
      * @return boolean - true if the question has been added, otherwise false
      */
-    function addToList($questionId) {
+    public function addToList($questionId)
+    {
         // checks if the question ID is not in the list
         if(!$this->isInList($questionId)) {
             // selects the max position
@@ -887,7 +907,8 @@ class Exercise
      * @param integer $questionId - question ID
      * @return boolean - true if the question has been removed, otherwise false
      */
-    function removeFromList($questionId) {
+    public function removeFromList($questionId)
+    {
         // searches the position of the question ID in the list
         $pos = array_search($questionId,$this->questionList);
 
@@ -915,7 +936,8 @@ class Exercise
      *
      * @author Olivier Brouckaert
      */
-    function delete() {
+    public function delete()
+    {
         $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
         $sql="UPDATE $TBL_EXERCICES SET active='-1' WHERE c_id = ".$this->course_id." AND id='".Database::escape_string($this->id)."'";
         Database::query($sql);
@@ -930,7 +952,7 @@ class Exercise
      * Creates the form to create / edit an exercise
      * @param FormValidator $form
      */
-    function createForm($form, $type='full')
+    public function createForm($form, $type='full')
     {
         global $id;
 

+ 24 - 20
main/exercice/overview.php

@@ -1,14 +1,12 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
 *	Exercise preview
 *
 *	@package chamilo.exercise
 * 	@author Julio Montoya <gugli100@gmail.com>
 */
-/**
- * Code
- */
 
 use \ChamiloSession as Session;
 
@@ -19,7 +17,7 @@ require_once 'exercise.lib.php';
 $current_course_tool  = TOOL_QUIZ;
 
 // Clear the exercise session just in case
-if (isset ($_SESSION['objExercise'])) {
+if (isset($_SESSION['objExercise'])) {
 	Session::erase('objExercise');
 }
 
@@ -36,13 +34,13 @@ if (!$result) {
 	api_not_allowed(true);
 }
 
-$gradebook 			= isset($_GET['gradebook'])             ? Security :: remove_XSS($_GET['gradebook']) : null;
-$learnpath_id       = isset($_REQUEST['learnpath_id']) 		? intval($_REQUEST['learnpath_id']) : null;
-$learnpath_item_id  = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null;
-$origin  			= isset($_REQUEST['origin']) 			? Security::remove_XSS($_REQUEST['origin']) : null;
+$gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null;
+$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : null;
+$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null;
+$origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : null;
 
-$interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
-$interbreadcrumb[] = array ("url" => "#","name" => $objExercise->name);
+$interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
+$interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
 
 $time_control = false;
 $clock_expired_time = get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
@@ -75,10 +73,13 @@ $message = '';
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 $edit_link = '';
 if ($is_allowed_to_edit && $objExercise->sessionId == $sessionId) {
-	$edit_link = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$objExercise->id);
+	$edit_link = Display::url(
+        Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL),
+        api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$objExercise->id
+    );
 }
 
-//Exercise name
+// Exercise name.
 $html .= Display::page_header($objExercise->name.' '.$edit_link);
 
 //Exercise description
@@ -130,7 +131,15 @@ if ($visible_return['value'] == false) {
     }
 }
 
-$attempts = get_exercise_results_by_user(api_get_user_id(), $objExercise->id, api_get_course_id(), api_get_session_id(), $learnpath_id, $learnpath_item_id, 'desc');
+$attempts = get_exercise_results_by_user(
+    api_get_user_id(),
+    $objExercise->id,
+    api_get_course_id(),
+    api_get_session_id(),
+    $learnpath_id,
+    $learnpath_item_id,
+    'desc'
+);
 $counter = count($attempts);
 
 $my_attempt_array = array();
@@ -156,11 +165,7 @@ if (!empty($attempts)) {
             $attempt_result['exe_result'],
             $attempt_result['exe_weighting']
         );
-        $attempt_url = api_get_path(
-                WEB_CODE_PATH
-            ) . 'exercice/result.php?' . api_get_cidreq(
-            ) . '&amp;id=' . $attempt_result['exe_id'] . '&amp;id_session=' . api_get_session_id(
-            ) . '&amp;height=500&amp;width=950' . $url_suffix;
+        $attempt_url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?' . api_get_cidreq() . '&amp;id=' . $attempt_result['exe_id'] . '&amp;id_session=' . api_get_session_id() . '&amp;height=500&amp;width=950' . $url_suffix;
         $attempt_link = Display::url(
             get_lang('Show'),
             $attempt_url,
@@ -189,8 +194,7 @@ if (!empty($attempts)) {
                 RESULT_DISABLE_SHOW_SCORE_ONLY,
                 RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES
             )
-        )
-        ) {
+        )) {
             $row['result'] = $score;
         }