當前位置: 首頁>>代碼示例>>PHP>>正文


PHP quiz_access_manager::get_active_rule_names方法代碼示例

本文整理匯總了PHP中quiz_access_manager::get_active_rule_names方法的典型用法代碼示例。如果您正苦於以下問題:PHP quiz_access_manager::get_active_rule_names方法的具體用法?PHP quiz_access_manager::get_active_rule_names怎麽用?PHP quiz_access_manager::get_active_rule_names使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在quiz_access_manager的用法示例。


在下文中一共展示了quiz_access_manager::get_active_rule_names方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_quiz_access_information

 /**
  * 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
  */
 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;
 }
開發者ID:IFPBMoodle,項目名稱:moodle,代碼行數:33,代碼來源:external.php


注:本文中的quiz_access_manager::get_active_rule_names方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。