Browse Source

Merge 1.9.x

Julio Montoya 10 years ago
parent
commit
923f0eba84
2 changed files with 24 additions and 11 deletions
  1. 19 8
      main/survey/reporting.php
  2. 5 3
      main/survey/survey.lib.php

+ 19 - 8
main/survey/reporting.php

@@ -79,8 +79,13 @@ $people_filled = survey_manager::get_people_who_filled_survey(
 SurveyUtil::check_parameters($people_filled);
 
 $survey_data = survey_manager::get_survey($survey_id);
+
+$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)) {
+if (!api_is_allowed_to_edit(false, true) || $isDrhOfCourse) {
 	Display :: display_header(get_lang('ToolSurvey'));
     // Show error message if the survey can be seen only by tutors
     if ($survey_data['visible_results'] != SURVEY_VISIBLE_TUTOR) {
@@ -151,13 +156,19 @@ 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;'.$cidReq.'&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;'.$cidReq.'&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;'.$cidReq.'&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;'.$cidReq.'&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.'&'.api_get_cidreq().'">'.
+        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.'&'.api_get_cidreq().'">'.
+        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.'&'.api_get_cidreq().'">'.
+        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.'&'.api_get_cidreq().'">'.
+        Display::return_icon('survey_reporting_complete.gif',get_lang('CompleteReport')).' '.get_lang('CompleteReport').'</a></div><div class="sectioncomment">'.get_lang('CompleteReportDetail').'</div>';
 }
 
 // Footer

+ 5 - 3
main/survey/survey.lib.php

@@ -857,11 +857,12 @@ class survey_manager
         $tbl_survey_question 			= Database :: get_course_table(TABLE_SURVEY_QUESTION);
         $table_survey_question_option 	= Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
 
-        if (empty($course_id))
-        {
+        if (empty($course_id)) {
             $course_id = api_get_course_int_id();
         }
 
+        $return = array();
+
         // Getting the information of the question
         $sql = "SELECT * FROM $tbl_survey_question
 		        WHERE c_id = $course_id AND survey_id='".intval($survey_id)."'";
@@ -1715,8 +1716,9 @@ class SurveyUtil
         $temp_questions_data = survey_manager::get_questions($_GET['survey_id']);
 
         // Sorting like they should be displayed and removing the non-answer question types (comment and pagebreak)
-        $my_temp_questions_data = ($temp_questions_data==null) ? array() : $temp_questions_data;
+        $my_temp_questions_data = $temp_questions_data == null ? array() : $temp_questions_data;
         $questions_data = array();
+
         foreach ($my_temp_questions_data as $key => & $value) {
             if ($value['type'] != 'comment' && $value['type'] != 'pagebreak') {
                 $questions_data[$value['sort']] = $value;