Add survey results visibility - refs BT#9068

1.10.x
Imanol Losada 10 years ago
parent 9bb3e1377a
commit c0f8152a3c
  1. 5
      main/inc/lib/main_api.lib.php
  2. 7
      main/survey/create_new_survey.php
  3. 11
      main/survey/reporting.php
  4. 7
      main/survey/survey.lib.php

@ -81,6 +81,11 @@ define('SUBSCRIBE_NOT_ALLOWED', 0);
define('UNSUBSCRIBE_ALLOWED', 1);
define('UNSUBSCRIBE_NOT_ALLOWED', 0);
// SURVEY VISIBILITY CONSTANTS
define('SURVEY_VISIBLE_TUTOR', 0);
define('SURVEY_VISIBLE_TUTOR_STUDENT', 1);
define('SURVEY_VISIBLE_PUBLIC', 2);
// CONSTANTS defining all tools, using the english version
/* When you add a new tool you must add it into function api_get_tools_lists() too */
define('TOOL_DOCUMENT','document');

@ -147,6 +147,13 @@ $form->addElement('date_picker', 'start_date', get_lang('StartDate'));
$form->addElement('date_picker', 'end_date', get_lang('EndDate'));
$form->addElement('checkbox', 'anonymous', null, get_lang('Anonymous'));
$visibleResults = array(
SURVEY_VISIBLE_TUTOR => get_lang('Coach'),
SURVEY_VISIBLE_TUTOR_STUDENT => get_lang('Coach').' '.get_lang('And').' '.get_lang('Student'),
SURVEY_VISIBLE_PUBLIC => get_lang('Everyone')
);
$form->addElement('select', 'visible_results', get_lang('ResultsVisibility'), $visibleResults);
//$defaults['visible_results'] = 0;
$form->addElement('html_editor', 'survey_introduction', get_lang('SurveyIntroduction'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));
$form->addElement('html_editor', 'survey_thanks', get_lang('SurveyThanks'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false));

@ -70,11 +70,16 @@ $people_filled = survey_manager::get_people_who_filled_survey(
// Checking the parameters
SurveyUtil::check_parameters($people_filled);
$survey_data = survey_manager::get_survey($survey_id);
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false, true)) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
// Show error message if the survey can be seen only by tutors
if ($survey_data['visible_results'] != SURVEY_VISIBLE_TUTOR) {
SurveyUtil::handle_reporting_actions($survey_data, $people_filled);
} else {
Display :: display_error_message(get_lang('NotAllowed'), false);
}
Display :: display_footer();
exit;
}
@ -85,7 +90,7 @@ $table_user = Database :: get_main_table(TABLE_MAIN_USER);
// Getting the survey information
$survey_data = survey_manager::get_survey($survey_id);
//$survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('InvallidSurvey'), false);

@ -322,6 +322,7 @@ class survey_manager
'".Database::escape_string($values['survey_thanks'])."',
'".api_get_utc_datetime()."',
'".Database::escape_string($values['anonymous'])."'".$additional['values'].",
'".Database::escape_string($values['visible_results'])."',
".api_get_session_id()."
)";
Database::query($sql);
@ -403,7 +404,8 @@ class survey_manager
template = '".Database::escape_string('template')."',
intro = '".Database::escape_string($values['survey_introduction'])."',
surveythanks = '".Database::escape_string($values['survey_thanks'])."',
anonymous = '".Database::escape_string($values['anonymous'])."'".$additionalsets."
anonymous = '".Database::escape_string($values['anonymous'])."'".$additionalsets.",
visible_results = '".Database::escape_string($values['visible_results'])."'
WHERE c_id = $course_id AND survey_id = '".Database::escape_string($values['survey_id'])."'";
Database::query($sql);
@ -4979,7 +4981,8 @@ class SurveyUtil
if ($row['answered'] == 0) {
echo '<td><a href="'.api_get_path(WEB_CODE_PATH).'survey/fillsurvey.php?course='.$_course['sysCode'].'&amp;invitationcode='.$row['invitation_code'].'&amp;cidReq='.$_course['sysCode'].'">'.$row['title'].'</a></td>';
} else {
echo '<td>'.$row['title'].'</td>';
//echo '<td>'.$row['title'].'</td>';
echo '<td><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=questionreport&amp;cidReq='.$_course['sysCode'].'&amp;id_session='.$row['session_id'].'&amp;gidReq='.'0'.'&amp;origin='.''.'&amp;survey_id='.$row['survey_id'].'">'.$row['title'].'</a></td>';
}
echo '<td>';
echo ($row['anonymous'] == 1) ? get_lang('Yes') : get_lang('No');

Loading…
Cancel
Save