Add survey_anonymous_show_answered conf settings - refs BT#15280

Allow show answers in anonymous surveys
pull/2858/head
Angel Fernando Quiroz Campos 7 years ago
parent affe7dd8c7
commit 89cbc14cd0
  1. 2
      main/install/configuration.dist.php
  2. 9
      main/survey/survey.lib.php
  3. 5
      main/survey/survey_invitation.php

@ -525,6 +525,8 @@ ALTER TABLE c_survey_question ADD is_required TINYINT(1) DEFAULT 0 NOT NULL;
// 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 @@ class SurveyManager
} 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 @@ Display::display_header($tool_name);
// 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 @@ while ($row = Database::fetch_assoc($res)) {
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().'">'.

Loading…
Cancel
Save