Skip to content
Permalink
Browse files

Add survey_anonymous_show_answered conf settings - refs BT#15280

Allow show answers in anonymous surveys
  • Loading branch information...
AngelFQC committed Mar 12, 2019
1 parent affe7dd commit 89cbc14cd0324f6be262bdaf618838b305ea86e3
Showing with 14 additions and 2 deletions.
  1. +2 −0 main/install/configuration.dist.php
  2. +9 −0 main/survey/survey.lib.php
  3. +3 −2 main/survey/survey_invitation.php
@@ -525,6 +525,8 @@
// Allow add additional actions (as links) in survey list for teachers.
// e.g. ['myplugin' => ['MyPlugin', 'urlGeneratorCallback']]
//$_configuration['survey_additional_teacher_modify_actions'] = [];
// Allow show answers in anonymous surveys
//$_configuration['survey_anonymous_show_answered'] = false;
// ------
// Allow career diagram, requires a DB change:
@@ -1790,6 +1790,15 @@ public static function get_people_who_filled_survey(
} else {
$sql = "SELECT DISTINCT user FROM $table_survey_answer
WHERE c_id = $course_id AND survey_id= '".$survey_id."' ";
if (api_get_configuration_value('survey_anonymous_show_answered')) {
$tblInvitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$tblSurvey = Database::get_course_table(TABLE_SURVEY);
$sql = "SELECT i.user FROM $tblInvitation i
INNER JOIN $tblSurvey s ON i.survey_code = s.code
WHERE i.answered IS TRUE AND s.iid = $survey_id";
}
}
$res = Database::query($sql);
@@ -55,7 +55,7 @@
// Getting all the people who have filled this survey
$answered_data = SurveyManager::get_people_who_filled_survey($survey_id);
if ($survey_data['anonymous'] == 1) {
if ($survey_data['anonymous'] == 1 && !api_get_configuration_value('survey_anonymous_show_answered')) {
echo Display::return_message(
get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count(
$answered_data
@@ -122,7 +122,8 @@
echo ' <td>'.Display::dateToStringAgoAndLongDate($row['invitation_date']).'</td>';
echo ' <td>';
if (in_array($row['user'], $answered_data) && !api_get_configuration_value('hide_survey_reporting_button')) {
if (in_array($row['user'], $answered_data) && !api_get_configuration_value('hide_survey_reporting_button') &&
!api_get_configuration_value('survey_anonymous_show_answered')) {
echo '<a href="'.
api_get_path(WEB_CODE_PATH).
'survey/reporting.php?action=userreport&survey_id='.$survey_id.'&user='.$row['user'].'&'.api_get_cidreq().'">'.

0 comments on commit 89cbc14

Please sign in to comment.
You can’t perform that action at this time.