コード例 #1
0
 /**
  * Returns the course where user was before taking the feedback.
  *
  * For feedbacks inside the course it will be the same as $this->get_feedback()->course.
  * For feedbacks on the frontpage it will be the same as $this->get_course_id()
  *
  * @return int
  */
 public function get_current_course_id()
 {
     return $this->structure->get_courseid() ?: $this->get_feedback()->course;
 }
コード例 #2
0
ファイル: complete.php プロジェクト: evltuma/moodle
require_once "../../config.php";
require_once "lib.php";
require_once $CFG->libdir . '/completionlib.php';
feedback_init_feedback_session();
$id = required_param('id', PARAM_INT);
$courseid = optional_param('courseid', null, PARAM_INT);
$gopage = optional_param('gopage', 0, PARAM_INT);
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
$feedback = $DB->get_record("feedback", array("id" => $cm->instance), '*', MUST_EXIST);
$urlparams = array('id' => $cm->id, 'gopage' => $gopage, 'courseid' => $courseid);
$PAGE->set_url('/mod/feedback/complete.php', $urlparams);
require_course_login($course, true, $cm);
$PAGE->set_activity_record($feedback);
$context = context_module::instance($cm->id);
$feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid);
$courseid = $feedbackcompletion->get_courseid();
// Check whether the feedback is mapped to the given courseid.
if (!has_capability('mod/feedback:edititems', $context) && !$feedbackcompletion->check_course_is_mapped()) {
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('cannotaccess', 'mod_feedback'));
    echo $OUTPUT->footer();
    exit;
}
//check whether the given courseid exists
if ($courseid and $courseid != SITEID) {
    require_course_login(get_course($courseid));
    // This overwrites the object $COURSE .
}
if (!$feedbackcompletion->can_complete()) {
    print_error('error');
}