diff --git a/mod/survey/lang/en/survey.php b/mod/survey/lang/en/survey.php index c7826ccca6d..6a011a9cfbd 100644 --- a/mod/survey/lang/en/survey.php +++ b/mod/survey/lang/en/survey.php @@ -242,6 +242,7 @@ $string['selectedquestions'] = 'Selected questions from a scale, all students'; $string['summary'] = 'Summary'; $string['survey:addinstance'] = 'Add a new survey'; $string['surveycompleted'] = 'You\'ve completed this survey. The graph below shows a summary of your results compared to the class averages.'; +$string['surveycompletednograph'] = 'You have completed this survey.'; $string['survey:download'] = 'Download responses'; $string['surveygraph'] = 'Survey graph'; $string['surveyname'] = 'Survey name'; diff --git a/mod/survey/view.php b/mod/survey/view.php index 0ba8cd4a587..dabc1b6f474 100644 --- a/mod/survey/view.php +++ b/mod/survey/view.php @@ -1,5 +1,4 @@ get_record("course", array("id"=>$cm->course))) { - print_error('coursemisconf'); - } +if (! $course = $DB->get_record("course", array("id" => $cm->course))) { + print_error('coursemisconf'); +} - $PAGE->set_url('/mod/survey/view.php', array('id'=>$id)); - require_login($course, false, $cm); - $context = context_module::instance($cm->id); +$PAGE->set_url('/mod/survey/view.php', array('id' => $id)); +require_login($course, false, $cm); +$context = context_module::instance($cm->id); - require_capability('mod/survey:participate', $context); +require_capability('mod/survey:participate', $context); - if (! $survey = $DB->get_record("survey", array("id"=>$cm->instance))) { - print_error('invalidsurveyid', 'survey'); - } - $trimmedintro = trim($survey->intro); - if (empty($trimmedintro)) { - $tempo = $DB->get_field("survey", "intro", array("id"=>$survey->template)); - $survey->intro = get_string($tempo, "survey"); - } +if (! $survey = $DB->get_record("survey", array("id" => $cm->instance))) { + print_error('invalidsurveyid', 'survey'); +} +$trimmedintro = trim($survey->intro); +if (empty($trimmedintro)) { + $tempo = $DB->get_field("survey", "intro", array("id" => $survey->template)); + $survey->intro = get_string($tempo, "survey"); +} - if (! $template = $DB->get_record("survey", array("id"=>$survey->template))) { - print_error('invalidtmptid', 'survey'); - } +if (! $template = $DB->get_record("survey", array("id" => $survey->template))) { + print_error('invalidtmptid', 'survey'); +} -// Update 'viewed' state if required by completion system +// Update 'viewed' state if required by completion system. require_once($CFG->libdir . '/completionlib.php'); $completion = new completion_info($course); $completion->set_module_viewed($cm); - $showscales = ($template->name != 'ciqname'); +$showscales = ($template->name != 'ciqname'); - $strsurvey = get_string("modulename", "survey"); - $PAGE->set_title($survey->name); - $PAGE->set_heading($course->fullname); - echo $OUTPUT->header(); - echo $OUTPUT->heading($survey->name); +$strsurvey = get_string("modulename", "survey"); +$PAGE->set_title($survey->name); +$PAGE->set_heading($course->fullname); +echo $OUTPUT->header(); +echo $OUTPUT->heading($survey->name); -/// 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; +// 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) 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 (has_capability('mod/survey:readresponses', $context)) { + $numusers = survey_count_responses($survey->id, $currentgroup, $groupingid); + echo ""; +} else if (!$cm->visible) { + notice(get_string("activityiscurrentlyhidden")); +} - if (!is_enrolled($context)) { - echo $OUTPUT->notification(get_string("guestsnotallowed", "survey")); - } +if (!is_enrolled($context)) { + echo $OUTPUT->notification(get_string("guestsnotallowed", "survey")); +} -// Check the survey hasn't already been filled out. +// Check the survey hasn't already been filled out. - if (survey_already_done($survey->id, $USER->id)) { - $params = array( - 'objectid' => $survey->id, - 'context' => $context, - 'courseid' => $course->id, - 'other' => array('viewed' => 'graph') - ); - $event = \mod_survey\event\course_module_viewed::create($params); - $event->trigger(); - $numusers = survey_count_responses($survey->id, $currentgroup, $groupingid); - - if ($showscales) { - echo $OUTPUT->box(get_string("surveycompleted", "survey")); - echo $OUTPUT->box(get_string("peoplecompleted", "survey", $numusers)); - echo '