original_string: public static function get_quiz_access_information($quizid) {
          global $DB, $USER;
  
          $warnings = array();
  
          $params = array(
              'quizid' => $quizid
          );
          $params = self::validate_parameters(self::get_quiz_access_information_parameters(), $params);
  
          list($quiz, $course, $cm, $context) = self::validate_quiz($params['quizid']);
  
          $result = array();
          // Capabilities first.
          $result['canattempt'] = has_capability('mod/quiz:attempt', $context);;
          $result['canmanage'] = has_capability('mod/quiz:manage', $context);;
          $result['canpreview'] = has_capability('mod/quiz:preview', $context);;
          $result['canreviewmyattempts'] = has_capability('mod/quiz:reviewmyattempts', $context);;
          $result['canviewreports'] = has_capability('mod/quiz:viewreports', $context);;
  
          // Access manager now.
          $quizobj = quiz::create($cm->instance, $USER->id);
          $ignoretimelimits = has_capability('mod/quiz:ignoretimelimits', $context, null, false);
          $timenow = time();
          $accessmanager = new quiz_access_manager($quizobj, $timenow, $ignoretimelimits);
  
          $result['accessrules'] = $accessmanager->describe_rules();
          $result['activerulenames'] = $accessmanager->get_active_rule_names();
          $result['preventaccessreasons'] = $accessmanager->prevent_access();
  
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_quiz_access_information($quizid) {
          global $DB, $USER;
  
          $warnings = array();
  
          $params = array(
              'quizid' => $quizid
          );
          $params = self::validate_parameters(self::get_quiz_access_information_parameters(), $params);
  
          list($quiz, $course, $cm, $context) = self::validate_quiz($params['quizid']);
  
          $result = array();
          // Capabilities first.
          $result['canattempt'] = has_capability('mod/quiz:attempt', $context);;
          $result['canmanage'] = has_capability('mod/quiz:manage', $context);;
          $result['canpreview'] = has_capability('mod/quiz:preview', $context);;
          $result['canreviewmyattempts'] = has_capability('mod/quiz:reviewmyattempts', $context);;
          $result['canviewreports'] = has_capability('mod/quiz:viewreports', $context);;
  
          // Access manager now.
          $quizobj = quiz::create($cm->instance, $USER->id);
          $ignoretimelimits = has_capability('mod/quiz:ignoretimelimits', $context, null, false);
          $timenow = time();
          $accessmanager = new quiz_access_manager($quizobj, $timenow, $ignoretimelimits);
  
          $result['accessrules'] = $accessmanager->describe_rules();
          $result['activerulenames'] = $accessmanager->get_active_rule_names();
          $result['preventaccessreasons'] = $accessmanager->prevent_access();
  
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_quiz_access_information ( $ quizid ) { global $ DB , $ USER ; $ warnings = array ( ) ; $ params = array ( 'quizid' => $ quizid ) ; $ params = self :: validate_parameters ( self :: get_quiz_access_information_parameters ( ) , $ params ) ; list ( $ quiz , $ course , $ cm , $ context ) = self :: validate_quiz ( $ params [ 'quizid' ] ) ; $ result = array ( ) ; // Capabilities first. $ result [ 'canattempt' ] = has_capability ( 'mod/quiz:attempt' , $ context ) ; ; $ result [ 'canmanage' ] = has_capability ( 'mod/quiz:manage' , $ context ) ; ; $ result [ 'canpreview' ] = has_capability ( 'mod/quiz:preview' , $ context ) ; ; $ result [ 'canreviewmyattempts' ] = has_capability ( 'mod/quiz:reviewmyattempts' , $ context ) ; ; $ result [ 'canviewreports' ] = has_capability ( 'mod/quiz:viewreports' , $ context ) ; ; // Access manager now. $ quizobj = quiz :: create ( $ cm -> instance , $ USER -> id ) ; $ ignoretimelimits = has_capability ( 'mod/quiz:ignoretimelimits' , $ context , null , false ) ; $ timenow = time ( ) ; $ accessmanager = new quiz_access_manager ( $ quizobj , $ timenow , $ ignoretimelimits ) ; $ result [ 'accessrules' ] = $ accessmanager -> describe_rules ( ) ; $ result [ 'activerulenames' ] = $ accessmanager -> get_active_rule_names ( ) ; $ result [ 'preventaccessreasons' ] = $ accessmanager -> prevent_access ( ) ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Return access information for a given quiz.
  
  @param int $quizid quiz instance id
  @return array of warnings and the access information
  @since Moodle 3.1
  @throws  moodle_quiz_exception
docstring_tokens: Return access information for a given quiz .