diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index ab6763722d..906c47e977 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -43,6 +43,7 @@ class SurveyManager break; } } + return $code.$num; } @@ -100,6 +101,7 @@ class SurveyManager WHERE c_id = {$course_info['real_id']} $session_condition "; $result = Database::query($sql); $result = Database::store_result($result, 'ASSOC'); + return $result; } @@ -128,7 +130,7 @@ class SurveyManager // Table definition if (!empty($course_code)) { $my_course_id = $course_code; - } else if (isset($_GET['course'])) { + } elseif (isset($_GET['course'])) { $my_course_id = Security::remove_XSS($_GET['course']); } else { $my_course_id = api_get_course_id(); @@ -371,17 +373,20 @@ class SurveyManager ); $return['type'] = 'error'; $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; + return $return; } - if (!isset($values['anonymous']) || - (isset($values['anonymous']) && $values['anonymous'] == '') + if (!isset($values['anonymous']) + || (isset($values['anonymous']) && $values['anonymous'] == '') ) { $values['anonymous'] = 0; } $values['shuffle'] = isset($values['shuffle']) ? $values['shuffle'] : null; - $values['one_question_per_page'] = isset($values['one_question_per_page']) ? $values['one_question_per_page'] : null; + $values['one_question_per_page'] = isset($values['one_question_per_page']) + ? $values['one_question_per_page'] + : null; $values['show_form_profile'] = isset($values['show_form_profile']) ? $values['show_form_profile'] : null; $extraParams = []; @@ -629,6 +634,7 @@ class SurveyManager 'SurveyDeleted', api_get_user_id() ); + return true; } @@ -696,7 +702,7 @@ class SurveyManager $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { $params = array( - 'c_id' => $targetCourseId, + 'c_id' => $targetCourseId, 'name' => $row['name'], 'description' => $row['description'], 'survey_id' => $new_survey_id @@ -716,17 +722,17 @@ class SurveyManager $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { $params = array( - 'c_id' => $targetCourseId, + 'c_id' => $targetCourseId, 'survey_id' => $new_survey_id, 'survey_question' => $row['survey_question'], 'survey_question_comment' => $row['survey_question_comment'], 'type' => $row['type'], 'display' => $row['display'], 'sort' => $row['sort'], - 'shared_question_id' => $row['shared_question_id'], - 'max_value' => $row['max_value'], - 'survey_group_pri' => $row['survey_group_pri'], - 'survey_group_sec1' => $row['survey_group_sec1'], + 'shared_question_id' => $row['shared_question_id'], + 'max_value' => $row['max_value'], + 'survey_group_pri' => $row['survey_group_pri'], + 'survey_group_sec1' => $row['survey_group_sec1'], 'survey_group_sec2' => $row['survey_group_sec2'] ); $insertId = Database::insert($table_survey_question, $params); @@ -743,7 +749,7 @@ class SurveyManager $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { $params = array( - 'c_id' => $targetCourseId, + 'c_id' => $targetCourseId, 'question_id' => $question_id[$row['question_id']], 'survey_id' => $new_survey_id, 'option_text' => $row['option_text'], @@ -1045,6 +1051,7 @@ class SurveyManager if ($survey_data['survey_type'] == 1) { if (empty($form_content['choose'])) { $return_message = 'PleaseChooseACondition'; + return $return_message; } @@ -1052,6 +1059,7 @@ class SurveyManager ($form_content['assigned1'] == $form_content['assigned2']) ) { $return_message = 'ChooseDifferentCategories'; + return $return_message; } } @@ -1109,7 +1117,9 @@ class SurveyManager } } - $questionComment = isset($form_content['question_comment']) ? $form_content['question_comment'] : ''; + $questionComment = isset($form_content['question_comment']) + ? $form_content['question_comment'] + : ''; $maxScore = isset($form_content['maximum_score']) ? $form_content['maximum_score'] : ''; $display = isset($form_content['horizontalvertical']) ? $form_content['horizontalvertical'] : ''; @@ -1155,7 +1165,9 @@ class SurveyManager } $maxScore = isset($form_content['maximum_score']) ? $form_content['maximum_score'] : null; - $questionComment = isset($form_content['question_comment']) ? $form_content['question_comment'] : null; + $questionComment = isset($form_content['question_comment']) + ? $form_content['question_comment'] + : null; // Adding the question to the survey_question table $params = [ @@ -1207,6 +1219,7 @@ class SurveyManager if (!empty($return_message)) { Display::addFlash(Display::return_message(get_lang($return_message))); } + return $return_message; } @@ -1581,6 +1594,7 @@ class SurveyManager $course_condition survey_id='".intval($survey_id)."' AND question_id='".intval($question_id)."'"; Database::query($sql); + return true; } @@ -1608,6 +1622,7 @@ class SurveyManager $sql = "DELETE FROM $table_survey_answer WHERE c_id = $course_id AND survey_id=$survey_id"; Database::query($sql); + return true; } @@ -1634,6 +1649,7 @@ class SurveyManager if (Database::num_rows($result)) { return true; } + return false; } @@ -1665,7 +1681,9 @@ class SurveyManager } if ($all_user_info) { - $order_clause = api_sort_by_first_name() ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; + $order_clause = api_sort_by_first_name() + ? ' ORDER BY user.firstname, user.lastname' + : ' ORDER BY user.lastname, user.firstname'; $sql = "SELECT DISTINCT answered_user.user as invited_user, user.firstname, @@ -1704,6 +1722,7 @@ class SurveyManager if (extension_loaded('mcrypt')) { return true; } + return false; } @@ -1717,6 +1736,7 @@ class SurveyManager public static function generate_survey_hash($survey_id, $course_id, $session_id, $group_id) { $hash = hash('sha512', api_get_security_key().'_'.$course_id.'_'.$session_id.'_'.$group_id.'_'.$survey_id); + return $hash; } @@ -1735,6 +1755,7 @@ class SurveyManager if ($survey_generated_hash == $hash) { return true; } + return false; } @@ -1758,7 +1779,9 @@ class SurveyManager $session_id, $group_id ); - return api_get_path(WEB_CODE_PATH).'survey/link.php?h='.$code.'&i='.$survey_id.'&c='.intval($course_id).'&s='.intval($session_id).'&g='.$group_id; + + return api_get_path(WEB_CODE_PATH).'survey/link.php?h='.$code.'&i='.$survey_id.'&c='.intval($course_id).'&s=' + .intval($session_id).'&g='.$group_id; } /** diff --git a/main/survey/surveyUtil.class.php b/main/survey/surveyUtil.class.php index 347c80e022..7be7b1ab93 100755 --- a/main/survey/surveyUtil.class.php +++ b/main/survey/surveyUtil.class.php @@ -1,5 +1,6 @@ - '. + '. get_lang('GoBack').''; echo Display::return_message($message, 'confirmation', false); } @@ -312,29 +315,37 @@ class SurveyUtil // Actions bar echo '
'; - echo ''. - Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM).''; + echo ''. + Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ReportingOverview'), '', ICON_SIZE_MEDIUM) + .''; if (isset($_GET['user'])) { if (api_is_allowed_to_edit()) { // The delete link - echo ''. + echo ''. Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_MEDIUM).''; } // Export the user report - echo ''. - Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).' '; - echo ''. - Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).' '; - echo '
'; + echo '' + .Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).' '; + echo '' + .Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).' '; + echo ''; echo ''; echo ''; echo '
'; - echo '
'; + echo ''; echo ''; echo ''; echo '
'; - echo '
'; + echo ''; } echo '
'; @@ -348,7 +359,9 @@ class SurveyUtil echo get_lang('SelectUserWhoFilledSurvey').'
'; echo ''; echo ''; echo ''; - echo '
'; + echo ''; echo ''; echo ''; echo '
'; - echo '
'; + echo ''; // The table echo '
'; @@ -842,9 +887,11 @@ class SurveyUtil if ((isset($_POST['submit_question_filter']) && $_POST['submit_question_filter']) || (isset($_POST['export_report']) && $_POST['export_report']) ) { - echo ''; + echo ''; } - echo ''; + echo ''; echo ''; $display_extra_user_fields = false; @@ -902,7 +949,8 @@ class SurveyUtil } echo '>'; - echo ''; // the user column + echo ''; // the user column } else { echo ''; // the user column } @@ -1170,10 +1219,20 @@ class SurveyUtil // We do not show comment and pagebreak question types if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { if ($row['number_of_options'] == 0 && $row['type'] == 'open') { - $return .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';'; + $return .= str_replace( + "\r\n", + ' ', + api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES) + ) + .';'; } else { for ($ii = 0; $ii < $row['number_of_options']; $ii++) { - $return .= str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES)).';'; + $return .= str_replace( + "\r\n", + ' ', + api_html_entity_decode(strip_tags($row['survey_question']), ENT_QUOTES) + ) + .';'; } } } @@ -1187,7 +1246,13 @@ class SurveyUtil // Show the fields names for user fields if (!empty($extra_user_fields)) { foreach ($extra_user_fields as & $field) { - $return .= '"'.str_replace("\r\n", ' ', api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES)).'";'; + $return .= '"' + .str_replace( + "\r\n", + ' ', + api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES) + ) + .'";'; } } @@ -1279,11 +1344,11 @@ class SurveyUtil /** * Add a line to the csv file * - * @param array Possible answers + * @param array Possible answers * @param array User's answers - * @param mixed User ID or user details as string - Used as a string in the result string - * @param boolean Whether to display user fields or not - * @return string One line of the csv file + * @param mixed User ID or user details as string - Used as a string in the result string + * @param boolean Whether to display user fields or not + * @return string One line of the csv file * @author Patrick Cool , Ghent University * @version February 2007 */ @@ -1366,7 +1431,7 @@ class SurveyUtil * Quite similar to display_complete_report(), returns an HTML string * that can be used in a csv file * @todo consider merging this function with display_complete_report - * @return string The contents of a csv file + * @return string The contents of a csv file * @author Patrick Cool , Ghent University * @version February 2007 */ @@ -1590,11 +1655,11 @@ class SurveyUtil /** * Add a line to the csv file * - * @param array Possible answers - * @param array User's answers - * @param mixed User ID or user details as string - Used as a string in the result string - * @param boolean Whether to display user fields or not - * @return string One line of the csv file + * @param array Possible answers + * @param array User's answers + * @param mixed User ID or user details as string - Used as a string in the result string + * @param boolean Whether to display user fields or not + * @return string One line of the csv file */ public static function export_complete_report_row_xls( $survey_data, @@ -1638,7 +1703,9 @@ class SurveyUtil foreach ($possible_options as $question_id => & $possible_option) { if (is_array($possible_option) && count($possible_option) > 0) { foreach ($possible_option as $option_id => & $value) { - $my_answers_of_user = isset($answers_of_user[$question_id]) ? $answers_of_user[$question_id] : []; + $my_answers_of_user = isset($answers_of_user[$question_id]) + ? $answers_of_user[$question_id] + : []; $key = array_keys($my_answers_of_user); if (isset($key[0]) && substr($key[0], 0, 4) == 'open') { $return[] = api_html_entity_decode( @@ -1670,7 +1737,7 @@ class SurveyUtil * In the intersection is the number of people who have * answered positive on both options. * - * @return string HTML code + * @return string HTML code * * @author Patrick Cool , Ghent University * @version February 2007 @@ -1694,8 +1761,15 @@ class SurveyUtil // Actions bar echo ''; // Displaying an information message that only the questions with predefined answers can be used in a comparative report @@ -1704,7 +1778,8 @@ class SurveyUtil $xAxis = isset($_GET['xaxis']) ? Security::remove_XSS($_GET['xaxis']) : ''; $yAxis = isset($_GET['yaxis']) ? Security::remove_XSS($_GET['yaxis']) : ''; - $url = api_get_self().'?'.api_get_cidreq().'&action='.Security::remove_XSS($_GET['action']).'&survey_id='.$surveyId.'&xaxis='.$xAxis.'&y='.$yAxis; + $url = api_get_self().'?'.api_get_cidreq().'&action='.Security::remove_XSS($_GET['action']) + .'&survey_id='.$surveyId.'&xaxis='.$xAxis.'&y='.$yAxis; $form = new FormValidator('compare', 'get', $url); $form->addHidden('action', Security::remove_XSS($_GET['action'])); @@ -1909,9 +1984,9 @@ class SurveyUtil /** * Get all the answers of a question grouped by user * - * @param integer $survey_id Survey ID - * @param integer $question_id Question ID - * @return array Array containing all answers of all users, grouped by user + * @param integer $survey_id Survey ID + * @param integer $question_id Question ID + * @return array Array containing all answers of all users, grouped by user * * @author Patrick Cool , Ghent University * @version February 2007 - Updated March 2008 @@ -1943,11 +2018,11 @@ class SurveyUtil /** * Count the number of users who answer positively on both options * - * @param array All answers of the x axis - * @param array All answers of the y axis - * @param integer x axis value (= the option_id of the first question) - * @param integer y axis value (= the option_id of the second question) - * @return integer Number of users who have answered positively to both options + * @param array All answers of the x axis + * @param array All answers of the y axis + * @param integer x axis value (= the option_id of the first question) + * @param integer y axis value (= the option_id of the second question) + * @return integer Number of users who have answered positively to both options * * @author Patrick Cool , Ghent University * @version February 2007 @@ -1992,7 +2067,7 @@ class SurveyUtil /** * Get all the information about the invitations of a certain survey * - * @return array Lines of invitation [user, code, date, empty element] + * @return array Lines of invitation [user, code, date, empty element] * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2030,7 +2105,7 @@ class SurveyUtil /** * Get the total number of survey invitations for a given survey (through $_GET['survey_id']) * - * @return integer Total number of survey invitations + * @return integer Total number of survey invitations * * @todo use survey_id parameter instead of $_GET * @@ -2059,8 +2134,8 @@ class SurveyUtil /** * Save the invitation mail * - * @param string Text of the e-mail - * @param integer Whether the mail contents are for invite mail (0, default) or reminder mail (1) + * @param string Text of the e-mail + * @param integer Whether the mail contents are for invite mail (0, default) or reminder mail (1) * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2183,7 +2258,9 @@ class SurveyUtil } $new_user = false; // User not already invited // Store the invitation if user_id not in $already_invited['course_users'] OR email is not in $already_invited['additional_users'] - $addit_users_array = isset($already_invited['additional_users']) && !empty($already_invited['additional_users']) ? explode(';', $already_invited['additional_users']) : array(); + $addit_users_array = isset($already_invited['additional_users']) && !empty($already_invited['additional_users']) + ? explode(';', $already_invited['additional_users']) + : array(); $my_alredy_invited = $already_invited['course_users'] == null ? array() : $already_invited['course_users']; if ((is_numeric($value) && !in_array($value, $my_alredy_invited)) || (!is_numeric($value) && !in_array($value, $addit_users_array)) @@ -2242,8 +2319,10 @@ class SurveyUtil WHERE iid = $insertId"; Database::query($sql); } + return $insertId; } + return false; } @@ -2279,7 +2358,7 @@ class SurveyUtil * * @param int invitedUser - the userId (course user) or emailaddress of additional user * $param string $invitation_code - the unique invitation code for the URL - * @return void + * @return void */ public static function send_invitation_mail( $invitedUser, @@ -2291,8 +2370,10 @@ class SurveyUtil $_course = api_get_course_info(); // Replacing the **link** part with a valid link for the user - $survey_link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['code'].'&invitationcode='.$invitation_code; - $text_link = ''.get_lang('ClickHereToAnswerTheSurvey')."
\r\n
\r\n".get_lang('OrCopyPasteTheFollowingUrl')."
\r\n ".$survey_link; + $survey_link = api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['code'].'&invitationcode=' + .$invitation_code; + $text_link = ''.get_lang('ClickHereToAnswerTheSurvey')."
\r\n
\r\n" + .get_lang('OrCopyPasteTheFollowingUrl')."
\r\n ".$survey_link; $replace_count = 0; $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count); @@ -2331,7 +2412,7 @@ class SurveyUtil $sender_user_id ); } else { - /** @todo check if the address is a valid email */ + /** @todo check if the address is a valid email */ $recipient_email = $invitedUser; @api_mail_html( '', @@ -2346,10 +2427,11 @@ class SurveyUtil } /** - * This function recalculates the number of users who have been invited and updates the survey table with this value. + * This function recalculates the number of users who have been invited and updates the survey table with this + * value. * - * @param string Survey code - * @return void + * @param string Survey code + * @return void * @author Patrick Cool , Ghent University * @version January 2007 */ @@ -2386,9 +2468,9 @@ class SurveyUtil /** * This function gets all the invited users for a given survey code. * - * @param string Survey code - * @param string optional - course database - * @return array Array containing the course users and additional users (non course users) + * @param string Survey code + * @param string optional - course database + * @return array Array containing the course users and additional users (non course users) * * @todo consider making $defaults['additional_users'] also an array * @@ -2457,14 +2539,15 @@ class SurveyUtil if (!empty($defaults['additional_users'])) { $defaults['additional_users'] = implode(';', $defaults['additional_users']); } + return $defaults; } /** * Get all the invitations * - * @param string Survey code - * @return array Database rows matching the survey code + * @param string Survey code + * @return array Database rows matching the survey code * * @author Patrick Cool , Ghent University * @version September 2007 @@ -2484,13 +2567,14 @@ class SurveyUtil while ($row = Database::fetch_array($result)) { $return[$row['user']] = $row; } + return $return; } /** * This function displays the form for searching a survey * - * @return void (direct output) + * @return void (direct output) * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2554,7 +2638,7 @@ class SurveyUtil /** * This function displays the sortable table with all the surveys * - * @return void (direct output) + * @return void (direct output) * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2712,7 +2796,10 @@ class SurveyUtil if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id) ) { - $return .= ''.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).''; + $return .= '' + .Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) + .''; if (SurveyManager::survey_generation_hash_available()) { $return .= Display::url( Display::return_icon('new_link.png', get_lang('GenerateSurveyAccessLink'), '', ICON_SIZE_SMALL), @@ -2724,20 +2811,30 @@ class SurveyUtil 'survey_list.php?action=copy_survey&survey_id='.$survey_id.'&'.api_get_cidreq() ); - $return .= ' '. - Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).' '; - } - $return .= ''. - Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).' '; - $return .= ''. - Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL).' '; + $return .= ' ' + .Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL) + .' '; + } + $return .= '' + .Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL) + .' '; + $return .= '' + .Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL) + .' '; $return .= $hideReportingButton ? '' : $reportingLink; if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id) ) { - $return .= ''. - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).' '; + $return .= '' + .Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) + .' '; } return $return; @@ -2750,17 +2847,24 @@ class SurveyUtil //$return .= ''.Display::return_icon('delete.gif', get_lang('Delete')).''; //$return .= ''.Display::return_icon('copy.gif', get_lang('Copy')).''; //$return .= ''.Display::return_icon('add.gif', get_lang('Add')).''; - $return = ''.Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).' '; - $return .= ''.Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL).' '; - $return .= ''.Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).' '; + $return = '' + .Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_SMALL).' '; + $return .= ''.Display::return_icon('mail_send.png', get_lang('Publish'), '', ICON_SIZE_SMALL) + .' '; + $return .= '' + .Display::return_icon('clean.png', get_lang('EmptySurvey'), '', ICON_SIZE_SMALL).' '; return $return; } /** * Returns "yes" when given parameter is one, "no" for any other value - * @param integer Whether anonymous or not - * @return string "Yes" or "No" in the current language + * @param integer Whether anonymous or not + * @return string "Yes" or "No" in the current language */ public static function anonymous_filter($anonymous) { @@ -2774,7 +2878,7 @@ class SurveyUtil /** * This function handles the search restriction for the SQL statements * - * @return string Part of a SQL statement or false on error + * @return string Part of a SQL statement or false on error * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2793,6 +2897,7 @@ class SurveyUtil } $my_search_term = ($search_term == null) ? array() : $search_term; $search_restriction = implode(' AND ', $my_search_term); + return $search_restriction; } else { return false; @@ -2802,7 +2907,7 @@ class SurveyUtil /** * This function calculates the total number of surveys * - * @return integer Total number of surveys + * @return integer Total number of surveys * * @author Patrick Cool , Ghent University * @version January 2007 @@ -2832,6 +2937,7 @@ class SurveyUtil public static function get_number_of_surveys_for_coach() { $survey_tree = new SurveyTree(); + return count($survey_tree->surveylist); } @@ -2879,31 +2985,37 @@ class SurveyUtil $condition_session = api_get_session_condition($session_id); $course_id = api_get_course_int_id(); - $sql = "SELECT - survey.survey_id AS col0, - survey.title AS col1, - survey.code AS col2, - count(survey_question.question_id) AS col3, - ".(api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)")." AS col4, - survey.avail_from AS col5, - survey.avail_till AS col6, - survey.invited AS col7, - survey.anonymous AS col8, - survey.survey_id AS col9, - survey.session_id AS session_id, - survey.answered, - survey.invited - FROM $table_survey survey - LEFT JOIN $table_survey_question survey_question - ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = $course_id) - LEFT JOIN $table_user user - ON (survey.author = user.user_id) - WHERE survey.c_id = $course_id - $search_restriction - $condition_session - GROUP BY survey.survey_id - ORDER BY col$column $direction - LIMIT $from,$number_of_items"; + $sql = " + SELECT + survey.survey_id AS col0, + survey.title AS col1, + survey.code AS col2, + count(survey_question.question_id) AS col3, + " + .(api_is_western_name_order() + ? "CONCAT(user.firstname, ' ', user.lastname)" + : "CONCAT(user.lastname, ' ', user.firstname)") + ." AS col4, + survey.avail_from AS col5, + survey.avail_till AS col6, + survey.invited AS col7, + survey.anonymous AS col8, + survey.survey_id AS col9, + survey.session_id AS session_id, + survey.answered, + survey.invited + FROM $table_survey survey + LEFT JOIN $table_survey_question survey_question + ON (survey.survey_id = survey_question.survey_id AND survey_question.c_id = $course_id) + LEFT JOIN $table_user user + ON (survey.author = user.user_id) + WHERE survey.c_id = $course_id + $search_restriction + $condition_session + GROUP BY survey.survey_id + ORDER BY col$column $direction + LIMIT $from,$number_of_items + "; $res = Database::query($sql); $surveys = array(); @@ -2932,11 +3044,13 @@ class SurveyUtil $array[7] = Display::url( $survey['answered'], - api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey[0].'&'.api_get_cidreq() + api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey[0].'&' + .api_get_cidreq() ).' / '. Display::url( $survey['invited'], - api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey[0].'&'.api_get_cidreq() + api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey[0].'&' + .api_get_cidreq() ); $array[8] = $survey[8]; @@ -2960,6 +3074,7 @@ class SurveyUtil $surveys[] = $array; } + return $surveys; } @@ -2999,22 +3114,28 @@ class SurveyUtil $course_id = api_get_course_int_id(); $efv = new ExtraFieldValue('survey'); - $sql = "SELECT + $sql = " + SELECT survey.survey_id AS col0, - survey.title AS col1, - survey.code AS col2, - count(survey_question.question_id) AS col3, - ".(api_is_western_name_order() ? "CONCAT(user.firstname, ' ', user.lastname)" : "CONCAT(user.lastname, ' ', user.firstname)")." AS col4, - survey.avail_from AS col5, - survey.avail_till AS col6, - CONCAT('',survey.answered,' / ',survey.invited, '') AS col7, - survey.anonymous AS col8, - survey.survey_id AS col9 + survey.title AS col1, + survey.code AS col2, + count(survey_question.question_id) AS col3, + " + .(api_is_western_name_order() + ? "CONCAT(user.firstname, ' ', user.lastname)" + : "CONCAT(user.lastname, ' ', user.firstname)") + ." AS col4, + survey.avail_from AS col5, + survey.avail_till AS col6, + CONCAT('',survey.answered,' / ',survey.invited, '') AS col7, + survey.anonymous AS col8, + survey.survey_id AS col9 FROM $table_survey survey LEFT JOIN $table_survey_question survey_question ON (survey.survey_id = survey_question.survey_id AND survey.c_id = survey_question.c_id), $table_user user - WHERE survey.author = user.user_id AND survey.c_id = $course_id $list_condition "; + WHERE survey.author = user.user_id AND survey.c_id = $course_id $list_condition + "; $sql .= " GROUP BY survey.survey_id"; $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; @@ -3111,7 +3232,9 @@ class SurveyUtil array(), ICON_SIZE_TINY ); - echo ''.$row['title'].''; + echo ''.$row['title'] + .''; } else { $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( $user_id, @@ -3299,6 +3422,7 @@ class SurveyUtil break; } } + return $field_list_array; } @@ -3348,11 +3472,11 @@ class SurveyUtil user="'.$user_answer.'" AND c_id = '.$course_id; - $result = Database::query($sql); + $result = Database::query($sql); $result2 = Database::query($sql2); $result3 = Database::query($sql3); - $row = Database::fetch_array($result, 'ASSOC'); + $row = Database::fetch_array($result, 'ASSOC'); $row2 = Database::fetch_array($result2, 'ASSOC'); $row3 = Database::fetch_array($result3, 'ASSOC'); @@ -3366,10 +3490,10 @@ class SurveyUtil /** * Display survey question chart - * @param array $chartData - * @param boolean $hasSerie Tells if the chart has a serie. False by default - * @param string $chartContainerId - * @return string (direct output) + * @param array $chartData + * @param boolean $hasSerie Tells if the chart has a serie. False by default + * @param string $chartContainerId + * @return string (direct output) */ public static function drawChart( $chartData, @@ -3407,21 +3531,22 @@ class SurveyUtil rtrim($htmlChart, ","); $htmlChart .= ']; var myChart = new dimple.chart(svg, data); - myChart.addMeasureAxis("y", "' . get_lang("Votes").'");'; + myChart.addMeasureAxis("y", "'.get_lang("Votes").'");'; if (!$hasSerie) { $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "'.get_lang("Option").'"); - xAxisCategory.addOrderRule(' . json_encode($order).'); - myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);'; + xAxisCategory.addOrderRule('.json_encode($order).'); + myChart.addSeries("'.get_lang("Option").'", dimple.plot.bar);'; } else { if (!is_array($chartDataElement['serie'])) { $serie = array_values(array_unique($serie)); - $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]); - xAxisCategory.addOrderRule(' . json_encode($serie).'); - xAxisCategory.addGroupOrderRule("' . get_lang("Score").'"); - myChart.addSeries("' . get_lang("Option").'", dimple.plot.bar);'; + $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["'.get_lang("Option").'","' + .get_lang("Score").'"]); + xAxisCategory.addOrderRule('.json_encode($serie).'); + xAxisCategory.addGroupOrderRule("'.get_lang("Score").'"); + myChart.addSeries("'.get_lang("Option").'", dimple.plot.bar);'; } else { $htmlChart .= 'myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]); - myChart.addSeries("' . get_lang("Serie").'", dimple.plot.bar);'; + myChart.addSeries("'.get_lang("Serie").'", dimple.plot.bar);'; } } $htmlChart .= 'myChart.draw();
'. - $user_displayed.'' + .$user_displayed.''.$user.'