Browse Source

Merge pull request #255 from danbarretodev/6829

Fix anonymous surveys -refs #6829
Yannick Warnier 11 years ago
parent
commit
73f7341726
2 changed files with 9 additions and 7 deletions
  1. 8 6
      main/survey/fillsurvey.php
  2. 1 1
      main/survey/survey.lib.php

+ 8 - 6
main/survey/fillsurvey.php

@@ -44,8 +44,12 @@ $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION)
 
 $table_user = Database :: get_main_table(TABLE_MAIN_USER);
 
-// We initialize test as private (not anonymous):
-$isAnonymous = false;
+// Check if user is anonymous or not
+if (api_is_anonymous($_user['user_id'], true)) {
+    $isAnonymous = true;
+} else {
+    $isAnonymous = false;
+}
 
 // getting all the course information
 if (isset($_GET['course'])) {
@@ -72,9 +76,7 @@ if ($surveyCode != "") {
     } 
 // If is anonymous and it is allowed to take the survey as anonymous, mark survey as anonymous:
 } else {
-    if (api_is_anonymous($_user['user_id'], true)) {
-        $isAnonymous = true;
-    }
+    //nothing to do
 } 
 
 // Header
@@ -134,7 +136,7 @@ if (Database::num_rows($result) < 1) {
 $survey_invitation = Database::fetch_array($result, 'ASSOC');
 
 // Now we check if the user already filled the survey
-if ($survey_invitation['answered'] == 1 && !isset($_GET['user_id'])) {
+if ($isAnonymous && isset($_SESSION['surveyuser']) || ($survey_invitation['answered'] == 1 && !isset($_GET['user_id']))) {
     Display :: display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false);
     Display :: display_footer();
     exit;

+ 1 - 1
main/survey/survey.lib.php

@@ -3105,7 +3105,7 @@ class SurveyUtil {
 				echo '<th>'.$user.'</th>'; // the user column
 			}
 		} else {
-			echo '<th>-</th>';
+			echo '<th>' . get_lang('Anonymous') . '</th>';
 		}
 
 		if ($display_extra_user_fields) {