course)) { error("Course is misconfigured"); } require_login($course->id); if (! $survey = get_record("survey", "id", $cm->instance)) { error("Survey ID was incorrect"); } print_header("$course->shortname: $survey->name", "$course->fullname", "id>$course->shortname -> id>Surveys -> $survey->name", "", "", true, update_module_icon($cm->id, $course->id)); if (isteacher($course->id)) { echo "

id\">View all responses

"; } // Check the survey hasn't already been filled out. if (survey_already_done($survey->id, $USER->id)) { add_to_log($course->id, "survey", "view graph", "view.php?id=$cm->id", "$survey->id"); print_heading("You've completed this survey. The graph below shows a summary of your results compared to the class averages."); $numusers = count_completed_surveys($survey->id); print_heading("$numusers people have completed the survey so far"); echo "
"; echo "wwwroot/mod/survey/graph.php?id=$cm->id&sid=$USER->id&type=student.png\">"; echo "
"; print_footer($course); exit; } // Start the survey form add_to_log($course->id, "survey", "view form", "view.php?id=$cm->id", "$survey->id"); echo "
"; echo ""; print_simple_box(text_to_html($survey->intro), "center", "80%"); // Get all the major questions and their proper order if (! $questions = get_records_sql("SELECT * FROM survey_questions WHERE id in ($survey->questions)")) { error("Couldn't find any questions in this survey!!"); } $questionorder = explode( ",", $survey->questions); // Cycle through all the questions in order and print them $qnum = 0; foreach ($questionorder as $key => $val) { $question = $questions["$val"]; $question->id = $val; if ($question->type > 0) { if ($question->multi) { print_multi($question); } else { print_single($question); } } } // End the survey page echo "

 

"; if ($ownerpreview) { echo "(Because this is only a preview, the button below will not send data)
\n"; echo ""; } else { echo "\n"; ?> "; print_footer($course); exit; ////////////////////////////////////////////////////////////////////////////////////// function print_multi($question) { GLOBAL $db, $qnum, $checklist, $THEME; echo "

 

\n"; echo "

$question->text

"; echo ""; $options = explode( ",", $question->options); $numoptions = count($options); $oneanswer = ($question->type == 1 || $question->type == 2) ? true : false; if ($question->type == 2) { $P = "P"; } else { $P = ""; } if ($oneanswer) { echo ""; } else { echo ""; } while (list ($key, $val) = each ($options)) { echo "\n"; } echo "\n"; $subquestions = get_records_sql("SELECT * FROM survey_questions WHERE id in ($question->multi) "); foreach ($subquestions as $q) { $qnum++; $bgcolor = question_color($qnum); echo ""; if ($oneanswer) { echo ""; echo ""; for ($i=1;$i<=$numoptions;$i++) { echo ""; } echo ""; $checklist["q$P$q->id"] = $numoptions; } else { echo ""; echo ""; echo ""; for ($i=1;$i<=$numoptions;$i++) { echo ""; } echo ""; echo ""; echo ""; echo ""; for ($i=1;$i<=$numoptions;$i++) { echo ""; } echo ""; $checklist["qP$q->id"] = $numoptions; $checklist["q$q->id"] = $numoptions; } echo "\n"; } echo "

$question->intro

$question->intro

$val

body\"> 

$qnum

$q->text

id VALUE=$i>id VALUE=0 checked>

$qnum

I prefer that 

$q->text

id VALUE=$i>body\">id VALUE=0 checked>

I found that 

id VALUE=$i>body\">id VALUE=0 checked>
"; } function print_single($question) { GLOBAL $db, $qnum; $bgcolor = question_color(0); $qnum++; echo "

 

\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo "
$qnum

$question->text

\n"; if ($question->type == 0) { // Plain text field echo ""; } else if ($question->type > 0) { // Choose one of a number echo ""; } else if ($question->type < 0) { // Choose several of a number $options = explode( ",", $question->options); echo "

THIS TYPE OF QUESTION NOT SUPPORTED YET

"; } echo "
"; } function question_color($qnum) { global $THEME; if ($qnum) { return $qnum % 2 ? $THEME->cellcontent : $THEME->cellcontent2; //return $qnum % 2 ? "#CCFFCC" : "#CCFFFF"; } else { return $THEME->cellcontent; } } ?>