|
|
@ -235,7 +235,7 @@ class SurveyUtil |
|
|
|
$questions_data = []; |
|
|
|
$questions_data = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($my_temp_questions_data as $key => &$value) { |
|
|
|
foreach ($my_temp_questions_data as $key => &$value) { |
|
|
|
if ($value['type'] != 'comment' && $value['type'] != 'pagebreak') { |
|
|
|
if ($value['type'] != 'pagebreak') { |
|
|
|
$questions_data[$value['sort']] = $value; |
|
|
|
$questions_data[$value['sort']] = $value; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -518,19 +518,19 @@ class SurveyUtil |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function display_question_report($survey_data) |
|
|
|
public static function display_question_report($survey_data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$singlePage = isset($_GET['single_page']) ? intval($_GET['single_page']) : 0; |
|
|
|
$singlePage = isset($_GET['single_page']) ? (int) $_GET['single_page'] : 0; |
|
|
|
|
|
|
|
// Determining the offset of the sql statement (the n-th question of the survey) |
|
|
|
|
|
|
|
$offset = !isset($_GET['question']) ? 0 : (int) $_GET['question']; |
|
|
|
|
|
|
|
$currentQuestion = isset($_GET['question']) ? (int) $_GET['question'] : 0; |
|
|
|
|
|
|
|
$surveyId = (int) $_GET['survey_id']; |
|
|
|
|
|
|
|
$action = Security::remove_XSS($_GET['action']); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
|
|
// Database table definitions |
|
|
|
// Database table definitions |
|
|
|
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); |
|
|
|
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
|
|
|
|
|
|
|
|
// Determining the offset of the sql statement (the n-th question of the survey) |
|
|
|
|
|
|
|
$offset = !isset($_GET['question']) ? 0 : intval($_GET['question']); |
|
|
|
|
|
|
|
$currentQuestion = isset($_GET['question']) ? intval($_GET['question']) : 0; |
|
|
|
|
|
|
|
$questions = []; |
|
|
|
$questions = []; |
|
|
|
$surveyId = intval($_GET['survey_id']); |
|
|
|
|
|
|
|
$action = Security::remove_XSS($_GET['action']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<div class="actions">'; |
|
|
|
echo '<div class="actions">'; |
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'&'.api_get_cidreq().'">'. |
|
|
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'&'.api_get_cidreq().'">'. |
|
|
@ -574,9 +574,8 @@ class SurveyUtil |
|
|
|
$sql = "SELECT * FROM $table_survey_question |
|
|
|
$sql = "SELECT * FROM $table_survey_question |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
survey_id='".intval($_GET['survey_id'])."' AND |
|
|
|
survey_id='".$surveyId."' AND |
|
|
|
type <>'pagebreak' AND |
|
|
|
type <>'pagebreak' |
|
|
|
type <>'comment' |
|
|
|
|
|
|
|
ORDER BY sort ASC |
|
|
|
ORDER BY sort ASC |
|
|
|
$limitStatement"; |
|
|
|
$limitStatement"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
@ -584,10 +583,10 @@ class SurveyUtil |
|
|
|
$questions[$row['question_id']] = $row; |
|
|
|
$questions[$row['question_id']] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($questions as $question) { |
|
|
|
foreach ($questions as $question) { |
|
|
|
$chartData = []; |
|
|
|
$chartData = []; |
|
|
|
$options = []; |
|
|
|
$options = []; |
|
|
|
|
|
|
|
$questionId = (int) $question['question_id']; |
|
|
|
echo '<div class="title-question">'; |
|
|
|
echo '<div class="title-question">'; |
|
|
|
echo strip_tags(isset($question['survey_question']) ? $question['survey_question'] : null); |
|
|
|
echo strip_tags(isset($question['survey_question']) ? $question['survey_question'] : null); |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>'; |
|
|
@ -595,13 +594,13 @@ class SurveyUtil |
|
|
|
if ($question['type'] == 'score') { |
|
|
|
if ($question['type'] == 'score') { |
|
|
|
/** @todo This function should return the options as this is needed further in the code */ |
|
|
|
/** @todo This function should return the options as this is needed further in the code */ |
|
|
|
$options = self::display_question_report_score($survey_data, $question, $offset); |
|
|
|
$options = self::display_question_report_score($survey_data, $question, $offset); |
|
|
|
} elseif ($question['type'] == 'open') { |
|
|
|
} elseif ($question['type'] == 'open' || $question['type'] == 'comment') { |
|
|
|
/** @todo Also get the user who has answered this */ |
|
|
|
/** @todo Also get the user who has answered this */ |
|
|
|
$sql = "SELECT * FROM $table_survey_answer |
|
|
|
$sql = "SELECT * FROM $table_survey_answer |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
survey_id='".intval($_GET['survey_id'])."' AND |
|
|
|
survey_id='".$surveyId."' AND |
|
|
|
question_id = '".intval($question['question_id'])."'"; |
|
|
|
question_id = '".$questionId."'"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
echo $row['option_id'].'<hr noshade="noshade" size="1" />'; |
|
|
|
echo $row['option_id'].'<hr noshade="noshade" size="1" />'; |
|
|
@ -611,8 +610,8 @@ class SurveyUtil |
|
|
|
$sql = "SELECT * FROM $table_survey_question_option |
|
|
|
$sql = "SELECT * FROM $table_survey_question_option |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
survey_id='".intval($_GET['survey_id'])."' |
|
|
|
survey_id='".$surveyId."' |
|
|
|
AND question_id = '".intval($question['question_id'])."' |
|
|
|
AND question_id = '".$questionId."' |
|
|
|
ORDER BY sort ASC"; |
|
|
|
ORDER BY sort ASC"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
|
@ -622,8 +621,8 @@ class SurveyUtil |
|
|
|
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer |
|
|
|
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
c_id = $course_id AND |
|
|
|
c_id = $course_id AND |
|
|
|
survey_id='".intval($_GET['survey_id'])."' |
|
|
|
survey_id='".$surveyId."' |
|
|
|
AND question_id = '".intval($question['question_id'])."' |
|
|
|
AND question_id = '".$questionId."' |
|
|
|
GROUP BY option_id, value"; |
|
|
|
GROUP BY option_id, value"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
|
$number_of_answers = []; |
|
|
|
$number_of_answers = []; |
|
|
@ -714,6 +713,7 @@ class SurveyUtil |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['viewoption'])) { |
|
|
|
if (isset($_GET['viewoption'])) { |
|
|
|
echo '<div class="answered-people">'; |
|
|
|
echo '<div class="answered-people">'; |
|
|
|
echo '<h4>'.get_lang('PeopleWhoAnswered').': ' |
|
|
|
echo '<h4>'.get_lang('PeopleWhoAnswered').': ' |
|
|
@ -865,7 +865,7 @@ class SurveyUtil |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
|
|
|
|
|
|
|
|
$surveyId = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : 0; |
|
|
|
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0; |
|
|
|
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; |
|
|
|
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; |
|
|
|
|
|
|
|
|
|
|
|
// Actions bar |
|
|
|
// Actions bar |
|
|
@ -940,14 +940,17 @@ class SurveyUtil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$sql = "SELECT q.question_id, q.type, q.survey_question, count(o.question_option_id) as number_of_options |
|
|
|
$sql = "SELECT |
|
|
|
|
|
|
|
q.question_id, |
|
|
|
|
|
|
|
q.type, |
|
|
|
|
|
|
|
q.survey_question, |
|
|
|
|
|
|
|
count(o.question_option_id) as number_of_options |
|
|
|
FROM $table_survey_question q |
|
|
|
FROM $table_survey_question q |
|
|
|
LEFT JOIN $table_survey_question_option o |
|
|
|
LEFT JOIN $table_survey_question_option o |
|
|
|
ON q.question_id = o.question_id |
|
|
|
ON q.question_id = o.question_id AND q.c_id = o.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
q.survey_id = '".$surveyId."' AND |
|
|
|
q.survey_id = '".$surveyId."' AND |
|
|
|
q.c_id = $course_id AND |
|
|
|
q.c_id = $course_id |
|
|
|
o.c_id = $course_id |
|
|
|
|
|
|
|
GROUP BY q.question_id |
|
|
|
GROUP BY q.question_id |
|
|
|
ORDER BY q.sort ASC"; |
|
|
|
ORDER BY q.sort ASC"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
@ -960,15 +963,12 @@ class SurveyUtil |
|
|
|
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { |
|
|
|
if ($row['type'] != 'pagebreak') { |
|
|
|
echo ' <th'; |
|
|
|
echo ' <th'; |
|
|
|
// <hub> modified tst to include percentage |
|
|
|
|
|
|
|
if ($row['number_of_options'] > 0 && $row['type'] != 'percentage') { |
|
|
|
if ($row['number_of_options'] > 0 && $row['type'] != 'percentage') { |
|
|
|
// </hub> |
|
|
|
|
|
|
|
echo ' colspan="'.$row['number_of_options'].'"'; |
|
|
|
echo ' colspan="'.$row['number_of_options'].'"'; |
|
|
|
} |
|
|
|
} |
|
|
|
echo '>'; |
|
|
|
echo '>'; |
|
|
|
|
|
|
|
|
|
|
|
echo '<label><input type="checkbox" name="questions_filter[]" value="'.$row['question_id'] |
|
|
|
echo '<label><input type="checkbox" name="questions_filter[]" value="'.$row['question_id'] |
|
|
|
.'" checked="checked"/> '; |
|
|
|
.'" checked="checked"/> '; |
|
|
|
echo $row['survey_question']; |
|
|
|
echo $row['survey_question']; |
|
|
@ -985,7 +985,8 @@ class SurveyUtil |
|
|
|
echo ' <th> </th>'; // the user column |
|
|
|
echo ' <th> </th>'; // the user column |
|
|
|
|
|
|
|
|
|
|
|
if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] || |
|
|
|
if (!(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter'] || |
|
|
|
isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter'])) { |
|
|
|
isset($_POST['export_report']) && $_POST['export_report']) || !empty($_POST['fields_filter']) |
|
|
|
|
|
|
|
) { |
|
|
|
//show the fields names for user fields |
|
|
|
//show the fields names for user fields |
|
|
|
foreach ($extra_user_fields as &$field) { |
|
|
|
foreach ($extra_user_fields as &$field) { |
|
|
|
echo '<th>'.$field[3].'</th>'; |
|
|
|
echo '<th>'.$field[3].'</th>'; |
|
|
@ -994,17 +995,21 @@ class SurveyUtil |
|
|
|
|
|
|
|
|
|
|
|
// cells with option (none for open question) |
|
|
|
// cells with option (none for open question) |
|
|
|
$sql = "SELECT |
|
|
|
$sql = "SELECT |
|
|
|
sq.question_id, sq.survey_id, |
|
|
|
sq.question_id, |
|
|
|
sq.survey_question, sq.display, |
|
|
|
sq.survey_id, |
|
|
|
sq.sort, sq.type, sqo.question_option_id, |
|
|
|
sq.survey_question, |
|
|
|
sqo.option_text, sqo.sort as option_sort |
|
|
|
sq.display, |
|
|
|
|
|
|
|
sq.sort, |
|
|
|
|
|
|
|
sq.type, |
|
|
|
|
|
|
|
sqo.question_option_id, |
|
|
|
|
|
|
|
sqo.option_text, |
|
|
|
|
|
|
|
sqo.sort as option_sort |
|
|
|
FROM $table_survey_question sq |
|
|
|
FROM $table_survey_question sq |
|
|
|
LEFT JOIN $table_survey_question_option sqo |
|
|
|
LEFT JOIN $table_survey_question_option sqo |
|
|
|
ON sq.question_id = sqo.question_id |
|
|
|
ON sq.question_id = sqo.question_id AND sq.c_id = sqo.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
sq.survey_id = '".$surveyId."' AND |
|
|
|
sq.survey_id = '".$surveyId."' AND |
|
|
|
sq.c_id = $course_id AND |
|
|
|
sq.c_id = $course_id |
|
|
|
sqo.c_id = $course_id |
|
|
|
|
|
|
|
ORDER BY sq.sort ASC, sqo.sort ASC"; |
|
|
|
ORDER BY sq.sort ASC, sqo.sort ASC"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
|
@ -1019,8 +1024,7 @@ class SurveyUtil |
|
|
|
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
(is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// <hub> modif 05-05-2010 |
|
|
|
// <hub> modif 05-05-2010 |
|
|
|
// we do not show comment and pagebreak question types |
|
|
|
if ($row['type'] == 'open' || $row['type'] == 'comment') { |
|
|
|
if ($row['type'] == 'open') { |
|
|
|
|
|
|
|
echo '<th> - </th>'; |
|
|
|
echo '<th> - </th>'; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$display_percentage_header = 1; |
|
|
|
$display_percentage_header = 1; |
|
|
@ -1030,15 +1034,13 @@ class SurveyUtil |
|
|
|
$display_percentage_header = 0; |
|
|
|
$display_percentage_header = 0; |
|
|
|
} elseif ($row['type'] == 'percentage') { |
|
|
|
} elseif ($row['type'] == 'percentage') { |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
} elseif ($row['type'] != 'comment' && $row['type'] != 'pagebreak' && $row['type'] != 'percentage') { |
|
|
|
} elseif ($row['type'] != 'pagebreak' && $row['type'] != 'percentage') { |
|
|
|
echo '<th>'; |
|
|
|
echo '<th>'; |
|
|
|
echo $row['option_text']; |
|
|
|
echo $row['option_text']; |
|
|
|
echo '</th>'; |
|
|
|
echo '</th>'; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$display_percentage_header = 1; |
|
|
|
$display_percentage_header = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
//no column at all if the question was not a question |
|
|
|
|
|
|
|
// </hub> |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1071,7 +1073,10 @@ class SurveyUtil |
|
|
|
); |
|
|
|
); |
|
|
|
$answers_of_user = []; |
|
|
|
$answers_of_user = []; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($questions[$row['question_id']]) && $questions[$row['question_id']]['type'] != 'open') { |
|
|
|
if (isset($questions[$row['question_id']]) && |
|
|
|
|
|
|
|
$questions[$row['question_id']]['type'] != 'open' && |
|
|
|
|
|
|
|
$questions[$row['question_id']]['type'] != 'comment' |
|
|
|
|
|
|
|
) { |
|
|
|
$answers_of_user[$row['question_id']][$row['option_id']] = $row; |
|
|
|
$answers_of_user[$row['question_id']][$row['option_id']] = $row; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$answers_of_user[$row['question_id']][0] = $row; |
|
|
|
$answers_of_user[$row['question_id']][0] = $row; |
|
|
@ -1141,7 +1146,7 @@ class SurveyUtil |
|
|
|
if ($display_extra_user_fields) { |
|
|
|
if ($display_extra_user_fields) { |
|
|
|
// Show user fields data, if any, for this user |
|
|
|
// Show user fields data, if any, for this user |
|
|
|
$user_fields_values = UserManager::get_extra_user_data( |
|
|
|
$user_fields_values = UserManager::get_extra_user_data( |
|
|
|
intval($user), |
|
|
|
$user, |
|
|
|
false, |
|
|
|
false, |
|
|
|
false, |
|
|
|
false, |
|
|
|
false, |
|
|
|
false, |
|
|
@ -1151,10 +1156,10 @@ class SurveyUtil |
|
|
|
echo '<td align="center">'.$value.'</td>'; |
|
|
|
echo '<td align="center">'.$value.'</td>'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (is_array($possible_options)) { |
|
|
|
if (is_array($possible_options)) { |
|
|
|
// <hub> modified to display open answers and percentage |
|
|
|
|
|
|
|
foreach ($possible_options as $question_id => &$possible_option) { |
|
|
|
foreach ($possible_options as $question_id => &$possible_option) { |
|
|
|
if ($questions[$question_id]['type'] == 'open') { |
|
|
|
if ($questions[$question_id]['type'] == 'open' || $questions[$question_id]['type'] == 'comment') { |
|
|
|
echo '<td align="center">'; |
|
|
|
echo '<td align="center">'; |
|
|
|
echo $answers_of_user[$question_id]['0']['option_id']; |
|
|
|
echo $answers_of_user[$question_id]['0']['option_id']; |
|
|
|
echo '</td>'; |
|
|
|
echo '</td>'; |
|
|
@ -1202,6 +1207,12 @@ class SurveyUtil |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($surveyId)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The first column |
|
|
|
// The first column |
|
|
|
$return = ';'; |
|
|
|
$return = ';'; |
|
|
|
|
|
|
|
|
|
|
@ -1217,7 +1228,6 @@ class SurveyUtil |
|
|
|
|
|
|
|
|
|
|
|
$num = count($extra_user_fields); |
|
|
|
$num = count($extra_user_fields); |
|
|
|
$return .= str_repeat(';', $num); |
|
|
|
$return .= str_repeat(';', $num); |
|
|
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT |
|
|
|
$sql = "SELECT |
|
|
@ -1227,9 +1237,9 @@ class SurveyUtil |
|
|
|
count(options.question_option_id) as number_of_options |
|
|
|
count(options.question_option_id) as number_of_options |
|
|
|
FROM $table_survey_question questions |
|
|
|
FROM $table_survey_question questions |
|
|
|
LEFT JOIN $table_survey_question_option options |
|
|
|
LEFT JOIN $table_survey_question_option options |
|
|
|
ON questions.question_id = options.question_id AND options.c_id = $course_id |
|
|
|
ON questions.question_id = options.question_id AND options.c_id = questions.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
questions.survey_id = '".intval($_GET['survey_id'])."' AND |
|
|
|
questions.survey_id = '".$surveyId."' AND |
|
|
|
questions.c_id = $course_id |
|
|
|
questions.c_id = $course_id |
|
|
|
GROUP BY questions.question_id |
|
|
|
GROUP BY questions.question_id |
|
|
|
ORDER BY questions.sort ASC"; |
|
|
|
ORDER BY questions.sort ASC"; |
|
|
@ -1244,8 +1254,8 @@ class SurveyUtil |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { |
|
|
|
if ($row['type'] != 'pagebreak') { |
|
|
|
if ($row['number_of_options'] == 0 && $row['type'] == 'open') { |
|
|
|
if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) { |
|
|
|
$return .= str_replace( |
|
|
|
$return .= str_replace( |
|
|
|
"\r\n", |
|
|
|
"\r\n", |
|
|
|
' ', |
|
|
|
' ', |
|
|
@ -1265,11 +1275,10 @@ class SurveyUtil |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$return .= "\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$return .= "\n"; |
|
|
|
// Getting all the questions and options |
|
|
|
// Getting all the questions and options |
|
|
|
$return .= ';'; |
|
|
|
$return .= ';'; |
|
|
|
|
|
|
|
|
|
|
|
// Show the fields names for user fields |
|
|
|
// Show the fields names for user fields |
|
|
|
if (!empty($extra_user_fields)) { |
|
|
|
if (!empty($extra_user_fields)) { |
|
|
|
foreach ($extra_user_fields as &$field) { |
|
|
|
foreach ($extra_user_fields as &$field) { |
|
|
@ -1297,9 +1306,9 @@ class SurveyUtil |
|
|
|
LEFT JOIN $table_survey_question_option survey_question_option |
|
|
|
LEFT JOIN $table_survey_question_option survey_question_option |
|
|
|
ON |
|
|
|
ON |
|
|
|
survey_question.question_id = survey_question_option.question_id AND |
|
|
|
survey_question.question_id = survey_question_option.question_id AND |
|
|
|
survey_question_option.c_id = $course_id |
|
|
|
survey_question_option.c_id = survey_question.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
survey_question.survey_id = '".intval($_GET['survey_id'])."' AND |
|
|
|
survey_question.survey_id = '".$surveyId."' AND |
|
|
|
survey_question.c_id = $course_id |
|
|
|
survey_question.c_id = $course_id |
|
|
|
ORDER BY survey_question.sort ASC, survey_question_option.sort ASC"; |
|
|
|
ORDER BY survey_question.sort ASC, survey_question_option.sort ASC"; |
|
|
|
$result = Database::query($sql); |
|
|
|
$result = Database::query($sql); |
|
|
@ -1315,7 +1324,7 @@ class SurveyUtil |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { |
|
|
|
if ($row['type'] != 'pagebreak') { |
|
|
|
$row['option_text'] = str_replace(["\r", "\n"], ['', ''], $row['option_text']); |
|
|
|
$row['option_text'] = str_replace(["\r", "\n"], ['', ''], $row['option_text']); |
|
|
|
$return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';'; |
|
|
|
$return .= api_html_entity_decode(strip_tags($row['option_text']), ENT_QUOTES).';'; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
|
$possible_answers[$row['question_id']][$row['question_option_id']] = $row['question_option_id']; |
|
|
@ -1329,7 +1338,7 @@ class SurveyUtil |
|
|
|
$old_user = ''; |
|
|
|
$old_user = ''; |
|
|
|
$answers_of_user = []; |
|
|
|
$answers_of_user = []; |
|
|
|
$sql = "SELECT * FROM $table_survey_answer |
|
|
|
$sql = "SELECT * FROM $table_survey_answer |
|
|
|
WHERE c_id = $course_id AND survey_id='".intval($_GET['survey_id'])."'"; |
|
|
|
WHERE c_id = $course_id AND survey_id='".$surveyId."'"; |
|
|
|
if ($user_id != 0) { |
|
|
|
if ($user_id != 0) { |
|
|
|
$sql .= "AND user='".Database::escape_string($user_id)."' "; |
|
|
|
$sql .= "AND user='".Database::escape_string($user_id)."' "; |
|
|
|
} |
|
|
|
} |
|
|
@ -1348,7 +1357,9 @@ class SurveyUtil |
|
|
|
); |
|
|
|
); |
|
|
|
$answers_of_user = []; |
|
|
|
$answers_of_user = []; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($possible_answers_type[$row['question_id']] == 'open') { |
|
|
|
if ($possible_answers_type[$row['question_id']] == 'open' || |
|
|
|
|
|
|
|
$possible_answers_type[$row['question_id']] == 'comment' |
|
|
|
|
|
|
|
) { |
|
|
|
$temp_id = 'open'.$open_question_iterator; |
|
|
|
$temp_id = 'open'.$open_question_iterator; |
|
|
|
$answers_of_user[$row['question_id']][$temp_id] = $row; |
|
|
|
$answers_of_user[$row['question_id']][$temp_id] = $row; |
|
|
|
$open_question_iterator++; |
|
|
|
$open_question_iterator++; |
|
|
@ -1516,7 +1527,7 @@ class SurveyUtil |
|
|
|
count(options.question_option_id) as number_of_options |
|
|
|
count(options.question_option_id) as number_of_options |
|
|
|
FROM $table_survey_question questions |
|
|
|
FROM $table_survey_question questions |
|
|
|
LEFT JOIN $table_survey_question_option options |
|
|
|
LEFT JOIN $table_survey_question_option options |
|
|
|
ON questions.question_id = options.question_id AND options.c_id = $course_id |
|
|
|
ON questions.question_id = options.question_id AND options.c_id = questions.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
questions.survey_id = $surveyId AND |
|
|
|
questions.survey_id = $surveyId AND |
|
|
|
questions.c_id = $course_id |
|
|
|
questions.c_id = $course_id |
|
|
@ -1532,8 +1543,8 @@ class SurveyUtil |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { |
|
|
|
if ($row['type'] != 'pagebreak') { |
|
|
|
if ($row['number_of_options'] == 0 && $row['type'] == 'open') { |
|
|
|
if ($row['number_of_options'] == 0 && ($row['type'] == 'open' || $row['type'] == 'comment')) { |
|
|
|
$worksheet->setCellValueByColumnAndRow( |
|
|
|
$worksheet->setCellValueByColumnAndRow( |
|
|
|
$column, |
|
|
|
$column, |
|
|
|
$line, |
|
|
|
$line, |
|
|
@ -1590,7 +1601,7 @@ class SurveyUtil |
|
|
|
LEFT JOIN $table_survey_question_option survey_question_option |
|
|
|
LEFT JOIN $table_survey_question_option survey_question_option |
|
|
|
ON |
|
|
|
ON |
|
|
|
survey_question.question_id = survey_question_option.question_id AND |
|
|
|
survey_question.question_id = survey_question_option.question_id AND |
|
|
|
survey_question_option.c_id = $course_id |
|
|
|
survey_question_option.c_id = survey_question.c_id |
|
|
|
WHERE |
|
|
|
WHERE |
|
|
|
survey_question.survey_id = $surveyId AND |
|
|
|
survey_question.survey_id = $surveyId AND |
|
|
|
survey_question.c_id = $course_id |
|
|
|
survey_question.c_id = $course_id |
|
|
@ -1607,7 +1618,7 @@ class SurveyUtil |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
in_array($row['question_id'], $_POST['questions_filter'])) |
|
|
|
) { |
|
|
|
) { |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
// We do not show comment and pagebreak question types |
|
|
|
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') { |
|
|
|
if ($row['type'] != 'pagebreak') { |
|
|
|
$worksheet->setCellValueByColumnAndRow( |
|
|
|
$worksheet->setCellValueByColumnAndRow( |
|
|
|
$column, |
|
|
|
$column, |
|
|
|
$line, |
|
|
|
$line, |
|
|
@ -1654,7 +1665,7 @@ class SurveyUtil |
|
|
|
$line++; |
|
|
|
$line++; |
|
|
|
$column = 0; |
|
|
|
$column = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($possible_answers_type[$row['question_id']] == 'open') { |
|
|
|
if ($possible_answers_type[$row['question_id']] == 'open' || $possible_answers_type[$row['question_id']] == 'comment') { |
|
|
|
$temp_id = 'open'.$open_question_iterator; |
|
|
|
$temp_id = 'open'.$open_question_iterator; |
|
|
|
$answers_of_user[$row['question_id']][$temp_id] = $row; |
|
|
|
$answers_of_user[$row['question_id']][$temp_id] = $row; |
|
|
|
$open_question_iterator++; |
|
|
|
$open_question_iterator++; |
|
|
|