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


PHP api::list_course_modules_using_competency方法代码示例

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


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

示例1: get_other_values

 protected function get_other_values(renderer_base $output)
 {
     // Arrays are copy on assign.
     $related = $this->related;
     $result = new stdClass();
     // Remove course from related as it is not wanted by the user_competency_summary_exporter.
     unset($related['course']);
     $related['usercompetencyplan'] = null;
     $related['usercompetency'] = null;
     $exporter = new user_competency_summary_exporter(null, $related);
     $result->usercompetencysummary = $exporter->export($output);
     $result->usercompetencysummary->cangrade = user_competency::can_grade_user_in_course($this->related['user']->id, $this->related['course']->id);
     $context = context_course::instance($this->related['course']->id);
     $exporter = new course_summary_exporter($this->related['course'], array('context' => $context));
     $result->course = $exporter->export($output);
     $coursemodules = api::list_course_modules_using_competency($this->related['competency']->get_id(), $this->related['course']->id);
     $fastmodinfo = get_fast_modinfo($this->related['course']->id);
     $exportedmodules = array();
     foreach ($coursemodules as $cm) {
         $cminfo = $fastmodinfo->cms[$cm];
         $cmexporter = new course_module_summary_exporter(null, array('cm' => $cminfo));
         $exportedmodules[] = $cmexporter->export($output);
     }
     $result->coursemodules = $exportedmodules;
     return (array) $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:26,代码来源:user_competency_summary_in_course_exporter.php

示例2: export_for_template

 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param renderer_base $output Renderer base.
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     global $USER;
     $data = new stdClass();
     $data->courseid = $this->courseid;
     $data->pagecontextid = $this->context->id;
     $data->competencies = array();
     $contextcache = array();
     $gradable = is_enrolled($this->context, $USER, 'moodle/competency:coursecompetencygradable');
     if ($gradable) {
         $usercompetencycourses = api::list_user_competencies_in_course($this->courseid, $USER->id);
         $data->gradableuserid = $USER->id;
     }
     $ruleoutcomelist = course_competency::get_ruleoutcome_list();
     $ruleoutcomeoptions = array();
     foreach ($ruleoutcomelist as $value => $text) {
         $ruleoutcomeoptions[$value] = array('value' => $value, 'text' => (string) $text, 'selected' => false);
     }
     foreach ($this->coursecompetencylist as $coursecompetencyelement) {
         $coursecompetency = $coursecompetencyelement['coursecompetency'];
         $competency = $coursecompetencyelement['competency'];
         if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
             $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
         }
         $context = $contextcache[$competency->get_competencyframeworkid()];
         $compexporter = new competency_exporter($competency, array('context' => $context));
         $ccexporter = new course_competency_exporter($coursecompetency, array('context' => $context));
         $ccoutcomeoptions = (array) (object) $ruleoutcomeoptions;
         $ccoutcomeoptions[$coursecompetency->get_ruleoutcome()]['selected'] = true;
         $coursemodules = api::list_course_modules_using_competency($competency->get_id(), $this->courseid);
         $fastmodinfo = get_fast_modinfo($this->courseid);
         $exportedmodules = array();
         foreach ($coursemodules as $cmid) {
             $cminfo = $fastmodinfo->cms[$cmid];
             $cmexporter = new course_module_summary_exporter(null, array('cm' => $cminfo));
             $exportedmodules[] = $cmexporter->export($output);
         }
         // Competency path.
         $pathexporter = new competency_path_exporter(['ancestors' => $competency->get_ancestors(), 'framework' => $competency->get_framework(), 'context' => $context]);
         $onerow = array('competency' => $compexporter->export($output), 'coursecompetency' => $ccexporter->export($output), 'ruleoutcomeoptions' => $ccoutcomeoptions, 'coursemodules' => $exportedmodules, 'comppath' => $pathexporter->export($output));
         if ($gradable) {
             $foundusercompetencycourse = false;
             foreach ($usercompetencycourses as $usercompetencycourse) {
                 if ($usercompetencycourse->get_competencyid() == $competency->get_id()) {
                     $foundusercompetencycourse = $usercompetencycourse;
                 }
             }
             if ($foundusercompetencycourse) {
                 $related = array('scale' => $competency->get_scale());
                 $exporter = new user_competency_course_exporter($foundusercompetencycourse, $related);
                 $onerow['usercompetencycourse'] = $exporter->export($output);
             }
         }
         array_push($data->competencies, $onerow);
     }
     $data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
     $data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
     $data->canconfigurecoursecompetencies = $this->canconfigurecoursecompetencies;
     $data->cangradecompetencies = $this->cangradecompetencies;
     $exporter = new course_competency_settings_exporter($this->coursecompetencysettings);
     $data->settings = $exporter->export($output);
     $related = array('context' => $this->context);
     $exporter = new course_competency_statistics_exporter($this->coursecompetencystatistics, $related);
     $data->statistics = $exporter->export($output);
     $data->manageurl = null;
     if ($this->canmanagecompetencyframeworks) {
         $data->manageurl = $this->manageurl->out(true);
     }
     return $data;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:76,代码来源:course_competencies_page.php

示例3: test_list_course_modules_using_competency

 public function test_list_course_modules_using_competency()
 {
     global $SITE;
     $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();
     $course2 = $dg->create_course();
     $this->setAdminUser();
     $f = $lpg->create_framework();
     $c = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
     $c2 = $lpg->create_competency(array('competencyframeworkid' => $f->get_id()));
     $cc = api::add_competency_to_course($course->id, $c->get_id());
     $cc2 = api::add_competency_to_course($course->id, $c2->get_id());
     // First check we get an empty list when there are no links.
     $expected = array();
     $result = api::list_course_modules_using_competency($c->get_id(), $course->id);
     $this->assertEquals($expected, $result);
     $pagegenerator = $this->getDataGenerator()->get_plugin_generator('mod_page');
     $page = $pagegenerator->create_instance(array('course' => $course->id));
     $cm = get_coursemodule_from_instance('page', $page->id);
     // Add a link and list again.
     $ccm = api::add_competency_to_course_module($cm, $c->get_id());
     $expected = array($cm->id);
     $result = api::list_course_modules_using_competency($c->get_id(), $course->id);
     $this->assertEquals($expected, $result);
     // Check a different course.
     $expected = array();
     $result = api::list_course_modules_using_competency($c->get_id(), $course2->id);
     $this->assertEquals($expected, $result);
     // Remove the link and check again.
     $result = api::remove_competency_from_course_module($cm, $c->get_id());
     $expected = true;
     $this->assertEquals($expected, $result);
     $expected = array();
     $result = api::list_course_modules_using_competency($c->get_id(), $course->id);
     $this->assertEquals($expected, $result);
     // Now add 2 links.
     api::add_competency_to_course_module($cm, $c->get_id());
     api::add_competency_to_course_module($cm, $c2->get_id());
     $result = api::list_course_module_competencies_in_course_module($cm->id);
     $this->assertEquals($result[0]->get_competencyid(), $c->get_id());
     $this->assertEquals($result[1]->get_competencyid(), $c2->get_id());
     // Now re-order.
     api::reorder_course_module_competency($cm, $c->get_id(), $c2->get_id());
     $result = api::list_course_module_competencies_in_course_module($cm->id);
     $this->assertEquals($result[0]->get_competencyid(), $c2->get_id());
     $this->assertEquals($result[1]->get_competencyid(), $c->get_id());
     // And re-order again.
     api::reorder_course_module_competency($cm, $c->get_id(), $c2->get_id());
     $result = api::list_course_module_competencies_in_course_module($cm->id);
     $this->assertEquals($result[0]->get_competencyid(), $c->get_id());
     $this->assertEquals($result[1]->get_competencyid(), $c2->get_id());
 }
开发者ID:dg711,项目名称:moodle,代码行数:56,代码来源:api_test.php


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