original_string: protected static function validate_feedback_access($feedback, $course, $cm, $context, $checksubmit = false) {
          $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $course->id);
  
          if (!$feedbackcompletion->can_complete()) {
              throw new required_capability_exception($context, 'mod/feedback:complete', 'nopermission', '');
          }
  
          if (!$feedbackcompletion->is_open()) {
              throw new moodle_exception('feedback_is_not_open', 'feedback');
          }
  
          if ($feedbackcompletion->is_empty()) {
              throw new moodle_exception('no_items_available_yet', 'feedback');
          }
  
          if ($checksubmit && !$feedbackcompletion->can_submit()) {
              throw new moodle_exception('this_feedback_is_already_submitted', 'feedback');
          }
          return $feedbackcompletion;
      }
code: protected static function validate_feedback_access($feedback, $course, $cm, $context, $checksubmit = false) {
          $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $course->id);
  
          if (!$feedbackcompletion->can_complete()) {
              throw new required_capability_exception($context, 'mod/feedback:complete', 'nopermission', '');
          }
  
          if (!$feedbackcompletion->is_open()) {
              throw new moodle_exception('feedback_is_not_open', 'feedback');
          }
  
          if ($feedbackcompletion->is_empty()) {
              throw new moodle_exception('no_items_available_yet', 'feedback');
          }
  
          if ($checksubmit && !$feedbackcompletion->can_submit()) {
              throw new moodle_exception('this_feedback_is_already_submitted', 'feedback');
          }
          return $feedbackcompletion;
      }
code_tokens: protected static function validate_feedback_access ( $ feedback , $ course , $ cm , $ context , $ checksubmit = false ) { $ feedbackcompletion = new mod_feedback_completion ( $ feedback , $ cm , $ course -> id ) ; if ( ! $ feedbackcompletion -> can_complete ( ) ) { throw new required_capability_exception ( $ context , 'mod/feedback:complete' , 'nopermission' , '' ) ; } if ( ! $ feedbackcompletion -> is_open ( ) ) { throw new moodle_exception ( 'feedback_is_not_open' , 'feedback' ) ; } if ( $ feedbackcompletion -> is_empty ( ) ) { throw new moodle_exception ( 'no_items_available_yet' , 'feedback' ) ; } if ( $ checksubmit && ! $ feedbackcompletion -> can_submit ( ) ) { throw new moodle_exception ( 'this_feedback_is_already_submitted' , 'feedback' ) ; } return $ feedbackcompletion ; }
docstring: Utility function for validating access to feedback.
  
  @param  stdClass   $feedback feedback object
  @param  stdClass   $course   course where user completes the feedback (for site feedbacks only)
  @param  stdClass   $cm       course module
  @param  stdClass   $context  context object
  @throws moodle_exception
  @return mod_feedback_completion feedback completion instance
  @since  Moodle 3.3
docstring_tokens: Utility function for validating access to feedback .