. /** * the first page to view the feedback * * @author Andreas Grabs * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package mod_feedback */ require_once("../../config.php"); require_once("lib.php"); $id = required_param('id', PARAM_INT); $courseid = optional_param('courseid', false, PARAM_INT); $current_tab = 'view'; if (! $cm = get_coursemodule_from_id('feedback', $id)) { print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { print_error('coursemisconf'); } if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { print_error('invalidcoursemodule'); } $context = context_module::instance($cm->id); $feedback_complete_cap = false; if (has_capability('mod/feedback:complete', $context)) { $feedback_complete_cap = true; } if (!empty($CFG->feedback_allowfullanonymous) AND $course->id == SITEID AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES AND (!isloggedin() OR isguestuser())) { // Guests are allowed to complete fully anonymous feedback without having 'mod/feedback:complete' capability. $feedback_complete_cap = true; } //check whether the feedback is located and! started from the mainsite if ($course->id == SITEID AND !$courseid) { $courseid = SITEID; } if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) { if ($course->id == SITEID) { require_login($course, true); } else { require_login($course, true, $cm); } } else { if ($course->id == SITEID) { require_course_login($course, true); } else { require_course_login($course, true, $cm); } } if ($course->id == SITEID) { $PAGE->set_context($context); $PAGE->set_cm($cm, $course); $PAGE->set_pagelayout('incourse'); } $PAGE->set_url('/mod/feedback/view.php', array('id'=>$cm->id, 'do_show'=>'view')); $PAGE->set_title($feedback->name); $PAGE->set_heading($course->fullname); // Check whether the feedback is mapped to the given courseid. if ($course->id == SITEID AND !has_capability('mod/feedback:edititems', $context)) { if ($DB->get_records('feedback_sitecourse_map', array('feedbackid' => $feedback->id))) { $params = array('feedbackid' => $feedback->id, 'courseid' => $courseid); if (!$DB->get_record('feedback_sitecourse_map', $params)) { if ($courseid == SITEID) { echo $OUTPUT->header(); echo $OUTPUT->notification(get_string('cannotaccess', 'mod_feedback')); echo $OUTPUT->footer(); exit; } else { print_error('invalidcoursemodule'); } } } } //check whether the given courseid exists if ($courseid AND $courseid != SITEID) { if ($course2 = $DB->get_record('course', array('id'=>$courseid))) { require_course_login($course2); //this overwrites the object $course :-( $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround } else { print_error('invalidcourseid'); } } // Trigger module viewed event. $event = \mod_feedback\event\course_module_viewed::create(array( 'objectid' => $feedback->id, 'context' => $context, 'anonymous' => ($feedback->anonymous == FEEDBACK_ANONYMOUS_YES), 'other' => array( 'anonymous' => $feedback->anonymous // Deprecated. ) )); $event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('feedback', $feedback); $event->trigger(); /// Print the page header $strfeedbacks = get_string("modulenameplural", "feedback"); $strfeedback = get_string("modulename", "feedback"); echo $OUTPUT->header(); //ishidden check. //feedback in courses $cap_viewhiddenactivities = has_capability('moodle/course:viewhiddenactivities', $context); if ((empty($cm->visible) and !$cap_viewhiddenactivities) AND $course->id != SITEID) { notice(get_string("activityiscurrentlyhidden")); } //ishidden check. //feedback on mainsite if ((empty($cm->visible) and !$cap_viewhiddenactivities) AND $courseid == SITEID) { notice(get_string("activityiscurrentlyhidden")); } /// Print the main part of the page /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// $previewimg = $OUTPUT->pix_icon('t/preview', get_string('preview')); $previewlnk = new moodle_url('/mod/feedback/print.php', array('id' => $id)); $preview = html_writer::link($previewlnk, $previewimg); echo $OUTPUT->heading(format_string($feedback->name) . $preview); // Print the tabs. require('tabs.php'); //show some infos to the feedback if (has_capability('mod/feedback:edititems', $context)) { //get the groupid $groupselect = groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/feedback/view.php?id='.$cm->id, true); $mygroupid = groups_get_activity_group($cm); echo $OUTPUT->box_start('boxaligncenter boxwidthwide'); echo $groupselect.'