Adding DRH support for the survey tool see #7064

1.9.x
Julio Montoya 12 years ago
parent 3adf5c2d57
commit 0a64437eed
  1. 144
      main/survey/reporting.php
  2. 131
      main/survey/survey.lib.php
  3. 13
      main/survey/survey.php
  4. 39
      main/survey/survey_list.php

@ -25,36 +25,43 @@ $survey_data = survey_manager::get_survey($survey_id);
* @todo use export_table_csv($data, $filename = 'export')
*/
if (isset($_POST['export_report']) && $_POST['export_report']) {
switch ($_POST['export_format']) {
case 'xls':
$filename = 'survey_results_'.$survey_id.'.xls';
$data = SurveyUtil::export_complete_report_xls($survey_data, $filename, $_GET['user_id']);
exit;
break;
case 'csv':
default:
$data = SurveyUtil::export_complete_report($survey_data, $_GET['user_id']);
$filename = 'survey_results_'.$survey_id.'.csv';
header('Content-type: application/octet-stream');
header('Content-Type: application/force-download');
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename= '.$filename);
} else {
header('Content-Disposition: attachment; filename= '.$filename);
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: ');
header('Cache-Control: ');
header('Cache-Control: public'); // IE cannot download from sessions without a cache
}
header('Content-Description: '.$filename);
header('Content-transfer-encoding: binary');
echo $data;
exit;
break;
}
switch ($_POST['export_format']) {
case 'xls':
$filename = 'survey_results_'.$survey_id.'.xls';
$data = SurveyUtil::export_complete_report_xls(
$survey_data,
$filename,
$_GET['user_id']
);
exit;
break;
case 'csv':
default:
$data = SurveyUtil::export_complete_report(
$survey_data,
$_GET['user_id']
);
$filename = 'survey_results_'.$survey_id.'.csv';
header('Content-type: application/octet-stream');
header('Content-Type: application/force-download');
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename= '.$filename);
} else {
header('Content-Disposition: attachment; filename= '.$filename);
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: ');
header('Cache-Control: ');
header('Cache-Control: public'); // IE cannot download from sessions without a cache
}
header('Content-Description: '.$filename);
header('Content-transfer-encoding: binary');
echo $data;
exit;
break;
}
}
if ($survey_data['anonymous'] == 0) {
@ -70,57 +77,63 @@ $people_filled = survey_manager::get_people_who_filled_survey(
// Checking the parameters
SurveyUtil::check_parameters($people_filled);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
/** @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);
Display :: display_footer();
exit;
if (!(api_is_allowed_to_edit(false, true) || $isDrhOfCourse)) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
exit;
}
// Database table definitions
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_course = Database:: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database:: get_main_table(TABLE_MAIN_USER);
// Getting the survey information
$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);
Display :: display_footer();
exit;
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('InvallidSurvey'), false);
Display :: display_footer();
exit;
}
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
$urlname .= '...';
}
// Breadcrumbs
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname);
if (!isset($_GET['action']) || isset($_GET['action']) && $_GET['action'] == 'overview') {
$tool_name = get_lang('Reporting');
$tool_name = get_lang('Reporting');
} else {
$interbreadcrumb[] = array(
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$survey_id,
'name' => get_lang('Reporting')
);
switch ($_GET['action']) {
case 'questionreport':
$tool_name = get_lang('DetailedReportByQuestion');
break;
case 'userreport':
$tool_name = get_lang('DetailedReportByUser');
break;
case 'comparativereport':
$tool_name = get_lang('ComparativeReport');
break;
case 'completereport':
$tool_name = get_lang('CompleteReport');
break;
}
switch ($_GET['action']) {
case 'questionreport':
$tool_name = get_lang('DetailedReportByQuestion');
break;
case 'userreport':
$tool_name = get_lang('DetailedReportByUser');
break;
case 'comparativereport':
$tool_name = get_lang('ComparativeReport');
break;
case 'completereport':
$tool_name = get_lang('CompleteReport');
break;
}
}
// Displaying the header
@ -136,12 +149,15 @@ echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$sur
echo '</div>';
// Content
if (!isset($_GET['action']) || isset($_GET['action']) && $_GET['action'] == 'overview') {
$myweb_survey_id = $survey_id;
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=questionreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_question.gif',get_lang('DetailedReportByQuestion')).' '.get_lang('DetailedReportByQuestion').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByQuestionDetail').' </div>';
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_user.gif',get_lang('DetailedReportByUser')).' '.get_lang('DetailedReportByUser').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByUserDetail').'.</div>';
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=comparativereport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_comparative.gif',get_lang('ComparativeReport')).' '.get_lang('ComparativeReport').'</a></div><div class="sectioncomment">'.get_lang('ComparativeReportDetail').'.</div>';
echo '<div class="sectiontitle"><a href="reporting.php?action=completereport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_complete.gif',get_lang('CompleteReport')).' '.get_lang('CompleteReport').'</a></div><div class="sectioncomment">'.get_lang('CompleteReportDetail').'</div>';
if (!isset($_GET['action']) ||
isset($_GET['action']) &&
$_GET['action'] == 'overview'
) {
$myweb_survey_id = $survey_id;
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=questionreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_question.gif',get_lang('DetailedReportByQuestion')).' '.get_lang('DetailedReportByQuestion').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByQuestionDetail').' </div>';
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_user.gif',get_lang('DetailedReportByUser')).' '.get_lang('DetailedReportByUser').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByUserDetail').'.</div>';
echo '<div class="sectiontitle"><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=comparativereport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_comparative.gif',get_lang('ComparativeReport')).' '.get_lang('ComparativeReport').'</a></div><div class="sectioncomment">'.get_lang('ComparativeReportDetail').'.</div>';
echo '<div class="sectiontitle"><a href="reporting.php?action=completereport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_complete.gif',get_lang('CompleteReport')).' '.get_lang('CompleteReport').'</a></div><div class="sectioncomment">'.get_lang('CompleteReportDetail').'</div>';
}
// Footer

@ -2454,14 +2454,12 @@ class ch_score extends survey_question
}
}
/**
* This class offers a series of general utility functions for survey querying and display
* @package chamilo.survey
*/
class SurveyUtil
{
/**
* Checks whether the given survey has a pagebreak question as the first or the last question.
* If so, break the current process, displaying an error message
@ -2723,14 +2721,20 @@ class SurveyUtil
// Actions bar
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
if (isset($_GET['user'])) {
// The delete link
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=deleteuserreport&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;user='.Security::remove_XSS($_GET['user']).'" >'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_edit()) {
// The delete link
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=deleteuserreport&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;user='.Security::remove_XSS($_GET['user']).'" >'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_MEDIUM).'</a>';
}
// Export the user report
echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
echo '<a href="javascript: void(0);" onclick="document.form1a.submit();">'.
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
echo '<a href="javascript: void(0);" onclick="document.form1b.submit();">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
echo '<form id="form1a" name="form1a" method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user_id='.Security::remove_XSS($_GET['user']).'">';
echo '<input type="hidden" name="export_report" value="export_report">';
echo '<input type="hidden" name="export_format" value="csv">';
@ -2867,7 +2871,7 @@ class SurveyUtil
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version February 2007 - Updated March 2008
*/
function display_question_report($survey_data)
public static function display_question_report($survey_data)
{
$course_id = api_get_course_int_id();
// Database table definitions
@ -2882,8 +2886,11 @@ class SurveyUtil
$offset = Database::escape_string($_GET['question']);
}
$currentQuestion = isset($_GET['question']) ? $_GET['question'] : 0;
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
if ($survey_data['number_of_questions'] > 0) {
@ -2912,13 +2919,13 @@ class SurveyUtil
$question = Database::fetch_array($result);
// Navigate through the questions (next and previous)
if ($_GET['question'] != 0) {
if ($currentQuestion != 0 ) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.$_GET['survey_id'].'&amp;question='.Security::remove_XSS($offset-1).'">'.Display::return_icon('action_prev.png', get_lang('PreviousQuestion'), array('align' => 'middle')).' '.get_lang('PreviousQuestion').'</a> ';
} else {
echo Display::return_icon('action_prev.png', get_lang('PreviousQuestion'), array('align' => 'middle')).' '.get_lang('PreviousQuestion').' ';
}
echo ' | ';
if ($_GET['question'] < ($survey_data['number_of_questions'] - 1)) {
if ($currentQuestion < ($survey_data['number_of_questions'] - 1)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;question='.Security::remove_XSS($offset+1).'">'.get_lang('NextQuestion').' '.Display::return_icon('action_next.png', get_lang('NextQuestion'), array('align' => 'middle')).'</a>';
} else {
echo get_lang('NextQuestion').' '.Display::return_icon('action_next.png', get_lang('NextQuestion'), array('align' => 'middle'));
@ -2954,17 +2961,19 @@ class SurveyUtil
}
// Getting the answers
$sql = "SELECT *, count(answer_id) as total FROM $table_survey_answer
WHERE c_id = $course_id AND
survey_id='".Database::escape_string($_GET['survey_id'])."' AND
question_id = '".Database::escape_string($question['question_id'])."'
GROUP BY option_id, value";
WHERE
c_id = $course_id AND
survey_id='".Database::escape_string($_GET['survey_id'])."' AND
question_id = '".Database::escape_string($question['question_id'])."'
GROUP BY option_id, value";
$result = Database::query($sql);
$number_of_answers = 0;
$data = array();
while ($row = Database::fetch_array($result)) {
$number_of_answers += $row['total'];
$data[$row['option_id']] = $row;
}
// displaying the table: headers
echo '<table class="data_table">';
echo ' <tr>';
@ -2977,7 +2986,10 @@ class SurveyUtil
// Displaying the table: the content
if (is_array($options)) {
foreach ($options as $key => & $value) {
$absolute_number = $data[$value['question_option_id']]['total'];
$absolute_number = null;
if (isset($data[$value['question_option_id']])) {
$absolute_number = $data[$value['question_option_id']]['total'];
}
if ($question['type'] == 'percentage' && empty($absolute_number)) {
continue;
}
@ -3032,7 +3044,7 @@ class SurveyUtil
* @param integer The offset of results shown
* @return void (direct output)
*/
function display_question_report_score($survey_data, $question, $offset)
public static function display_question_report_score($survey_data, $question, $offset)
{
$course_id = api_get_course_int_id();
// Database table definitions
@ -3112,7 +3124,7 @@ class SurveyUtil
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version February 2007
*/
static function display_complete_report($survey_data)
public static function display_complete_report($survey_data)
{
// Database table definitions
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
@ -3428,7 +3440,10 @@ class SurveyUtil
// We show the questions if
// 1. there is no question filter and the export button has not been clicked
// 2. there is a quesiton filter but the question is selected for display
if (!($_POST['submit_question_filter']) || (is_array($_POST['questions_filter']) && in_array($row['question_id'], $_POST['questions_filter']))) {
if (!($_POST['submit_question_filter']) ||
(is_array($_POST['questions_filter']) &&
in_array($row['question_id'], $_POST['questions_filter']))
) {
// We do not show comment and pagebreak question types
if ($row['type'] != 'comment' && $row['type'] != 'pagebreak') {
if ($row['number_of_options'] == 0 && $row['type'] == 'open') {
@ -4468,6 +4483,32 @@ class SurveyUtil
echo '<div style="clear: both;margin-bottom: 10px;"></div>';
}
/**
* Show table only visible by DRH users
*/
public static function displaySurveyListForDrh()
{
$parameters = array();
$parameters['cidReq'] = api_get_course_id();
// Create a sortable table with survey-data
$table = new SortableTable('surveys', 'get_number_of_surveys', 'get_survey_data_drh', 2);
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false);
$table->set_header(1, get_lang('SurveyName'));
$table->set_header(2, get_lang('SurveyCode'));
$table->set_header(3, get_lang('NumberOfQuestions'));
$table->set_header(4, get_lang('Author'));
$table->set_header(5, get_lang('AvailableFrom'));
$table->set_header(6, get_lang('AvailableUntil'));
$table->set_header(7, get_lang('Invite'));
$table->set_header(8, get_lang('Anonymous'));
$table->set_header(9, get_lang('Modify'), false, 'width="150"');
$table->set_column_filter(8, 'anonymous_filter');
$table->set_column_filter(9, 'modify_filter_drh');
$table->display();
}
/**
* This function displays the sortable table with all the surveys
*
@ -4541,18 +4582,26 @@ class SurveyUtil
* This function changes the modify column of the sortable table
*
* @param integer $survey_id the id of the survey
* @return html code that are the actions that can be performed on any survey
* @param bool $drh
* @return string html code that are the actions that can be performed on any survey
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version January 2007
*/
static function modify_filter($survey_id)
static function modify_filter($survey_id, $drh = false)
{
$survey_id = Security::remove_XSS($survey_id);
$return = '';
if ($drh) {
return '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.
Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
}
// Coach can see that only if the survey is in his session
if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) {
if (api_is_allowed_to_edit() ||
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
) {
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=edit&amp;survey_id='.$survey_id.'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
if (survey_manager::survey_generation_hash_available()) {
$return .= Display::url(
@ -4560,15 +4609,26 @@ class SurveyUtil
api_get_path(WEB_CODE_PATH).'survey/generate_link.php?survey_id='.$survey_id.'&'.api_get_cidreq()
);
}
$return .= Display::url(Display::return_icon('copy.png', get_lang('DuplicateSurvey'), '', ICON_SIZE_SMALL), 'survey_list.php?action=copy_survey&survey_id='.$survey_id.'&'.api_get_cidreq());
$return .= Display::url(
Display::return_icon('copy.png', get_lang('DuplicateSurvey'), '', ICON_SIZE_SMALL),
'survey_list.php?action=copy_survey&survey_id='.$survey_id.'&'.api_get_cidreq()
);
$return .= ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=empty&amp;survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'.Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=empty&amp;survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("EmptySurvey").'?')).'\')) return false;">'.
Display::return_icon('clean.png', get_lang('EmptySurvey'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
}
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) {
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/preview.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.
Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invite.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.
Display::return_icon('mail_send.png', get_lang('Publish'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.
Display::return_icon('stats.png', get_lang('Reporting'),'',ICON_SIZE_SMALL).'</a>';
if (api_is_allowed_to_edit() ||
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
) {
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?', ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
}
return $return;
}
@ -4670,13 +4730,14 @@ class SurveyUtil
* @param int $number_of_items
* @param int $column
* @param string $direction
* @param bool $isDrh
* @return unknown
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya <gugli100@gmail.com>, Beeznest - Adding intvals
* @version January 2007
*/
static function get_survey_data($from, $number_of_items, $column, $direction)
static function get_survey_data($from, $number_of_items, $column, $direction, $isDrh = false)
{
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -4730,7 +4791,6 @@ class SurveyUtil
$surveys = array();
$array = array();
while ($survey = Database::fetch_array($res)) {
$array[0] = $survey[0];
$array[1] = Display::url(
$survey[1],
@ -4756,7 +4816,12 @@ class SurveyUtil
$array[8] = $survey[8];
$array[9] = $survey[9];
//$array[10] = $survey[10];
if ($isDrh) {
$array[1] = $survey[1];
$array[7] = strip_tags($array[7]);
}
$surveys[] = $array;
}
return $surveys;

@ -26,7 +26,18 @@ require_once 'survey.lib.php';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
if (!api_is_allowed_to_edit(false, true) || (api_is_course_coach() && $extend_rights_for_coachs == 'false')) {
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
if ($isDrhOfCourse) {
header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq());
exit;
}
if (!api_is_allowed_to_edit(false, true) ||
(api_is_course_coach() && $extend_rights_for_coachs == 'false')
) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();

@ -37,6 +37,19 @@ event_access_tool(TOOL_SURVEY);
* This has to be moved to a more appropriate place (after the display_header
* of the code)
*/
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
$courseInfo
);
if ($isDrhOfCourse) {
Display::display_header(get_lang('SurveyList'));
SurveyUtil::displaySurveyListForDrh();
Display::display_footer();
exit;
}
if (!api_is_allowed_to_edit(false, true)) {
// Coach can see this
Display::display_header(get_lang('SurveyList'));
@ -48,10 +61,10 @@ if (!api_is_allowed_to_edit(false, true)) {
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_survey = Database:: get_course_table(TABLE_SURVEY);
$table_survey_question = Database:: get_course_table(TABLE_SURVEY_QUESTION);
$table_course = Database:: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database:: get_main_table(TABLE_MAIN_USER);
// Language variables
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
@ -148,9 +161,11 @@ if (isset($_POST['action']) && $_POST['action']) {
echo '<div class="actions">';
if (!api_is_course_coach() || $extend_rights_for_coachs == 'true') {
// Action links
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'),'',ICON_SIZE_MEDIUM).'</a> ';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.
Display::return_icon('new_survey.png', get_lang('CreateNewSurvey'),'',ICON_SIZE_MEDIUM).'</a> ';
}
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.Display::return_icon('search.png', get_lang('Search'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.
Display::return_icon('search.png', get_lang('Search'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
// Load main content
@ -180,6 +195,11 @@ function modify_filter($survey_id)
return SurveyUtil::modify_filter($survey_id);
}
function modify_filter_drh($survey_id)
{
return SurveyUtil::modify_filter($survey_id, true);
}
function get_number_of_surveys_for_coach()
{
return SurveyUtil::get_number_of_surveys_for_coach();
@ -198,3 +218,10 @@ function anonymous_filter($anonymous)
{
return SurveyUtil::anonymous_filter($anonymous);
}
function get_survey_data_drh($from, $number_of_items, $column, $direction)
{
return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction, true);
}

Loading…
Cancel
Save