diff --git a/main/admin/career_dashboard.php b/main/admin/career_dashboard.php index 1421eff957..6a5c235a38 100755 --- a/main/admin/career_dashboard.php +++ b/main/admin/career_dashboard.php @@ -82,7 +82,7 @@ $actionleft .= Display::url( ICON_SIZE_MEDIUM), 'promotions.php'); -$actions = Display::toolbarAction('toolbar-career', array( 0 => $actionleft)); +$actions = Display::toolbarAction('toolbar-career', array(0 => $actionleft)); $html .= $form->return_form(); diff --git a/main/admin/user_list.php b/main/admin/user_list.php index 4114a28604..5768cc95c2 100755 --- a/main/admin/user_list.php +++ b/main/admin/user_list.php @@ -124,10 +124,10 @@ function clear_session_list(div_session) { function display_advanced_search_form () { if ($("#advanced_search_form").css("display") == "none") { $("#advanced_search_form").css("display","block"); - $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-down') . ' '. get_lang('AdvancedSearch').'\'); + $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-down').' '.get_lang('AdvancedSearch').'\'); } else { $("#advanced_search_form").css("display","none"); - $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-right') . ' '.get_lang('AdvancedSearch').'\'); + $("#img_plus_and_minus").html(\' '. Display::returnFontAwesomeIcon('arrow-right').' '.get_lang('AdvancedSearch').'\'); } } @@ -204,7 +204,7 @@ function prepare_user_sql_query($is_count) // adding the filter to see the user's only of the current access_url if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); - $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)"; + $sql .= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.id=url_rel_user.user_id)"; } $keywordList = array( @@ -243,7 +243,7 @@ function prepare_user_sql_query($is_count) */ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { - $keywordFiltered = Database::escape_string("%". $_GET['keyword'] ."%"); + $keywordFiltered = Database::escape_string("%".$_GET['keyword']."%"); $sql .= " WHERE ( u.firstname LIKE '$keywordFiltered' OR u.lastname LIKE '$keywordFiltered' OR @@ -277,13 +277,13 @@ function prepare_user_sql_query($is_count) */ $sql .= " $query_admin_table WHERE ( - u.firstname LIKE '". Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND + u.firstname LIKE '".Database::escape_string("%".$keywordListValues['keyword_firstname']."%")."' AND u.lastname LIKE '". Database::escape_string("%".$keywordListValues['keyword_lastname']."%")."' AND u.username LIKE '". Database::escape_string("%".$keywordListValues['keyword_username']."%")."' AND u.email LIKE '". Database::escape_string("%".$keywordListValues['keyword_email']."%")."' AND u.status LIKE '".Database::escape_string($keywordListValues['keyword_status'])."' "; if (!empty($keywordListValues['keyword_officialcode'])) { - $sql .= " AND u.official_code LIKE '" . Database::escape_string("%" . $keywordListValues['keyword_officialcode'] . "%") . "' "; + $sql .= " AND u.official_code LIKE '".Database::escape_string("%".$keywordListValues['keyword_officialcode']."%")."' "; } $sql .= " $keyword_admin @@ -470,7 +470,7 @@ function get_number_of_users() function get_user_data($from, $number_of_items, $column, $direction) { $sql = prepare_user_sql_query(false); - if (!in_array($direction, array('ASC','DESC'))) { + if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $column = intval($column); @@ -581,8 +581,8 @@ function modify_filter($user_id, $url_params, $row)
  
'; } else { - $result .= Display::return_icon('course_na.png',get_lang('Courses')).'  '; - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).'  '; + $result .= Display::return_icon('course_na.png', get_lang('Courses')).'  '; + $result .= Display::return_icon('course_na.png', get_lang('Sessions')).'  '; } if (api_is_platform_admin()) { @@ -617,7 +617,7 @@ function modify_filter($user_id, $url_params, $row) if (api_is_platform_admin(true)) { $editProfileUrl = Display::getProfileEditionLink($user_id, true); if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { - $result .= ''.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).' '; + $result .= ''.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).' '; } else { $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).' '; } @@ -628,7 +628,7 @@ function modify_filter($user_id, $url_params, $row) if ($allowAssignSkill) { $result .= Display::url( Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_SMALL), - api_get_path(WEB_CODE_PATH) . 'badge/assign.php?' . http_build_query(['user' => $user_id]) + api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $user_id]) ); } @@ -768,10 +768,10 @@ if (!empty($action)) { case 'add_user_to_my_url': $user_id = $_REQUEST["user_id"]; $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); - if ($result ) { + if ($result) { $user_info = api_get_user_info($user_id); $message = get_lang('UserAdded').' '.$user_info['firstname'].' '.$user_info['lastname'].' ('.$user_info['username'].')'; - $message = Display::return_message($message, 'confirmation'); + $message = Display::return_message($message, 'confirmation'); } break; case 'delete_user': @@ -830,7 +830,7 @@ $form->addButtonSearch(get_lang('Search')); $searchAdvanced = '   - '. Display::returnFontAwesomeIcon('arrow-right') . ' '.get_lang('AdvancedSearch').' + '. Display::returnFontAwesomeIcon('arrow-right').' '.get_lang('AdvancedSearch').' '; $actionsLeft = ''; @@ -838,7 +838,7 @@ $actionsCenter = ''; $actionsRight = ''; if (api_is_platform_admin()) { $actionsRight .= ''. - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).''; + Display::return_icon('new_user.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).''; } $actionsLeft .= $form->returnForm(); @@ -864,7 +864,7 @@ Session::write('admin_list', $_admins_list); // Display Advanced search form. $form = new FormValidator('advanced_search', 'get', '', '', array(), FormValidator::LAYOUT_HORIZONTAL); -$form->addElement('html',''); $form = $form->returnForm(); @@ -984,10 +984,10 @@ if ($table->get_total_number_of_items() == 0) { } if ($add_user) { $row_table = array(); - $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '; - $row_table[] = $access_info_to_string; + $row_table[] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') '; + $row_table[] = $access_info_to_string; $url = api_get_self().'?action=add_user_to_my_url&user_id='.$user['id'].'&sec_token='.$_SESSION['sec_token']; - $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn')); + $row_table[] = Display::url(get_lang('AddUserToMyURL'), $url, array('class' => 'btn')); foreach ($row_table as $cell) { $table->setCellContents($row, $column, $cell); diff --git a/main/document/create_audio.php b/main/document/create_audio.php index a1aaa398bd..bcbb44cf10 100755 --- a/main/document/create_audio.php +++ b/main/document/create_audio.php @@ -328,33 +328,33 @@ function downloadMP3_google($filepath, $dir) $clean_title = trim($_POST['title']); $clean_text = trim($_POST['text']); if (empty($clean_title) || empty($clean_text)) { - echo ''; + echo ''; return; } $clean_title = Security::remove_XSS($clean_title); $clean_title = Database::escape_string($clean_title); - $clean_title = str_replace(' ', '_', $clean_title);//compound file names + $clean_title = str_replace(' ', '_', $clean_title); //compound file names $clean_text = Security::remove_XSS($clean_text); $clean_lang = Security::remove_XSS($_POST['lang']); $extension = 'mp3'; - $audio_filename = $clean_title . '.' . $extension; + $audio_filename = $clean_title.'.'.$extension; $audio_title = str_replace('_', ' ', $clean_title); //prevent duplicates - if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) { + if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) { $i = 1; - while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) { + while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) { $i++; } - $audio_filename = $clean_title . '_' . $i . '.' . $extension; - $audio_title = $clean_title . '_' . $i . '.' . $extension; + $audio_filename = $clean_title.'_'.$i.'.'.$extension; + $audio_title = $clean_title.'_'.$i.'.'.$extension; $audio_title = str_replace('_', ' ', $audio_title); } - $documentPath = $filepath . '/' . $audio_filename; + $documentPath = $filepath.'/'.$audio_filename; $clean_text = api_replace_dangerous_char($clean_text); // adding the file diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index e721c42821..949ceb9d7a 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -31,7 +31,7 @@ class Exercise public $feedback_type; public $end_time; public $start_time; - public $questionList; // array with the list of this exercise's questions + public $questionList; // array with the list of this exercise's questions /* including question list of the media */ public $questionListUncompressed; public $results_disabled; @@ -131,7 +131,7 @@ class Exercise $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $table_lp_item = Database::get_course_table(TABLE_LP_ITEM); - $id = (int)$id; + $id = (int) $id; if (empty($this->course_id)) { return false; } @@ -168,7 +168,7 @@ class 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; - $this->hideQuestionTitle = isset($object->hide_question_title) ? (int)$object->hide_question_title : 0; + $this->hideQuestionTitle = isset($object->hide_question_title) ? (int) $object->hide_question_title : 0; $sql = "SELECT lp_id, max_score FROM $table_lp_item @@ -526,7 +526,7 @@ class Exercise */ public function setHideQuestionTitle($value) { - $this->hideQuestionTitle = (int)$value; + $this->hideQuestionTitle = (int) $value; } /** @@ -542,7 +542,7 @@ class Exercise */ public function setScoreTypeModel($value) { - $this->scoreTypeModel = (int)$value; + $this->scoreTypeModel = (int) $value; } /** @@ -561,7 +561,7 @@ class Exercise if (is_array($value) && isset($value[0])) { $value = $value[0]; } - $this->globalCategoryId = (int)$value; + $this->globalCategoryId = (int) $value; } /** @@ -631,7 +631,7 @@ class Exercise $question_media = null; if (!empty($objQuestionTmp->parent_id)) { $objQuestionMedia = Question::read($objQuestionTmp->parent_id); - $question_media = Question::getMediaLabel($objQuestionMedia->question); + $question_media = Question::getMediaLabel($objQuestionMedia->question); } $questionType = Display::tag( @@ -1026,7 +1026,7 @@ class Exercise $cat = new TestCategory(); $cat = $cat->getCategory($categoryId); - $cat = (array)$cat; + $cat = (array) $cat; $cat['iid'] = $cat['id']; $categoryParentInfo = null; // Parent is not set no loop here @@ -1211,7 +1211,7 @@ class Exercise */ public function updateTitle($title) { - $this->exercise=$title; + $this->exercise = $title; } /** @@ -1221,7 +1221,7 @@ class Exercise */ public function updateAttempts($attempts) { - $this->attempts=$attempts; + $this->attempts = $attempts; } /** @@ -1231,7 +1231,7 @@ class Exercise */ public function updateFeedbackType($feedback_type) { - $this->feedback_type=$feedback_type; + $this->feedback_type = $feedback_type; } /** @@ -1242,7 +1242,7 @@ class Exercise */ public function updateDescription($description) { - $this->description=$description; + $this->description = $description; } /** @@ -1317,7 +1317,7 @@ class Exercise */ public function updateEndButton($value) { - $this->endButton = (int)$value; + $this->endButton = (int) $value; } /** @@ -1378,25 +1378,25 @@ class Exercise * @param string $sound - exercise sound file * @param string $delete - ask to delete the file */ - public function updateSound($sound,$delete) + public function updateSound($sound, $delete) { global $audioPath, $documentPath; $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); - if ($sound['size'] && (strstr($sound['type'],'audio') || strstr($sound['type'],'video'))) { + if ($sound['size'] && (strstr($sound['type'], 'audio') || strstr($sound['type'], 'video'))) { $this->sound = $sound['name']; - if (@move_uploaded_file($sound['tmp_name'],$audioPath.'/'.$this->sound)) { + if (@move_uploaded_file($sound['tmp_name'], $audioPath.'/'.$this->sound)) { $sql = "SELECT 1 FROM $TBL_DOCUMENT WHERE c_id = ".$this->course_id." AND - path = '".str_replace($documentPath,'',$audioPath).'/'.$this->sound."'"; + path = '".str_replace($documentPath, '', $audioPath).'/'.$this->sound."'"; $result = Database::query($sql); if (!Database::num_rows($result)) { $id = add_document( $this->course, - str_replace($documentPath,'',$audioPath).'/'.$this->sound, + str_replace($documentPath, '', $audioPath).'/'.$this->sound, 'file', $sound['size'], $sound['name'] @@ -1464,7 +1464,7 @@ class Exercise */ public function enable() { - $this->active=1; + $this->active = 1; } /** @@ -1474,7 +1474,7 @@ class Exercise */ public function disable() { - $this->active=0; + $this->active = 0; } /** @@ -1602,7 +1602,7 @@ class Exercise api_get_user_id() ); - if (api_get_setting('search_enabled')=='true') { + if (api_get_setting('search_enabled') == 'true') { $this->search_engine_edit(); } } else { @@ -1798,7 +1798,7 @@ class Exercise api_get_user_id() ); - if (api_get_setting('search_enabled')=='true' && + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { $this->search_engine_delete(); @@ -1957,8 +1957,8 @@ class Exercise // Type of questions disposition on page $radios = array(); - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1', array('onclick' => 'check_per_page_all()', 'id'=>'option_page_all')); + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2', array('onclick' => 'check_per_page_one()', 'id'=>'option_page_one')); $form->addGroup($radios, null, get_lang('QuestionsPerPage')); @@ -1967,31 +1967,31 @@ class Exercise if ($this->selectNbrQuestions() == 0) { // feedback type $radios_feedback = array(); - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'),'0',array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('ExerciseAtTheEndOfTheTest'), '0', array('id' =>'exerciseType_0', 'onclick' => 'check_feedback()')); if (api_get_setting('enable_quiz_scenario') == 'true') { - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1' , 'onclick' => 'check_direct_feedback()')); + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('DirectFeedback'), '1', array('id' =>'exerciseType_1', 'onclick' => 'check_direct_feedback()')); } - $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'),'2',array('id' =>'exerciseType_2')); - $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'),get_lang('FeedbackDisplayOptions'))); + $radios_feedback[] = $form->createElement('radio', 'exerciseFeedbackType', null, get_lang('NoFeedback'), '2', array('id' =>'exerciseType_2')); + $form->addGroup($radios_feedback, null, array(get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions'))); //$form->addElement('select', 'exerciseFeedbackType',get_lang('FeedbackType'),$feedback_option,'onchange="javascript:feedbackselection()"'); $radios_results_disabled = array(); $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); - $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'),''); + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); + $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents'), ''); // Type of questions disposition on page $radios = array(); - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); - $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2'); + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SimpleExercise'), '1'); + $radios[] = $form->createElement('radio', 'exerciseType', null, get_lang('SequentialExercise'), '2'); $form->addGroup($radios, null, get_lang('ExerciseType')); } else { //Show options freeze $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('ShowScoreAndRightAnswer'), '0', array('id'=>'result_disabled_0')); - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1',array('id'=>'result_disabled_1','onclick' => 'check_results_disabled()')); - $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2',array('id'=>'result_disabled_2','onclick' => 'check_results_disabled()')); + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('DoNotShowScoreNorRightAnswer'), '1', array('id'=>'result_disabled_1', 'onclick' => 'check_results_disabled()')); + $radios_results_disabled[] = $form->createElement('radio', 'results_disabled', null, get_lang('OnlyShowScore'), '2', array('id'=>'result_disabled_2', 'onclick' => 'check_results_disabled()')); $result_disable_group = $form->addGroup($radios_results_disabled, null, get_lang('ShowResultsToStudents')); $result_disable_group->freeze(); @@ -2113,7 +2113,7 @@ class Exercise $cat = new TestCategory(); $cat_form = $cat->returnCategoryForm($this); if (empty($cat_form)) { - $cat_form = '' . get_lang('NoCategoriesDefined') . ''; + $cat_form = ''.get_lang('NoCategoriesDefined').''; } $form->addElement('label', null, $cat_form); $form->addElement('html', ''); @@ -2152,7 +2152,7 @@ class Exercise ); // Exercise time limit - $form->addElement('checkbox', 'activate_start_date_check',null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); + $form->addElement('checkbox', 'activate_start_date_check', null, get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); $var = self::selectTimeLimit(); @@ -2163,8 +2163,8 @@ class Exercise } $form->addElement('date_time_picker', 'start_time'); - $form->addElement('html',''); - $form->addElement('checkbox', 'activate_end_date_check', null , get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); + $form->addElement('html', ''); + $form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); if (!empty($this->end_time)) { $form->addElement('html', '
'); @@ -2173,7 +2173,7 @@ class Exercise } $form->addElement('date_time_picker', 'end_time'); - $form->addElement('html','
'); + $form->addElement('html', ''); $display = 'block'; $form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults')); @@ -2182,10 +2182,10 @@ class Exercise null, get_lang('SaveTheCorrectAnswersForTheNextAttempt') ); - $form->addElement('html','
 
'); + $form->addElement('html', '
 
'); $form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers')); - $form->addElement('html','
'); + $form->addElement('html', '
'); // Timer control //$time_hours_option = range(0,12); @@ -2202,12 +2202,12 @@ class Exercise ) ); - $expired_date = (int)$this->selectExpiredTime(); + $expired_date = (int) $this->selectExpiredTime(); if (($expired_date != '0')) { - $form->addElement('html','
'); + $form->addElement('html', '
'); } else { - $form->addElement('html',''); $form->addElement( 'text', 'pass_percentage', @@ -2243,22 +2243,22 @@ class Exercise $defaults = array(); if (api_get_setting('search_enabled') === 'true') { - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); $form->addSelectLanguage('language', get_lang('SearchFeatureDocumentLanguage')); $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { - $form->addElement ('text', $specific_field['code'], $specific_field['name']); + $form->addElement('text', $specific_field['code'], $specific_field['name']); $filter = array( 'c_id' => api_get_course_int_id(), 'field_id' => $specific_field['id'], 'ref_id' => $this->id, - 'tool_id' => "'" . TOOL_QUIZ . "'" + 'tool_id' => "'".TOOL_QUIZ."'" ); $values = get_specific_field_values_list($filter, array('value')); - if ( !empty($values) ) { + if (!empty($values)) { $arr_str_values = array(); foreach ($values as $value) { $arr_str_values[] = $value['value']; @@ -2268,8 +2268,8 @@ class Exercise } } - $form->addElement('html','
'); //End advanced setting - $form->addElement('html','
'); + $form->addElement('html', '
'); //End advanced setting + $form->addElement('html', '
'); } // submit @@ -2289,10 +2289,10 @@ class Exercise } // defaults - if ($type=='full') { + if ($type == 'full') { if ($this->id > 0) { if ($this->random > $this->selectNbrQuestions()) { - $defaults['randomQuestions'] = $this->selectNbrQuestions(); + $defaults['randomQuestions'] = $this->selectNbrQuestions(); } else { $defaults['randomQuestions'] = $this->random; } @@ -2322,7 +2322,7 @@ class Exercise } $defaults['start_time'] = !empty($this->start_time) ? api_get_local_time($this->start_time) : date('Y-m-d 12:00:00'); - $defaults['end_time'] = !empty($this->end_time) ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time()+84600); + $defaults['end_time'] = !empty($this->end_time) ? api_get_local_time($this->end_time) : date('Y-m-d 12:00:00', time() + 84600); // Get expired time if ($this->expired_time != '0') { @@ -2343,7 +2343,7 @@ class Exercise $defaults['text_when_finished'] = ''; $defaults['start_time'] = date('Y-m-d 12:00:00'); $defaults['display_category_name'] = 1; - $defaults['end_time'] = date('Y-m-d 12:00:00', time()+84600); + $defaults['end_time'] = date('Y-m-d 12:00:00', time() + 84600); $defaults['pass_percentage'] = ''; $defaults['end_button'] = $this->selectEndButton(); $defaults['question_selection_type'] = 1; @@ -2478,9 +2478,9 @@ class Exercise } $course_id = api_get_course_id(); - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; $specific_fields = get_specific_field_list(); $ic_slide = new IndexableChunk(); @@ -2490,7 +2490,7 @@ class Exercise if (isset($_REQUEST[$specific_field['code']])) { $sterms = trim($_REQUEST[$specific_field['code']]); if (!empty($sterms)) { - $all_specific_terms .= ' '. $sterms; + $all_specific_terms .= ' '.$sterms; $sterms = explode(',', $sterms); foreach ($sterms as $sterm) { $ic_slide->addTerm(trim($sterm), $specific_field['code']); @@ -2507,15 +2507,15 @@ class Exercise $xapian_data = array( SE_COURSE_ID => $course_id, SE_TOOL_ID => TOOL_QUIZ, - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), - SE_USER => (int)api_get_user_id(), + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), + SE_USER => (int) api_get_user_id(), ); $ic_slide->xapian_data = serialize($xapian_data); - $exercise_description = $all_specific_terms .' '. $this->description; + $exercise_description = $all_specific_terms.' '.$this->description; $ic_slide->addValue("content", $exercise_description); $di = new ChamiloIndexer(); - isset($_POST['language'])? $lang=Database::escape_string($_POST['language']): $lang = 'english'; + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; $di->connectDb(NULL, NULL, $lang); $di->addChunk($ic_slide); @@ -2534,7 +2534,7 @@ class Exercise function search_engine_edit() { // update search enchine and its values table if enabled - if (api_get_setting('search_enabled')=='true' && extension_loaded('xapian')) { + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { $course_id = api_get_course_id(); // actually, it consists on delete terms from db, @@ -2546,9 +2546,9 @@ class Exercise $res = Database::query($sql); if (Database::num_rows($res) > 0) { - require_once(api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'); - require_once(api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'); - require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'); + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); + require_once(api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'); + require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'); $se_ref = Database::fetch_array($res); $specific_fields = get_specific_field_list(); @@ -2559,7 +2559,7 @@ class Exercise delete_all_specific_field_value($course_id, $specific_field['id'], TOOL_QUIZ, $this->id); if (isset($_REQUEST[$specific_field['code']])) { $sterms = trim($_REQUEST[$specific_field['code']]); - $all_specific_terms .= ' '. $sterms; + $all_specific_terms .= ' '.$sterms; $sterms = explode(',', $sterms); foreach ($sterms as $sterm) { $ic_slide->addTerm(trim($sterm), $specific_field['code']); @@ -2575,17 +2575,17 @@ class Exercise $xapian_data = array( SE_COURSE_ID => $course_id, SE_TOOL_ID => TOOL_QUIZ, - SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int)$this->id), - SE_USER => (int)api_get_user_id(), + SE_DATA => array('type' => SE_DOCTYPE_EXERCISE_EXERCISE, 'exercise_id' => (int) $this->id), + SE_USER => (int) api_get_user_id(), ); $ic_slide->xapian_data = serialize($xapian_data); - $exercise_description = $all_specific_terms .' '. $this->description; + $exercise_description = $all_specific_terms.' '.$this->description; $ic_slide->addValue("content", $exercise_description); $di = new ChamiloIndexer(); - isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']): $lang = 'english'; + isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; $di->connectDb(null, null, $lang); - $di->remove_document((int)$se_ref['search_did']); + $di->remove_document((int) $se_ref['search_did']); $di->addChunk($ic_slide); //index and return search engine document id @@ -2609,7 +2609,7 @@ class Exercise function search_engine_delete() { // remove from search engine if enabled - if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian') ) { + if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) { $course_id = api_get_course_id(); $tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF); $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level IS NULL LIMIT 1'; @@ -2617,19 +2617,19 @@ class Exercise $res = Database::query($sql); if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); - require_once(api_get_path(LIBRARY_PATH) .'search/ChamiloIndexer.class.php'); + require_once(api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'); $di = new ChamiloIndexer(); - $di->remove_document((int)$row['search_did']); + $di->remove_document((int) $row['search_did']); unset($di); $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); - foreach ( $this->questionList as $question_i) { + foreach ($this->questionList as $question_i) { $sql = 'SELECT type FROM %s WHERE id=%s'; $sql = sprintf($sql, $tbl_quiz_question, $question_i); $qres = Database::query($sql); if (Database::num_rows($qres) > 0) { $qrow = Database::fetch_array($qres); $objQuestion = Question::getInstance($qrow['type']); - $objQuestion = Question::read((int)$question_i); + $objQuestion = Question::read((int) $question_i); $objQuestion->search_engine_edit($this->id, FALSE, TRUE); unset($objQuestion); } @@ -2640,7 +2640,7 @@ class Exercise Database::query($sql); // remove terms from db - require_once api_get_path(LIBRARY_PATH) .'specific_fields_manager.lib.php'; + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; delete_all_values_for_item($course_id, TOOL_QUIZ, $this->id); } } @@ -2811,20 +2811,20 @@ class Exercise if (empty($lp_item_view_id)) { $lp_item_view_id = 0; } - $condition = ' WHERE exe_exo_id = ' . "'" . $this->id . "'" .' AND - exe_user_id = ' . "'" . api_get_user_id() . "'" . ' AND - c_id = ' . api_get_course_int_id() . ' AND - status = ' . "'" . Database::escape_string($status). "'" . ' AND - orig_lp_id = ' . "'" . $lp_id . "'" . ' AND - orig_lp_item_id = ' . "'" . $lp_item_id . "'" . ' AND - orig_lp_item_view_id = ' . "'" . $lp_item_view_id . "'" . ' AND - session_id = ' . "'" . api_get_session_id() . "' LIMIT 1"; //Adding limit 1 just in case + $condition = ' WHERE exe_exo_id = '."'".$this->id."'".' AND + exe_user_id = ' . "'".api_get_user_id()."'".' AND + c_id = ' . api_get_course_int_id().' AND + status = ' . "'".Database::escape_string($status)."'".' AND + orig_lp_id = ' . "'".$lp_id."'".' AND + orig_lp_item_id = ' . "'".$lp_item_id."'".' AND + orig_lp_item_view_id = ' . "'".$lp_item_view_id."'".' AND + session_id = ' . "'".api_get_session_id()."' LIMIT 1"; //Adding limit 1 just in case $sql_track = 'SELECT * FROM '.$track_exercises.$condition; $result = Database::query($sql_track); $new_array = array(); - if (Database::num_rows($result) > 0 ) { + if (Database::num_rows($result) > 0) { $new_array = Database::fetch_array($result, 'ASSOC'); $new_array['num_exe'] = Database::num_rows($result); } @@ -2870,12 +2870,12 @@ class Exercise $questionList = array_map('intval', $questionList); $params = array( - 'exe_exo_id' => $this->id , + 'exe_exo_id' => $this->id, 'exe_user_id' => api_get_user_id(), 'c_id' => api_get_course_int_id(), 'status' => 'incomplete', 'session_id' => api_get_session_id(), - 'data_tracking' => implode(',', $questionList) , + 'data_tracking' => implode(',', $questionList), 'start_date' => api_get_utc_datetime(), 'orig_lp_id' => $safe_lp_id, 'orig_lp_item_id' => $safe_lp_item_id, @@ -2908,7 +2908,7 @@ class Exercise $nbrQuestions = $this->get_count_question_list(); $all_button = []; $html = $label = ''; - $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']):null; + $hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null; if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { $urlTitle = get_lang('ContinueTest'); @@ -2919,7 +2919,7 @@ class Exercise $html .= Display::url( $urlTitle, - 'exercise_submit_modal.php?' . http_build_query([ + 'exercise_submit_modal.php?'.http_build_query([ 'learnpath_id' => $safe_lp_id, 'learnpath_item_id' => $safe_lp_item_id, 'learnpath_item_view_id' => $safe_lp_item_view_id, @@ -2936,7 +2936,7 @@ class Exercise 'data-size' => 'md' ] ); - $html .='
'; + $html .= '
'; } else { // User if (api_is_allowed_to_session_edit()) { @@ -3003,7 +3003,7 @@ class Exercise $all_label, ['type' => 'button', 'class' => $class] ); - $all_button[] = ' ' . Display::span(null, ['id' => 'save_all_reponse']); + $all_button[] = ' '.Display::span(null, ['id' => 'save_all_reponse']); $html .= implode(PHP_EOL, $all_button); } } @@ -3285,10 +3285,10 @@ class Exercise $answer = $objAnswerTmp->selectAnswer($answerId); $answerComment = $objAnswerTmp->selectComment($answerId); $answerCorrect = $objAnswerTmp->isCorrect($answerId); - $answerWeighting = (float)$objAnswerTmp->selectWeighting($answerId); + $answerWeighting = (float) $objAnswerTmp->selectWeighting($answerId); $answerAutoId = $objAnswerTmp->selectAutoId($answerId); $answerIid = isset($objAnswerTmp->iid[$answerId]) ? $objAnswerTmp->iid[$answerId] : ''; - $answer_correct_array[$answerId] = (bool)$answerCorrect; + $answer_correct_array[$answerId] = (bool) $answerCorrect; if ($debug) { error_log("answer auto id: $answerAutoId "); @@ -3297,7 +3297,7 @@ class Exercise // Delineation $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); + $answer_delineation_destination = $objAnswerTmp->selectDestination(1); switch ($answerType) { // for unique answer @@ -3311,7 +3311,7 @@ class Exercise exe_id = '".$exeId."' AND question_id= '".$questionId."'"; $result = Database::query($sql); - $choice = Database::result($result,0,"answer"); + $choice = Database::result($result, 0, "answer"); $studentChoice = $choice == $answerAutoId ? 1 : 0; if ($studentChoice) { @@ -3362,7 +3362,7 @@ class Exercise } else { // If no result then the user just hit don't know $studentChoice = 3; - $questionScore += $doubt_score; + $questionScore += $doubt_score; } $totalScore = $questionScore; break; @@ -3378,17 +3378,17 @@ class Exercise } $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; - $real_answers[$answerId] = (bool)$studentChoice; + $real_answers[$answerId] = (bool) $studentChoice; if ($studentChoice) { - $questionScore +=$answerWeighting; + $questionScore += $answerWeighting; } } else { $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; - $real_answers[$answerId] = (bool)$studentChoice; + $real_answers[$answerId] = (bool) $studentChoice; if (isset($studentChoice)) { - $questionScore += $answerWeighting; + $questionScore += $answerWeighting; } } $totalScore += $answerWeighting; @@ -3406,16 +3406,16 @@ class Exercise $choice[$ind] = 1; } $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; - $real_answers[$answerId] = (bool)$studentChoice; + $real_answers[$answerId] = (bool) $studentChoice; if ($studentChoice) { - $questionScore +=$answerWeighting; + $questionScore += $answerWeighting; } } else { $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; if (isset($studentChoice)) { $questionScore += $answerWeighting; } - $real_answers[$answerId] = (bool)$studentChoice; + $real_answers[$answerId] = (bool) $studentChoice; } $totalScore += $answerWeighting; if ($debug) error_log("studentChoice: $studentChoice"); @@ -3427,7 +3427,7 @@ class Exercise $resultans = Database::query($sql); while ($row = Database::fetch_array($resultans)) { $ind = $row['answer']; - $result = explode(':',$ind); + $result = explode(':', $ind); if (isset($result[0])) { $my_answer_id = isset($result[0]) ? $result[0] : ''; $option = isset($result[1]) ? $result[1] : ''; @@ -3549,10 +3549,10 @@ class Exercise } // adds the piece of text that is before the blank //and ends with '[' into a general storage array - $real_text[] = api_substr($temp, 0, $pos +1); - $answer .= api_substr($temp, 0, $pos +1); + $real_text[] = api_substr($temp, 0, $pos + 1); + $answer .= api_substr($temp, 0, $pos + 1); //take the string remaining (after the last "[" we found) - $temp = api_substr($temp, $pos +1); + $temp = api_substr($temp, $pos + 1); // quit the loop if there are no more blanks, and update $pos to the position of next ']' if (($pos = api_strpos($temp, ']')) === false) { // adds the end of the text @@ -3583,7 +3583,7 @@ class Exercise //put the contents of the [] answer tag into correct_tags[] $correct_tags[] = api_substr($temp, 0, $pos); $j++; - $temp = api_substr($temp, $pos +1); + $temp = api_substr($temp, $pos + 1); } $answer = ''; $real_correct_tags = $correct_tags; @@ -3606,7 +3606,7 @@ class Exercise } elseif (!empty($user_tags[$i])) { // else if the word entered by the student IS NOT the same as the one defined by the professor // adds the word in red at the end of the string, and strikes it - $answer .= '' . $user_tags[$i] . ''; + $answer .= ''.$user_tags[$i].''; } else { // adds a tabulation if no word has been typed by the student $answer .= ''; // remove   that causes issue @@ -3625,17 +3625,17 @@ class Exercise } elseif (!empty ($user_tags[$i])) { // else if the word entered by the student IS NOT the same as the one defined by the professor // adds the word in red at the end of the string, and strikes it - $answer .= '' . $user_tags[$i] . ''; + $answer .= ''.$user_tags[$i].''; } else { // adds a tabulation if no word has been typed by the student - $answer .= ''; // remove   that causes issue + $answer .= ''; // remove   that causes issue } } // adds the correct word, followed by ] to close the blank - $answer .= ' / ' . $real_correct_tags[$i] . ']'; - if (isset($real_text[$i +1])) { - $answer .= $real_text[$i +1]; + $answer .= ' / '.$real_correct_tags[$i].']'; + if (isset($real_text[$i + 1])) { + $answer .= $real_text[$i + 1]; } } } else { @@ -3751,10 +3751,10 @@ class Exercise } // adds the piece of text that is before the blank //and ends with '[' into a general storage array - $realText[] = api_substr($temp, 0, $pos +1); - $answer .= api_substr($temp, 0, $pos +1); + $realText[] = api_substr($temp, 0, $pos + 1); + $answer .= api_substr($temp, 0, $pos + 1); //take the string remaining (after the last "[" we found) - $temp = api_substr($temp, $pos +1); + $temp = api_substr($temp, $pos + 1); // quit the loop if there are no more blanks, and update $pos to the position of next ']' if (($pos = api_strpos($temp, ']')) === false) { // adds the end of the text @@ -3795,7 +3795,7 @@ class Exercise //put the contents of the [] answer tag into correct_tags[] $correctTags[] = api_substr($temp, 0, $pos); $j++; - $temp = api_substr($temp, $pos +1); + $temp = api_substr($temp, $pos + 1); } $answer = ''; $realCorrectTags = $correctTags; @@ -3815,7 +3815,7 @@ class Exercise } elseif (!empty($userTags[$i])) { // else if the word entered by the student IS NOT the same as the one defined by the professor // adds the word in red at the end of the string, and strikes it - $answer .= '' . $userTags[$i] . ''; + $answer .= ''.$userTags[$i].''; } else { // adds a tabulation if no word has been typed by the student $answer .= ''; // remove   that causes issue @@ -3825,19 +3825,19 @@ class Exercise if ( $this->results_disabled != EXERCISE_FEEDBACK_TYPE_EXAM ) { - $answer .= ' / ' . $realCorrectTags[$i] . ''; + $answer .= ' / '.$realCorrectTags[$i].''; } $answer .= ']'; - if (isset($realText[$i +1])) { - $answer .= $realText[$i +1]; + if (isset($realText[$i + 1])) { + $answer .= $realText[$i + 1]; } } break; case FREE_ANSWER: if ($from_database) { - $sql = "SELECT answer, marks FROM $TBL_TRACK_ATTEMPT + $sql = "SELECT answer, marks FROM $TBL_TRACK_ATTEMPT WHERE exe_id = $exeId AND question_id= ".$questionId; @@ -3850,9 +3850,9 @@ class Exercise $questionScore = $data['marks']; if ($questionScore == -1) { - $totalScore+= 0; + $totalScore += 0; } else { - $totalScore+= $questionScore; + $totalScore += $questionScore; } if ($questionScore == '') { $questionScore = 0; @@ -3931,7 +3931,7 @@ class Exercise while ($a_answers = Database::fetch_array($res_answers)) { $i_answer_id = $a_answers['id']; //3 - $s_answer_label = $a_answers['answer']; // your daddy - your mother + $s_answer_label = $a_answers['answer']; // your daddy - your mother $i_answer_correct_answer = $a_answers['correct']; //1 - 2 $i_answer_id_auto = $a_answers['id_auto']; // 3 - 4 @@ -4001,8 +4001,8 @@ class Exercise $user_answer = ''; } echo ''; - echo '' . $s_answer_label . ''; - echo '' . $user_answer; + echo ''.$s_answer_label.''; + echo ''.$user_answer; if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { if (isset($real_list[$i_answer_correct_answer]) && @@ -4167,7 +4167,7 @@ class Exercise if ($from_database) { // getting the user answer $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); - $query = "SELECT hotspot_correct, hotspot_coordinate + $query = "SELECT hotspot_correct, hotspot_coordinate FROM $TBL_TRACK_HOTSPOT WHERE hotspot_exe_id = '".$exeId."' AND @@ -4175,20 +4175,20 @@ class Exercise hotspot_answer_id='1'"; //by default we take 1 because it's a delineation $resq = Database::query($query); - $row = Database::fetch_array($resq,'ASSOC'); + $row = Database::fetch_array($resq, 'ASSOC'); $choice = $row['hotspot_correct']; $user_answer = $row['hotspot_coordinate']; // THIS is very important otherwise the poly_compile will throw an error!! // round-up the coordinates - $coords = explode('/',$user_answer); + $coords = explode('/', $user_answer); $user_array = ''; foreach ($coords as $coord) { - list($x,$y) = explode(';',$coord); + list($x, $y) = explode(';', $coord); $user_array .= round($x).';'.round($y).'/'; } - $user_array = substr($user_array,0,-1); + $user_array = substr($user_array, 0, -1); } else { if (!empty($studentChoice)) { $newquestionList[] = $questionId; @@ -4208,7 +4208,7 @@ class Exercise break; case ANNOTATION: if ($from_database) { - $sql = "SELECT answer, marks FROM $TBL_TRACK_ATTEMPT + $sql = "SELECT answer, marks FROM $TBL_TRACK_ATTEMPT WHERE exe_id = $exeId AND question_id= ".$questionId; @@ -4280,7 +4280,7 @@ class Exercise $results_disabled, $showTotalScoreAndUserChoicesInLastAttempt ); - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) { + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { ExerciseShowFunctions::display_multiple_answer_combination_true_false( $feedback_type, $answerType, @@ -4366,13 +4366,13 @@ class Exercise $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId]; //round-up the coordinates - $coords = explode('/',$user_answer); + $coords = explode('/', $user_answer); $user_array = ''; foreach ($coords as $coord) { - list($x,$y) = explode(';',$coord); + list($x, $y) = explode(';', $coord); $user_array .= round($x).';'.round($y).'/'; } - $user_array = substr($user_array,0,-1); + $user_array = substr($user_array, 0, -1); if ($next) { $user_answer = $user_array; @@ -4397,7 +4397,7 @@ class Exercise //$overlap = round(polygons_overlap($poly_answer,$poly_user)); // //this is an area in pixels if ($debug > 0) { - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); } if ($overlap < 1) { @@ -4410,19 +4410,19 @@ class Exercise // that is overlapped by the user's polygon $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); if ($debug > 1) { - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); } // the final missing area is the percentage of the initial polygon // that is not overlapped by the user's polygon $final_missing = 100 - $final_overlap; if ($debug > 1) { - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); + error_log(__LINE__.' - Final missing is '.$final_missing, 0); } // the final excess area is the percentage of the initial polygon's size // that is covered by the user's polygon outside of the initial polygon $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); if ($debug > 1) { - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); + error_log(__LINE__.' - Final excess is '.$final_excess, 0); } } @@ -4438,7 +4438,7 @@ class Exercise ); $threadhold1 = $threadhold_items[0]; // overlap $threadhold2 = $threadhold_items[1]; // excess - $threadhold3 = $threadhold_items[2]; //missing + $threadhold3 = $threadhold_items[2]; //missing // if is delineation if ($answerId === 1) { @@ -4461,28 +4461,28 @@ class Exercise $final_missing <= $threadhold3 && $final_excess <= $threadhold2 ) { - $next=1; //go to the oars - $result_comment=get_lang('Acceptable'); - $final_answer = 1; // do not update with update_exercise_attempt + $next = 1; //go to the oars + $result_comment = get_lang('Acceptable'); + $final_answer = 1; // do not update with update_exercise_attempt } else { - $next=0; - $result_comment=get_lang('Unacceptable'); - $comment=$answerDestination=$objAnswerTmp->selectComment(1); - $answerDestination=$objAnswerTmp->selectDestination(1); + $next = 0; + $result_comment = get_lang('Unacceptable'); + $comment = $answerDestination = $objAnswerTmp->selectComment(1); + $answerDestination = $objAnswerTmp->selectDestination(1); //checking the destination parameters parsing the "@@" - $destination_items= explode('@@', $answerDestination); + $destination_items = explode('@@', $answerDestination); } - } elseif($answerId>1) { + } elseif ($answerId > 1) { if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { - if ($debug>0) { - error_log(__LINE__.' - answerId is of type noerror',0); + if ($debug > 0) { + error_log(__LINE__.' - answerId is of type noerror', 0); } //type no error shouldn't be treated $next = 1; continue; } - if ($debug>0) { - error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0); + if ($debug > 0) { + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); } //check the intersection between the oar and the user //echo 'user'; print_r($x_user_list); print_r($y_user_list); @@ -4490,26 +4490,26 @@ class Exercise //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list); $inter = $result['success']; $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId); - $poly_answer = convert_coordinates($delineation_cord,'|'); - $max_coord = poly_get_max($poly_user,$poly_answer); - $poly_answer_compiled = poly_compile($poly_answer,$max_coord); - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); + $poly_answer = convert_coordinates($delineation_cord, '|'); + $max_coord = poly_get_max($poly_user, $poly_answer); + $poly_answer_compiled = poly_compile($poly_answer, $max_coord); + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); if ($overlap == false) { //all good, no overlap $next = 1; continue; } else { - if ($debug>0) { - error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0); + if ($debug > 0) { + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); } $organs_at_risk_hit++; //show the feedback $next = 0; - $comment = $answerDestination=$objAnswerTmp->selectComment($answerId); - $answerDestination=$objAnswerTmp->selectDestination($answerId); + $comment = $answerDestination = $objAnswerTmp->selectComment($answerId); + $answerDestination = $objAnswerTmp->selectDestination($answerId); - $destination_items= explode('@@', $answerDestination); + $destination_items = explode('@@', $answerDestination); $try_hotspot = $destination_items[1]; $lp_hotspot = $destination_items[2]; $select_question_hotspot = $destination_items[3]; @@ -4517,8 +4517,8 @@ class Exercise } } } else { // the first delineation feedback - if ($debug>0) { - error_log(__LINE__.' first',0); + if ($debug > 0) { + error_log(__LINE__.' first', 0); } } } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) { @@ -4526,7 +4526,7 @@ class Exercise echo Display::tag('td', $answerMatching[$answerId]); echo Display::tag( 'td', - "$user_answer / " . Display::tag( + "$user_answer / ".Display::tag( 'strong', $answerMatching[$answerCorrect], ['style' => 'color: #008000; font-weight: bold;'] @@ -4693,7 +4693,7 @@ class Exercise $questionId, $objQuestionTmp->getFileUrl(), $results_disabled - ) . ' + ).' '; break; @@ -4751,7 +4751,7 @@ class Exercise $missing = $poly_results['s1Only']; $excess = $poly_results['s2Only']; if ($debug > 0) { - error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0); + error_log(__LINE__.' - Polygons results are '.print_r($poly_results, 1), 0); } if ($overlap < 1) { //shortcut to avoid complicated calculations @@ -4762,17 +4762,17 @@ class Exercise // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon $final_overlap = round(((float) $overlap / (float) $poly_answer_area) * 100); if ($debug > 1) { - error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0); + error_log(__LINE__.' - Final overlap is '.$final_overlap, 0); } // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon $final_missing = 100 - $final_overlap; if ($debug > 1) { - error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0); + error_log(__LINE__.' - Final missing is '.$final_missing, 0); } // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon $final_excess = round((((float) $poly_user_area - (float) $overlap) / (float) $poly_answer_area) * 100); if ($debug > 1) { - error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0); + error_log(__LINE__.' - Final excess is '.$final_excess, 0); } } @@ -4782,7 +4782,7 @@ class Exercise $threadhold_items = explode(';', $threadhold_total); $threadhold1 = $threadhold_items[0]; // overlap $threadhold2 = $threadhold_items[1]; // excess - $threadhold3 = $threadhold_items[2]; //missing + $threadhold3 = $threadhold_items[2]; //missing // if is delineation if ($answerId === 1) { //setting colors @@ -4817,14 +4817,14 @@ class Exercise } elseif ($answerId > 1) { if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { if ($debug > 0) { - error_log(__LINE__ . ' - answerId is of type noerror', 0); + error_log(__LINE__.' - answerId is of type noerror', 0); } //type no error shouldn't be treated $next = 1; continue; } if ($debug > 0) { - error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0); + error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR', 0); } //check the intersection between the oar and the user //echo 'user'; print_r($x_user_list); print_r($y_user_list); @@ -4838,7 +4838,7 @@ class Exercise $poly_answer = convert_coordinates($delineation_cord, '|'); $max_coord = poly_get_max($poly_user, $poly_answer); $poly_answer_compiled = poly_compile($poly_answer, $max_coord); - $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled,$max_coord); + $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord); if ($overlap == false) { //all good, no overlap @@ -4846,7 +4846,7 @@ class Exercise continue; } else { if ($debug > 0) { - error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0); + error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit', 0); } $organs_at_risk_hit++; //show the feedback @@ -4858,12 +4858,12 @@ class Exercise $try_hotspot = $destination_items[1]; $lp_hotspot = $destination_items[2]; $select_question_hotspot = $destination_items[3]; - $url_hotspot=$destination_items[4]; + $url_hotspot = $destination_items[4]; } } } else { // the first delineation feedback if ($debug > 0) { - error_log(__LINE__ . ' first', 0); + error_log(__LINE__.' first', 0); } } break; @@ -4885,7 +4885,7 @@ class Exercise echo Display::tag('td', $answerMatching[$answerId]); echo Display::tag( 'td', - "$user_answer / " . Display::tag( + "$user_answer / ".Display::tag( 'strong', $answerMatching[$answerCorrect], ['style' => 'color: #008000; font-weight: bold;'] @@ -4980,26 +4980,26 @@ class Exercise // we use the results from the session (from_db=0) // TODO Change this, because it is wrong to show the user // some results that haven't been stored in the database yet - if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION ) { + if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) { if ($debug) error_log('$from AND this is a hotspot kind of question '); $my_exe_id = 0; $from_database = 0; if ($answerType == HOT_SPOT_DELINEATION) { if (0) { if ($overlap_color) { - $overlap_color='green'; + $overlap_color = 'green'; } else { - $overlap_color='red'; + $overlap_color = 'red'; } if ($missing_color) { - $missing_color='green'; + $missing_color = 'green'; } else { - $missing_color='red'; + $missing_color = 'red'; } if ($excess_color) { - $excess_color='green'; + $excess_color = 'green'; } else { - $excess_color='red'; + $excess_color = 'red'; } if (!is_numeric($final_overlap)) { $final_overlap = 0; @@ -5011,33 +5011,33 @@ class Exercise $final_excess = 0; } - if ($final_overlap>100) { + if ($final_overlap > 100) { $final_overlap = 100; } - $table_resume=' + $table_resume = '
- - + + - - - + + + - - - + + + - - - + + +
' . get_lang('Requirements') . '' . get_lang('YourAnswer') . '' . get_lang('Requirements').'' . get_lang('YourAnswer').'
' . get_lang('Overlap') . '' . get_lang('Min') . ' ' . $threadhold1 . '
' - . (($final_overlap < 0) ? 0 : intval($final_overlap)) . '
' . 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('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)) . '
' . get_lang('Missing').'' . get_lang('Max').' '.$threadhold3.'
' + . (($final_missing < 0) ? 0 : intval($final_missing)).'
'; if ($next == 0) { @@ -5052,20 +5052,20 @@ class Exercise $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); } - echo '

' . get_lang('Feedback') . '

+ echo '

'.get_lang('Feedback').'

'; - $message = '

' . get_lang('YourDelineation') . '

'; + $message = '

'.get_lang('YourDelineation').'

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

' . get_lang('OARHit') . '

'; + $message .= '

'.get_lang('OARHit').'

'; } - $message .='

' . $comment . '

'; + $message .= '

'.$comment.'

'; echo $message; } else { echo $hotspot_delineation_result[0]; //prints message - $from_database = 1; // the hotspot_solution.swf needs this variable + $from_database = 1; // the hotspot_solution.swf needs this variable } //save the score attempts @@ -5087,12 +5087,12 @@ class Exercise $exerciseResultCoordinates[$quesId] ); } else { - if ($final_answer==0) { + if ($final_answer == 0) { $questionScore = 0; - $answer=0; + $answer = 0; Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); if (is_array($exerciseResultCoordinates[$quesId])) { - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { Event::saveExerciseAttemptHotspot( $exeId, $quesId, @@ -5105,7 +5105,7 @@ class Exercise } else { Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0); if (is_array($exerciseResultCoordinates[$quesId])) { - foreach($exerciseResultCoordinates[$quesId] as $idx => $val) { + foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { $hotspotValue = (int) $choice[$idx] === 1 ? 1 : 0; Event::saveExerciseAttemptHotspot( $exeId, @@ -5134,7 +5134,7 @@ class Exercise echo " -

" . get_lang('HotSpot') . "

+

" . get_lang('HotSpot')."

'; api_block_anonymous_users(); -$htmlHeadXtra[]= '