[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * prints the form so the user can fill out the feedback 19 * 20 * @author Andreas Grabs 21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 22 * @package mod_feedback 23 */ 24 25 require_once("../../config.php"); 26 require_once ("lib.php"); 27 require_once($CFG->libdir . '/completionlib.php'); 28 29 feedback_init_feedback_session(); 30 31 $id = required_param('id', PARAM_INT); 32 $courseid = optional_param('courseid', null, PARAM_INT); 33 $gopage = optional_param('gopage', 0, PARAM_INT); 34 35 list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); 36 $feedback = $DB->get_record("feedback", array("id" => $cm->instance), '*', MUST_EXIST); 37 38 $urlparams = array('id' => $cm->id, 'gopage' => $gopage, 'courseid' => $courseid); 39 $PAGE->set_url('/mod/feedback/complete.php', $urlparams); 40 41 require_course_login($course, true, $cm); 42 $PAGE->set_activity_record($feedback); 43 44 $context = context_module::instance($cm->id); 45 $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid); 46 47 $courseid = $feedbackcompletion->get_courseid(); 48 49 // Check whether the feedback is mapped to the given courseid. 50 if (!has_capability('mod/feedback:edititems', $context) && 51 !$feedbackcompletion->check_course_is_mapped()) { 52 echo $OUTPUT->header(); 53 echo $OUTPUT->notification(get_string('cannotaccess', 'mod_feedback')); 54 echo $OUTPUT->footer(); 55 exit; 56 } 57 58 //check whether the given courseid exists 59 if ($courseid AND $courseid != SITEID) { 60 require_course_login(get_course($courseid)); // This overwrites the object $COURSE . 61 } 62 63 if (!$feedbackcompletion->can_complete()) { 64 print_error('error'); 65 } 66 67 $PAGE->navbar->add(get_string('feedback:complete', 'feedback')); 68 $PAGE->set_heading($course->fullname); 69 $PAGE->set_title($feedback->name); 70 $PAGE->set_pagelayout('incourse'); 71 72 // Check if the feedback is open (timeopen, timeclose). 73 if (!$feedbackcompletion->is_open()) { 74 echo $OUTPUT->header(); 75 echo $OUTPUT->heading(format_string($feedback->name)); 76 echo $OUTPUT->box_start('generalbox boxaligncenter'); 77 echo $OUTPUT->notification(get_string('feedback_is_not_open', 'feedback')); 78 echo $OUTPUT->continue_button(course_get_url($courseid ?: $feedback->course)); 79 echo $OUTPUT->box_end(); 80 echo $OUTPUT->footer(); 81 exit; 82 } 83 84 // Mark activity viewed for completion-tracking. 85 $completion = new completion_info($course); 86 if (isloggedin() && !isguestuser()) { 87 $completion->set_module_viewed($cm); 88 } 89 90 // Check if user is prevented from re-submission. 91 $cansubmit = $feedbackcompletion->can_submit(); 92 93 // Initialise the form processing feedback completion. 94 if (!$feedbackcompletion->is_empty() && $cansubmit) { 95 $form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_COMPLETE, 96 $feedbackcompletion, 'feedback_complete_form', array('gopage' => $gopage)); 97 if ($form->is_cancelled()) { 98 // Form was cancelled - return to the course page. 99 redirect(course_get_url($courseid ?: $course)); 100 } else if ($form->is_submitted() && 101 ($form->is_validated() || optional_param('gopreviouspage', null, PARAM_RAW))) { 102 // Form was submitted (skip validation for "Previous page" button). 103 $data = $form->get_submitted_data(); 104 if (!isset($SESSION->feedback->is_started) OR !$SESSION->feedback->is_started == true) { 105 print_error('error', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); 106 } 107 $feedbackcompletion->save_response_tmp($data); 108 if (!empty($data->savevalues) || !empty($data->gonextpage)) { 109 if (($nextpage = $feedbackcompletion->get_next_page($gopage)) !== null) { 110 redirect(new moodle_url($PAGE->url, array('gopage' => $nextpage))); 111 } else { 112 $feedbackcompletion->save_response(); 113 if (!$feedback->page_after_submit) { 114 \core\notification::success(get_string('entries_saved', 'feedback')); 115 } 116 } 117 } else if (!empty($data->gopreviouspage)) { 118 $prevpage = $feedbackcompletion->get_previous_page($gopage); 119 redirect(new moodle_url($PAGE->url, array('gopage' => intval($prevpage)))); 120 } 121 } 122 } 123 124 // Print the page header. 125 $strfeedbacks = get_string("modulenameplural", "feedback"); 126 $strfeedback = get_string("modulename", "feedback"); 127 128 echo $OUTPUT->header(); 129 echo $OUTPUT->heading(format_string($feedback->name)); 130 131 if ($feedbackcompletion->is_empty()) { 132 \core\notification::error(get_string('no_items_available_yet', 'feedback')); 133 } else if ($cansubmit) { 134 if (!empty($data->savevalues) || !empty($data->gonextpage)) { 135 // Display information after the submit. 136 if ($feedback->page_after_submit) { 137 echo $OUTPUT->box($feedbackcompletion->page_after_submit(), 138 'generalbox boxaligncenter'); 139 } 140 if ($feedbackcompletion->can_view_analysis()) { 141 echo '<p align="center">'; 142 $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $cm->id, 'courseid' => $courseid)); 143 echo html_writer::link($analysisurl, get_string('completed_feedbacks', 'feedback')); 144 echo '</p>'; 145 } 146 147 if ($feedback->site_after_submit) { 148 $url = feedback_encode_target_url($feedback->site_after_submit); 149 } else { 150 $url = course_get_url($courseid ?: $course->id); 151 } 152 echo $OUTPUT->continue_button($url); 153 } else { 154 // Print the items. 155 $SESSION->feedback->is_started = true; 156 $form->display(); 157 } 158 } else { 159 echo $OUTPUT->box_start('generalbox boxaligncenter'); 160 echo $OUTPUT->notification(get_string('this_feedback_is_already_submitted', 'feedback')); 161 echo $OUTPUT->continue_button(course_get_url($courseid ?: $course->id)); 162 echo $OUTPUT->box_end(); 163 } 164 165 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |