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


PHP api::list_course_competencies方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param string $elementName Element name
  * @param mixed $elementLabel Label(s) for an element
  * @param array $options Options to control the element's display
  * @param mixed $attributes Either a typical HTML attribute string or an associative array.
  */
 public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
 {
     global $OUTPUT;
     if ($elementName == null) {
         // This is broken quickforms messing with the constructors.
         return;
     }
     if (!isset($options['courseid'])) {
         throw new coding_exception('Course id is required for the course_competencies form element');
     }
     $courseid = $options['courseid'];
     if (!empty($options['cmid'])) {
         $current = \core_competency\api::list_course_module_competencies_in_course_module($options['cmid']);
         $ids = array();
         foreach ($current as $coursemodulecompetency) {
             array_push($ids, $coursemodulecompetency->get_competencyid());
         }
         $this->setValue($ids);
     }
     $competencies = api::list_course_competencies($courseid);
     $validoptions = array();
     $context = context_course::instance($courseid);
     foreach ($competencies as $competency) {
         // We don't need to show the description as part of the options, so just set this to null.
         $competency['competency']->set_description(null);
         $exporter = new competency_exporter($competency['competency'], array('context' => $context));
         $templatecontext = array('competency' => $exporter->export($OUTPUT));
         $id = $competency['competency']->get_id();
         $validoptions[$id] = $OUTPUT->render_from_template('tool_lp/competency_summary', $templatecontext);
     }
     $attributes['tags'] = false;
     $attributes['multiple'] = 'multiple';
     parent::__construct($elementName, $elementLabel, $validoptions, $attributes);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:42,代码来源:course_competencies_form_element.php

示例2: __construct

 /**
  * Construct this renderable.
  * @param int $courseid The course record for this page.
  */
 public function __construct($courseid)
 {
     $this->context = context_course::instance($courseid);
     $this->courseid = $courseid;
     $this->coursecompetencylist = api::list_course_competencies($courseid);
     $this->canmanagecoursecompetencies = has_capability('moodle/competency:coursecompetencymanage', $this->context);
     $this->canconfigurecoursecompetencies = has_capability('moodle/competency:coursecompetencyconfigure', $this->context);
     $this->cangradecompetencies = has_capability('moodle/competency:competencygrade', $this->context);
     $this->coursecompetencysettings = api::read_course_competency_settings($courseid);
     $this->coursecompetencystatistics = new course_competency_statistics($courseid);
     // Check the lowest level in which the user can manage the competencies.
     $this->manageurl = null;
     $this->canmanagecompetencyframeworks = false;
     $contexts = array_reverse($this->context->get_parent_contexts(true));
     foreach ($contexts as $context) {
         $canmanage = has_capability('moodle/competency:competencymanage', $context);
         if ($canmanage) {
             $this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $context->id));
             $this->canmanagecompetencyframeworks = true;
             break;
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:27,代码来源:course_competencies_page.php

示例3: 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

示例4: list_course_competencies

 /**
  * List the competencies (visible to this user) in this course.
  *
  * @param int $courseid The course id to check.
  * @return array
  */
 public static function list_course_competencies($courseid)
 {
     global $PAGE;
     $params = self::validate_parameters(self::list_course_competencies_parameters(), array('id' => $courseid));
     $coursecontext = context_course::instance($params['id']);
     self::validate_context($coursecontext);
     $output = $PAGE->get_renderer('core');
     $competencies = api::list_course_competencies($params['id']);
     $result = array();
     $contextcache = array();
     foreach ($competencies as $competency) {
         if (!isset($contextcache[$competency['competency']->get_competencyframeworkid()])) {
             $contextcache[$competency['competency']->get_competencyframeworkid()] = $competency['competency']->get_context();
         }
         $context = $contextcache[$competency['competency']->get_competencyframeworkid()];
         $exporter = new competency_exporter($competency['competency'], array('context' => $context));
         $competencyrecord = $exporter->export($output);
         $exporter = new course_competency_exporter($competency['coursecompetency'], array('context' => $context));
         $coursecompetencyrecord = $exporter->export($output);
         $result[] = array('competency' => $competencyrecord, 'coursecompetency' => $coursecompetencyrecord);
     }
     return $result;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:29,代码来源:external.php

示例5: export_for_template

 /**
  * Export the data.
  *
  * @param renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     global $CFG, $DB, $PAGE;
     $context = context_course::instance($this->courseid);
     $data = new stdClass();
     $data->userid = $this->userid;
     $data->competencyid = $this->competencyid;
     $data->courseid = $this->courseid;
     $data->baseurl = $this->baseurl;
     $data->groupselector = '';
     if (has_any_capability(array('moodle/competency:usercompetencyview', 'moodle/competency:coursecompetencymanage'), $context)) {
         $course = $DB->get_record('course', array('id' => $this->courseid));
         $currentgroup = groups_get_course_group($course, true);
         if ($currentgroup !== false) {
             $select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup);
             $data->groupselector = $select;
         }
         // Fetch showactive.
         $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
         $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
         $showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
         $users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.*', null, 0, 0, $showonlyactiveenrol);
         $data->users = array();
         foreach ($users as $user) {
             $exporter = new user_summary_exporter($user);
             $user = $exporter->export($output);
             if ($user->id == $this->userid) {
                 $user->selected = true;
             }
             $data->users[] = $user;
         }
         $data->hasusers = true;
     } else {
         $data->users = array();
         $data->hasusers = false;
     }
     $coursecompetencies = \core_competency\api::list_course_competencies($this->courseid);
     $data->competencies = array();
     $contextcache = array();
     foreach ($coursecompetencies as $coursecompetency) {
         $frameworkid = $coursecompetency['competency']->get_competencyframeworkid();
         if (!isset($contextcache[$frameworkid])) {
             $contextcache[$frameworkid] = $coursecompetency['competency']->get_context();
         }
         $context = $contextcache[$frameworkid];
         $coursecompetencycontext = $context;
         $exporter = new competency_exporter($coursecompetency['competency'], array('context' => $coursecompetencycontext));
         $competency = $exporter->export($output);
         if ($competency->id == $this->competencyid) {
             $competency->selected = true;
         }
         $data->competencies[] = $competency;
     }
     $data->hascompetencies = count($data->competencies);
     return $data;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:62,代码来源:user_competency_course_navigation.php

示例6: export_for_template

 /**
  * Export this data so it can be used as the context for a mustache template.
  *
  * @param \renderer_base $output
  * @return stdClass
  */
 public function export_for_template(renderer_base $output)
 {
     global $DB;
     $data = new stdClass();
     $data->courseid = $this->courseid;
     $course = $DB->get_record('course', array('id' => $this->courseid));
     $coursecontext = context_course::instance($course->id);
     $exporter = new course_summary_exporter($course, array('context' => $coursecontext));
     $coursecompetencysettings = api::read_course_competency_settings($course->id);
     $data->pushratingstouserplans = $coursecompetencysettings->get_pushratingstouserplans();
     $data->course = $exporter->export($output);
     $data->usercompetencies = array();
     $scalecache = array();
     $frameworkcache = array();
     $user = core_user::get_user($this->userid);
     $exporter = new user_summary_exporter($user);
     $data->user = $exporter->export($output);
     $data->usercompetencies = array();
     $coursecompetencies = api::list_course_competencies($this->courseid);
     $usercompetencycourses = api::list_user_competencies_in_course($this->courseid, $user->id);
     foreach ($usercompetencycourses as $usercompetencycourse) {
         $onerow = new stdClass();
         $competency = null;
         foreach ($coursecompetencies as $coursecompetency) {
             if ($coursecompetency['competency']->get_id() == $usercompetencycourse->get_competencyid()) {
                 $competency = $coursecompetency['competency'];
                 break;
             }
         }
         if (!$competency) {
             continue;
         }
         // Fetch the framework.
         if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
             $frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
         }
         $framework = $frameworkcache[$competency->get_competencyframeworkid()];
         // Fetch the scale.
         $scaleid = $competency->get_scaleid();
         if ($scaleid === null) {
             $scaleid = $framework->get_scaleid();
             if (!isset($scalecache[$scaleid])) {
                 $scalecache[$competency->get_scaleid()] = $framework->get_scale();
             }
         } else {
             if (!isset($scalecache[$scaleid])) {
                 $scalecache[$competency->get_scaleid()] = $competency->get_scale();
             }
         }
         $scale = $scalecache[$competency->get_scaleid()];
         $exporter = new user_competency_course_exporter($usercompetencycourse, array('scale' => $scale));
         $record = $exporter->export($output);
         $onerow->usercompetencycourse = $record;
         $exporter = new competency_summary_exporter(null, array('competency' => $competency, 'framework' => $framework, 'context' => $framework->get_context(), 'relatedcompetencies' => array(), 'linkedcourses' => array()));
         $onerow->competency = $exporter->export($output);
         array_push($data->usercompetencies, $onerow);
     }
     return $data;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:65,代码来源:report.php


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