|
|
|
|
@ -2454,14 +2454,12 @@ class ch_score extends survey_question |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This class offers a series of general utility functions for survey querying and display |
|
|
|
|
* @package chamilo.survey |
|
|
|
|
*/ |
|
|
|
|
class SurveyUtil |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Checks whether the given survey has a pagebreak question as the first or the last question. |
|
|
|
|
* If so, break the current process, displaying an error message |
|
|
|
|
@ -2723,14 +2721,20 @@ class SurveyUtil |
|
|
|
|
|
|
|
|
|
// Actions bar |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'. |
|
|
|
|
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
if (isset($_GET['user'])) { |
|
|
|
|
// The delete link |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=deleteuserreport&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.Security::remove_XSS($_GET['user']).'" >'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
if (api_is_allowed_to_edit()) { |
|
|
|
|
// The delete link |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=deleteuserreport&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.Security::remove_XSS($_GET['user']).'" >'. |
|
|
|
|
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Export the user report |
|
|
|
|
echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
|
|
|
echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
|
|
|
echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'. |
|
|
|
|
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
|
|
|
echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'. |
|
|
|
|
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> '; |
|
|
|
|
echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user_id='.Security::remove_XSS($_GET['user']).'">'; |
|
|
|
|
echo '<input type="hidden" name="export_report" value="export_report">'; |
|
|
|
|
echo '<input type="hidden" name="export_format" value="csv">'; |
|
|
|
|
@ -2867,7 +2871,7 @@ class SurveyUtil |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @version February 2007 - Updated March 2008 |
|
|
|
|
*/ |
|
|
|
|
function display_question_report($survey_data) |
|
|
|
|
public static function display_question_report($survey_data) |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
// Database table definitions |
|
|
|
|
@ -2882,8 +2886,11 @@ class SurveyUtil |
|
|
|
|
$offset = Database::escape_string($_GET['question']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$currentQuestion = isset($_GET['question']) ? $_GET['question'] : 0; |
|
|
|
|
|
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'. |
|
|
|
|
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
|
|
|
|
|
if ($survey_data['number_of_questions'] > 0) { |
|
|
|
|
@ -2912,13 +2919,13 @@ class SurveyUtil |
|
|
|
|
$question = Database::fetch_array($result); |
|
|
|
|
|
|
|
|
|
// Navigate through the questions (next and previous) |
|
|
|
|
if ($_GET['question'] != 0) { |
|
|
|
|
if ($currentQuestion != 0 ) { |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$_GET['survey_id'].'&question='.Security::remove_XSS($offset-1).'">'.Display::return_icon('action_prev.png', get_lang('PreviousQuestion'), array('align' => 'middle')).' '.get_lang('PreviousQuestion').'</a> '; |
|
|
|
|
} else { |
|
|
|
|
echo Display::return_icon('action_prev.png', get_lang('PreviousQuestion'), array('align' => 'middle')).' '.get_lang('PreviousQuestion').' '; |
|
|
|
|
} |
|
|
|
|
echo ' | '; |
|
|
|
|
if ($_GET['question'] < ($survey_data['number_of_questions'] - 1)) { |
|
|
|
|
if ($currentQuestion < ($survey_data['number_of_questions'] - 1)) { |
|
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset+1).'">'.get_lang('NextQuestion').' '.Display::return_icon('action_next.png', get_lang('NextQuestion'), array('align' => 'middle')).'</a>'; |
|
|
|
|
} else { |
|
|
|
|
echo get_lang('NextQuestion').' '.Display::return_icon('action_next.png', get_lang('NextQuestion'), array('align' => 'middle')); |
|
|
|
|
@ -2954,17 +2961,19 @@ class SurveyUtil |
|
|
|
|
} |
|
|
|
|
// Getting the answers |
|
|
|
|
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer |
|
|
|
|
WHERE c_id = $course_id AND |
|
|
|
|
survey_id='".Database::escape_string($_GET['survey_id'])."' AND |
|
|
|
|
question_id = '".Database::escape_string($question['question_id'])."' |
|
|
|
|
GROUP BY option_id, value"; |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
survey_id='".Database::escape_string($_GET['survey_id'])."' AND |
|
|
|
|
question_id = '".Database::escape_string($question['question_id'])."' |
|
|
|
|
GROUP BY option_id, value"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$number_of_answers = 0; |
|
|
|
|
$data = array(); |
|
|
|
|
while ($row = Database::fetch_array($result)) { |
|
|
|
|
$number_of_answers += $row['total']; |
|
|
|
|
$data[$row['option_id']] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// displaying the table: headers |
|
|
|
|
echo '<table class="data_table">'; |
|
|
|
|
echo ' <tr>'; |
|
|
|
|
@ -2977,7 +2986,10 @@ class SurveyUtil |
|
|
|
|
// Displaying the table: the content |
|
|
|
|
if (is_array($options)) { |
|
|
|
|
foreach ($options as $key => & $value) { |
|
|
|
|
$absolute_number = $data[$value['question_option_id']]['total']; |
|
|
|
|
$absolute_number = null; |
|
|
|
|
if (isset($data[$value['question_option_id']])) { |
|
|
|
|
$absolute_number = $data[$value['question_option_id']]['total']; |
|
|
|
|
} |
|
|
|
|
if ($question['type'] == 'percentage' && empty($absolute_number)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
@ -3032,7 +3044,7 @@ class SurveyUtil |
|
|
|
|
* @param integer The offset of results shown |
|
|
|
|
* @return void (direct output) |
|
|
|
|
*/ |
|
|
|
|
function display_question_report_score($survey_data, $question, $offset) |
|
|
|
|
public static function display_question_report_score($survey_data, $question, $offset) |
|
|
|
|
{ |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
// Database table definitions |
|
|
|
|
@ -3112,7 +3124,7 @@ class SurveyUtil |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @version February 2007 |
|
|
|
|
*/ |
|
|
|
|
static function display_complete_report($survey_data) |
|
|
|
|
public static function display_complete_report($survey_data) |
|
|
|
|
{ |
|
|
|
|
// Database table definitions |
|
|
|
|
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
|
|
|
@ -3428,7 +3440,10 @@ class SurveyUtil |
|
|
|
|
// We show the questions if |
|
|
|
|
// 1. there is no question filter and the export button has not been clicked |
|
|
|
|
// 2. there is a quesiton filter but the question is selected for display |
|
|
|
|
if (!($_POST['submit_question_filter']) || (is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter']))) { |
|
|
|
|
if (!($_POST['submit_question_filter']) || |
|
|
|
|
(is_array($_POST['questions_filter']) && |
|
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
|
) { |
|
|
|
|
// 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') { |
|
|
|
|
@ -4468,6 +4483,32 @@ class SurveyUtil |
|
|
|
|
echo '<div style="clear: both;margin-bottom: 10px;"></div>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Show table only visible by DRH users |
|
|
|
|
*/ |
|
|
|
|
public static function displaySurveyListForDrh() |
|
|
|
|
{ |
|
|
|
|
$parameters = array(); |
|
|
|
|
$parameters['cidReq'] = api_get_course_id(); |
|
|
|
|
|
|
|
|
|
// Create a sortable table with survey-data |
|
|
|
|
$table = new SortableTable('surveys', 'get_number_of_surveys', 'get_survey_data_drh', 2); |
|
|
|
|
$table->set_additional_parameters($parameters); |
|
|
|
|
$table->set_header(0, '', false); |
|
|
|
|
$table->set_header(1, get_lang('SurveyName')); |
|
|
|
|
$table->set_header(2, get_lang('SurveyCode')); |
|
|
|
|
$table->set_header(3, get_lang('NumberOfQuestions')); |
|
|
|
|
$table->set_header(4, get_lang('Author')); |
|
|
|
|
$table->set_header(5, get_lang('AvailableFrom')); |
|
|
|
|
$table->set_header(6, get_lang('AvailableUntil')); |
|
|
|
|
$table->set_header(7, get_lang('Invite')); |
|
|
|
|
$table->set_header(8, get_lang('Anonymous')); |
|
|
|
|
$table->set_header(9, get_lang('Modify'), false, 'width="150"'); |
|
|
|
|
$table->set_column_filter(8, 'anonymous_filter'); |
|
|
|
|
$table->set_column_filter(9, 'modify_filter_drh'); |
|
|
|
|
$table->display(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This function displays the sortable table with all the surveys |
|
|
|
|
* |
|
|
|
|
@ -4541,18 +4582,26 @@ class SurveyUtil |
|
|
|
|
* This function changes the modify column of the sortable table |
|
|
|
|
* |
|
|
|
|
* @param integer $survey_id the id of the survey |
|
|
|
|
* @return html code that are the actions that can be performed on any survey |
|
|
|
|
* @param bool $drh |
|
|
|
|
* @return string html code that are the actions that can be performed on any survey |
|
|
|
|
* |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @version January 2007 |
|
|
|
|
*/ |
|
|
|
|
static function modify_filter($survey_id) |
|
|
|
|
static function modify_filter($survey_id, $drh = false) |
|
|
|
|
{ |
|
|
|
|
$survey_id = Security::remove_XSS($survey_id); |
|
|
|
|
$return = ''; |
|
|
|
|
|
|
|
|
|
if ($drh) { |
|
|
|
|
return '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'. |
|
|
|
|
Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Coach can see that only if the survey is in his session |
|
|
|
|
if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) { |
|
|
|
|
if (api_is_allowed_to_edit() || |
|
|
|
|
api_is_element_in_the_session(TOOL_SURVEY, $survey_id) |
|
|
|
|
) { |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&action=edit&survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
if (survey_manager::survey_generation_hash_available()) { |
|
|
|
|
$return .= Display::url( |
|
|
|
|
@ -4560,15 +4609,26 @@ class SurveyUtil |
|
|
|
|
api_get_path(WEB_CODE_PATH).'survey/generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$return .= Display::url(Display::return_icon('copy.png', get_lang('DuplicateSurvey'), '', ICON_SIZE_SMALL), 'survey_list.php?action=copy_survey&survey_id='.$survey_id.'&'.api_get_cidreq()); |
|
|
|
|
$return .= Display::url( |
|
|
|
|
Display::return_icon('copy.png', get_lang('DuplicateSurvey'), '', ICON_SIZE_SMALL), |
|
|
|
|
'survey_list.php?action=copy_survey&survey_id='.$survey_id.'&'.api_get_cidreq() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$return .= ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=empty&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'.Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=empty&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'. |
|
|
|
|
Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
} |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) { |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'. |
|
|
|
|
Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'. |
|
|
|
|
Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&survey_id='.$survey_id.'">'. |
|
|
|
|
Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit() || |
|
|
|
|
api_is_element_in_the_session(TOOL_SURVEY, $survey_id) |
|
|
|
|
) { |
|
|
|
|
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'. |
|
|
|
|
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a> '; |
|
|
|
|
} |
|
|
|
|
return $return; |
|
|
|
|
} |
|
|
|
|
@ -4670,13 +4730,14 @@ class SurveyUtil |
|
|
|
|
* @param int $number_of_items |
|
|
|
|
* @param int $column |
|
|
|
|
* @param string $direction |
|
|
|
|
* @param bool $isDrh |
|
|
|
|
* @return unknown |
|
|
|
|
* |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @author Julio Montoya <gugli100@gmail.com>, Beeznest - Adding intvals |
|
|
|
|
* @version January 2007 |
|
|
|
|
*/ |
|
|
|
|
static function get_survey_data($from, $number_of_items, $column, $direction) |
|
|
|
|
static function get_survey_data($from, $number_of_items, $column, $direction, $isDrh = false) |
|
|
|
|
{ |
|
|
|
|
$table_survey = Database :: get_course_table(TABLE_SURVEY); |
|
|
|
|
$table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
|
|
|
@ -4730,7 +4791,6 @@ class SurveyUtil |
|
|
|
|
$surveys = array(); |
|
|
|
|
$array = array(); |
|
|
|
|
while ($survey = Database::fetch_array($res)) { |
|
|
|
|
|
|
|
|
|
$array[0] = $survey[0]; |
|
|
|
|
$array[1] = Display::url( |
|
|
|
|
$survey[1], |
|
|
|
|
@ -4756,7 +4816,12 @@ class SurveyUtil |
|
|
|
|
|
|
|
|
|
$array[8] = $survey[8]; |
|
|
|
|
$array[9] = $survey[9]; |
|
|
|
|
//$array[10] = $survey[10]; |
|
|
|
|
|
|
|
|
|
if ($isDrh) { |
|
|
|
|
$array[1] = $survey[1]; |
|
|
|
|
$array[7] = strip_tags($array[7]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$surveys[] = $array; |
|
|
|
|
} |
|
|
|
|
return $surveys; |
|
|
|
|
|