protected static function validate_feedback($feedbackid, $courseid = 0) {
        global $DB, $USER;

        // Request and permission validation.
        $feedback = $DB->get_record('feedback', array('id' => $feedbackid), '*', MUST_EXIST);
        list($feedbackcourse, $cm) = get_course_and_cm_from_instance($feedback, 'feedback');

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Set default completion course.
        $completioncourse = (object) array('id' => 0);
        if ($feedbackcourse->id == SITEID && $courseid) {
            $completioncourse = get_course($courseid);
            self::validate_context(context_course::instance($courseid));

            $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid);
            if (!$feedbackcompletion->check_course_is_mapped()) {
                throw new moodle_exception('cannotaccess', 'mod_feedback');
            }
        }

        return array($feedback, $feedbackcourse, $cm, $context, $completioncourse);
    }