Add config survey_answered_at_field see BT#12909

Requires DB change:

ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL;
pull/2487/head
jmontoyaa 8 years ago
parent b29e0ac635
commit 2f14ce19ab
  1. 5
      main/install/configuration.dist.php
  2. 11
      main/survey/survey.lib.php

@ -448,4 +448,7 @@ $_configuration['agenda_legend'] = [
// information the browser includes with navigation away from a document
// and should be set by all sites.
//$_configuration['security_referrer_policy'] = 'origin-when-cross-origin';
// HTTP headers security section ends here
// HTTP headers security section ends here
// Add answered_at field in table survey_invitation
//$_configuration['survey_answered_at_field'] = 'false';

@ -828,9 +828,18 @@ class SurveyManager
survey_id = ".intval($survey_id);
Database::query($sql);
$allow = api_get_configuration_value('survey_answered_at_field');
// Requires DB change:
// ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL;
$answeredAt = '';
if ($allow) {
$answeredAt = " answered_at = '".api_get_utc_datetime()."' AND";
}
// Storing that the user has finished the survey.
$sql = "UPDATE $table_survey_invitation SET answered='1'
WHERE
$answeredAt
c_id = $course_id AND
session_id='".$session_id."' AND
user='".Database::escape_string($user)."' AND
@ -1714,4 +1723,4 @@ class SurveyManager
$code = self::generate_survey_hash($survey_id, $course_id, $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;
}
}
}

Loading…
Cancel
Save