public static function list_course_modules_using_competency($competencyid, $courseid) {
global $PAGE;
- $params = self::validate_parameters(self::list_course_modules_using_competency_parameters(),
- array(
- 'competencyid' => $competencyid,
- 'courseid' => $courseid,
- ));
+ $params = self::validate_parameters(self::list_course_modules_using_competency_parameters(), array(
+ 'competencyid' => $competencyid,
+ 'courseid' => $courseid,
+ ));
$coursecontext = context_course::instance($params['courseid']);
self::validate_context($coursecontext);
$coursemodules = api::list_course_modules_using_competency($params['competencyid'], $params['courseid']);
$result = array();
- // FIXME: Test this code and find it broken.
- $fastmodinfo = get_fast_modinfo($cm->course);
+ $fastmodinfo = get_fast_modinfo($params['courseid']);
foreach ($coursemodules as $cmid) {
$cminfo = $fastmodinfo->cms[$cmid];
$othervalues = $this->get_other_values($output);
if (array_intersect_key($values, $othervalues)) {
// Attempt to replace a standard property.
- //FIXME: property is not defined.
- throw new coding_exception('Cannot override a standard property value: ' . $property);
+ throw new coding_exception('Cannot override a standard property value.');
}
$values += $othervalues;
$record = (object) $values;
* Setup the headers for the table.
*/
protected function define_table_columns() {
- // FIXME: Should we use these?
- $extrafields = get_extra_user_fields($this->context);
-
// Define headers and columns.
$cols = array(
'name' => get_string('name', 'cohort'),
$competencies = user_competency_plan::list_competencies($this->get_id(), $this->get_userid());
} else if ($this->is_based_on_template()) {
// Get the competencies from the template.
- // FIXME: why are you passing a second param?
- $competencies = template_competency::list_competencies($this->get_templateid(), true);
+ $competencies = template_competency::list_competencies($this->get_templateid());
} else {
// Get the competencies from the plan.
$competencies = plan_competency::list_competencies($this->get_id());
if (\tool_lp\plan::can_read_user($user->id)) {
$node = $navigation->add(get_string('learningplans', 'tool_lp'),
new moodle_url('/admin/tool/lp/plans.php', array('userid' => $user->id)));
- }
- if (\tool_lp\user_evidence::can_read_user($user->id)) {
- // FIXME: this should be in the above if statment, or fixed, don't rely on the
- // first condition always being true.
- $node->add(get_string('userevidence', 'tool_lp'),
- new moodle_url('/admin/tool/lp/user_evidence_list.php', array('userid' => $user->id)));
+ if (\tool_lp\user_evidence::can_read_user($user->id)) {
+ $node->add(get_string('userevidence', 'tool_lp'),
+ new moodle_url('/admin/tool/lp/user_evidence_list.php', array('userid' => $user->id)));
+ }
}
+
}
/**
$settings = course_competency_settings::get_by_courseid($course->id);
$this->assertTrue((bool)$settings->get_pushratingstouserplans());
-
+
$result = external::update_course_competency_settings($course->id, array('pushratingstouserplans' => false));
$settings = course_competency_settings::get_by_courseid($course->id);
$this->setExpectedException('required_capability_exception');
$result = external::update_course_competency_settings($course->id, array('pushratingstouserplans' => true));
}
+
+ public function test_list_course_modules_using_competency() {
+ $this->setAdminUser();
+
+ $dg = $this->getDataGenerator();
+ $lpg = $dg->get_plugin_generator('tool_lp');
+
+ $course = $dg->create_course();
+ $cm1 = $dg->create_module('assign', array('course' => $course->id));
+
+ $f1 = $lpg->create_framework();
+ $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
+ $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $c1->get_id()));
+ $lpg->create_course_module_competency(array('cmid' => $cm1->cmid, 'competencyid' => $c1->get_id()));
+
+ $result = external::list_course_modules_using_competency($c1->get_id(), $course->id);
+ $result = external_api::clean_returnvalue(external::list_course_modules_using_competency_returns(), $result);
+ $this->assertCount(1, $result);
+ $this->assertEquals($cm1->cmid, $result[0]['id']);
+ }
}