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


PHP api::create_plan_from_template方法代码示例

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


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

示例1: execute

 /**
  * Do the job.
  */
 public function execute()
 {
     if (!api::is_enabled()) {
         return;
     }
     $missingplans = template_cohort::get_all_missing_plans(self::get_last_run_time());
     foreach ($missingplans as $missingplan) {
         foreach ($missingplan['userids'] as $userid) {
             try {
                 api::create_plan_from_template($missingplan['template'], $userid);
             } catch (\Exception $e) {
                 debugging(sprintf('Exception caught while creating plan for user %d from template %d. Message: %s', $userid, $missingplan['template']->get_id(), $e->getMessage()), DEBUG_DEVELOPER);
             }
         }
     }
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:19,代码来源:sync_plans_from_template_cohorts_task.php

示例2: test_hidden_template

 /**
  * Test when using hidden template in plan/cohort.
  */
 public function test_hidden_template()
 {
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $dg = $this->getDataGenerator();
     $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
     $user = $dg->create_user();
     // Create a cohort.
     $cohort = $dg->create_cohort();
     // Create a hidden template.
     $template = $lpg->create_template(array('visible' => false));
     // Can not link hidden template to plan.
     try {
         api::create_plan_from_template($template->get_id(), $user->id);
         $this->fail('Can not link a hidden template to plan');
     } catch (coding_exception $e) {
         $this->assertTrue(true);
     }
     // Can associate hidden template to cohort.
     $templatecohort = api::create_template_cohort($template->get_id(), $cohort->id);
     $this->assertInstanceOf('\\core_competency\\template_cohort', $templatecohort);
 }
开发者ID:dg711,项目名称:moodle,代码行数:25,代码来源:api_test.php

示例3: required_capability_exception

$template = \core_competency\api::read_template($id);
$context = $template->get_context();
$canreadtemplate = $template->can_read();
$canmanagetemplate = $template->can_manage();
if (!$canreadtemplate) {
    throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
// Set up the page.
$url = new moodle_url('/admin/tool/lp/template_plans.php', array('id' => $id, 'pagecontextid' => $pagecontextid));
list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template, get_string('userplans', 'core_competency'));
// Capture the form submission.
$form = new \tool_lp\form\template_plans($url->out(false));
if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->users)) {
    $i = 0;
    foreach ($data->users as $userid) {
        $result = \core_competency\api::create_plan_from_template($template->get_id(), $userid);
        if ($result) {
            $i++;
        }
    }
    if ($i == 0) {
        $notification = get_string('noplanswerecreated', 'tool_lp');
    } else {
        if ($i == 1) {
            $notification = get_string('oneplanwascreated', 'tool_lp');
        } else {
            $notification = get_string('aplanswerecreated', 'tool_lp', $i);
        }
    }
    redirect($url, $notification);
}
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:template_plans.php


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