diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index c161975e59..07558fe3c8 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.php @@ -24,6 +24,7 @@ class Version110 extends AbstractMigrationChamilo $this->addSql("ALTER TABLE session_rel_course ENGINE=InnoDB"); $this->addSql("ALTER TABLE session_rel_course_rel_user ENGINE=InnoDB"); $this->addSql("ALTER TABLE session_rel_user ENGINE=InnoDB"); + $this->addSql("UPDATE session SET session.id_coach = 1 WHERE id_coach NOT IN ( SELECT user_id FROM user)"); } /** diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index 2f05966f62..9c8cfea7ba 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -8,7 +8,7 @@ framework: web_profiler: toolbar: true - intercept_redirects: false + intercept_redirects: true monolog: handlers: diff --git a/documentation/changelog.html b/documentation/changelog.html index 275cbbdaef..45b852f32e 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -49,52 +49,82 @@ -

Chamilo 1.10.6 - ???, ?? of May 2016

+

Chamilo 1.10.6 - Zacatecas, 23rd of May 2016

Release notes - summary

Chamilo 1.10.6 is a minor, bugfix release of the 1.10.x branch, with a few new features and bugfixes on top of 1.10.4.

Release name

-

NNNh .....

+

Zacatecas is a small city North of Mexico City, in the region of Zacatecas, that harbours Spanish colonial style constructions in the historical center, and is an active mining area. It is also the home of the Laboratorio de Software Libre (Free Software lab) in the Consejo Zacatecano de Ciencia, Tecnología e Innovación (Science, Technology and Innovation Council of Zacatecas), possibly the first such initiative in Latin America, and a good development bed for software like Chamilo.

Security fixes

-

None that we know of.

+

None in this version.

Possibly breaking changes

-

None that we know of.

+

None in this version.

Notable new Features

For end-users, teachers and Chamilo admins

For developers and sysadmins

-

Improvements (minor features) and debug

Stylesheets and theming

Web services

Removals

Known issues

-

Chamilo 1.10.4 - Bath, 22th of March 2016

diff --git a/main/auth/external_login/ldap.inc.php b/main/auth/external_login/ldap.inc.php index 999892d275..6bd48e4ea6 100755 --- a/main/auth/external_login/ldap.inc.php +++ b/main/auth/external_login/ldap.inc.php @@ -28,7 +28,7 @@ function extldap_purify_string($string) /** * Establishes a connection to the LDAP server and sets the protocol version * - * @return resource ldap link identifier or false + * @return boolean ldap link identifier or false * @author ndiechburg * */ function extldap_connect() @@ -77,6 +77,7 @@ function extldap_connect() /** * Authenticate user on external ldap server and return user ldap entry if that succeeds * + * @param string $password * @return mixed false if user cannot authenticate on ldap, user ldap entry if tha succeeds * @author ndiechburg * Modified by hubert.borderiou@grenet.fr @@ -237,7 +238,7 @@ function extldap_get_user_search_string($username) /** * Imports all LDAP users into Chamilo - * @return bool false on error, true otherwise + * @return false|null false on error, true otherwise */ function extldap_import_all_users() { diff --git a/main/auth/shibboleth/db/shibboleth_upgrade.class.php b/main/auth/shibboleth/db/shibboleth_upgrade.class.php index d0c61d4a55..dd5b7c18df 100755 --- a/main/auth/shibboleth/db/shibboleth_upgrade.class.php +++ b/main/auth/shibboleth/db/shibboleth_upgrade.class.php @@ -35,7 +35,7 @@ class ShibbolethUpgrade * Creates the 'shibb_unique_id' field in the table 'user' of the main Chamilo database if it doesn't exist yet * * @author Nicolas Rod - * @return void + * @return false|null */ public static function create_shibb_unique_id_field_if_missing() { diff --git a/main/auth/shibboleth/lib/store.class.php b/main/auth/shibboleth/lib/store.class.php index a6a416639e..7eacfedc43 100755 --- a/main/auth/shibboleth/lib/store.class.php +++ b/main/auth/shibboleth/lib/store.class.php @@ -346,6 +346,9 @@ class Store return $result; } + /** + * @param string $sql + */ protected function execute($sql) { return Database::query($sql, null, __FILE__); diff --git a/main/auth/sso/sso.Drupal.class.php b/main/auth/sso/sso.Drupal.class.php index 1fe6433492..7a1e795214 100755 --- a/main/auth/sso/sso.Drupal.class.php +++ b/main/auth/sso/sso.Drupal.class.php @@ -90,7 +90,7 @@ class ssoDrupal /** * Validates the received active connection data with the database - * @return bool Return the loginFailed variable value to local.inc.php + * @return null|false Return the loginFailed variable value to local.inc.php */ public function check_user() { diff --git a/main/coursecopy/classes/Course.class.php b/main/coursecopy/classes/Course.class.php index eb46701f5a..8e4082ab55 100755 --- a/main/coursecopy/classes/Course.class.php +++ b/main/coursecopy/classes/Course.class.php @@ -327,6 +327,7 @@ class Course /** * Serialize the course with the best serializer available + * @return string */ public static function serialize($course) { @@ -339,6 +340,7 @@ class Course /** * Unserialize the course with the best serializer available + * @param string $course */ public static function unserialize($course) { diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 6106084386..9d25ac769c 100755 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -123,7 +123,7 @@ class CourseBuilder * @param string $courseCode * @param bool true if you want to get the elements that exists in the course and * in the session, (session_id = 0 or session_id = X) - * @return object The course object structure + * @return Course The course object structure */ public function build( $session_id = 0, diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 3df33435c6..018403a1c1 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -84,7 +84,7 @@ class CourseRestorer /** * CourseRestorer constructor. - * @param array $course + * @param Course $course */ public function __construct($course) { @@ -133,7 +133,7 @@ class CourseRestorer * @param int $session_id * @param bool $update_course_settings Course settings are going to be restore? * @param bool $respect_base_content - * @return bool + * @return false|null */ public function restore( $destination_course_code = '', @@ -1154,6 +1154,7 @@ class CourseRestorer /** * Restore a forum-topic + * @param false|string $forum_id */ public function restore_topic($thread_id, $forum_id, $sessionId = 0) { @@ -1210,6 +1211,7 @@ class CourseRestorer /** * Restore a forum-post * @TODO Restore tree-structure of posts. For example: attachments to posts. + * @param false|string $topic_id */ public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) { @@ -2306,6 +2308,7 @@ class CourseRestorer /** * Check availability of a survey code + * @param string $survey_code */ public function is_survey_code_available($survey_code) { @@ -2320,6 +2323,7 @@ class CourseRestorer /** * Restore survey-questions + * @param string $survey_id */ public function restore_survey_question($id, $survey_id) { @@ -2776,6 +2780,8 @@ class CourseRestorer * @param string The path origin * @param string The path destination * @param boolean Option Overwrite + * @param string $source + * @param string $dest * @return void() * @deprecated */ diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index 5aef2afa6e..f83d2a1795 100755 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -13,7 +13,7 @@ class CourseSelectForm { /** * Display the form - * @param array $hidden_fiels Hidden fields to add to the form. + * @param array $hidden_fields Hidden fields to add to the form. * @param boolean the document array will be serialize. This is used in the course_copy.php file */ static function display_form($course, $hidden_fields = null, $avoid_serialize = false) @@ -570,7 +570,7 @@ class CourseSelectForm /** * Display the form session export - * @param array $hidden_fiels Hidden fields to add to the form. + * @param array $hidden_fields Hidden fields to add to the form. * @param boolean the document array will be serialize. This is used in the course_copy.php file */ public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) diff --git a/main/coursecopy/classes/Event.class.php b/main/coursecopy/classes/Event.class.php index 32f99a1b31..8d57daf7f6 100755 --- a/main/coursecopy/classes/Event.class.php +++ b/main/coursecopy/classes/Event.class.php @@ -50,9 +50,6 @@ class CalendarEvent extends Coursecopy\Resource * @param int $id * @param string $title * @param string $content - * @param string $date - * @param string $hour - * @param int $duration */ public function __construct( $id, diff --git a/main/coursecopy/classes/QuizQuestion.class.php b/main/coursecopy/classes/QuizQuestion.class.php index 4c1a4f3d62..ab04695bbf 100755 --- a/main/coursecopy/classes/QuizQuestion.class.php +++ b/main/coursecopy/classes/QuizQuestion.class.php @@ -115,6 +115,9 @@ class QuizQuestion extends Coursecopy\Resource $this->answers[] = $answer; } + /** + * @param QuizQuestionOption $option_obj + */ public function add_option($option_obj) { $this->question_options[$option_obj->obj->id] = $option_obj; diff --git a/main/coursecopy/classes/Resource.class.php b/main/coursecopy/classes/Resource.class.php index 41b9d90960..d421d4e2d5 100755 --- a/main/coursecopy/classes/Resource.class.php +++ b/main/coursecopy/classes/Resource.class.php @@ -128,7 +128,7 @@ class Resource /** * Resturns the type of this resource - * @return constant The type. + * @return integer The type. */ public function get_type() { diff --git a/main/coursecopy/copy_course_session_selected.php b/main/coursecopy/copy_course_session_selected.php index 0a8de648be..52d57fc2b3 100644 --- a/main/coursecopy/copy_course_session_selected.php +++ b/main/coursecopy/copy_course_session_selected.php @@ -65,6 +65,9 @@ $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); /* FUNCTIONS */ +/** + * @param string $name + */ function make_select_session_list($name, $sessions, $attr = array()) { diff --git a/main/cron/create_course_sessions.php b/main/cron/create_course_sessions.php index 6fd6c04c19..1a28bd52fd 100644 --- a/main/cron/create_course_sessions.php +++ b/main/cron/create_course_sessions.php @@ -50,6 +50,7 @@ function getQuarterFirstAndLastDates($initialDate = null) /** * Returns a quarter from a month * @param string The month (digit), with or without leading 0 + * @param string $month * @return int The yearly quarter (1, 2, 3 or 4) in which this month lies */ function getQuarter($month) @@ -96,6 +97,7 @@ function getQuarter($month) /** * Returns the first month of the quarter * @param int Quarter + * @param integer $quarter * @return string Number of the month, with leading 0 */ function getQuarterFirstMonth($quarter) @@ -116,6 +118,7 @@ function getQuarterFirstMonth($quarter) /** * Get the quarter in Roman letters * @param int Quarter + * @param integer $quarter * @return string Roman letters */ function getQuarterRoman($quarter) diff --git a/main/cron/import_csv.php b/main/cron/import_csv.php index c692789408..b93d632347 100755 --- a/main/cron/import_csv.php +++ b/main/cron/import_csv.php @@ -48,7 +48,7 @@ class ImportCsv public $conditions; /** - * @param Logger $logger + * @param Monolog\Logger $logger * @param array */ public function __construct($logger, $conditions) @@ -66,7 +66,7 @@ class ImportCsv } /** - * @return mixed + * @return boolean */ public function getDumpValues() { diff --git a/main/dropbox/dropbox_class.inc.php b/main/dropbox/dropbox_class.inc.php index c8094dbfd2..749657d233 100755 --- a/main/dropbox/dropbox_class.inc.php +++ b/main/dropbox/dropbox_class.inc.php @@ -587,6 +587,7 @@ class Dropbox_Person /** * Deletes all the received categories and work of this person + * @param integer $id */ function deleteReceivedWorkFolder($id) { diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index c1c486a42b..96eb0df3fe 100755 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -22,7 +22,7 @@ $(document).ready(function () { /** * This function is a wrapper function for the multiple actions feature. -* @return Mixed If there is a problem, return a string message, otherwise nothing +* @return string|null If there is a problem, return a string message, otherwise nothing * @author Patrick Cool , Ghent University * @version march 2006 */ @@ -209,9 +209,9 @@ function display_move_form($part, $id, $target = array(), $extra_params = array( * * @param $id the id of the file we are moving * @param $target the id of the folder we are moving to -* @param $part are we moving a received file or a sent file? +* @param string $part are we moving a received file or a sent file? * -* @return language string +* @return string string * * @author Patrick Cool , Ghent University * @version march 2006 @@ -290,7 +290,7 @@ function display_action_options($part, $categories, $current_category = 0) * @param $id the unique id of the file * @param $part are we dealing with a sent or with a received file? * -* @return html code +* @return string code * * @author Patrick Cool , Ghent University * @version march 2006 @@ -771,6 +771,7 @@ function getLoginFromId($id) } /** +* @param string $user_id * @return boolean indicating if user with user_id=$user_id is a course member * @todo check if this function is still necessary. There might be a library function for this. */ @@ -1132,7 +1133,7 @@ function feedback($array) { /** * This function returns the html code to display the feedback messages on a given dropbox file * @param $feedback_array an array that contains all the feedback messages about the given document. -* @return html code +* @return string code * @todo add the form for adding new comment (if the other party has not deleted it yet). * * @author Patrick Cool , Ghent University @@ -1149,7 +1150,7 @@ function format_feedback($feedback) /** * this function returns the code for the form for adding a new feedback message to a dropbox file. -* @return html code +* @return string code * * @author Patrick Cool , Ghent University * @version march 2006 @@ -1210,7 +1211,7 @@ function check_if_file_exist($id) } /** -* @return a language string (depending on the success or failure. +* @return string language string (depending on the success or failure. * * @author Patrick Cool , Ghent University * @version march 2006 diff --git a/main/exercice/TestCategory.php b/main/exercice/TestCategory.php index 55ac9e8cd0..4967602abd 100644 --- a/main/exercice/TestCategory.php +++ b/main/exercice/TestCategory.php @@ -367,7 +367,7 @@ class TestCategory * Return the list of differents categories NAME for a test * @param int exercise id * @param bool - * @return array of string + * @return integer of string * * @author function rewrote by jmontoya */ @@ -990,7 +990,6 @@ class TestCategory /** * Return the id of the test category with title = $in_title * @param $in_title - * @param int $in_c_id * * @return int is id of test category */ @@ -1018,7 +1017,7 @@ class TestCategory * @param int $questionId * @param int $courseId * - * @return int + * @return string|false */ public static function add_category_for_question_id($categoryId, $questionId, $courseId) { diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index 9c09b9c91c..b2439f4b64 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -72,7 +72,8 @@ class Answer $objExercise = new Exercise($this->course_id); $exerciseId = isset($_REQUEST['exerciseId']) ? $_REQUEST['exerciseId'] : null; $objExercise->read($exerciseId); - if ($objExercise->random_answers == '1') { + + if ($objExercise->random_answers == '1' && $this->getQuestionType() != CALCULATED_ANSWER) { $this->readOrderedBy('rand()', '');// randomize answers } else { $this->read(); // natural order @@ -187,6 +188,7 @@ class Answer * Reads answer information from the data base ordered by parameter * @param string Field we want to order by * @param string DESC or ASC + * @param string $field * @author Frederic Vauthier */ public function readOrderedBy($field, $order='ASC') @@ -308,6 +310,7 @@ class Answer * returns the question ID of the destination question * * @author Julio Montoya + * @param integer $id * @return integer - the question ID */ public function selectDestination($id) @@ -329,6 +332,7 @@ class Answer /** * return array answer by id else return a bool + * @param integer $auto_id */ public function selectAnswerByAutoId($auto_id) { @@ -467,6 +471,7 @@ class Answer * * @author Olivier Brouckaert * @param - integer $id - answer ID + * @param integer $id * @return integer - answer weighting */ public function selectWeighting($id) @@ -491,6 +496,7 @@ class Answer * * @author Olivier Brouckaert * @param integer Answer ID + * @param integer $id * @return integer Answer position */ public function selectHotspotCoordinates($id) @@ -503,6 +509,7 @@ class Answer * * @author Toon Keppens * @param integer Answer ID + * @param integer $id * @return integer Answer position */ public function selectHotspotType($id) @@ -729,6 +736,7 @@ class Answer * @author Olivier Brouckaert * @param int question id * @param array destination course info (result of the function api_get_course_info() ) + * @param string $newQuestionId */ public function duplicate($newQuestionId, $course_info = null) { diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 992cf387bc..0a342585aa 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1,8 +1,6 @@ display_category_name = $object->display_category_name; $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->review_answers = (isset($object->review_answers) && $object->review_answers == 1) ? true : false; $this->globalCategoryId = isset($object->global_category_id) ? $object->global_category_id : null; $this->questionSelectionType = isset($object->question_selection_type) ? $object->question_selection_type : null; @@ -187,11 +187,19 @@ class Exercise $this->edit_exercise_in_lp = true; } +<<<<<<< HEAD if (!empty($object->end_time)) { $this->end_time = $object->end_time; } if (!empty($object->start_time)) { $this->start_time = $object->start_time; +======= + if ($object->end_time != '0000-00-00 00:00:00') { + $this->end_time = $object->end_time; + } + if ($object->start_time != '0000-00-00 00:00:00') { + $this->start_time = $object->start_time; +>>>>>>> origin/1.10.x } //control time @@ -353,7 +361,7 @@ class Exercise } /** - * @return int + * @return string */ public function selectPassPercentage() { @@ -462,7 +470,7 @@ class Exercise * tells if questions are selected randomly, and if so returns the draws * * @author Olivier Brouckaert - * @return integer - 0 if not random, otherwise the draws + * @return boolean - 0 if not random, otherwise the draws */ public function isRandom() { @@ -2830,7 +2838,7 @@ class Exercise * @param int int lp id * @param int int lp item id * @param int int lp item_view id - * @param float $weight + * @param integer $weight * @param array question list */ public function save_stat_track_exercise_info( @@ -3093,7 +3101,7 @@ class Exercise * @param bool $show_result show results or not * @param int $propagate_neg * @param array $hotspot_delineation_result - * + * @param boolean $showTotalScoreAndUserChoices * @todo reduce parameters of this function * @return string html code */ @@ -3717,16 +3725,7 @@ class Exercise } break; case CALCULATED_ANSWER: - $calculatedAnswerId = Session::read('calculatedAnswerId'); - $answer = ''; - if ($calculatedAnswerId) { - $calculatedAnswerInfo = Session::read('calculatedAnswerInfo'); - if (isset($calculatedAnswerInfo[$questionId])) { - $answer = $calculatedAnswerInfo[$questionId]; - } else { - $answer = $objAnswerTmp->selectAnswer($calculatedAnswerId[$questionId]); - } - } + $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]); $preArray = explode('@@', $answer); $last = count($preArray) - 1; $answer = ''; @@ -3765,7 +3764,7 @@ class Exercise $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND - question_id= ".intval($questionId).""; + question_id= ".intval($questionId); $resfill = Database::query($queryfill); $str = Database::result($resfill, 0, 'answer'); api_preg_match_all('#\[([^[]*)\]#', $str, $arr); @@ -3773,7 +3772,14 @@ class Exercise $choice = $arr[1]; if (isset($choice[$j])) { $tmp = api_strrpos($choice[$j], ' / '); - $choice[$j] = api_substr($choice[$j], 0, $tmp); + + if ($tmp) { + $choice[$j] = api_substr($choice[$j], 0, $tmp); + } else { + $tmp = ltrim($tmp, '['); + $tmp = rtrim($tmp, ']'); + } + $choice[$j] = trim($choice[$j]); // Needed to let characters ' and " to work as part of an answer $choice[$j] = stripslashes($choice[$j]); @@ -3792,18 +3798,6 @@ class Exercise } $answer = ''; $realCorrectTags = $correctTags; - - if ($from_database && empty($calculatedAnswerId)) { - $queryfill = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT." - WHERE - exe_id = '".$exeId."' AND - question_id= ".intval($questionId) ; - $resfill = Database::query($queryfill); - $rowFill = Database::fetch_assoc($resfill); - $answer = $rowFill['answer']; - $questionScore = $rowFill['marks']; - } - for ($i = 0; $i < count($realCorrectTags); $i++) { if ($i == 0) { $answer .= $realText[0]; @@ -3825,18 +3819,17 @@ class Exercise // adds a tabulation if no word has been typed by the student $answer .= ''; // remove   that causes issue } +<<<<<<< HEAD // adds the correct word, followed by ] to close the blank $addCorrecWord = true; +======= + + // adds the correct word, followed by ] to close the blank +>>>>>>> origin/1.10.x if ( - Session::has('objExercise') && - Session::read('objExercise')->selectResultsDisabled() == EXERCISE_FEEDBACK_TYPE_EXAM + $this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM ) { - $addCorrecWord = false; - } - - if ($addCorrecWord) { - // adds the correct word, followed by ] to close the blank $answer .= ' / ' . $realCorrectTags[$i] . ''; } @@ -4594,7 +4587,8 @@ class Exercise $studentChoice, $answerComment, $results_disabled, - $answerId + $answerId, + $showTotalScoreAndUserChoices ); break; case HOT_SPOT_DELINEATION: @@ -5168,6 +5162,7 @@ class Exercise /** * Sends a notification when a user ends an examn * + * @param integer $exe_id */ public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) { @@ -5248,6 +5243,7 @@ class Exercise /** * Sends a notification when a user ends an examn * + * @param integer $exe_id */ function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) { @@ -5345,6 +5341,9 @@ class Exercise } } + /** + * @param integer $exe_id + */ function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { @@ -5438,7 +5437,7 @@ class Exercise /** * @param array $user_data result of api_get_user_info() - * @param null $start_date + * @param string $start_date * @param null $duration * @param string $ip Optional. The user IP * @return string @@ -5496,7 +5495,7 @@ class Exercise * @param int Maximum number of attempts (0 if no limit) * @param int Feedback type * @todo this was function was added due the import exercise via CSV - * @return int New exercise ID + * @return string New exercise ID */ public function createExercise( $title, @@ -6831,7 +6830,7 @@ class Exercise * @param bool $show_comment * @param null $exercise_feedback * @param bool $show_answers - * @param null $modelType + * @param integer $modelType * @param bool $categoryMinusOne * @return bool|null|string */ @@ -7998,8 +7997,8 @@ class Exercise /** * Returns an HTML ribbon to show on top of the exercise result, with * colouring depending on the success or failure of the student - * @param $score - * @param $weight + * @param integer $score + * @param integer $weight * @param bool $check_pass_percentage * @return string */ diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 40c39c060f..fa5dae3cb4 100755 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -185,6 +185,7 @@ ExerciseLib::exercise_time_control_delete( $learnpath_id, $learnpath_item_id ); + ExerciseLib::delete_chat_exercise_session($exe_id); if ($origin != 'learnpath') { @@ -199,8 +200,6 @@ if ($origin != 'learnpath') { if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); - Session::erase('calculatedAnswerId'); - Session::erase('calculatedAnswerInfo'); } Display::display_footer(); } else { @@ -211,8 +210,6 @@ if ($origin != 'learnpath') { if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); - Session::erase('calculatedAnswerId'); - Session::erase('calculatedAnswerInfo'); } // Record the results in the learning path, using the SCORM interface (API) diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 7a84745a49..7e866929b7 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -1,8 +1,6 @@ read($exercise_id); } $feedback_type = $objExercise->feedback_type; @@ -100,23 +122,23 @@ $feedback_type = $objExercise->feedback_type; //Only users can see their own results if (!$is_allowedToEdit) { if ($student_id != $current_user_id) { - api_not_allowed(true); + api_not_allowed(true); } } if (isset($_SESSION['gradebook'])) { - $gradebook= Security::remove_XSS($_SESSION['gradebook']); + $gradebook = Security::remove_XSS($_SESSION['gradebook']); } -if (!empty($gradebook) && $gradebook=='view') { - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); +if (!empty($gradebook) && $gradebook == 'view') { + $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" => "#", "name" => get_lang('Result')); +$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; @@ -124,53 +146,53 @@ $htmlHeadXtra[] = ''; if ($origin != 'learnpath') { - Display::display_header(''); + Display::display_header(''); } else { $htmlHeadXtra[] = " "; - Display::display_reduced_header(); + Display::display_reduced_header(); } ?> - + + function getFCK(vals, marksid) { + var f = document.getElementById('myform'); + + var m_id = marksid.split(','); + for (var i = 0; i < m_id.length; i++) { + var oHidn = document.createElement("input"); + oHidn.type = "hidden"; + var selname = oHidn.name = "marks_" + m_id[i]; + var selid = document.forms['marksform_' + m_id[i]].marks.selectedIndex; + oHidn.value = document.forms['marksform_' + m_id[i]].marks.options[selid].text; + f.appendChild(oHidn); + } + + var ids = vals.split(','); + for (var k = 0; k < ids.length; k++) { + var oHidden = document.createElement("input"); + oHidden.type = "hidden"; + oHidden.name = "comments_" + ids[k]; + if (CKEDITOR.instances[oHidden.name]) { + oHidden.value = CKEDITOR.instances[oHidden.name].getData(); + } else { + oHidden.value = $("textarea[name='" + oHidden.name + "']").val(); + } + f.appendChild(oHidden); + } + } + '; Display::display_warning_message( - get_lang('ThankYouForPassingTheTest').'

'.(get_lang('BackToExercisesList')).'', + get_lang('ThankYouForPassingTheTest') . '

' . (get_lang('BackToExercisesList')) . '', false ); echo ' @@ -232,12 +254,12 @@ if (!empty($track_exercise_info)) { } } } else { - Display::display_warning_message(get_lang('CantViewResults')); - $show_results = false; + Display::display_warning_message(get_lang('CantViewResults')); + $show_results = false; } -if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) { - $show_results = false; +if ($origin == 'learnpath' && !isset($_GET['fb_type'])) { + $show_results = false; } if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { @@ -254,29 +276,29 @@ if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { $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); @@ -285,13 +307,13 @@ $question_list_from_database = array(); $exerciseResult = array(); while ($row = Database::fetch_array($result)) { - $question_list_from_database[] = $row['question_id']; - $exerciseResult[$row['question_id']] = $row['answer']; + $question_list_from_database[] = $row['question_id']; + $exerciseResult[$row['question_id']] = $row['answer']; } //Fixing #2073 Fixing order of questions if (!empty($track_exercise_info['data_tracking'])) { - $temp_question_list = explode(',', $track_exercise_info['data_tracking']); + $temp_question_list = explode(',', $track_exercise_info['data_tracking']); // Getting question list from data_tracking if (!empty($temp_question_list)) { @@ -316,12 +338,13 @@ if (!empty($end_of_message) && ($origin == 'learnpath')) { $total_weighting = 0; foreach ($questionList as $questionId) { $objQuestionTmp = Question::read($questionId); - $total_weighting +=$objQuestionTmp->selectWeighting(); + $total_weighting += $objQuestionTmp->selectWeighting(); } $counter = 1; $exercise_content = null; $category_list = array(); + $useAdvancedEditor = true; if (!empty($maxEditors) && count($questionList) > $maxEditors) { @@ -329,379 +352,280 @@ if (!empty($maxEditors) && count($questionList) > $maxEditors) { } foreach ($questionList as $questionId) { - - $choice = $exerciseResult[$questionId]; - // destruction of the Question object - unset($objQuestionTmp); + $choice = $exerciseResult[$questionId]; + // destruction of the Question object + unset($objQuestionTmp); // creates a temporary Question object $objQuestionTmp = Question::read($questionId); $questionWeighting = $objQuestionTmp->selectWeighting(); $answerType = $objQuestionTmp->selectType(); - // Start buffer + // Start buffer ob_start(); - // Use switch - - if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { + if ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { $choice = array(); - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - echo ''; - } elseif ($answerType == FILL_IN_BLANKS) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == CALCULATED_ANSWER) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == FREE_ANSWER) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == ORAL_EXPRESSION) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) { - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - } elseif ($answerType == HOT_SPOT) { - if ($show_results || $showTotalScoreAndUserChoices) { - echo ' + } + + switch ($answerType) { + case MULTIPLE_ANSWER_COMBINATION: + //no break + case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: + //no break + case UNIQUE_ANSWER: + //no break; + case UNIQUE_ANSWER_NO_OPTION: + //no break + case MULTIPLE_ANSWER: + //no break + case MULTIPLE_ANSWER_TRUE_FALSE: + //no break + case FILL_IN_BLANKS: + //no break + case CALCULATED_ANSWER: + //no break + case GLOBAL_MULTIPLE_ANSWER: + //no break + case FREE_ANSWER: + //no break + case ORAL_EXPRESSION: + //no break + case MATCHING: + //no break + case DRAGGABLE: + //no break + case MATCHING_DRAGGABLE: + $question_result = $objExercise->manage_answer( + $id, + $questionId, + $choice, + 'exercise_show', + array(), + false, + true, + $show_results, + $objExercise->selectPropagateNeg(), + [], + $showTotalScoreAndUserChoices + ); + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; + break; + case HOT_SPOT: + if ($show_results || $showTotalScoreAndUserChoices) { + echo '
'; - echo " - - - -
'; - } - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - [], - $showTotalScoreAndUserChoices - ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; - - if ($show_results) { - $relPath = api_get_path(REL_PATH); - echo '
-
- -
-
- "; - } - } else if($answerType == HOT_SPOT_DELINEATION) { - - $question_result = $objExercise->manage_answer( - $id, - $questionId, - $choice, - 'exercise_show', - array(), - false, - true, - $show_results, - $objExercise->selectPropagateNeg(), - 'database', - [], - $showTotalScoreAndUserChoices - ); + + + + +
+ "; + } + break; + case HOT_SPOT_DELINEATION: + $question_result = $objExercise->manage_answer( + $id, + $questionId, + $choice, + 'exercise_show', + array(), + false, + true, + $show_results, + $objExercise->selectPropagateNeg(), + 'database', + [], + $showTotalScoreAndUserChoices + ); - $questionScore = $question_result['score']; - $totalScore += $question_result['score']; + $questionScore = $question_result['score']; + $totalScore += $question_result['score']; - $final_overlap = $question_result['extra']['final_overlap']; - $final_missing = $question_result['extra']['final_missing']; - $final_excess = $question_result['extra']['final_excess']; + $final_overlap = $question_result['extra']['final_overlap']; + $final_missing = $question_result['extra']['final_missing']; + $final_excess = $question_result['extra']['final_excess']; - $overlap_color = $question_result['extra']['overlap_color']; - $missing_color = $question_result['extra']['missing_color']; - $excess_color = $question_result['extra']['excess_color']; + $overlap_color = $question_result['extra']['overlap_color']; + $missing_color = $question_result['extra']['missing_color']; + $excess_color = $question_result['extra']['excess_color']; - $threadhold1 = $question_result['extra']['threadhold1']; - $threadhold2 = $question_result['extra']['threadhold2']; - $threadhold3 = $question_result['extra']['threadhold3']; + $threadhold1 = $question_result['extra']['threadhold1']; + $threadhold2 = $question_result['extra']['threadhold2']; + $threadhold3 = $question_result['extra']['threadhold3']; - if ($show_results) { + if ($show_results) { - if ($overlap_color) { - $overlap_color='green'; - } else { - $overlap_color='red'; - } + if ($overlap_color) { + $overlap_color = 'green'; + } else { + $overlap_color = 'red'; + } - if ($missing_color) { - $missing_color='green'; - } else { - $missing_color='red'; - } - if ($excess_color) { - $excess_color='green'; - } else { - $excess_color='red'; - } + if ($missing_color) { + $missing_color = 'green'; + } else { + $missing_color = 'red'; + } + if ($excess_color) { + $excess_color = 'green'; + } else { + $excess_color = 'red'; + } - if (!is_numeric($final_overlap)) { - $final_overlap = 0; - } + if (!is_numeric($final_overlap)) { + $final_overlap = 0; + } - if (!is_numeric($final_missing)) { - $final_missing = 0; - } - if (!is_numeric($final_excess)) { - $final_excess = 0; - } + if (!is_numeric($final_missing)) { + $final_missing = 0; + } + if (!is_numeric($final_excess)) { + $final_excess = 0; + } - if ($final_excess>100) { - $final_excess = 100; - } + if ($final_excess > 100) { + $final_excess = 100; + } - $table_resume=' - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('Requirements').''.get_lang('YourAnswer').'
'.get_lang('Overlap').''.get_lang('Min').' '.$threadhold1.'
'.(($final_overlap < 0)?0:intval($final_overlap)).'
'.get_lang('Excess').''.get_lang('Max').' '.$threadhold2.'
'.(($final_excess < 0)?0:intval($final_excess)).'
'.get_lang('Missing').''.get_lang('Max').' '.$threadhold3.'
'.(($final_missing < 0)?0:intval($final_missing)).'
'; - - if ($answerType!= HOT_SPOT_DELINEATION) { - $item_list = explode('@@',$destination); - - $try = $item_list[0]; - $lp = $item_list[1]; - $destinationid = $item_list[2]; - $url = $item_list[3]; - $table_resume=''; - } else { - if ($next==0) { - $try = $try_hotspot; - $lp = $lp_hotspot; - $destinationid= $select_question_hotspot; - $url=$url_hotspot; + $table_resume = ' + + + + + + + + + + + + + + + + + + + + + + +
' . get_lang('Requirements') . '' . get_lang('YourAnswer') . '
' . get_lang('Overlap') . '' . get_lang('Min') . ' ' . $threadhold1 . '
' . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '
' . get_lang('Excess') . '' . get_lang('Max') . ' ' . $threadhold2 . '
' . (($final_excess < 0) ? 0 : intval($final_excess)) . '
' . get_lang('Missing') . '' . get_lang('Max') . ' ' . $threadhold3 . '
' . (($final_missing < 0) ? 0 : intval($final_missing)) . '
'; + + if ($answerType != HOT_SPOT_DELINEATION) { + $item_list = explode('@@', $destination); + + $try = $item_list[0]; + $lp = $item_list[1]; + $destinationid = $item_list[2]; + $url = $item_list[3]; + $table_resume = ''; } else { - //show if no error - $comment=$answerComment = $objAnswerTmp->selectComment($nbrAnswers); - $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); + if ($next == 0) { + $try = $try_hotspot; + $lp = $lp_hotspot; + $destinationid = $select_question_hotspot; + $url = $url_hotspot; + } else { + //show if no error + $comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers); + $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); + } } - } - echo '

'.get_lang('Feedback').'

'; - if ($answerType == HOT_SPOT_DELINEATION) { - if ($organs_at_risk_hit > 0) { - $message='
'.get_lang('ResultIs').' '.$result_comment.'
'; - $message.='

'.get_lang('OARHit').'

'; + echo '

' . get_lang('Feedback') . '

'; + if ($answerType == HOT_SPOT_DELINEATION) { + if ($organs_at_risk_hit > 0) { + $message = '
' . get_lang('ResultIs') . ' ' . $result_comment . '
'; + $message .= '

' . get_lang('OARHit') . '

'; + } else { + $message = '

' . get_lang('YourDelineation') . '

'; + $message .= $table_resume; + $message .= '
' . get_lang('ResultIs') . ' ' . $result_comment . '
'; + } + $message .= '

' . $comment . '

'; + echo $message; } else { - $message='

'.get_lang('YourDelineation').'

'; - $message.=$table_resume; - $message.='
'.get_lang('ResultIs').' '.$result_comment.'
'; + echo '

' . $comment . '

'; } - $message.='

'.$comment.'

'; - echo $message; - } else { - echo '

'.$comment.'

'; - } - //showing the score - $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; - $relPath = api_get_path(REL_PATH); - echo ''; - - echo " - - -
- - - - - "; - } - } + + + + + "; + } + break; + } - if ($show_results) { - if ($answerType != HOT_SPOT) { - echo ''; - } - } + if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { + echo ''; + } + + if ($show_results && $answerType != HOT_SPOT) { + echo ''; + } - $comnt = null; + $comnt = null; if ($show_results) { if ( @@ -718,46 +642,40 @@ foreach ($questionList as $questionId) { $marksname = ''; - if ($isFeedbackAllowed) { - $name = "fckdiv".$questionId; - $marksname = "marksName".$questionId; - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { - $url_name = get_lang('EditCommentsAndMarks'); - } else { - if ($action=='edit') { - $url_name = get_lang('EditIndividualComment'); - } else { - $url_name = get_lang('AddComments'); - } - } + if ($isFeedbackAllowed) { + $name = "fckdiv" . $questionId; + $marksname = "marksName" . $questionId; + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { + $url_name = get_lang('EditCommentsAndMarks'); + } else { + if ($action == 'edit') { + $url_name = get_lang('EditIndividualComment'); + } else { + $url_name = get_lang('AddComments'); + } + } echo '
'; - echo Display::url( - $url_name, - 'javascript://', - array( - 'class' => 'btn btn-default', - 'onclick' => "showfck('".$name."', '".$marksname."');") - ); - echo '
'; - - echo '
'; - $comnt = trim(Event::get_comments($id, $questionId)); - if (empty($comnt)) { - echo '
'; - } else { - echo '
'.$comnt.'
'; - } - echo '
'; - - echo ''; + + } else { + $comnt = Event::get_comments($id, $questionId); + echo '
'; + if (!empty($comnt)) { + echo '' . get_lang('Feedback') . ''; + echo '
' . $comnt . '
'; + } + } + + if ($is_allowedToEdit && $isFeedbackAllowed) { + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { + $marksname = "marksName" . $questionId; + echo ''; + + if ($questionScore == -1) { + $questionScore = 0; + echo Display::return_message(get_lang('notCorrectedYet')); + } + } else { + $arrmarks[] = $questionId; + echo ''; + } + } else { + if ($questionScore == -1) { + $questionScore = 0; + } + } + } $my_total_score = $questionScore; - $my_total_weight = $questionWeighting; + $my_total_weight = $questionWeighting; $totalWeighting += $questionWeighting; $category_was_added_for_this_test = false; @@ -838,7 +756,7 @@ foreach ($questionList as $questionId) { } if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) { - foreach($objQuestionTmp->category_list as $category_id) { + foreach ($objQuestionTmp->category_list as $category_id) { $category_list[$category_id]['score'] += $my_total_score; $category_list[$category_id]['total'] += $my_total_weight; $category_was_added_for_this_test = true; @@ -865,7 +783,12 @@ foreach ($questionList as $questionId) { $score = array(); if ($show_results) { - $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); + $score['result'] = get_lang('Score') . " : " . ExerciseLib::show_score( + $my_total_score, + $my_total_weight, + false, + false + ); $score['pass'] = $my_total_score >= $my_total_weight ? true : false; $score['type'] = $answerType; $score['score'] = $my_total_score; @@ -873,16 +796,18 @@ foreach ($questionList as $questionId) { $score['comments'] = isset($comnt) ? $comnt : null; } - unset($objAnswerTmp); - $i++; + unset($objAnswerTmp); + $i++; $contents = ob_get_clean(); + $question_content = '
'; - if ($show_results) { - // Shows question title an description - $question_content .= $objQuestionTmp->return_header(null, $counter, $score); - } - $counter++; + + if ($show_results) { + //Shows question title an description + $question_content .= $objQuestionTmp->return_header(null, $counter, $score); + } + $counter++; $question_content .= $contents; $question_content .= '
'; $exercise_content .= $question_content; @@ -891,13 +816,13 @@ foreach ($questionList as $questionId) { $total_score_text = null; //Total score -if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { - if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { +if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { + if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices) { $total_score_text .= '
'; $my_total_score_temp = $totalScore; - if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { - $my_total_score_temp = 0; - } + if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { + $my_total_score_temp = 0; + } $total_score_text .= ExerciseLib::get_question_ribbon( $objExercise, $my_total_score_temp, @@ -905,7 +830,7 @@ if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) true ); $total_score_text .= '
'; - } + } } if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoices)) { @@ -923,63 +848,94 @@ echo $total_score_text; if ($isFeedbackAllowed) { if (is_array($arrid) && is_array($arrmarks)) { - $strids = implode(",",$arrid); - $marksid = implode(",",$arrmarks); + $strids = implode(",", $arrid); + $marksid = implode(",", $arrmarks); } } if ($isFeedbackAllowed) { - if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { - echo '
'; - echo ''; - echo ''; - echo ''; - echo ' '; - echo ' '; - } else { - echo ' '; - } - if ($origin !='learnpath' && $origin!='student_progress') { - echo ''; - ?> -
- -
- + - - - + + -'.$href.''; - // Record the results in the learning path, using the SCORM interface (API) - echo ""; - echo ''; - } else { - Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); + if (!isset($_GET['fb_type'])) { + $lp_mode = $_SESSION['lp_mode']; + $url = '../newscorm/lp_controller.php?' . api_get_cidreq() . '&'; + $url .= http_build_url([ + 'action' => 'view', + 'lp_id' => $learnpath_id, + 'lp_item_id' => $learnpath_item_id, + 'exeId' => $exeId, + 'fb_type' => $feedback_type + ]); + $href = ($lp_mode == 'fullscreen') ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" '; + echo ''; + // Record the results in the learning path, using the SCORM interface (API) + echo ""; + echo ''; + } else { + Display::display_normal_message(get_lang('ExerciseFinished') . ' ' . get_lang('ToContinueUseMenu')); echo '
'; - } + } } // Destroying the session diff --git a/main/exercice/export/aiken/aiken_classes.php b/main/exercice/export/aiken/aiken_classes.php index 87f1dd2d39..02612cd481 100755 --- a/main/exercice/export/aiken/aiken_classes.php +++ b/main/exercice/export/aiken/aiken_classes.php @@ -10,6 +10,10 @@ if ( count( get_included_files() ) == 1 ) die( '---' ); if (!function_exists('mime_content_type')) { + + /** + * @param string $filename + */ function mime_content_type($filename) { return DocumentManager::file_get_mime_type((string)$filename); } diff --git a/main/exercice/export/aiken/aiken_import.inc.php b/main/exercice/export/aiken/aiken_import.inc.php index 1dd73bca2b..a26dc68984 100755 --- a/main/exercice/export/aiken/aiken_import.inc.php +++ b/main/exercice/export/aiken/aiken_import.inc.php @@ -55,6 +55,8 @@ function aiken_display_form($msg = '') { * Gets the uploaded file (from $_FILES) and unzip it to the given directory * @param string The directory where to do the work * @param string The path of the temporary directory where the exercise was uploaded and unzipped + * @param string $baseWorkDir + * @param string $uploadPath * @return bool True on success, false on failure */ function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) { @@ -229,7 +231,10 @@ function aiken_import_exercise($file) * @param string Path to the directory with the file to be parsed (without final /) * @param string Name of the last directory part for the file (without /) * @param string Name of the file to be parsed (including extension) - * @return mixed True on success, error message on error + * @param string $exercisePath + * @param string $file + * @param string $questionFile + * @return string|boolean True on success, error message on error * @assert ('','','') === false */ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) { diff --git a/main/exercice/export/exercise_import.inc.php b/main/exercice/export/exercise_import.inc.php index e83b475480..069ff9ea70 100755 --- a/main/exercice/export/exercise_import.inc.php +++ b/main/exercice/export/exercise_import.inc.php @@ -30,6 +30,8 @@ function tempdir($dir, $prefix = 'tmp', $mode = 0777) * Unzip the exercise in the temp folder * @param string The path of the temporary directory where the exercise was uploaded and unzipped * @param string + * @param string $baseWorkDir + * @param string $uploadPath * @return bool */ function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) @@ -217,9 +219,9 @@ function formatText($text) /** * Parses a given XML file and fills global arrays with the elements - * @param $exercisePath - * @param $file - * @param $questionFile + * @param string $exercisePath + * @param string $file + * @param string $questionFile * @return bool */ function parse_file($exercisePath, $file, $questionFile) diff --git a/main/exercice/export/qti2/qti2_export.php b/main/exercice/export/qti2/qti2_export.php index 002fa0c5c3..6753232800 100755 --- a/main/exercice/export/qti2/qti2_export.php +++ b/main/exercice/export/qti2/qti2_export.php @@ -32,7 +32,7 @@ class ImsAssessmentItem /** * Constructor. * - * @param $question Ims2Question object we want to export. + * @param Ims2Question $question Ims2Question object we want to export. */ function ImsAssessmentItem($question) { @@ -101,7 +101,7 @@ class ImsAssessmentItem * This is a default behaviour, some classes may want to override this. * * @param $standalone: Boolean stating if it should be exported as a stand-alone question - * @return A string, the XML flow for an Item. + * @return string string, the XML flow for an Item. */ function export($standalone = false) { @@ -154,7 +154,7 @@ class ImsSection /** * Constructor. - * @param $exe The Exercise instance to export + * @param Exercise $exe The Exercise instance to export * @author Amand Tihon */ function ImsSection($exe) @@ -239,7 +239,7 @@ class ImsSection * Export the exercise in IMS/QTI. * * @param bool $standalone Wether it should include XML tag and DTD line. - * @return a string containing the XML flow + * @return string string containing the XML flow * @author Amand Tihon */ function export($standalone) @@ -383,7 +383,7 @@ class ImsItem * This is a default behaviour, some classes may want to override this. * * @param $standalone: Boolean stating if it should be exported as a stand-alone question - * @return A string, the XML flow for an Item. + * @return string string, the XML flow for an Item. * @author Amand Tihon */ function export($standalone = False) @@ -417,7 +417,7 @@ class ImsItem * * @param int $exerciseId The exercise to export * @param boolean $standalone Wether it should include XML tag and DTD line. - * @return The XML as a string, or an empty string if there's no exercise with given ID. + * @return string XML as a string, or an empty string if there's no exercise with given ID. */ function export_exercise_to_qti($exerciseId, $standalone = true) { @@ -474,6 +474,9 @@ function formatExerciseQtiTitle($text) return htmlspecialchars($text); } +/** + * @param string $text + */ function cleanAttribute($text) { return $text; diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php index b1de5ed89f..c8dd6ccfa2 100755 --- a/main/exercice/export/scorm/scorm_classes.php +++ b/main/exercice/export/scorm/scorm_classes.php @@ -27,6 +27,7 @@ class ScormQuestion extends Question * @param int The JavaScript ID for this question. * Due to the nature of interactions, we must have a natural sequence for * questions in the generated JavaScript. + * @param integer $js_id */ public static function export_question($questionId, $standalone = true, $js_id) { @@ -687,7 +688,7 @@ class ScormAssessmentItem /** * Constructor. * - * @param $question The Question object we want to export. + * @param ScormQuestion $question The Question object we want to export. */ public function ScormAssessmentItem($question, $standalone = false) { @@ -915,7 +916,7 @@ class ScormSection * * @param int $exerciseId The exercise to exporte * @param boolean $standalone Wether it should include XML tag and DTD line. - * @return The XML as a string, or an empty string if there's no exercise with given ID. + * @return string XML as a string, or an empty string if there's no exercise with given ID. */ public static function export_exercise_to_scorm($exerciseId, $standalone=true) { $exercise = new Exercise(); @@ -930,7 +931,7 @@ class ScormSection /** * Constructor. - * @param $exe The Exercise instance to export + * @param Exercise $exe The Exercise instance to export * @author Amand Tihon */ function ScormSection($exe) { @@ -1091,7 +1092,7 @@ class ScormSection * This is a default behaviour, some classes may want to override this. * * @param $standalone: Boolean stating if it should be exported as a stand-alone question - * @return A string, the XML flow for an Item. + * @return string string, the XML flow for an Item. */ function export() { diff --git a/main/exercice/fill_blanks.class.php b/main/exercice/fill_blanks.class.php index 807be3b3f8..45a290f4c1 100755 --- a/main/exercice/fill_blanks.class.php +++ b/main/exercice/fill_blanks.class.php @@ -413,7 +413,7 @@ class FillBlanks extends Question * @param null $feedback_type * @param null $counter * @param null $score - * @return null|string + * @return string */ public function return_header($feedback_type = null, $counter = null, $score = null) { @@ -427,15 +427,16 @@ class FillBlanks extends Question } /** - * @param $separatorStartRegexp - * @param $separatorEndRegexp - * @param $correctItemRegexp - * @param $questionId + * @param string $separatorStartRegexp + * @param string $separatorEndRegexp + * @param string $correctItemRegexp + * @param integer $questionId * @param $correctItem * @param $attributes - * @param $answer + * @param string $answer * @param $listAnswersInfo - * @param $displayForStudent + * @param boolean $displayForStudent + * @param integer $inBlankNumber * @return string */ public static function getFillTheBlankHtml( @@ -734,11 +735,11 @@ class FillBlanks extends Question * 0 : student answer is correct * >0 : for fill the blank question with choice menu, is the index of the student answer (right answer indice is 0) * - * @param $testId - * @param $questionId + * @param integer $testId + * @param integer $questionId * @param $studentsIdList - * @param $startDate - * @param $endDate + * @param string $startDate + * @param string $endDate * @param bool $useLastAnswerredAttempt * @return array * ( @@ -915,7 +916,7 @@ class FillBlanks extends Question * return $text protected for use in regexp * @param string $text * - * @return mixed + * @return string */ public static function getRegexpProtected($text) { @@ -973,7 +974,7 @@ class FillBlanks extends Question * return the start separator for answer * @param string $number * - * @return mixed + * @return string */ public static function getStartSeparator($number) { @@ -986,7 +987,7 @@ class FillBlanks extends Question * return the end separator for answer * @param string $number * - * @return mixed + * @return string */ public static function getEndSeparator($number) { diff --git a/main/exercice/hotpotatoes.lib.php b/main/exercice/hotpotatoes.lib.php index 5818cc7674..5f4ae8830c 100755 --- a/main/exercice/hotpotatoes.lib.php +++ b/main/exercice/hotpotatoes.lib.php @@ -94,7 +94,7 @@ function GetComment($path, $course_code = '') * Sets the comment in the database for a particular path. * @param string File path * @param string Comment to set - * @return string Result of the database operation (Database::query will output some message directly on error anyway) + * @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway) */ function SetComment($path, $comment) { @@ -112,6 +112,7 @@ function SetComment($path, $comment) /** * Reads the file contents into a string. * @param string Urlencoded path + * @param string $full_file_path * @return string The file contents or false on security error */ function ReadFileCont($full_file_path) @@ -257,6 +258,7 @@ function GenerateHiddenList($imgparams) * Searches for a node in the given array. * @param reference Reference to the array to search * @param string Node we are looking for in the array + * @param string $node * @return mixed Node name or false if not found */ function myarraysearch(&$array, $node) @@ -316,6 +318,8 @@ function ReplaceImgTag($content) * Fills the folder name up to a certain length with "0". * @param string Original folder name * @param integer Length to reach + * @param integer $name + * @param integer $nsize * @return string Modified folder name */ function FillFolderName($name, $nsize) diff --git a/main/exercice/hotpotatoes_exercise_result.class.php b/main/exercice/hotpotatoes_exercise_result.class.php index bb1b2fb0c8..9ed5d04aaf 100755 --- a/main/exercice/hotpotatoes_exercise_result.class.php +++ b/main/exercice/hotpotatoes_exercise_result.class.php @@ -18,6 +18,7 @@ class HotpotatoesExerciseResult * Gets the results of all students (or just one student if access is limited) * @param string The document path (for HotPotatoes retrieval) * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null + * @param string $document_path */ public function getExercisesReporting($document_path, $hotpotato_name) { diff --git a/main/exercice/hotspot.class.php b/main/exercice/hotspot.class.php index 084c4177b6..65d183e3bd 100755 --- a/main/exercice/hotspot.class.php +++ b/main/exercice/hotspot.class.php @@ -52,7 +52,7 @@ class HotSpot extends Question /** * @param FormValidator $form * @param null $objExercise - * @return bool + * @return null|false */ public function processCreation($form, $objExercise = null) { diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 2d4f1206f0..ca7126286c 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -264,7 +264,7 @@ abstract class Question } /** - * @return bool|string + * @return string|false */ public function selectPicturePath() { @@ -589,7 +589,7 @@ abstract class Question * @param string $Dimension - Resizing happens proportional according to given dimension: height|width|any * @param integer $Max - Maximum size * - * @return boolean - true if success, false if failed + * @return boolean|null - true if success, false if failed * * @author Toon Keppens */ @@ -750,6 +750,7 @@ abstract class Question /** * Sets extra info + * @param string $extra */ public function setExtra($extra) { @@ -1273,7 +1274,7 @@ abstract class Question * * @author Olivier Brouckaert * @param array $course_info Course info of the destination course - * @return int ID of the new question + * @return false|string ID of the new question */ public function duplicate($course_info = []) { @@ -1649,7 +1650,7 @@ abstract class Question * @param string $name * @param int $course_id * @param int $position - * @return bool|int + * @return false|string */ static function saveQuestionOption($question_id, $name, $course_id, $position = 0) { @@ -1788,6 +1789,7 @@ abstract class Question * @param int Maximum result for the question * @param int Type of question (see constants at beginning of question.class.php) * @param int Question level/category + * @param string $quiz_id */ public function create_question( $quiz_id, @@ -1870,6 +1872,7 @@ abstract class Question /** * Get course medias * @param int course id + * @param integer $course_id */ static function get_course_medias( $course_id, @@ -1935,7 +1938,7 @@ abstract class Question } /** - * @return array + * @return integer[] */ public static function get_default_levels() { diff --git a/main/exercice/unique_answer.class.php b/main/exercice/unique_answer.class.php index 89accb1d92..144767145a 100755 --- a/main/exercice/unique_answer.class.php +++ b/main/exercice/unique_answer.class.php @@ -417,8 +417,8 @@ class UniqueAnswer extends Question * @param int $question_id The question ID (to which the answer is attached) * @param string $title The text of the answer * @param string $comment The feedback for the answer - * @param float|null $score The score you get when picking this answer - * @param int|null $correct Whether this answer is considered *the* correct one (this is the unique answer type) + * @param double $score The score you get when picking this answer + * @param integer $correct Whether this answer is considered *the* correct one (this is the unique answer type) */ public function addAnswer( $id, diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 5d74e62799..67eb4752c5 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -1064,7 +1064,7 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona * an up and down icon except for the first (no up icon) and the last (no down icon) * The key of this $list array is the id of the item. * - * @return void HTML + * @return string HTML **/ function return_up_down_icon($content, $id, $list) { @@ -2033,7 +2033,7 @@ function get_thread_information($thread_id) * This function retrieves forum thread users details * @param int Thread ID * @param string Course DB name (optional) - * @return resource array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) + * @return Doctrine\DBAL\Driver\Statement|null array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) * @author Christian Fasanando , * @todo this function need to be improved * @version octubre 2008, dokeos 1.8 @@ -2088,7 +2088,7 @@ function get_thread_users_details($thread_id) * This function retrieves forum thread users qualify * @param int Thread ID * @param string Course DB name (optional) - * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) + * @return Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) * @author Jhon Hinojosa * @todo this function need to be improved */ @@ -2155,7 +2155,7 @@ function get_thread_users_qualify($thread_id) * This function retrieves forum thread users not qualify * @param int Thread ID * @param string Course DB name (optional) - * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) + * @return Doctrine\DBAL\Driver\Statement|null Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) * @author Jhon Hinojosa, * @version oct 2008, dokeos 1.8 */ @@ -3185,6 +3185,10 @@ function getThreadScoreHistory($user_id, $thread_id, $opt) * @param integer contains the information the current user id * @param integer contains the information the current thread id * @param integer contains the information the current qualify + * @param string $option + * @param integer $course_id + * @param integer $user_id + * @param integer $thread_id * @return void * $option=1 obtained the qualification of the current thread * @author Isaac Flores , U.N.A.S University @@ -3768,6 +3772,8 @@ function increase_thread_view($thread_id) * * @author Patrick Cool , Ghent University * @version february 2006, dokeos 1.8 + * @param string $last_post_id + * @param string $post_date */ function updateThreadInfo($thread_id, $last_post_id, $post_date) { @@ -3982,6 +3988,8 @@ function send_notification_mails($thread_id, $reply_info) * * @param string Content type (post, thread, forum, forum_category) * @param int Item DB ID + * @param string $content + * @param integer $id * @return string language variable * @author Patrick Cool , Ghent University * @version february 2006, dokeos 1.8 @@ -4459,6 +4467,7 @@ function forum_search() /** * Display the search results * @param string + * @param string $search_term * @return void display the results * @author Patrick Cool , Ghent University, Belgium * @version march 2008, dokeos 1.8.5 @@ -4588,7 +4597,7 @@ function search_link() * This function adds an attachment file into a forum * @param string $file_comment a comment about file * @param int $last_id from forum_post table - * @return int|bool + * @return false|null */ function add_forum_attachment_file($file_comment, $last_id) { @@ -4799,7 +4808,7 @@ function getAllAttachment($postId) * @param post id * @param int $id_attach * @param bool $display to show or not result message - * @return void + * @return integer * @author Julio Montoya Dokeos * @version october 2014, chamilo 1.9.8 */ @@ -5081,7 +5090,7 @@ function get_notifications($content, $id) * @param integer $forum_id the id of the forum * @param integer $thread_id the id of the thread * @param integer $post_id the id of the post - * @return bool + * @return false|null * * @author Patrick Cool , Ghent University, Belgium * @version May 2008, dokeos 1.8.5 diff --git a/main/gradebook/lib/GradebookUtils.php b/main/gradebook/lib/GradebookUtils.php index 5717f94138..474f20fb5c 100644 --- a/main/gradebook/lib/GradebookUtils.php +++ b/main/gradebook/lib/GradebookUtils.php @@ -19,6 +19,7 @@ class GradebookUtils * @param int Visibility (0 hidden, 1 shown) * @param int Session ID (optional or 0 if not defined) * @param int + * @param integer $resource_type * @return boolean True on success, false on failure */ public static function add_resource_to_course_gradebook( @@ -117,7 +118,6 @@ class GradebookUtils /** * Builds an img tag for a gradebook item - * @param string $type value returned by a gradebookitem's get_icon_name() */ public static function build_type_icon_tag($kind, $attributes = array()) { @@ -580,6 +580,9 @@ class GradebookUtils * @param int The user id * @param float The score obtained for certified * @param Datetime The date when you obtained the certificate + * @param integer $cat_id + * @param integer $user_id + * @param string $date_certificate * @return void() */ public static function register_user_info_about_certificate($cat_id, $user_id, $score_certificate, $date_certificate) @@ -959,7 +962,7 @@ class GradebookUtils } /** - * @param array $list_values + * @param string[] $list_values * @return string */ public static function score_badges($list_values) @@ -1019,7 +1022,7 @@ class GradebookUtils } /** - * @param $result + * @param Doctrine\DBAL\Driver\Statement|null $result * @return array */ public static function get_user_array_from_sql_result($result) diff --git a/main/gradebook/lib/be/abstractlink.class.php b/main/gradebook/lib/be/abstractlink.class.php index 7a36159990..ecfbc4d1b7 100755 --- a/main/gradebook/lib/be/abstractlink.class.php +++ b/main/gradebook/lib/be/abstractlink.class.php @@ -193,6 +193,9 @@ abstract class AbstractLink implements GradebookItem $this->visible = $visible; } + /** + * @param integer $id + */ public function set_session_id($id) { $this->session_id = $id; @@ -217,6 +220,12 @@ abstract class AbstractLink implements GradebookItem /** * Retrieve links and return them as an array of extensions of AbstractLink. * To keep consistency, do not call this method but LinkFactory::load instead. + * @param integer $id + * @param integer $type + * @param integer $user_id + * @param string $course_code + * @param integer $category_id + * @param integer $visible */ public static function load( $id = null, @@ -288,7 +297,7 @@ abstract class AbstractLink implements GradebookItem } /** - * @param $result + * @param Doctrine\DBAL\Driver\Statement|null $result * @return array */ private static function create_objects_from_sql_result($result) @@ -463,6 +472,7 @@ abstract class AbstractLink implements GradebookItem /** * Internal function used by get_target_categories() + * @param integer $level */ private function add_target_subcategories($targets, $level, $catid) { @@ -492,6 +502,7 @@ abstract class AbstractLink implements GradebookItem * Find links by name * To keep consistency, do not call this method but LinkFactory::find_links instead. * @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) { @@ -559,21 +570,21 @@ abstract class AbstractLink implements GradebookItem } /** - * @param $name + * @param string $name */ public function set_name($name) { } /** - * @param $description + * @param string $description */ public function set_description($description) { } /** - * @param $max + * @param integer $max */ public function set_max($max) { diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index f6ce3b4f7a..7b0b556730 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -77,7 +77,7 @@ class Category implements GradebookItem } /** - * @return float + * @return integer|null */ public function get_certificate_min_score() { @@ -97,7 +97,7 @@ class Category implements GradebookItem } /** - * @return mixed + * @return integer */ public function get_parent_id() { @@ -105,7 +105,7 @@ class Category implements GradebookItem } /** - * @return mixed + * @return integer */ public function get_weight() { @@ -121,7 +121,7 @@ class Category implements GradebookItem } /** - * @return mixed + * @return boolean */ public function is_visible() { @@ -244,7 +244,7 @@ class Category implements GradebookItem } /** - * @return null + * @return null|integer */ public function get_grade_model_id() { @@ -487,7 +487,7 @@ class Category implements GradebookItem } /** - * @param $result + * @param Doctrine\DBAL\Driver\Statement|null $result * * @return array */ @@ -863,7 +863,8 @@ class Category implements GradebookItem /** * Calculate the score of this category - * @param $stud_id student id (default: all students - then the average is returned) + * @param integer $stud_id student id (default: all students - then the average is returned) + * @param integer $session_id * @return array (score sum, weight sum) * or null if no scores available */ @@ -1124,6 +1125,9 @@ class Category implements GradebookItem * @param int student id * @param string Course code * @param int Session id + * @param integer $stud_id + * @param string $course_code + * @param integer $session_id */ public function get_root_categories_for_student($stud_id, $course_code = null, $session_id = null) { @@ -1204,6 +1208,9 @@ class Category implements GradebookItem * @param int user id (to return everything, use 'null' here) * @param string course code (optional) * @param int session id (optional) + * @param integer $user_id + * @param string $course_code + * @param integer $session_id */ public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null) { @@ -1302,6 +1309,7 @@ class Category implements GradebookItem /** * Internal function used by get_target_categories() + * @param integer $level */ private function add_target_subcategories($targets, $level, $catid) { @@ -1401,6 +1409,8 @@ class Category implements GradebookItem /** * Internal function used by get_tree() + * @param integer $level + * @param null|integer $visible */ private function add_subtree ($targets, $level, $catid, $visible) { @@ -1418,6 +1428,7 @@ class Category implements GradebookItem /** * Generate an array of courses that a teacher hasn't created a category for. + * @param integer $user_id * @return array 2-dimensional array - every element contains 2 subelements (code, title) */ public function get_not_created_course_categories ($user_id) @@ -1452,6 +1463,7 @@ class Category implements GradebookItem /** * Generate an array of all courses that a teacher is admin of. + * @param integer $user_id * @return array 2-dimensional array - every element contains 2 subelements (code, title) */ public function get_all_courses ($user_id) @@ -1532,7 +1544,7 @@ class Category implements GradebookItem /** * Retrieve all categories inside a course independent category * that should be visible to a student. - * @param $cat_id parent category + * @param integer $cat_id parent category * @param $stud_id student id * @param $cats optional: if defined, the categories will be added to this array */ @@ -1853,7 +1865,7 @@ class Category implements GradebookItem * the platform administrator. * @param int locked 1 or unlocked 0 - * @return bool + * @return boolean|null * */ public function lock($locked) { @@ -2270,7 +2282,7 @@ class Category implements GradebookItem * @param float $score The achieved score * @param int $userId The user id * @param int $categoryId The gradebook category - * @return int The insert id + * @return false|string The insert id */ public static function registerCurrentScore($score, $userId, $categoryId) { diff --git a/main/gradebook/lib/be/evaluation.class.php b/main/gradebook/lib/be/evaluation.class.php index cfda6f721b..60e53007b7 100755 --- a/main/gradebook/lib/be/evaluation.class.php +++ b/main/gradebook/lib/be/evaluation.class.php @@ -81,6 +81,9 @@ class Evaluation implements GradebookItem return $this->name; } + /** + * @return string + */ public function get_description() { return $this->description; @@ -208,7 +211,7 @@ class Evaluation implements GradebookItem * @param int $user_id user id (evaluation owner) * @param string $course_code course code * @param int $category_id parent category - * @param $visible visible + * @param integer $visible visible */ public static function load( $id = null, @@ -658,6 +661,7 @@ class Evaluation implements GradebookItem /** * Internal function used by get_target_categories() + * @param integer $level */ private function add_target_subcategories($targets, $level, $catid) { diff --git a/main/gradebook/lib/be/exerciselink.class.php b/main/gradebook/lib/be/exerciselink.class.php index ada63cfbb3..caed75a93a 100755 --- a/main/gradebook/lib/be/exerciselink.class.php +++ b/main/gradebook/lib/be/exerciselink.class.php @@ -372,7 +372,7 @@ class ExerciseLink extends AbstractLink } /** - * @return array|string + * @return string */ public function get_type_name() { diff --git a/main/gradebook/lib/be/forumthreadlink.class.php b/main/gradebook/lib/be/forumthreadlink.class.php index 477db0c6c8..863291e702 100755 --- a/main/gradebook/lib/be/forumthreadlink.class.php +++ b/main/gradebook/lib/be/forumthreadlink.class.php @@ -121,7 +121,7 @@ class ForumThreadLink extends AbstractLink /** * Has anyone done this exercise yet ? - * @return int + * @return boolean */ public function has_results() { diff --git a/main/gradebook/lib/be/result.class.php b/main/gradebook/lib/be/result.class.php index c0cec3a6c2..e26024b356 100755 --- a/main/gradebook/lib/be/result.class.php +++ b/main/gradebook/lib/be/result.class.php @@ -62,6 +62,9 @@ class Result $this->evaluation = $evaluation_id; } + /** + * @param string $creation_date + */ public function set_date($creation_date) { $this->created_at = $creation_date; diff --git a/main/gradebook/lib/fe/linkform.class.php b/main/gradebook/lib/fe/linkform.class.php index 3637812d36..482d7bce2c 100755 --- a/main/gradebook/lib/fe/linkform.class.php +++ b/main/gradebook/lib/fe/linkform.class.php @@ -124,8 +124,8 @@ class LinkForm extends FormValidator } /** - * @param $link - * @param $courseCode + * @param integer $link + * @param null|string $courseCode * @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink */ private function createLink($link, $courseCode) diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index b99e928d97..5063448903 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -30,7 +30,7 @@ class FlatViewDataGenerator * @param array $evals * @param array $links * @param array $params - * @param null $mainCourseCategory + * @param Category|null $mainCourseCategory */ public function __construct( $users = array(), @@ -276,6 +276,8 @@ class FlatViewDataGenerator /** * Get actual array data + * @param integer $users_count + * @param integer $items_count * @return array 2-dimensional array - each array contains the elements: * 0: user id * 1: user lastname diff --git a/main/gradebook/lib/gradebook_data_generator.class.php b/main/gradebook/lib/gradebook_data_generator.class.php index 3186c067dd..dfd3cd8154 100755 --- a/main/gradebook/lib/gradebook_data_generator.class.php +++ b/main/gradebook/lib/gradebook_data_generator.class.php @@ -71,6 +71,7 @@ class GradebookDataGenerator /** * Get actual array data + * @param integer $count * @return array 2-dimensional array - each array contains the elements: * 0: cat/eval/link object * 1: item name @@ -304,7 +305,7 @@ class GradebookDataGenerator /** * @param int $userId * @param GradebookItem $item - * @param $ignore_score_color + * @param boolean $ignore_score_color * @return null|string */ private function build_result_column( diff --git a/main/gradebook/lib/gradebook_result.class.php b/main/gradebook/lib/gradebook_result.class.php index 46468c1f6c..80bac373fb 100644 --- a/main/gradebook/lib/gradebook_result.class.php +++ b/main/gradebook/lib/gradebook_result.class.php @@ -76,7 +76,7 @@ class GradeBookResult /** * Exports the complete report as an XLS file - * @return boolean False on error + * @return boolean|null False on error */ public function exportCompleteReportXLS($data) { diff --git a/main/gradebook/lib/results_data_generator.class.php b/main/gradebook/lib/results_data_generator.class.php index 4776e3d7c3..3a5b73fe2a 100755 --- a/main/gradebook/lib/results_data_generator.class.php +++ b/main/gradebook/lib/results_data_generator.class.php @@ -45,6 +45,7 @@ class ResultsDataGenerator /** * Get actual array data + * @param integer $count * @return array 2-dimensional array - each array contains the elements: * 0 ['id'] : user id * 1 ['result_id'] : result id @@ -130,6 +131,7 @@ class ResultsDataGenerator * @param float Current absolute score (max score is taken from $this->evaluation->get_max() * @param bool Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc) * @param bool Whether we want to ignore the score color + * @param boolean $realscore * @result string The score as we want to show it */ private function get_score_display ($score, $realscore, $ignore_score_color = false) diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php index 19d0dd4dc7..28ce1e53df 100755 --- a/main/gradebook/lib/scoredisplay.class.php +++ b/main/gradebook/lib/scoredisplay.class.php @@ -231,7 +231,7 @@ class ScoreDisplay /** * @param int $category_id - * @return bool + * @return false|null */ public function insert_defaults($category_id) { @@ -262,7 +262,7 @@ class ScoreDisplay } /** - * @return int|null|string + * @return integer */ public function get_number_decimals() { @@ -336,8 +336,8 @@ class ScoreDisplay /** * @param $score - * @param $type - * @return float|string + * @param integer $type + * @return string */ private function display_default($score, $type) { diff --git a/main/group/group_space.php b/main/group/group_space.php index 84b5a27433..d7a6db2170 100755 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -491,7 +491,7 @@ function email_filter($email) * Display a user icon that links to the user page * * @param integer $user_id the id of the user - * @return html code + * @return string code * * @author Patrick Cool , Ghent University, Belgium * @version April 2008 diff --git a/main/inc/ajax/admin.ajax.php b/main/inc/ajax/admin.ajax.php index b11eeac92c..2f8223a3fe 100755 --- a/main/inc/ajax/admin.ajax.php +++ b/main/inc/ajax/admin.ajax.php @@ -189,6 +189,8 @@ function check_system_version() * @param float Timeout * @param bool Include HTTP Request headers? * @param bool Include HTTP Response headers? + * @param string $ip + * @return string */ function _http_request($ip, $port = 80, $uri = '/', $getdata = array(), $timeout = 5, $req_hdr = false, $res_hdr = false) { diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index 383d99c077..fb3531aa78 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -283,9 +283,7 @@ switch ($action) { $attempt_list = array(); // First time here we create an attempt (getting the exe_id). - if (empty($exercise_stat_info)) { - - } else { + if (!empty($exercise_stat_info)) { // We know the user we get the exe_id. $exe_id = $exercise_stat_info['exe_id']; $total_score = $exercise_stat_info['exe_result']; @@ -325,10 +323,10 @@ switch ($action) { error_log("exe_id is empty"); } exit; - } else { - $_SESSION['exe_id'] = $exe_id; } + $_SESSION['exe_id'] = $exe_id; + // Getting the total weight if the request is simple $total_weight = 0; @@ -351,7 +349,8 @@ switch ($action) { continue; } - $my_choice = isset($choice[$my_question_id]) ? $choice[$my_question_id] : null; + $my_choice = isset($choice[$my_question_id]) ? + $choice[$my_question_id] : null; if ($debug) { error_log("my_choice = ".print_r($my_choice, 1).""); @@ -361,7 +360,7 @@ switch ($action) { $objQuestionTmp = Question::read($my_question_id, $course_id); // Getting free choice data. - if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') { + if ($objQuestionTmp->type == FREE_ANSWER && $type == 'all') { $my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id]) ? $_REQUEST['free_choice'][$my_question_id]: null; } diff --git a/main/inc/lib/AnnouncementEmail.php b/main/inc/lib/AnnouncementEmail.php index 402891c9cf..9e0c51cc60 100644 --- a/main/inc/lib/AnnouncementEmail.php +++ b/main/inc/lib/AnnouncementEmail.php @@ -16,7 +16,7 @@ class AnnouncementEmail /** * * @param int|array $course - * @param int|array $annoucement + * @param integer $announcement * * @return AnnouncementEmail */ @@ -50,7 +50,7 @@ class AnnouncementEmail * * @param string $key * - * @return array + * @return string|null */ public function course($key = '') { diff --git a/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php b/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php index c3cbb59f8e..2e3335811b 100755 --- a/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php +++ b/main/inc/lib/access_url_edit_courses_to_url_functions.lib.php @@ -22,7 +22,7 @@ class Accessurleditcoursestourl * a given string * @param string String to search for * @param int Deprecated param - * @return string A formatted, xajax answer block + * @return xajaxResponse A formatted, xajax answer block * @assert () === false */ function search_courses($needle, $id) diff --git a/main/inc/lib/access_url_edit_users_to_url_functions.lib.php b/main/inc/lib/access_url_edit_users_to_url_functions.lib.php index c2860aaf1c..69d67d19e7 100755 --- a/main/inc/lib/access_url_edit_users_to_url_functions.lib.php +++ b/main/inc/lib/access_url_edit_users_to_url_functions.lib.php @@ -23,7 +23,7 @@ class Accessurledituserstourl * search string * @param string Search string * @param int Deprecated param - * @return string Xajax response block + * @return xajaxResponse Xajax response block * @assert () === false */ function search_users($needle, $id) diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index 9810ca1317..5a05e3f041 100755 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -189,7 +189,7 @@ class AddCourse /** * Gets an array with all the course tables (deprecated?) - * @return array + * @return string[] * @assert (null) !== null */ public static function get_course_tables() @@ -310,6 +310,8 @@ class AddCourse * @param string Complete path to directory we want to list * @param array A list of files to which we want to add the files found * @param string Type of base directory from which we want to recover the files + * @param string $path + * @param string $media * @return array * @assert (null,null,null) === false * @assert ('abc',array(),'') === array() @@ -371,6 +373,7 @@ class AddCourse * Sorts pictures by type (used?) * @param array List of files (sthg like array(0=>array('png'=>1))) * @param string File type + * @param string $type * @return array The received array without files not matching type * @assert (array(),null) === array() */ diff --git a/main/inc/lib/add_courses_to_session_functions.lib.php b/main/inc/lib/add_courses_to_session_functions.lib.php index 0a16f90c90..a8f3469885 100755 --- a/main/inc/lib/add_courses_to_session_functions.lib.php +++ b/main/inc/lib/add_courses_to_session_functions.lib.php @@ -10,7 +10,7 @@ class AddCourseToSession * Searches a course, given a search string and a type of search box * @param string $needle Search string * @param string $type Type of search box ('single' or anything else) - * @return string XajaxResponse + * @return xajaxResponse XajaxResponse * @assert ('abc', 'single') !== null * @assert ('abc', 'multiple') !== null */ diff --git a/main/inc/lib/add_many_session_to_category_functions.lib.php b/main/inc/lib/add_many_session_to_category_functions.lib.php index e1ddb71d2c..c6127b4a96 100755 --- a/main/inc/lib/add_many_session_to_category_functions.lib.php +++ b/main/inc/lib/add_many_session_to_category_functions.lib.php @@ -17,7 +17,7 @@ class AddManySessionToCategoryFunctions * Search for a session based on a given search string * @param string A search string * @param string A search box type (single or anything else) - * @return string XajaxResponse + * @return xajaxResponse XajaxResponse * @assert () !== '' * @assert ('abc','single') !== '' */ diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index d7870dd994..b6c32159da 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -565,7 +565,7 @@ class Agenda * @param string $color * @param bool $addAnnouncement * - * @return bool + * @return null|false */ public function editEvent( $id, @@ -1308,6 +1308,7 @@ class Agenda * * @param int $eventId * @param int $courseId + * @param integer $sessionId * @paraù int $sessionId * * @return array @@ -2469,6 +2470,7 @@ class Agenda * Adds x weeks to a UNIX timestamp * @param int The timestamp * @param int The number of weeks to add + * @param integer $timestamp * @return int The new timestamp */ function addWeek($timestamp, $num = 1) @@ -2480,6 +2482,7 @@ class Agenda * Adds x months to a UNIX timestamp * @param int The timestamp * @param int The number of years to add + * @param integer $timestamp * @return int The new timestamp */ function addMonth($timestamp, $num = 1) @@ -2498,6 +2501,7 @@ class Agenda * Adds x years to a UNIX timestamp * @param int The timestamp * @param int The number of years to add + * @param integer $timestamp * @return int The new timestamp */ function addYear($timestamp, $num = 1) @@ -2697,7 +2701,7 @@ class Agenda /** * @param array $courseInfo * @param $file - * @return array|bool|string + * @return false|string */ public function importEventFile($courseInfo, $file) { @@ -2810,7 +2814,7 @@ class Agenda /** * Parse filter turns USER:12 to ['users' => [12])] or G:1 ['groups' => [1]] - * @param $filter + * @param integer $filter * @return array */ public function parseAgendaFilter($filter) @@ -3324,6 +3328,7 @@ class Agenda * @param int user ID of the user * @param string Optional start date in datetime format (if no start date is given, uses today) * @param string Optional end date in datetime format (if no date is given, uses one year from now) + * @param integer $user_id * @return array Array of events ordered by start date, in * [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format, * where datestart and dateend are in yyyyMMddhhmmss format. diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 4e9a3e6746..093da85ef1 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -581,9 +581,14 @@ require_once __DIR__.'/internationalization.lib.php'; * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too. * * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters. +<<<<<<< HEAD * @param string $path The requested path type (a defined constant), see the examples. * @param array $configuration +======= + * @param string $path (optional) A path which type is to be converted. Also, it may be a defined constant for a path. + * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored. +>>>>>>> origin/1.10.x * @return string The requested path or the converted path. * * @@ -935,7 +940,7 @@ function api_remove_trailing_slash($path) { * Checks the RFC 3986 syntax of a given URL. * @param string $url The URL to be checked. * @param bool $absolute Whether the URL is absolute (beginning with a scheme such as "http:"). - * @return bool Returns the URL if it is valid, FALSE otherwise. + * @return string|false Returns the URL if it is valid, FALSE otherwise. * This function is an adaptation from the function valid_url(), Drupal CMS. * @link http://drupal.org * Note: The built-in function filter_var($urs, FILTER_VALIDATE_URL) has a bug for some versions of PHP. @@ -1511,6 +1516,7 @@ function api_get_course_path($course_code = null) * Gets a course setting from the current course_setting table. Try always using integer values. * @param string The name of the setting we want from the table * @param string Optional: course code + * @param string $setting_name * @return mixed The value of that setting in that table. Return -1 if not found. */ function api_get_course_setting($setting_name, $course_code = null) @@ -1839,7 +1845,7 @@ function api_generate_password($length = 8) { /** * Checks a password to see wether it is OK to use. * @param string $password - * @return true if the password is acceptable, false otherwise + * @return boolean if the password is acceptable, false otherwise * Notes about what a password "OK to use" is: * 1. The password should be at least 5 characters long. * 2. Only English letters (uppercase or lowercase, it doesn't matter) and digits are allowed. @@ -2011,7 +2017,7 @@ class api_failure { * @author Hugues Peeters * @param string $failure_type - the type of failure * @global array $api_failureList - * @return bolean false to stay consistent with the main script + * @return boolean false to stay consistent with the main script */ static function set_failure($failure_type) { global $api_failureList; @@ -3027,8 +3033,8 @@ function api_is_allowed_to_session_edit($tutor = false, $coach = false) /** * Checks whether the user is allowed in a specific tool for a specific action -* @param $tool the tool we are checking if the user has a certain permission -* @param $action the action we are checking (add, edit, delete, move, visibility) +* @param string $tool the tool we are checking if the user has a certain permission +* @param string $action the action we are checking (add, edit, delete, move, visibility) * @author Patrick Cool , Ghent University * @author Julio Montoya * @version 1.0 @@ -3330,7 +3336,7 @@ function api_not_allowed($print_headers = false, $message = null) /** * Gets a UNIX timestamp from a database (MySQL) datetime format string * @param $last_post_datetime standard output date in a sql query - * @return unix timestamp + * @return integer timestamp * @author Toon Van Hoecke * @version October 2003 * @desc convert sql date to unix timestamp @@ -3363,6 +3369,9 @@ function api_get_datetime($time = null) { * @param string Tool (learnpath, document, etc) * @param int The item ID in the given tool * @param int The session ID (optional) + * @param string $tool + * @param integer $user_id + * @param string $type * @return int -1 on error, 0 if invisible, 1 if visible */ function api_get_item_visibility( @@ -3431,7 +3440,7 @@ function api_get_item_visibility( * @param int $userId * @param int $groupId * @param int $sessionId - * @return void + * @return false|null */ function api_item_property_delete( $courseInfo, @@ -3486,7 +3495,7 @@ function api_item_property_delete( * @param array $_course array with course properties * @param string $tool tool id, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) * @param int $item_id id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool - * @param string $lastedit_type add or update action + * @param string $last_edit_type add or update action * (1) message to be translated (in trad4all) : e.g. DocumentAdded, DocumentUpdated; * (2) "delete" * (3) "visible" @@ -3769,6 +3778,8 @@ function api_item_property_update( * @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!) * @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool * @param int $session_id + * @param string $tool + * @param string $course_code * @return array All fields from c_item_property (all rows found) or empty array */ function api_get_item_property_by_tool($tool, $course_code, $session_id = null) @@ -4032,7 +4043,7 @@ function api_get_languages_combo($name = 'language') * Displays a form (drop down menu) so the user can select his/her preferred language. * The form works with or without javascript * @param boolean Hide form if only one language available (defaults to false = show the box anyway) - * @return void Display the box directly + * @return null|string Display the box directly */ function api_display_language_form($hide_if_no_choice = false) { @@ -4321,6 +4332,7 @@ function api_get_themes() { * and also when a user subscribes to courses (the new course is added at the end of the main category * @author Patrick Cool , Ghent University * @param int $user_course_category: the id of the user_course_category + * @param integer $user_id * @return int the value of the highest sort of the user_course_category */ function api_max_sort_value($user_course_category, $user_id) @@ -4514,6 +4526,8 @@ function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = fals * @param the dest folder * @param an array of excluded file_name (without extension) * @param copied_files the returned array of copied files + * @param string $source + * @param string $dest */ function copyr($source, $dest, $exclude = array(), $copied_files = array()) { if (empty($dest)) { return false; } @@ -4553,6 +4567,11 @@ function copyr($source, $dest, $exclude = array(), $copied_files = array()) { } // TODO: Using DIRECTORY_SEPARATOR is not recommended, this is an obsolete approach. Documentation header to be added here. +/** + * @param string $pathname + * @param string $base_path_document + * @param integer $session_id + */ function copy_folder_course_session( $pathname, $base_path_document, @@ -4638,6 +4657,9 @@ function copy_folder_course_session( } // TODO: chmodr() is a better name. Some corrections are needed. Documentation header to be added here. +/** + * @param string $path + */ function api_chmod_R($path, $filemode) { if (!is_dir($path)) { return chmod($path, $filemode); @@ -4720,7 +4742,7 @@ function api_chmod_R($path, $filemode) { * version = VERSION * @endverbatim * - * @param $filename + * @param string $filename * The file we are parsing. Accepts file with relative or absolute path. * @return * The info array. @@ -4812,7 +4834,7 @@ function api_get_software_name() { /** * Checks whether status given in parameter exists in the platform * @param mixed the status (can be either int either string) - * @return true if the status exists, else returns false + * @return boolean if the status exists, else returns false */ function api_status_exists($status_asked) { global $_status_list; @@ -4834,7 +4856,7 @@ function api_status_key($status) { /** * Gets the status langvars list - * @return array the list of status with their translations + * @return string[] the list of status with their translations */ function api_get_status_langvars() { return array( @@ -4910,6 +4932,7 @@ function api_delete_setting_option($id) { * @param string The sub-variable if any (in most cases, this will remain null) * @param string The category if any (in most cases, this will remain null) * @param int The access_url for which this parameter is valid + * @param string $cat */ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url = 1) { @@ -5005,6 +5028,8 @@ function api_set_setting($var, $value, $subvar = null, $cat = null, $access_url * @param string Value * @param int Access URL. Optional. Defaults to 1 * @param array Optional array of filters on field type + * @param string $category + * @param string $value */ function api_set_settings_category($category, $value = null, $access_url = 1, $fieldtype = array()) { @@ -5248,6 +5273,10 @@ function api_delete_category_settings_by_subkey($subkey, $access_url_id = 1) { * @param string The subkey text * @param int The access_url for which this parameter is valid * @param int The changeability of this setting for non-master urls + * @param string $val + * @param string $var + * @param string $sk + * @param string $c * @return boolean true on success, false on failure */ function api_add_setting($val, $var, $sk = null, $type = 'textfield', $c = null, $title = '', $com = '', $sc = null, $skt = null, $a = 1, $v = 0) { @@ -5513,6 +5542,7 @@ function api_is_course_visible_for_user($userid = null, $cid = null) { * @param String the tool of the element * @param int the element id in database * @param int the session_id to compare with element session id + * @param string $tool * @return boolean true if the element is in the session, false else */ function api_is_element_in_the_session($tool, $element_id, $session_id = null) { @@ -5558,8 +5588,6 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null) { * Replaces "forbidden" characters in a filename string. * * @param string $filename - * @param int $length - * @param bool $file_name * * @return string */ @@ -5801,6 +5829,7 @@ function api_is_xml_http_request() { * @link http://php.net/manual/en/function.getimagesize.php * @link http://www.dokeos.com/forum/viewtopic.php?t=12345 * @link http://www.dokeos.com/forum/viewtopic.php?t=16355 + * @return integer */ function api_getimagesize($path) { $image = new Image($path); @@ -5961,6 +5990,7 @@ function shorten($input, $length = 15, $encoding = null) { * with his user id and the access_url_id=1 * * @author Julio Montoya + * @param integer $user_id */ function api_is_global_platform_admin($user_id = null) { @@ -6022,7 +6052,7 @@ function api_global_admin_can_edit_admin($admin_id_to_check, $my_user_id = null, * @param int $admin_id_to_check * @param int $my_user_id * @param bool $allow_session_admin - * @return bool + * @return boolean|null */ function api_protect_super_admin($admin_id_to_check, $my_user_id = null, $allow_session_admin = false) { @@ -6264,6 +6294,7 @@ function api_get_asset($file) { /** * Returns the HTML tag + * @param string $file */ function api_get_css($file, $media = 'screen') { return ''."\n"; @@ -6401,7 +6432,8 @@ function api_get_jquery_libraries_js($libraries) { * This function relies on api_get_course_info() * @param string The course code - optional (takes it from session if not given) * @param int The session id - optional (takes it from session if not given) - * @return mixed The URL of the course or null if something does not work + * @param integer $session_id + * @return string|null The URL of the course or null if something does not work * @author Julio Montoya */ function api_get_course_url($course_code = null, $session_id = null) @@ -6518,7 +6550,7 @@ function api_resource_is_locked_by_gradebook($item_id, $link_type, $course_code * @param int LINK_EXERCISE, LINK_STUDENTPUBLICATION, LINK_LEARNPATH LINK_FORUM_THREAD, LINK_ATTENDANCE * see gradebook/lib/be/linkfactory * @param string course code - * @return boolean + * @return false|null */ function api_block_course_item_locked_by_gradebook($item_id, $link_type, $course_code = null) { if (api_is_platform_admin()) { @@ -6602,7 +6634,7 @@ function api_get_locked_settings() { * false if he isn't. If the user ID is given and is an integer, then the same * ID is simply returned * @param integer User ID - * @return mixed Integer User ID is logged in, or false otherwise + * @return boolean Integer User ID is logged in, or false otherwise */ function api_user_is_login($user_id = null) { $user_id = empty($user_id) ? api_get_user_id() : intval($user_id); @@ -6637,6 +6669,7 @@ function api_get_real_ip(){ * Checks whether an IP is included inside an IP range * @param string IP address * @param string IP range + * @param string $ip * @return bool True if IP is in the range, false otherwise * @author claudiu at cnixs dot com on http://www.php.net/manual/fr/ref.network.php#55230 * @author Yannick Warnier for improvements and managment of multiple ranges @@ -7021,6 +7054,7 @@ function api_set_setting_last_update() /** * Tries to set memory limit, if authorized and new limit is higher than current * @param string New memory limit + * @param string $mem * @return bool True on success, false on failure or current is higher than suggested * @assert (null) === false * @assert (-1) === false @@ -7077,7 +7111,6 @@ function api_get_bytes_memory_limit($mem){ /** * Finds all the information about a user from username instead of user id - * @param string $username * * @return array $user_info user_id, lastname, firstname, username, email, ... * @author Yannick Warnier @@ -7099,7 +7132,6 @@ function api_get_user_info_from_official_code($official_code = '') /** * - * @param string $inputId the jquery id example: #password * * @return string */ @@ -7224,6 +7256,7 @@ function api_get_user_blocked_by_captcha($username) /** * Remove tags from HTML anf return the $in_number_char first non-HTML char * Postfix the text with "..." if it has been truncated. + * @param integer $in_number_char * @return string * @author hubert borderiou */ @@ -7268,7 +7301,7 @@ function api_drh_can_access_all_session_content() /** * @param string $tool * @param string $setting - * @param mixed $defaultValue + * @param integer $defaultValue * @return string */ function api_get_default_tool_setting($tool, $setting, $defaultValue) @@ -7393,7 +7426,7 @@ function api_delete_firstpage_parameter() } /** - * @return true if course_code for direct course access after login is set + * @return boolean if course_code for direct course access after login is set */ function exist_firstpage_parameter() { @@ -7685,7 +7718,7 @@ function api_create_protected_dir($name, $parentDirectory) * @param array data file (path and filename) * @param bool True for attaching a embedded file inside content html (optional) * @param array Additional parameters - * @return returns true if mail was sent + * @return integer true if mail was sent * @see class.phpmailer.php */ function api_mail_html( diff --git a/main/inc/lib/app_view.php b/main/inc/lib/app_view.php index 8e0510ea80..d0a20856d8 100755 --- a/main/inc/lib/app_view.php +++ b/main/inc/lib/app_view.php @@ -18,6 +18,7 @@ class View /** * Constructor, init tool path for rendering * @param string tool name (optional) + * @param string $template_path */ public function __construct($toolname = '', $template_path=null) { @@ -50,6 +51,7 @@ class View /** * Set layout view sent from a controller * @param string layout view + * @param string $layout */ public function set_layout( $layout ) { @@ -59,6 +61,7 @@ class View /** * Set template view sent from a controller * @param string template view + * @param string $template */ public function set_template($template) { diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 4e12bc4ee6..ae86c4e27f 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -153,9 +153,13 @@ function getCustomTabs() } /** +<<<<<<< HEAD * Return the active logo of the portal, based on a series of settings * @param string $theme The name of the theme folder from web/css/themes/ * @return string HTML string with logo as an HTML element +======= + * @param string $theme +>>>>>>> origin/1.10.x */ function return_logo($theme) { @@ -574,11 +578,15 @@ function menuArray() } /** +<<<<<<< HEAD * Return the breadcrumb menu elements as an array of
  • items * @param array $interbreadcrumb The elements to add to the breadcrumb * @param string $language_file Deprecated * @param string $nameTools The name of the current tool (not linked) * @return string HTML string of
  • items +======= + * @param string $nameTools +>>>>>>> origin/1.10.x */ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { diff --git a/main/inc/lib/blog.lib.php b/main/inc/lib/blog.lib.php index dd34e39608..97e9dcf85e 100755 --- a/main/inc/lib/blog.lib.php +++ b/main/inc/lib/blog.lib.php @@ -96,9 +96,7 @@ class Blog /** * Creates a new blog in the given course * @author Toon Keppens - * @param int $course_id Id * @param string $title - * @param Text $description */ public static function create_blog($title, $subtitle) { @@ -185,9 +183,7 @@ class Blog /** * Update title and subtitle of a blog in the given course * @author Toon Keppens - * @param int $course_id Id * @param string $title - * @param string $description */ public static function edit_blog($blog_id, $title, $subtitle) { @@ -711,7 +707,6 @@ class Blog /** * Deletes an assigned task from a blog * @param Integer $blog_id - * @param Integer $assignment_id */ public static function delete_assigned_task($blog_id, $task_id, $user_id) { @@ -1129,9 +1124,7 @@ class Blog * * @param String $type * @param Integer $blog_id - * @param Integer $item_id - * - *@return String + * @param integer $post_id */ public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) { @@ -2136,7 +2129,7 @@ class Blog * * @param Integer $blog_id * - * @return Html Form with sortable table with users to unsubcribe from a blog. + * @return false|null Form with sortable table with users to unsubcribe from a blog. */ public static function display_form_user_unsubscribe ($blog_id) { @@ -2257,6 +2250,7 @@ class Blog * @author Toon Keppens * * @param Integer $blog_id + * @param integer $post_id */ public static function display_new_comment_form($blog_id, $post_id, $title) { @@ -2305,10 +2299,8 @@ class Blog * @author Patrick Cool * @author Toon Keppens * - * @param Array $blogitems an array containing all the blog items for the given month * @param Integer $month: the integer value of the month we are viewing * @param Integer $year: the 4-digit year indication e.g. 2005 - * @param String $monthName: the language variable for the mont name * * @return html code */ @@ -2597,6 +2589,7 @@ class Blog * @param the blog's id * @param the post's id * @param the comment's id + * @param integer $blog_id * @return array with the post info according the parameters * @author Julio Montoya Dokeos * @version avril 2008, dokeos 1.8.5 @@ -2638,6 +2631,9 @@ function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) * @param the blog's id * @param the post's id * @param the comment's id + * @param integer $blog_id + * @param integer $post_id + * @param integer $comment_id * @author Julio Montoya Dokeos * @version avril 2008, dokeos 1.8.5 */ diff --git a/main/inc/lib/browser/Browser.php b/main/inc/lib/browser/Browser.php index d17027939e..eb631dc4a5 100755 --- a/main/inc/lib/browser/Browser.php +++ b/main/inc/lib/browser/Browser.php @@ -158,7 +158,7 @@ class Browser /** * Set the name of the browser - * @param $browser string The name of the Browser + * @param string $browser string The name of the Browser */ public function setBrowser($browser) { @@ -266,7 +266,7 @@ class Browser /** * Set the browser to be from AOL - * @param $isAol + * @param boolean $isAol */ public function setAol($isAol) { diff --git a/main/inc/lib/chat.lib.php b/main/inc/lib/chat.lib.php index 8f845c8ee1..158629a507 100755 --- a/main/inc/lib/chat.lib.php +++ b/main/inc/lib/chat.lib.php @@ -41,6 +41,7 @@ class Chat extends Model /** * Set user chat status * @param int 0 if disconnected, 1 if connected + * @param integer $status * * @return void */ @@ -164,6 +165,7 @@ class Chat extends Model /** * Saves into session the fact that a chat window exists with the given user * @param int The ID of the user with whom the current user is chatting + * @param integer $user_id * @return void */ public function save_window($user_id) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index bc5acd4a2e..b2efe3d8aa 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -731,7 +731,7 @@ class CourseManager * @param int $status (optional) The user's status in the course * @param int The user category in which this subscription will be classified * - * @return boolean true if subscription succeeds, boolean false otherwise. + * @return false|string true if subscription succeeds, boolean false otherwise. * @assert ('', '') === false */ public static function add_user_to_course($user_id, $courseCode, $status = STUDENT, $userCourseCategoryId = 0) @@ -803,7 +803,7 @@ class CourseManager * Checks wether a parameter exists. * If it doesn't, the function displays an error message. * - * @return true if parameter is set and not empty, false otherwise + * @return boolean if parameter is set and not empty, false otherwise * @todo move function to better place, main_api ? */ public static function check_parameter($parameter, $error_message) @@ -827,7 +827,7 @@ class CourseManager } /** - * @return true if there already are one or more courses + * @return boolean if there already are one or more courses * with the same code OR visual_code (visualcode), false otherwise */ public static function course_code_exists($wanted_course_code) @@ -1010,7 +1010,7 @@ class CourseManager /** * @param int $userId * @param array $courseInfo - * @return bool + * @return boolean|null */ public static function isUserSubscribedInCourseAsDrh($userId, $courseInfo) { @@ -1116,10 +1116,10 @@ class CourseManager /** * Is the user a teacher in the given course? * - * @param $user_id , the id (int) of the user + * @param integer $user_id , the id (int) of the user * @param $course_code , the course code * - * @return true if the user is a teacher in the course, false otherwise + * @return boolean if the user is a teacher in the course, false otherwise */ public static function is_course_teacher($user_id, $course_code) { @@ -1148,7 +1148,7 @@ class CourseManager * @param int the id of the user * @param int $courseId * @deprecated linked_courses definition doesn't exists - * @return true if the user is registered in the real course or linked courses, false otherwise + * @return boolean if the user is registered in the real course or linked courses, false otherwise */ public static function is_user_subscribed_in_real_or_linked_course($user_id, $courseId, $session_id = '') { @@ -1219,9 +1219,9 @@ class CourseManager * @param string $order_by the field to order the users by. * Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement * that starts with ORDER BY ... - * @param null $filter_by_status if using the session_id: 0 or 2 (student, coach), + * @param integer|null $filter_by_status if using the session_id: 0 or 2 (student, coach), * if using session_id = 0 STUDENT or COURSEMANAGER - * @param null $return_count + * @param boolean|null $return_count * @param bool $add_reports * @param bool $resumed_report * @param array $extra_field @@ -2015,7 +2015,7 @@ class CourseManager * @param int $courseId * @param string $separator * @param bool $add_link_to_profile - * @return null|string + * @return string */ public static function get_coachs_from_course_to_string( $session_id = 0, @@ -2088,7 +2088,7 @@ class CourseManager * Get the list of groups from the course * @param string $course_code * @param int $session_id Session ID (optional) - * @param boolean $in_get_empty_group get empty groups (optional) + * @param integer $in_get_empty_group get empty groups (optional) * @return array List of groups info */ public static function get_group_list_of_course($course_code, $session_id = 0, $in_get_empty_group = 0) @@ -2144,6 +2144,7 @@ class CourseManager * course. * * @param string The code of the course to delete + * @param string $code * @todo When deleting a virtual course: unsubscribe users from that virtual * course from the groups in the real course if they are not subscribed in * that real course. @@ -2355,6 +2356,7 @@ class CourseManager * Sort courses for a specific user ?? * @param int User ID * @param string Course code + * @param integer $user_id * @return int Minimum course order * @todo Review documentation */ @@ -2432,7 +2434,7 @@ class CourseManager * check if course exists * @param string course_code * @param string whether to accept virtual course codes or not - * @return true if exists, false else + * @return integer if exists, false else */ public static function course_exists($course_code, $accept_virtual = false) { @@ -2451,9 +2453,9 @@ class CourseManager * Send an email to tutor after the auth-suscription of a student in your course * @author Carlos Vargas , Dokeos Latino * @param int $user_id the id of the user - * @param string $course_code the course code + * @param string $courseId the course code * @param bool $send_to_tutor_also - * @return string we return the message that is displayed when the action is successful + * @return false|null we return the message that is displayed when the action is successful */ public static function email_to_tutor($user_id, $courseId, $send_to_tutor_also = false) { @@ -2696,6 +2698,7 @@ class CourseManager /** * Get emails of tutors to course * @param string Visual code + * @param integer $courseId * @return array List of emails of tutors to course * @author @author Carlos Vargas , Dokeos Latino * */ @@ -2719,6 +2722,7 @@ class CourseManager * Get coaches emails by session * @param int session id * @param int $courseId + * @param integer $session_id * @return array array(email => name_tutor) by coach * @author Carlos Vargas */ @@ -2767,7 +2771,9 @@ class CourseManager * @param string Field's internal variable name * @param int Field's type * @param string Field's language var name - * @return int new extra field id + * @param integer $fieldType + * @param string $default + * @return boolean new extra field id */ public static function create_course_extra_field($variable, $fieldType, $displayText, $default) { @@ -2789,7 +2795,7 @@ class CourseManager * @param int Course id * @param string Attribute name * @param string Attribute value - * @return bool True if attribute was successfully updated, + * @return Doctrine\DBAL\Driver\Statement|null True if attribute was successfully updated, * false if course was not found or attribute name is invalid */ public static function update_attribute($id, $name, $value) @@ -2807,7 +2813,7 @@ class CourseManager * * @param int Course id * @param array Associative array with field names as keys and field values as values - * @return bool True if update was successful, false otherwise + * @return Doctrine\DBAL\Driver\Statement|null True if update was successful, false otherwise */ public static function update_attributes($id, $attributes) { @@ -2833,7 +2839,7 @@ class CourseManager * @param integer Course ID * @param string Field variable name * @param string Field value - * @return boolean true if field updated, false otherwise + * @return boolean|null true if field updated, false otherwise */ public static function update_course_extra_field_value($course_code, $variable, $value = '') { @@ -3454,6 +3460,7 @@ class CourseManager * @uses displayCoursesInCategory() to display the courses themselves * @param int user id * @param bool Whether to show the document quick-loader or not + * @param integer $user_id * @return string */ public static function returnCourses($user_id, $load_dirs = false) @@ -4118,6 +4125,8 @@ class CourseManager * @param int source session id * @param string destination course code * @param int destination session id + * @param integer $source_session_id + * @param integer $destination_session_id * @return bool */ public static function copy_course( @@ -4152,6 +4161,7 @@ class CourseManager * @param int source session id * @param int destination session id * @param bool new copied tools (Exercises and LPs)will be set to invisible by default? + * @param string $new_title * * @return array */ @@ -4405,6 +4415,7 @@ class CourseManager * @param int course id * @param int session id * @param id url id + * @param integer $session_id * @return array **/ public static function update_course_ranking( @@ -4487,7 +4498,7 @@ class CourseManager * @param int course id * @param int session id * @param int url id (access_url_id) - * @return mixed 'added', 'updated' or 'nothing' + * @return false|string 'added', 'updated' or 'nothing' */ public static function add_course_vote($user_id, $vote, $course_id, $session_id = null, $url_id = null) { @@ -4782,6 +4793,7 @@ class CourseManager * Get courses count * @param int Access URL ID (optional) * @param int $visibility + * @param integer $access_url_id * * @return int Number of courses */ @@ -4838,6 +4850,7 @@ class CourseManager /** * Get available le courses count * @param int Access URL ID (optional) + * @param integer $accessUrlId * @return int Number of courses */ public static function countAvailableCourses($accessUrlId = null) @@ -4882,6 +4895,7 @@ class CourseManager * @param int User ID * @param array Course details array * @param array List of courses to which the user is subscribed (if not provided, will be generated) + * @param integer $uid * @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access */ static function get_access_link_by_user($uid, $course, $user_courses = array()) @@ -4952,7 +4966,7 @@ class CourseManager * @param bool $deleteTeachersNotInList * @param bool $editTeacherInSessions * @param bool $deleteSessionTeacherNotInList - * @return bool + * @return false|null */ public static function updateTeachers( $courseId, diff --git a/main/inc/lib/course_category.lib.php b/main/inc/lib/course_category.lib.php index fcb6bea26e..494335c433 100755 --- a/main/inc/lib/course_category.lib.php +++ b/main/inc/lib/course_category.lib.php @@ -94,8 +94,25 @@ class CourseCategory $category['nbr_courses'] = 1; } +<<<<<<< HEAD return $categories; } +======= +/** + * @param string $code + * @param string $name + * @param string $canHaveCourses + * @param int $parent_id + * + * @return false|string + */ +function addNode($code, $name, $canHaveCourses, $parent_id) +{ + $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $code = trim($code); + $name = trim($name); + $parent_id = trim($parent_id); +>>>>>>> origin/1.10.x /** * @param string $code @@ -291,7 +308,27 @@ class CourseCategory WHERE code= '".$row['code']."'"; Database::query($sql); +<<<<<<< HEAD return true; +======= +/** + * Counts the number of children categories a category has + * @param int $categoryId The ID of the category of which we want to count the children + * @return integer The number of subcategories this category has + */ +function courseCategoryChildrenCount($categoryId) +{ + $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $categoryId = intval($categoryId); + $count = 0; + if (empty($categoryId)) { + return 0; + } + $sql = "SELECT id, code FROM $tbl_category WHERE parent_id = $categoryId"; + $result = Database::query($sql); + while ($row = Database::fetch_array($result)) { + $count += courseCategoryChildrenCount($row['id']); +>>>>>>> origin/1.10.x } /** @@ -473,6 +510,7 @@ class CourseCategory return Database::store_result(Database::query($sql)); } +<<<<<<< HEAD /** * @param int $id * @@ -481,6 +519,17 @@ class CourseCategory public static function addToUrl($id) { UrlManager::addCourseCategoryListToUrl(array($id), array(api_get_current_access_url_id())); +======= +/** + * @param int $id + * + * @return false|null + */ +function addToUrl($id) +{ + if (!isMultipleUrlSupport()) { + return false; +>>>>>>> origin/1.10.x } /** @@ -918,6 +967,7 @@ class CourseCategory return Database::store_result($result, 'ASSOC'); } +<<<<<<< HEAD /** * @return array */ @@ -935,6 +985,33 @@ class CourseCategory 'current' => $pageCurrent, 'length' => $pageLength, ); +======= + return $limitFilter; +} + +/** + * Get Pagination HTML div + * @param $pageCurrent + * @param $pageLength + * @param integer $pageTotal + * @return string + */ +function getCataloguePagination($pageCurrent, $pageLength, $pageTotal) +{ + // Start empty html + $pageDiv = ''; + $html=''; + $pageBottom = max(1, $pageCurrent - 3); + $pageTop = min($pageTotal, $pageCurrent + 3); + + if ($pageBottom > 1) { + $pageDiv .= getPageNumberItem(1, $pageLength); + if ($pageBottom > 2) { + $pageDiv .= getPageNumberItem($pageBottom - 1, $pageLength, null, '...'); + } + } else { + // Nothing to do +>>>>>>> origin/1.10.x } /** diff --git a/main/inc/lib/course_description.lib.php b/main/inc/lib/course_description.lib.php index ead2631bcd..2ab08581fd 100755 --- a/main/inc/lib/course_description.lib.php +++ b/main/inc/lib/course_description.lib.php @@ -95,7 +95,7 @@ class CourseDescription * Get all data by description and session id, * first you must set session_id property with the object CourseDescription * @param int $description_type Description type - * @param string $course_code Course code (optional) + * @param string $courseId Course code (optional) * @param int $session_id Session id (optional) * @return array List of fields from the descriptions found of the given type */ diff --git a/main/inc/lib/course_request.lib.php b/main/inc/lib/course_request.lib.php index 10006381ba..18e6ee9266 100755 --- a/main/inc/lib/course_request.lib.php +++ b/main/inc/lib/course_request.lib.php @@ -18,7 +18,7 @@ class CourseRequestManager /** * Checks whether a given course code has been already occupied. * @param string $wanted_course_code The code to be checked. - * @return string + * @return boolean * Returns TRUE if there is created: * - a course with the same code OR visual_code (visualcode). * - a course request with the same code as the given one, or @@ -368,7 +368,7 @@ class CourseRequestManager } /** - * @param null $status + * @param integer $status * @return bool */ public static function count_course_requests($status = null) @@ -390,7 +390,7 @@ class CourseRequestManager /** * Gets all the information about a course request using its database id as an access key. - * @param int/string $id The id (an integer number) of the corresponding database record. + * @param integer $id The id (an integer number) of the corresponding database record. * @return array/bool Returns the requested data as an array or FALSE on failure. */ public static function get_course_request_info($id) diff --git a/main/inc/lib/dashboard.lib.php b/main/inc/lib/dashboard.lib.php index ca9c0c3b2b..5cbf10a400 100755 --- a/main/inc/lib/dashboard.lib.php +++ b/main/inc/lib/dashboard.lib.php @@ -493,6 +493,7 @@ class DashboardManager * This function update extra user blocks data after closing a dashboard block * @param int User id * @param string plugin path + * @param integer $user_id * @return bool */ public static function close_user_block($user_id, $path) diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index c707b584be..93287ff9a8 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -66,7 +66,7 @@ class Database * * @param string $table * - * @return mixed + * @return string */ public static function get_main_table($table) { @@ -272,7 +272,7 @@ class Database /** * Frees all the memory associated with the provided result identifier. - * @return bool Returns TRUE on success or FALSE on failure. + * @return boolean|null Returns TRUE on success or FALSE on failure. * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. * Anyway, all associated result memory is automatically freed at the end of the script's execution. */ @@ -388,7 +388,7 @@ class Database * @param array $attributes * @param bool $show_query * - * @return bool|int + * @return false|string */ public static function insert($table_name, $attributes, $show_query = false) { @@ -689,7 +689,7 @@ class Database } /** - * @param $table + * @param string $table * @return \Doctrine\DBAL\Schema\Column[] */ public static function listTableColumns($table) diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 02d6c2fc65..34a6f886bd 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -16,17 +16,18 @@ class ExerciseLib /** * Shows a question * - * @param int $questionId question id - * @param bool $only_questions if true only show the questions, no exercise title - * @param bool $origin i.e = learnpath + * @param int $questionId $questionId question id + * @param bool $only_questions if true only show the questions, no exercise title + * @param bool $origin i.e = learnpath * @param string $current_item current item from the list of questions - * @param bool $show_title - * @param bool $freeze - * @param array $user_choice - * @param bool $show_comment - * @param bool $exercise_feedback - * @param bool $show_answers - * */ + * @param bool $show_title + * @param bool $freeze + * @param array $user_choice + * @param bool $show_comment + * @param null $exercise_feedback + * @param bool $show_answers + * @return bool|int + */ public static function showQuestion( $questionId, $only_questions = false, @@ -38,7 +39,8 @@ class ExerciseLib $show_comment = false, $exercise_feedback = null, $show_answers = false - ) { + ) + { $course_id = api_get_course_int_id(); // Change false to true in the following line to enable answer hinting $debug_mark_answer = $show_answers; @@ -89,13 +91,6 @@ class ExerciseLib $objAnswerTmp = new Answer($questionId); $nbrAnswers = $objAnswerTmp->selectNbrAnswers(); - if ($answerType == FREE_ANSWER || - $answerType == ORAL_EXPRESSION || - $answerType == CALCULATED_ANSWER - ) { - $nbrAnswers = 1; - } - $quiz_question_options = Question::readQuestionOption( $questionId, $course_id @@ -117,7 +112,7 @@ class ExerciseLib
      '; } else { - $s .= '
      + $s .= '
      '; } @@ -164,7 +159,7 @@ class ExerciseLib } elseif ($answerType == FREE_ANSWER) { $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null; - $form = new FormValidator('free_choice_'.$questionId); + $form = new FormValidator('free_choice_' . $questionId); $config = array( 'ToolbarSet' => 'TestFreeAnswer' ); @@ -196,7 +191,7 @@ class ExerciseLib echo $objQuestionTmp->returnRecorder(); } - $form = new FormValidator('free_choice_'.$questionId); + $form = new FormValidator('free_choice_' . $questionId); $config = array( 'ToolbarSet' => 'TestFreeAnswer' ); @@ -238,17 +233,17 @@ class ExerciseLib if ($show_comment) { if ( - in_array( - $answerType, - array( - MULTIPLE_ANSWER, - MULTIPLE_ANSWER_COMBINATION, - UNIQUE_ANSWER, - UNIQUE_ANSWER_IMAGE, - UNIQUE_ANSWER_NO_OPTION, - GLOBAL_MULTIPLE_ANSWER - ) + in_array( + $answerType, + array( + MULTIPLE_ANSWER, + MULTIPLE_ANSWER_COMBINATION, + UNIQUE_ANSWER, + UNIQUE_ANSWER_IMAGE, + UNIQUE_ANSWER_NO_OPTION, + GLOBAL_MULTIPLE_ANSWER ) + ) ) { $header = Display::tag('th', get_lang('Options')); if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) { @@ -279,124 +274,226 @@ class ExerciseLib $attributes = array(); - // Unique answer - if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) { - $input_id = 'choice-' . $questionId . '-' . $answerId; - if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { - $attributes = array( - 'id' => $input_id, - 'checked' => 1, - 'selected' => 1 - ); - } else { - $attributes = array('id' => $input_id); - } + switch ($answerType) { + case UNIQUE_ANSWER: + //no break + case UNIQUE_ANSWER_NO_OPTION: + //no break + case UNIQUE_ANSWER_IMAGE: + $input_id = 'choice-' . $questionId . '-' . $answerId; - if ($debug_mark_answer) { - if ($answerCorrect) { - $attributes['checked'] = 1; - $attributes['selected'] = 1; + if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { + $attributes = array( + 'id' => $input_id, + 'checked' => 1, + 'selected' => 1 + ); + } else { + $attributes = array('id' => $input_id); } - } - if ($show_comment) { - $s .= ''; + $s .= ''; + $s .= ''; } else { - $s .= '
      '; + $s .= $answer_input; + } + break; + case MULTIPLE_ANSWER: + //no break + case MULTIPLE_ANSWER_TRUE_FALSE: + //no break + case GLOBAL_MULTIPLE_ANSWER: + $input_id = 'choice-' . $questionId . '-' . $answerId; + $answer = Security::remove_XSS($answer, STUDENT); + + if (in_array($numAnswer, $user_choice_array)) { + $attributes = array( + 'id' => $input_id, + 'checked' => 1, + 'selected' => 1 + ); + } else { + $attributes = array('id' => $input_id); } - } - $answer = Security::remove_XSS($answer, STUDENT); - $s .= Display::input( - 'hidden', - 'choice2[' . $questionId . ']', - '0' - ); + if ($debug_mark_answer) { + if ($answerCorrect) { + $attributes['checked'] = 1; + $attributes['selected'] = 1; + } + } - $answer_input = null; + if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { + $s .= ''; - if ($answerType == UNIQUE_ANSWER_IMAGE) { - $attributes['style'] = 'display: none;'; - $answer = '
      ' . $answer . '
      '; - } + $answer_input = ''; + + if ($show_comment) { + $s .= '
      '; + $s .= ''; + $s .= ''; + } else { + $s .= $answer_input; + } + } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { - $answer_input .= ''; + $my_choice = array(); + if (!empty($user_choice_array)) { + foreach ($user_choice_array as $item) { + $item = explode(':', $item); + $my_choice[$item[0]] = $item[1]; + } + } - if ($answerType == UNIQUE_ANSWER_IMAGE) { - $answer_input .= ""; - } + $s .= ''; + $s .= Display::tag('td', $answer); - if ($show_comment) { - $s .= $answer_input; - $s .= ''; - $s .= ''; - $s .= ''; - } else { - $s .= $answer_input; - } + if (!empty($quiz_question_options)) { + foreach ($quiz_question_options as $id => $item) { - } elseif ( - $answerType == MULTIPLE_ANSWER || - $answerType == MULTIPLE_ANSWER_TRUE_FALSE || - $answerType == GLOBAL_MULTIPLE_ANSWER - ) { - $input_id = 'choice-' . $questionId . '-' . $answerId; - $answer = Security::remove_XSS($answer, STUDENT); - - if (in_array($numAnswer, $user_choice_array)) { - $attributes = array( - 'id' => $input_id, - 'checked' => 1, - 'selected' => 1 - ); - } else { - $attributes = array('id' => $input_id); - } + if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) { + $attributes = array( + 'checked' => 1, + 'selected' => 1 + ); + } else { + $attributes = array(); + } + + if ($debug_mark_answer) { + if ($id == $answerCorrect) { + $attributes['checked'] = 1; + $attributes['selected'] = 1; + } + } + $s .= Display::tag( + 'td', + Display::input( + 'radio', + 'choice[' . $questionId . '][' . $numAnswer . ']', + $id, + $attributes + ), + array('style' => '') + ); + } + } + + if ($show_comment) { + $s .= ''; + } + $s .= ''; + } + break; + case MULTIPLE_ANSWER_COMBINATION: + // multiple answers + $input_id = 'choice-' . $questionId . '-' . $answerId; - if ($debug_mark_answer) { - if ($answerCorrect) { - $attributes['checked'] = 1; - $attributes['selected'] = 1; + if (in_array($numAnswer, $user_choice_array)) { + $attributes = array( + 'id' => $input_id, + 'checked' => 1, + 'selected' => 1 + ); + } else { + $attributes = array('id' => $input_id); } - } - if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { - $s .= ''; + if ($debug_mark_answer) { + if ($answerCorrect) { + $attributes['checked'] = 1; + $attributes['selected'] = 1; + } + } - $answer_input = ''; + $s .= ''; $s .= ''; $s .= Display::tag('td', $answer); - if (!empty($quiz_question_options)) { - foreach ($quiz_question_options as $id => $item) { - - if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) { - $attributes = array( - 'checked' => 1, - 'selected' => 1 - ); - } else { - $attributes = array(); - } + foreach ($objQuestionTmp->options as $key => $item) { + if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) { + $attributes = array( + 'checked' => 1, + 'selected' => 1 + ); + } else { + $attributes = array(); + } - if ($debug_mark_answer) { - if ($id == $answerCorrect) { - $attributes['checked'] = 1; - $attributes['selected'] = 1; - } + if ($debug_mark_answer) { + if ($key == $answerCorrect) { + $attributes['checked'] = 1; + $attributes['selected'] = 1; } - $s .= Display::tag( - 'td', - Display::input( - 'radio', - 'choice[' . $questionId . '][' . $numAnswer . ']', - $id, - $attributes - ), - array('style' => '') - ); } + $s .= Display::tag( + 'td', + Display::input( + 'radio', + 'choice[' . $questionId . '][' . $numAnswer . ']', + $key, + $attributes + ) + ); } if ($show_comment) { @@ -456,443 +553,337 @@ class ExerciseLib $s .= ''; } $s .= ''; - } - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { - // multiple answers - $input_id = 'choice-' . $questionId . '-' . $answerId; - - if (in_array($numAnswer, $user_choice_array)) { - $attributes = array( - 'id' => $input_id, - 'checked' => 1, - 'selected' => 1 - ); - } else { - $attributes = array('id' => $input_id); - } - - if ($debug_mark_answer) { - if ($answerCorrect) { - $attributes['checked'] = 1; - $attributes['selected'] = 1; - } - } - - $answer = Security::remove_XSS($answer, STUDENT); - $answer_input = ''; - $answer_input .= ''; - - if ($show_comment) { - $s .= ''; - $s .= ''; - $s .= ''; - $s .= ''; - } else { - $s .= $answer_input; - } + break; + case FILL_IN_BLANKS: + // display the question, with field empty, for student to fill it, + // or filled to display the answer in the Question preview of the exercice/admin.php page + $displayForStudent = true; + $listAnswerInformations = FillBlanks::getAnswerInfo($answer); + $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); + $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { - $s .= ''; + list($answer) = explode('::', $answer); - $my_choice = array(); - if (!empty($user_choice_array)) { - foreach ($user_choice_array as $item) { - $item = explode(':', $item); - if (isset($item[1]) && isset($item[0])) { - $my_choice[$item[0]] = $item[1]; - } - } - } - $answer = Security::remove_XSS($answer, STUDENT); - $s .= ''; - $s .= Display::tag('td', $answer); + //Correct answers + $correctAnswerList = $listAnswerInformations['tabwords']; - foreach ($objQuestionTmp->options as $key => $item) { - if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) { - $attributes = array( - 'checked' => 1, - 'selected' => 1 - ); - } else { - $attributes = array(); + //Student's answer + $studentAnswerList = array(); + if (isset($user_choice[0]['answer'])) { + $arrayStudentAnswer = FillBlanks::getAnswerInfo($user_choice[0]['answer'], true); + $studentAnswerList = $arrayStudentAnswer['studentanswer']; } + // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview + // set the student-answer to the correct answer if ($debug_mark_answer) { - if ($key == $answerCorrect) { - $attributes['checked'] = 1; - $attributes['selected'] = 1; - } + $studentAnswerList = $correctAnswerList; + $displayForStudent = false; } - $s .= Display::tag( - 'td', - Display::input( - 'radio', - 'choice[' . $questionId . '][' . $numAnswer . ']', - $key, - $attributes - ) - ); - } - - if ($show_comment) { - $s .= ''; - } - $s .= ''; - } elseif ($answerType == FILL_IN_BLANKS) { - // display the question, with field empty, for student to fill it, - // or filled to display the answer in the Question preview of the exercice/admin.php page - $displayForStudent = true; - $listAnswerInformations = FillBlanks::getAnswerInfo($answer); - $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); - $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); - - list($answer) = explode('::', $answer); - - //Correct answers - $correctAnswerList = $listAnswerInformations['tabwords']; - - //Student's answer - $studentAnswerList = array(); - if (isset($user_choice[0]['answer'])) { - $arrayStudentAnswer = FillBlanks::getAnswerInfo($user_choice[0]['answer'], true); - $studentAnswerList = $arrayStudentAnswer['studentanswer']; - } - - // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview - // set the student-answer to the correct answer - if ($debug_mark_answer) { - $studentAnswerList = $correctAnswerList; - $displayForStudent = false; - } - if (!empty($correctAnswerList) && !empty($studentAnswerList)) { - $answer = ""; - for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { - // display the common word + if (!empty($correctAnswerList) && !empty($studentAnswerList)) { + $answer = ""; + for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { + // display the common word + $answer .= $listAnswerInformations["commonwords"][$i]; + // display the blank word + $correctItem = $listAnswerInformations["tabwords"][$i]; + $correctItemRegexp = $correctItem; + // replace / with \/ to allow the preg_replace bellow and all the regexp char + $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); + if (isset($studentAnswerList[$i])) { + // If student already started this test and answered this question, + // fill the blank with his previous answers + // may be "" if student viewed the question, but did not fill the blanks + $correctItem = $studentAnswerList[$i]; + } + $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; + $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); + } + // display the last common word $answer .= $listAnswerInformations["commonwords"][$i]; - // display the blank word - $correctItem = $listAnswerInformations["tabwords"][$i]; - $correctItemRegexp = $correctItem; - // replace / with \/ to allow the preg_replace bellow and all the regexp char - $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); - if (isset($studentAnswerList[$i])) { - // If student already started this test and answered this question, - // fill the blank with his previous answers - // may be "" if student viewed the question, but did not fill the blanks - $correctItem = $studentAnswerList[$i]; + } else { + // display empty [input] with the right width for student to fill it + $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); + $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); + $answer = ""; + for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { + // display the common words + $answer .= $listAnswerInformations["commonwords"][$i]; + // display the blank word + $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px"; + $correctItem = $listAnswerInformations["tabwords"][$i]; + $correctItemRegexp = $correctItem; + // replace / with \/ to allow the preg_replace bellow and all the regexp char + $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); + $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, '', $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); } - $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; - $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); - } - // display the last common word - $answer .= $listAnswerInformations["commonwords"][$i]; - } else { - // display empty [input] with the right width for student to fill it - $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']); - $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']); - $answer = ""; - for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) { - // display the common words + // display the last common word $answer .= $listAnswerInformations["commonwords"][$i]; - // display the blank word - $attributes["style"] = "width:".$listAnswerInformations["tabinputsize"][$i]."px"; - $correctItem = $listAnswerInformations["tabwords"][$i]; - $correctItemRegexp = $correctItem; - // replace / with \/ to allow the preg_replace bellow and all the regexp char - $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp); - $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, '', $attributes, $answer, $listAnswerInformations, $displayForStudent, $i); } - // display the last common word - $answer .= $listAnswerInformations["commonwords"][$i]; - } - $s .= $answer; - - } elseif ($answerType == CALCULATED_ANSWER) { - - /* - * In the CALCULATED_ANSWER test - * you mustn't have [ and ] in the textarea - * you mustn't have @@ in the textarea - * the text to find mustn't be empty or contains only spaces - * the text to find mustn't contains HTML tags - * the text to find mustn't contains char " - */ - global $exerciseId; - $trackAttempts = Database::get_main_table( - TABLE_STATISTIC_TRACK_E_ATTEMPT - ); - $sql = 'SELECT answer FROM ' . $trackAttempts . ' - WHERE exe_id=' . $exerciseId . ' AND question_id=' . $questionId; - $rsLastAttempt = Database::query($sql); - $rowLastAttempt = Database::fetch_array($rsLastAttempt); - $answer = $rowLastAttempt['answer']; - - $calculatedAnswerId = Session::read('calculatedAnswerId'); - $calculatedAnswerInfo = Session::read('calculatedAnswerInfo'); - if (empty($answer)) { - if (empty($calculatedAnswerId)) { - $_SESSION['calculatedAnswerId'][$questionId] = mt_rand( - 1, - $nbrAnswers - ); - $answer = $objAnswerTmp->selectAnswer( - $_SESSION['calculatedAnswerId'][$questionId] + $s .= $answer; + break; + case CALCULATED_ANSWER: + /* + * In the CALCULATED_ANSWER test + * you mustn't have [ and ] in the textarea + * you mustn't have @@ in the textarea + * the text to find mustn't be empty or contains only spaces + * the text to find mustn't contains HTML tags + * the text to find mustn't contains char " + */ + if ($origin !== null) { + global $exe_id; + $trackAttempts = Database::get_main_table( + TABLE_STATISTIC_TRACK_E_ATTEMPT ); - - Session::write('calculatedAnswerInfo', [$questionId => $answer]); - - } else { - $calculatedAnswerInfo = Session::read('calculatedAnswerInfo'); - if (isset($calculatedAnswerInfo[$questionId])) { - $answer = $calculatedAnswerInfo[$questionId]; + $sql = 'SELECT answer FROM ' . $trackAttempts . ' + WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId; + $rsLastAttempt = Database::query($sql); + $rowLastAttempt = Database::fetch_array($rsLastAttempt); + $answer = $rowLastAttempt['answer']; + if (empty($answer)) { + $_SESSION['calculatedAnswerId'][$questionId] = mt_rand( + 1, + $nbrAnswers + ); + $answer = $objAnswerTmp->selectAnswer( + $_SESSION['calculatedAnswerId'][$questionId] + ); } } - } - - list($answer) = explode('@@', $answer); - // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]] - api_preg_match_all( - '/\[[^]]+\]/', - $answer, - $correctAnswerList - ); - - // get student answer to display it if student go back to previous calculated answer question in a test - if (isset($user_choice[0]['answer'])) { + list($answer) = explode('@@', $answer); + // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]] api_preg_match_all( '/\[[^]]+\]/', $answer, - $studentAnswerList + $correctAnswerList ); - $studentAnswerListTobecleaned = $studentAnswerList[0]; - $studentAnswerList = array(); - for ($i = 0; $i < count( - $studentAnswerListTobecleaned - ); $i++) { - $answerCorrected = $studentAnswerListTobecleaned[$i]; - $answerCorrected = api_preg_replace( - '| / .*$|', - '', - $answerCorrected + // get student answer to display it if student go back to previous calculated answer question in a test + if (isset($user_choice[0]['answer'])) { + api_preg_match_all( + '/\[[^]]+\]/', + $answer, + $studentAnswerList ); - $answerCorrected = api_preg_replace( - '/^\[/', - '', - $answerCorrected - ); - $answerCorrected = api_preg_replace( - '|^|', - '', - $answerCorrected - ); - $answerCorrected = api_preg_replace( - '|$|', - '', - $answerCorrected - ); - $answerCorrected = '[' . $answerCorrected . ']'; - $studentAnswerList[] = $answerCorrected; + $studentAnswerListTobecleaned = $studentAnswerList[0]; + $studentAnswerList = array(); + + for ($i = 0; $i < count( + $studentAnswerListTobecleaned + ); $i++) { + $answerCorrected = $studentAnswerListTobecleaned[$i]; + $answerCorrected = api_preg_replace( + '| / .*$|', + '', + $answerCorrected + ); + $answerCorrected = api_preg_replace( + '/^\[/', + '', + $answerCorrected + ); + $answerCorrected = api_preg_replace( + '|^|', + '', + $answerCorrected + ); + $answerCorrected = api_preg_replace( + '|$|', + '', + $answerCorrected + ); + $answerCorrected = '[' . $answerCorrected . ']'; + $studentAnswerList[] = $answerCorrected; + } } - } - // If display preview of answer in test view for exemple, set the student answer to the correct answers - if ($debug_mark_answer) { - // contain the rights answers surronded with brackets - $studentAnswerList = $correctAnswerList[0]; - } + // If display preview of answer in test view for exemple, set the student answer to the correct answers + if ($debug_mark_answer) { + // contain the rights answers surronded with brackets + $studentAnswerList = $correctAnswerList[0]; + } - /* - Split the response by bracket - tabComments is an array with text surrounding the text to find - we add a space before and after the answerQuestion to be sure to - have a block of text before and after [xxx] patterns - so we have n text to find ([xxx]) and n+1 block of texts before, - between and after the text to find - */ - $tabComments = api_preg_split( - '/\[[^]]+\]/', - ' ' . $answer . ' ' - ); - if (!empty($correctAnswerList) && !empty($studentAnswerList)) { - $answer = ""; - $i = 0; - foreach ($studentAnswerList as $studentItem) { - // remove surronding brackets - $studentResponse = api_substr( - $studentItem, - 1, - api_strlen($studentItem) - 2 - ); - $size = strlen($studentItem); - $attributes['class'] = self::detectInputAppropriateClass( - $size - ); + /* + Split the response by bracket + tabComments is an array with text surrounding the text to find + we add a space before and after the answerQuestion to be sure to + have a block of text before and after [xxx] patterns + so we have n text to find ([xxx]) and n+1 block of texts before, + between and after the text to find + */ + $tabComments = api_preg_split( + '/\[[^]]+\]/', + ' ' . $answer . ' ' + ); + if (!empty($correctAnswerList) && !empty($studentAnswerList)) { + $answer = ""; + $i = 0; + foreach ($studentAnswerList as $studentItem) { + // remove surronding brackets + $studentResponse = api_substr( + $studentItem, + 1, + api_strlen($studentItem) - 2 + ); + $size = strlen($studentItem); + $attributes['class'] = self::detectInputAppropriateClass( + $size + ); - $answer .= $tabComments[$i] . - Display::input( - 'text', - "choice[$questionId][]", - $studentResponse, - $attributes + $answer .= $tabComments[$i] . + Display::input( + 'text', + "choice[$questionId][]", + $studentResponse, + $attributes + ); + $i++; + } + $answer .= $tabComments[$i]; + } else { + // display exercise with empty input fields + // every [xxx] are replaced with an empty input field + foreach ($correctAnswerList[0] as $item) { + $size = strlen($item); + $attributes['class'] = self::detectInputAppropriateClass( + $size ); - $i++; + $answer = str_replace( + $item, + Display::input( + 'text', + "choice[$questionId][]", + '', + $attributes + ), + $answer + ); + } } - $answer .= $tabComments[$i]; - } else { - // display exercise with empty input fields - // every [xxx] are replaced with an empty input field - foreach ($correctAnswerList[0] as $item) { - $size = strlen($item); - $attributes['class'] = self::detectInputAppropriateClass( - $size - ); - $answer = str_replace( - $item, - Display::input( - 'text', - "choice[$questionId][]", - '', - $attributes - ), - $answer - ); + if ($origin !== null) { + $s = $answer; + break; + } else { + $s .= $answer; } - } - if ($origin !== null) { - $s = $answer; break; - } else { - $s .= $answer; - } - } elseif ($answerType == MATCHING) { - // matching type, showing suggestions and answers - // TODO: replace $answerId by $numAnswer - - if ($answerCorrect != 0) { - // only show elements to be answered (not the contents of - // the select boxes, who are corrrect = 0) - $s .= ''; - //middle part (matches selects) - - $s .= ''; + //middle part (matches selects) + + $s .= ''; - $s .= ''; - $s .= ''; - $lines_count++; - //if the left side of the "matching" has been completely - // shown but the right side still has values to show... - if (($lines_count - 1) == $num_suggestions) { - // if it remains answers to shown at the right side - while (isset($select_items[$lines_count])) { - $s .= ' + $s .= ''; + $s .= ''; + $s .= ''; + $lines_count++; + //if the left side of the "matching" has been completely + // shown but the right side still has values to show... + if (($lines_count - 1) == $num_suggestions) { + // if it remains answers to shown at the right side + while (isset($select_items[$lines_count])) { + $s .= ' + $s .= '' . $select_items[$lines_count]['letter'] . '. ' . $select_items[$lines_count]['answer']; + $s .= " "; - $lines_count++; - } // end while() - } // end if() - $matching_correct_answer++; - } - } elseif ($answerType == DRAGGABLE) { - if ($answerCorrect != 0) { - $parsed_answer = $answer; - /*$lines_count = ''; - $data = $objAnswerTmp->getAnswerByAutoId($numAnswer); - $data = $objAnswerTmp->getAnswerByAutoId($data['correct']); - $lines_count = $data['answer'];*/ + $lines_count++; + } // end while() + } // end if() + $matching_correct_answer++; + } + break; + case DRAGGABLE: + if ($answerCorrect != 0) { + $parsed_answer = $answer; + /*$lines_count = ''; + $data = $objAnswerTmp->getAnswerByAutoId($numAnswer); + $data = $objAnswerTmp->getAnswerByAutoId($data['correct']); + $lines_count = $data['answer'];*/ - $windowId = $questionId . '_' . $lines_count; + $windowId = $questionId . '_' . $lines_count; - $s .= '
    • '; - $s .= Display::div( - $parsed_answer, - [ - 'id' => "window_$windowId", - 'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option" - ] - ); - $selectedValue = 0; - $draggableSelectOptions = []; + $s .= '
    • '; + $s .= Display::div( + $parsed_answer, + [ + 'id' => "window_$windowId", + 'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option" + ] + ); + $selectedValue = 0; + $draggableSelectOptions = []; - foreach ($select_items as $key => $val) { - if ($debug_mark_answer) { - if ($val['id'] == $answerCorrect) { + foreach ($select_items as $key => $val) { + if ($debug_mark_answer) { + if ($val['id'] == $answerCorrect) { + $selectedValue = $val['id']; + } + } + + if ( + isset($user_choice[$matching_correct_answer]) && + $val['id'] == $user_choice[$matching_correct_answer]['answer'] + ) { $selectedValue = $val['id']; } - } - if ( - isset($user_choice[$matching_correct_answer]) && - $val['id'] == $user_choice[$matching_correct_answer]['answer'] - ) { - $selectedValue = $val['id']; + $draggableSelectOptions[$val['id']] = $val['letter']; } - $draggableSelectOptions[$val['id']] = $val['letter']; - } - - $s .= Display::select( - "choice[$questionId][$numAnswer]", - $draggableSelectOptions, - $selectedValue, - [ - 'id' => "window_{$windowId}_select", - 'class' => 'select_option', - 'style' => 'display: none;' - ], - false - ); + $s .= Display::select( + "choice[$questionId][$numAnswer]", + $draggableSelectOptions, + $selectedValue, + [ + 'id' => "window_{$windowId}_select", + 'class' => 'select_option', + 'style' => 'display: none;' + ], + false + ); - if (!empty($answerCorrect) && !empty($selectedValue)) { - $s .= << $(function() { DraggableAnswer.deleteItem( @@ -902,47 +893,48 @@ class ExerciseLib }); JAVASCRIPT; - } + } - if (isset($select_items[$lines_count])) { - $s .= Display::div( - Display::tag( - 'b', - $select_items[$lines_count]['letter'] - ) . $select_items[$lines_count]['answer'], - [ - 'id' => "window_{$windowId}_answer", - 'style' => 'display: none;' - ] - ); - } else { - $s .= ' '; - } + if (isset($select_items[$lines_count])) { + $s .= Display::div( + Display::tag( + 'b', + $select_items[$lines_count]['letter'] + ) . $select_items[$lines_count]['answer'], + [ + 'id' => "window_{$windowId}_answer", + 'style' => 'display: none;' + ] + ); + } else { + $s .= ' '; + } - $lines_count++; + $lines_count++; - if (($lines_count - 1) == $num_suggestions) { - while (isset($select_items[$lines_count])) { - $s .= Display::tag('b', $select_items[$lines_count]['letter']); - $s .= $select_items[$lines_count]['answer']; - $lines_count++; + if (($lines_count - 1) == $num_suggestions) { + while (isset($select_items[$lines_count])) { + $s .= Display::tag('b', $select_items[$lines_count]['letter']); + $s .= $select_items[$lines_count]['answer']; + $lines_count++; + } } - } - $matching_correct_answer++; + $matching_correct_answer++; - $s .= '
    • '; - } - } elseif ($answerType == MATCHING_DRAGGABLE) { - if ($answerId == 1) { - echo $objAnswerTmp->getJs(); - } + $s .= ''; + } + break; + case MATCHING_DRAGGABLE: + if ($answerId == 1) { + echo $objAnswerTmp->getJs(); + } - if ($answerCorrect != 0) { - $parsed_answer = $answer; - $windowId = "{$questionId}_{$lines_count}"; + if ($answerCorrect != 0) { + $parsed_answer = $answer; + $windowId = "{$questionId}_{$lines_count}"; - $s .= <<
      '; + $s .= ''; - $lines_count++; + $lines_count++; - if (($lines_count - 1) == $num_suggestions) { - while (isset($select_items[$lines_count])) { - $s .= << HTML; - $lines_count++; + $lines_count++; + } } + $matching_correct_answer++; } - $matching_correct_answer++; - } + break; } } // end for() if ($show_comment) { $s .= '
      '; - } + if ($debug_mark_answer) { + if ($answerCorrect) { + $attributes['checked'] = 1; + $attributes['selected'] = 1; + } + } - if ($answerType == UNIQUE_ANSWER_IMAGE) { if ($show_comment) { - if (empty($comment)) { - $s .= '
      '; + $s .= '
      '; + } + + if ($answerType == UNIQUE_ANSWER_IMAGE) { + if ($show_comment) { + if (empty($comment)) { + $s .= '
      '; + } else { + $s .= '
      '; + } } else { $s .= '
      '; + . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">'; } + } + + $answer = Security::remove_XSS($answer, STUDENT); + $s .= Display::input( + 'hidden', + 'choice2[' . $questionId . ']', + '0' + ); + + $answer_input = null; + + if ($answerType == UNIQUE_ANSWER_IMAGE) { + $attributes['style'] = 'display: none;'; + $answer = '
      ' . $answer . '
      '; + } + + $answer_input .= ''; + + if ($answerType == UNIQUE_ANSWER_IMAGE) { + $answer_input .= "
      "; + } + + if ($show_comment) { + $s .= $answer_input; + $s .= '
      '; + $s .= $comment; + $s .= '
      '; + $s .= $answer_input; + $s .= ''; + $s .= $comment; + $s .= '
      '; - $s .= $comment; - $s .= '
      '; + $s .= $comment; + $s .= '
      '; + $s .= '
      '; $s .= $answer_input; $s .= ''; @@ -406,48 +503,48 @@ class ExerciseLib } else { $s .= $answer_input; } - } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) { + break; + case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: + $s .= ''; $my_choice = array(); if (!empty($user_choice_array)) { foreach ($user_choice_array as $item) { $item = explode(':', $item); - $my_choice[$item[0]] = $item[1]; + if (isset($item[1]) && isset($item[0])) { + $my_choice[$item[0]] = $item[1]; + } } } - + $answer = Security::remove_XSS($answer, STUDENT); $s .= '
      '; - $s .= $answer_input; - $s .= ''; - $s .= $comment; - $s .= '
      '; - $s .= $comment; - $s .= '
      '; - $parsed_answer = $answer; - //left part questions - $s .= '

      ' . $lines_count . '. ' . $parsed_answer . '

      + case MATCHING: + // matching type, showing suggestions and answers + // TODO: replace $answerId by $numAnswer + + if ($answerCorrect != 0) { + // only show elements to be answered (not the contents of + // the select boxes, who are corrrect = 0) + $s .= '
      '; + $parsed_answer = $answer; + //left part questions + $s .= '

      ' . $lines_count . '. ' . $parsed_answer . '

       '; - if (isset($select_items[$lines_count])) { - $s .= '

      ' . $select_items[$lines_count]['letter'].'.  '. $select_items[$lines_count]['answer'].'

      '; - } else { - $s .= ' '; - } - $s .= '
       '; + if (isset($select_items[$lines_count])) { + $s .= '

      ' . $select_items[$lines_count]['letter'] . '.  ' . $select_items[$lines_count]['answer'] . '

      '; + } else { + $s .= ' '; + } + $s .= '
      '; - $s .= '' . $select_items[$lines_count]['letter'] . '. ' . $select_items[$lines_count]['answer']; - $s .= "
      @@ -951,47 +943,47 @@ JAVASCRIPT;
      HTML; - $selectedValue = 0; - $selectedPosition = 0; - $questionOptions = []; + $selectedValue = 0; + $selectedPosition = 0; + $questionOptions = []; - $iTempt = 0; + $iTempt = 0; - foreach ($select_items as $key => $val) { - if ($debug_mark_answer) { - if ($val['id'] == $answerCorrect) { + foreach ($select_items as $key => $val) { + if ($debug_mark_answer) { + if ($val['id'] == $answerCorrect) { + $selectedValue = $val['id']; + $selectedPosition = $iTempt; + } + } + + if ( + isset($user_choice[$matching_correct_answer]) && + $val['id'] == $user_choice[$matching_correct_answer]['answer'] + ) { $selectedValue = $val['id']; $selectedPosition = $iTempt; } - } - if ( - isset($user_choice[$matching_correct_answer]) && - $val['id'] == $user_choice[$matching_correct_answer]['answer'] - ) { - $selectedValue = $val['id']; - $selectedPosition = $iTempt; + $questionOptions[$val['id']] = $val['letter']; + $iTempt++; } - $questionOptions[$val['id']] = $val['letter']; - $iTempt++; - } - - $s .= Display::select( - "choice[$questionId][$numAnswer]", - $questionOptions, - $selectedValue, - [ - 'id' => "window_{$windowId}_select", - 'class' => 'hidden' - ], - false - ); + $s .= Display::select( + "choice[$questionId][$numAnswer]", + $questionOptions, + $selectedValue, + [ + 'id' => "window_{$windowId}_select", + 'class' => 'hidden' + ], + false + ); - if (!empty($answerCorrect) && !empty($selectedValue)) { - // Show connect if is not freeze (question preview) - if (!$freeze) { - $s .= << $(document).on('ready', function () { jsPlumb.ready(function() { @@ -1010,31 +1002,31 @@ HTML; }); JAVASCRIPT; + } } - } - $s .= << HTML; - if (isset($select_items[$lines_count])) { - $s .= << {$select_items[$lines_count]['letter']}. {$select_items[$lines_count]['answer']} HTML; - } else { - $s .= ' '; - } + } else { + $s .= ' '; + } - $s .= '
      @@ -1043,27 +1035,28 @@ HTML;
      '; - } elseif( - in_array( - $answerType, - [ - MATCHING, - MATCHING_DRAGGABLE, - UNIQUE_ANSWER_NO_OPTION, - MULTIPLE_ANSWER_TRUE_FALSE, - MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE - ] - ) + } elseif ( + in_array( + $answerType, + [ + MATCHING, + MATCHING_DRAGGABLE, + UNIQUE_ANSWER_NO_OPTION, + MULTIPLE_ANSWER_TRUE_FALSE, + MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE + ] + ) ) { $s .= ''; } @@ -1114,11 +1107,11 @@ HTML; // destruction of the Question object unset($objQuestionTmp); - if ($origin != 'export') { - echo $s; - } else { + if ($origin == 'export') { return $s; } + + echo $s; } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) { global $exerciseId, $exe_id; // Question is a HOT_SPOT @@ -1152,7 +1145,7 @@ HTML; echo "