original_string: 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);
      }
code: 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);
      }
code_tokens: 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 ) ; }
docstring: Utility function for validating a feedback.
  
  @param int $feedbackid feedback instance id
  @param int $courseid courseid course where user completes the feedback (for site feedbacks only)
  @return array containing the feedback, feedback course, context, course module and the course where is being completed.
  @throws moodle_exception
  @since  Moodle 3.3
docstring_tokens: Utility function for validating a feedback .