Skip to content

Commit

Permalink
Fix mandatory surveys - refs BT#12915
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jul 5, 2017
1 parent f5df218 commit 379b295
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
23 changes: 18 additions & 5 deletions main/survey/fillsurvey.php
Expand Up @@ -17,8 +17,6 @@
$_cid = $_GET['cidReq'];
}

$fillingSurvey = true;

// Including the global initialization file
require_once '../inc/global.inc.php';

Expand Down Expand Up @@ -167,7 +165,13 @@
} else {
// Header
Display :: display_header(get_lang('ToolSurvey'));
echo '<form id="language" name="language" method="POST" action="'.api_get_self().'?course='.Security::remove_XSS($_GET['course']).'&invitationcode='.Security::remove_XSS($_GET['invitationcode']).'&cidReq='.Security::remove_XSS($_GET['cidReq']).'">';
$frmLangUrl = api_get_self().'?'.api_get_cidreq().'&'
.http_build_query([
'course' => Security::remove_XSS($_GET['course']),
'invitationcode' => Security::remove_XSS($_GET['invitationcode'])
]);

echo '<form id="language" name="language" method="POST" action="'.$frmLangUrl.'">';
echo '<select name="language">';
while ($row = Database::fetch_array($result, 'ASSOC')) {
echo '<option value="'.$row['survey_id'].'">'.$row['lang'].'</option>';
Expand Down Expand Up @@ -364,7 +368,8 @@
$form = new FormValidator(
'profile',
'post',
api_get_self()."?".str_replace('&show_form=1', '&show_form=1', Security::remove_XSS($_SERVER['QUERY_STRING']))
api_get_self()."?".api_get_cidreq().'&'
.str_replace('&show_form=1', '&show_form=1', Security::remove_XSS($_SERVER['QUERY_STRING']))
);

if (api_is_western_name_order()) {
Expand Down Expand Up @@ -586,6 +591,14 @@

SurveyUtil::flagSurveyAsAnswered($survey_invitation['survey_code'], $survey_invitation['c_id']);

if ($course_info) {
echo Display::toolbarButton(
get_lang('ReturnToCourseHomepage'),
api_get_course_url($course_info['code']),
'home'
);
}

unset($_SESSION['paged_questions']);
unset($_SESSION['page_questions_sec']);
Display :: display_footer();
Expand Down Expand Up @@ -1178,7 +1191,7 @@

$add_parameters = isset($_GET['user_id']) ? 'user_id='.intval($_GET['user_id']).'&amp;' : '';

$url = api_get_self().'?'.$add_parameters.'course='.$g_c.'&invitationcode='.$g_ic.'&show='.$show.'&cidReq='.$g_cr;
$url = api_get_self().'?'.api_get_cidreq().'&'.$add_parameters.'course='.$g_c.'&invitationcode='.$g_ic.'&show='.$show;
$form = new FormValidator('question', 'post', $url);
$form->addHidden('language', $p_l);

Expand Down
4 changes: 2 additions & 2 deletions main/survey/survey.lib.php
Expand Up @@ -1693,7 +1693,7 @@ public static function generate_survey_link($survey_id, $course_id, $session_id,
*/
public static function protectByMandatory()
{
if (isset($GLOBALS['fillingSurvey']) && $GLOBALS['fillingSurvey']) {
if (strpos($_SERVER['SCRIPT_NAME'], 'fillsurvey.php') !== false) {
return;
}

Expand Down Expand Up @@ -1752,7 +1752,7 @@ public static function protectByMandatory()
Display::return_message(get_lang('MandatorySurveyNoAnswered'), 'warning')
);

header('Location: '.api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?'.$urlParams);
header('Location: '.api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?'.$urlParams.'&'.api_get_cidreq());
exit;
}
}
Expand Down

0 comments on commit 379b295

Please sign in to comment.