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


PHP question_edit_contexts::have_cap方法代码示例

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


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

示例1: stdClass

        }
    }
}
$qtypeobj = question_bank::get_qtype($question->qtype);
// Validate the question category.
if (!($category = $DB->get_record('question_categories', array('id' => $question->category)))) {
    print_error('categorydoesnotexist', 'question', $returnurl);
}
// Check permissions
$question->formoptions = new stdClass();
$categorycontext = context::instance_by_id($category->contextid);
$addpermission = has_capability('moodle/question:add', $categorycontext);
if ($id) {
    if ($movecontext) {
        $question->formoptions->canedit = false;
        $question->formoptions->canmove = question_has_capability_on($question, 'move') && $contexts->have_cap('moodle/question:add');
        $question->formoptions->cansaveasnew = false;
        $question->formoptions->repeatelements = false;
        $question->formoptions->movecontext = true;
        $formeditable = true;
        question_require_capability_on($question, 'move');
    } else {
        $question->formoptions->canedit = question_has_capability_on($question, 'edit');
        $question->formoptions->canmove = $addpermission && question_has_capability_on($question, 'move');
        $question->formoptions->cansaveasnew = $addpermission && (question_has_capability_on($question, 'view') || $question->formoptions->canedit);
        $question->formoptions->repeatelements = $question->formoptions->canedit || $question->formoptions->cansaveasnew;
        $formeditable = $question->formoptions->canedit || $question->formoptions->cansaveasnew || $question->formoptions->canmove;
        $question->formoptions->movecontext = false;
        if (!$formeditable) {
            question_require_capability_on($question, 'view');
        }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:question.php

示例2: random_question_form

 /**
  * Return random question form.
  * @param \moodle_url $thispageurl the canonical URL of this page.
  * @param \question_edit_contexts $contexts the relevant question bank contexts.
  * @param array $pagevars the variables from {@link \question_edit_setup()}.
  * @return string HTML to output.
  */
 protected function random_question_form(\moodle_url $thispageurl, \question_edit_contexts $contexts, array $pagevars)
 {
     if (!$contexts->have_cap('moodle/question:useall')) {
         return '';
     }
     $randomform = new \quiz_add_random_form(new \moodle_url('/mod/quiz/addrandom.php'), array('contexts' => $contexts, 'cat' => $pagevars['cat']));
     $randomform->set_data(array('category' => $pagevars['cat'], 'returnurl' => $thispageurl->out_as_local_url(true), 'randomnumber' => 1, 'cmid' => $thispageurl->param('cmid')));
     return html_writer::div($randomform->render(), 'randomquestionformforpopup');
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:edit_renderer.php


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