]> git.mjollnir.org Git - moodle.git/commitdiff
Fix for Bug 1383. Added support for the Critical Incident Survey type in the Complete...
authormoodler <moodler>
Thu, 13 May 2004 08:57:39 +0000 (08:57 +0000)
committermoodler <moodler>
Thu, 13 May 2004 08:57:39 +0000 (08:57 +0000)
(Shane Elliott)

mod/survey/lib.php

index d5e641198f48acc3ca3535a8ce01a8d2ce5adf08..ee96418a703506be0a317bb31cbf1cb4e573cee6 100644 (file)
@@ -14,6 +14,14 @@ $SURVEY_QTYPE = array (
          "3" => "Actual and Preferred",
         );
 
+
+define("SURVEY_COLLES_ACTUAL",           "1");
+define("SURVEY_COLLES_PREFERRED",        "2");
+define("SURVEY_COLLES_PREFERRED_ACTUAL", "3");
+define("SURVEY_ATTLS",                   "4");
+define("SURVEY_CIQ",                     "5");
+
+
 // STANDARD FUNCTIONS ////////////////////////////////////////////////////////
 
 function survey_add_instance($survey) {
@@ -94,7 +102,31 @@ function survey_user_complete($course, $user, $mod, $survey) {
     global $CFG;
 
     if (survey_already_done($survey->id, $user->id)) {
-        survey_print_graph("id=$mod->id&sid=$user->id&type=student.png");
+        if ($survey->template == SURVEY_CIQ) { // print out answers for critical incidents
+            $table = NULL;
+            $table->align = array("left", "left");
+
+            $questions = get_records_list("survey_questions", "id", $survey->questions);
+            $questionorder = explode(",", $survey->questions);
+            
+            foreach ($questionorder as $key=>$val) {
+                $question = $questions[$val];
+                $questiontext = get_string($question->shorttext, "survey");
+                
+                if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
+                    $answertext = "$answer->answer1";
+                } else {
+                    $answertext = "No answer";
+                }
+                $table->data[] = array("<b>$questiontext</b>", $answertext);
+            }
+            print_table($table);
+            
+        } else {
+        
+            survey_print_graph("id=$mod->id&sid=$user->id&type=student.png");
+        }
+        
     } else {
         print_string("notdone", "survey");
     }