当前位置: 首页>>代码示例>>PHP>>正文


PHP quiz_attempt::require_capability方法代码示例

本文整理汇总了PHP中quiz_attempt::require_capability方法的典型用法代码示例。如果您正苦于以下问题:PHP quiz_attempt::require_capability方法的具体用法?PHP quiz_attempt::require_capability怎么用?PHP quiz_attempt::require_capability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在quiz_attempt的用法示例。


在下文中一共展示了quiz_attempt::require_capability方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 * @package quiz
 */
require_once '../../config.php';
require_once 'locallib.php';
$attemptid = required_param('attempt', PARAM_INT);
// attempt id
$questionid = required_param('question', PARAM_INT);
// question id
$attemptobj = new quiz_attempt($attemptid);
/// Can only grade finished attempts.
if (!$attemptobj->is_finished()) {
    print_error('attemptclosed', 'quiz');
}
/// Check login and permissions.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
$attemptobj->require_capability('mod/quiz:grade');
/// Load the questions and states.
$questionids = array($questionid);
$attemptobj->load_questions($questionids);
$attemptobj->load_question_states($questionids);
/// Log this action.
add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid, $attemptobj->get_quizid(), $attemptobj->get_cmid());
/// Print the page header
print_header();
print_heading(format_string($attemptobj->get_question($questionid)->name));
/// Process any data that was submitted.
if ($data = data_submitted() and confirm_sesskey()) {
    $error = $attemptobj->process_comment($questionid, $data->response['comment'], $data->response['grade']);
    /// If success, notify and print a close button.
    if (!is_string($error)) {
        notify(get_string('changessaved'), 'notifysuccess');
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:comment.php

示例2: explode

    $nexturl = $attemptobj->attempt_url(0, $nextpage);
}
/// We treat automatically closed attempts just like normally closed attempts
if ($timeup) {
    $finishattempt = 1;
}
/// Check login.
require_login($attemptobj->get_courseid(), false, $attemptobj->get_cm());
confirm_sesskey();
/// Check that this attempt belongs to this user.
if ($attemptobj->get_userid() != $USER->id) {
    quiz_error($attemptobj->get_quiz(), 'notyourattempt');
}
/// Check capabilites.
if (!$attemptobj->is_preview_user()) {
    $attemptobj->require_capability('mod/quiz:attempt');
}
/// If the attempt is already closed, send them to the review page.
if ($attemptobj->is_finished()) {
    quiz_error($attemptobj->get_quiz(), 'attemptalreadyclosed');
}
/// Don't log - we will end with a redirect to a page that is logged.
/// Get the list of questions needed by this page.
if (!empty($submittedquestionids)) {
    $submittedquestionids = explode(',', $submittedquestionids);
} else {
    $submittedquestionids = array();
}
if ($finishattempt) {
    $questionids = $attemptobj->get_question_ids();
} else {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:processattempt.php


注:本文中的quiz_attempt::require_capability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。