本文整理匯總了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;
}