course)) { error("Course is misconfigured"); } require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/survey:participate', $context); if (! $survey = get_record("survey", "id", $cm->instance)) { error("Survey ID was incorrect"); } $trimmedintro = trim($survey->intro); if (empty($trimmedintro)) { $tempo = get_field("survey", "intro", "id", $survey->template); $survey->intro = get_string($tempo, "survey"); } if (! $template = get_record("survey", "id", $survey->template)) { error("Template ID was incorrect"); } $showscales = ($template->name != 'ciqname'); $strsurvey = get_string("modulename", "survey"); $navigation = build_navigation('', $cm); print_header_simple(format_string($survey->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm)); /// Check to see if groups are being used in this survey if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used $currentgroup = groups_get_activity_group($cm); } else { $currentgroup = 0; } $groupingid = $cm->groupingid; if (has_capability('mod/survey:readresponses', $context) or ($groupmode == VISIBLEGROUPS)) { $currentgroup = 0; } if (has_capability('mod/survey:readresponses', $context)) { $numusers = survey_count_responses($survey->id, $currentgroup, $groupingid); echo "
"; } else if (!$cm->visible) { notice(get_string("activityiscurrentlyhidden")); } if (isguest()) { notify(get_string("guestsnotallowed", "survey")); } // 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, $cm->id); $numusers = survey_count_responses($survey->id, $currentgroup, $groupingid); if ($showscales) { print_heading(get_string("surveycompleted", "survey")); print_heading(get_string("peoplecompleted", "survey", $numusers)); echo '