original_string: protected static function validate_attempt_review($params) {
  
          $attemptobj = quiz_attempt::create($params['attemptid']);
          $attemptobj->check_review_capability();
  
          $displayoptions = $attemptobj->get_display_options(true);
          if ($attemptobj->is_own_attempt()) {
              if (!$attemptobj->is_finished()) {
                  throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'attemptclosed');
              } else if (!$displayoptions->attempt) {
                  throw new moodle_exception($attemptobj->cannot_review_message());
              }
          } else if (!$attemptobj->is_review_allowed()) {
              throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'noreviewattempt');
          }
          return array($attemptobj, $displayoptions);
      }
code: protected static function validate_attempt_review($params) {
  
          $attemptobj = quiz_attempt::create($params['attemptid']);
          $attemptobj->check_review_capability();
  
          $displayoptions = $attemptobj->get_display_options(true);
          if ($attemptobj->is_own_attempt()) {
              if (!$attemptobj->is_finished()) {
                  throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'attemptclosed');
              } else if (!$displayoptions->attempt) {
                  throw new moodle_exception($attemptobj->cannot_review_message());
              }
          } else if (!$attemptobj->is_review_allowed()) {
              throw new moodle_quiz_exception($attemptobj->get_quizobj(), 'noreviewattempt');
          }
          return array($attemptobj, $displayoptions);
      }
code_tokens: protected static function validate_attempt_review ( $ params ) { $ attemptobj = quiz_attempt :: create ( $ params [ 'attemptid' ] ) ; $ attemptobj -> check_review_capability ( ) ; $ displayoptions = $ attemptobj -> get_display_options ( true ) ; if ( $ attemptobj -> is_own_attempt ( ) ) { if ( ! $ attemptobj -> is_finished ( ) ) { throw new moodle_quiz_exception ( $ attemptobj -> get_quizobj ( ) , 'attemptclosed' ) ; } else if ( ! $ displayoptions -> attempt ) { throw new moodle_exception ( $ attemptobj -> cannot_review_message ( ) ) ; } } else if ( ! $ attemptobj -> is_review_allowed ( ) ) { throw new moodle_quiz_exception ( $ attemptobj -> get_quizobj ( ) , 'noreviewattempt' ) ; } return array ( $ attemptobj , $ displayoptions ) ; }
docstring: Validate an attempt finished for review. The attempt would be reviewed by a user or a teacher.
  
  @param  array $params Array of parameters including the attemptid
  @return  array containing the attempt object and display options
  @since  Moodle 3.1
  @throws  moodle_exception
  @throws  moodle_quiz_exception
docstring_tokens: Validate an attempt finished for review . The attempt would be reviewed by a user or a teacher .