Survey: Show page break text as the new page's introduction section - refs BT#16553

pull/3433/head
Yannick Warnier 5 years ago
parent 1717ea24b9
commit fe2796ddc1
  1. 18
      main/survey/fillsurvey.php
  2. 15
      main/survey/preview.php

@ -676,6 +676,7 @@ if (1 == $survey_data['shuffle']) {
$shuffle = ' BY RAND() ';
}
$pageBreakText = [];
if ((isset($_GET['show']) && $_GET['show'] != '') ||
isset($_POST['personality'])
) {
@ -711,6 +712,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') ||
} else {
if ($row['type'] === 'pagebreak') {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
$paged_questions[$counter][] = $row['question_id'];
}
@ -1030,6 +1032,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') ||
$counter++;
} elseif ($row['type'] == 'pagebreak') {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
// ids from question of the current survey
$paged_questions_sec[$counter][] = $row['question_id'];
@ -1134,6 +1137,7 @@ if ((isset($_GET['show']) && $_GET['show'] != '') ||
} else {
if ($row['type'] == 'pagebreak') {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
// ids from question of the current survey
$paged_questions[$counter][] = $row['question_id'];
@ -1288,6 +1292,18 @@ if (isset($questions) && is_array($questions)) {
$form->addHtml('<div class="start-survey">');
$js = '';
if (isset($pageBreakText[$originalShow]) && !empty(strip_tags($pageBreakText[$originalShow]))) {
// Only show page-break texts if there is something there, apart from
// HTML tags
$form->addHtml(
'<div>'.
Security::remove_XSS($pageBreakText[$originalShow]).
'</div>'
);
$form->addHtml('<br />');
}
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
$questionNumber = $questionCounter;
@ -1312,7 +1328,7 @@ if (isset($questions) && is_array($questions)) {
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$questionNumber.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div>');
$userAnswerData = SurveyUtil::get_answers_of_question_by_user($question['survey_id'], $question['question_id']);
$finalAnswer = null;

@ -76,6 +76,7 @@ if (isset($_POST['finish_survey'])) {
}
$questions = [];
$pageBreakText = [];
if (isset($_GET['show'])) {
// Getting all the questions for this page and add them to a
// multidimensional array where the first index is the page.
@ -101,6 +102,7 @@ if (isset($_GET['show'])) {
} else {
if ('pagebreak' === $row['type']) {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
$paged_questions[$counter][] = $row['question_id'];
}
@ -197,6 +199,17 @@ if (is_array($questions) && count($questions) > 0) {
}
$js = '';
if (isset($pageBreakText[$originalShow]) && !empty(strip_tags($pageBreakText[$originalShow]))) { // Only show page-break texts if there is something there, apart from
// HTML tags
$form->addHtml(
'<div>'.
Security::remove_XSS($pageBreakText[$originalShow]).
'</div>'
);
$form->addHtml('<br />');
}
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
$display = survey_question::createQuestion($question['type']);
@ -219,7 +232,7 @@ if (is_array($questions) && count($questions) > 0) {
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$counter.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div>');
$display->render($form, $question);
$form->addHtml('</div>');
$counter++;

Loading…
Cancel
Save