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


PHP api::set_course_competency_ruleoutcome方法代码示例

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


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

示例1: process_courses

 /**
  * Process each course individually.
  * @return void
  */
 protected function process_courses()
 {
     global $DB;
     $this->progress->start_progress(get_string('migratingcourses', 'tool_lpmigrate'), count($this->coursescompetencies));
     // Process each course.
     foreach ($this->coursescompetencies as $courseid => $competencyids) {
         $this->progress->increment_progress();
         $competenciestoremovefromcourse = array();
         $skipcompetencies = array();
         // First, add all the new competencies to the course.
         foreach ($competencyids as $key => $competencyid) {
             $this->coursecompetencyexpectedmigrations++;
             $mapto = isset($this->mappings[$competencyid]) ? $this->mappings[$competencyid] : false;
             // Skip the competencies that are not mapped.
             if ($mapto === false) {
                 $this->missingmappings[$competencyid] = true;
                 if ($this->removewhenmappingismissing) {
                     $competenciestoremovefromcourse[$competencyid] = true;
                 }
                 continue;
             }
             $transaction = $DB->start_delegated_transaction();
             try {
                 // Add the new competency to the course.
                 if (api::add_competency_to_course($courseid, $mapto)) {
                     // Find the added course competency.
                     $cc = course_competency::get_record(array('courseid' => $courseid, 'competencyid' => $mapto));
                     // Set the rule.
                     api::set_course_competency_ruleoutcome($cc, $this->coursescompetenciesoutcomes[$courseid][$competencyid]);
                     // Adapt the sortorder.
                     api::reorder_course_competency($courseid, $mapto, $competencyid);
                     $competenciestoremovefromcourse[$competencyid] = true;
                     $this->coursecompetencymigrations++;
                 } else {
                     // The competency was already in the course...
                     if ($this->removeoriginalwhenalreadypresent) {
                         $competenciestoremovefromcourse[$competencyid] = true;
                     } else {
                         $this->log_warning($courseid, $competencyid, null, get_string('warningdestinationcoursecompetencyalreadyexists', 'tool_lpmigrate'));
                     }
                 }
             } catch (moodle_exception $e) {
                 // There was a major problem with this competency, we will ignore it entirely for the course.
                 $skipcompetencies[$competencyid] = true;
                 $this->log_error($courseid, $competencyid, null, get_string('errorwhilemigratingcoursecompetencywithexception', 'tool_lpmigrate', $e->getMessage()));
                 try {
                     $transaction->rollback($e);
                 } catch (moodle_exception $e) {
                     // Catch the re-thrown exception.
                 }
                 continue;
             }
             $transaction->allow_commit();
         }
         // Then, convert the module competencies.
         if (!empty($this->modulecompetencies[$courseid])) {
             foreach ($this->modulecompetencies[$courseid] as $cmid => $competencyids) {
                 foreach ($competencyids as $competencyid) {
                     $this->modulecompetencyexpectedmigrations++;
                     // This mapped competency was not added to the course.
                     if (!empty($skipcompetencies[$competencyid])) {
                         continue;
                     }
                     $remove = true;
                     $mapto = isset($this->mappings[$competencyid]) ? $this->mappings[$competencyid] : false;
                     // We don't have mapping.
                     if ($mapto === false) {
                         if (!$this->removewhenmappingismissing) {
                             $remove = false;
                         }
                     } else {
                         // We have a mapping.
                         $transaction = $DB->start_delegated_transaction();
                         try {
                             // The competency was added successfully.
                             if (api::add_competency_to_course_module($cmid, $mapto)) {
                                 // Find the added module competency.
                                 $mc = course_module_competency::get_record(array('cmid' => $cmid, 'competencyid' => $mapto));
                                 // Set the competency rule.
                                 api::set_course_module_competency_ruleoutcome($mc, $this->modulecompetenciesoutcomes[$courseid][$cmid][$competencyid]);
                                 // Adapt the sortorder.
                                 api::reorder_course_module_competency($cmid, $mapto, $competencyid);
                                 $this->modulecompetencymigrations++;
                             } else {
                                 // The competency was already in the module.
                                 if (!$this->removeoriginalwhenalreadypresent) {
                                     $remove = false;
                                     $competencieswithissues[$competencyid] = true;
                                     $this->log_warning($courseid, $competencyid, $cmid, get_string('warningdestinationmodulecompetencyalreadyexists', 'tool_lpmigrate'));
                                 }
                             }
                         } catch (moodle_exception $e) {
                             // There was a major problem with this competency in this module.
                             $competencieswithissues[$competencyid] = true;
                             $message = get_string('errorwhilemigratingmodulecompetencywithexception', 'tool_lpmigrate', $e->getMessage());
                             $this->log_error($courseid, $competencyid, $cmid, $message);
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:framework_processor.php

示例2: test_set_ruleoutcome_course_competency

 /**
  * Test update ruleoutcome for course_competency.
  */
 public function test_set_ruleoutcome_course_competency()
 {
     $this->resetAfterTest(true);
     $dg = $this->getDataGenerator();
     $lpg = $dg->get_plugin_generator('core_competency');
     $u1 = $dg->create_user();
     $u2 = $dg->create_user();
     $course = $dg->create_course();
     $this->setAdminUser();
     $f = $lpg->create_framework();
     $c = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
     $cc = api::add_competency_to_course($course->id, $c->get_id());
     // Check record was created with default rule value Evidence.
     $this->assertEquals(1, \core_competency\course_competency::count_records());
     $recordscc = api::list_course_competencies($course->id);
     $this->assertEquals(\core_competency\course_competency::OUTCOME_EVIDENCE, $recordscc[0]['coursecompetency']->get_ruleoutcome());
     // Check ruleoutcome value is updated to None.
     $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get_id(), \core_competency\course_competency::OUTCOME_NONE));
     $recordscc = api::list_course_competencies($course->id);
     $this->assertEquals(\core_competency\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get_ruleoutcome());
 }
开发者ID:dg711,项目名称:moodle,代码行数:24,代码来源:api_test.php

示例3: set_course_competency_ruleoutcome

 /**
  * Change the ruleoutcome of a course competency.
  *
  * @param int $coursecompetencyid The course competency id
  * @param int $ruleoutcome The ruleoutcome value
  * @return bool
  */
 public static function set_course_competency_ruleoutcome($coursecompetencyid, $ruleoutcome)
 {
     $params = self::validate_parameters(self::set_course_competency_ruleoutcome_parameters(), array('coursecompetencyid' => $coursecompetencyid, 'ruleoutcome' => $ruleoutcome));
     $coursecompetency = new course_competency($params['coursecompetencyid']);
     self::validate_context(context_course::instance($coursecompetency->get_courseid()));
     return api::set_course_competency_ruleoutcome($coursecompetency, $params['ruleoutcome']);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:external.php


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