/** * Process a course module competency. * * @param array $data The data. */ public function process_course_module_competency($data) { $data = (object) $data; // Mapping the competency by ID numbers. $framework = \core_competency\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber)); if (!$framework) { return; } $competency = \core_competency\competency::get_record(array('idnumber' => $data->idnumber, 'competencyframeworkid' => $framework->get_id())); if (!$competency) { return; } $params = array('competencyid' => $competency->get_id(), 'cmid' => $this->task->get_moduleid()); $query = 'competencyid = :competencyid AND cmid = :cmid'; $existing = \core_competency\course_module_competency::record_exists_select($query, $params); if (!$existing) { // Sortorder is ignored by precaution, anyway we should walk through the records in the right order. $record = (object) $params; $record->ruleoutcome = $data->ruleoutcome; $coursemodulecompetency = new \core_competency\course_module_competency(0, $record); $coursemodulecompetency->create(); } }
/** * Assert that the course module competency does not exist. * * @param stdClass $cm The CM. * @param competency $competency The competency. */ protected function assertModuleCompetencyNotExists($cm, $competency) { $this->assertFalse(course_module_competency::record_exists_select("cmid = :cmid AND competencyid = :competencyid", array('cmid' => $cm->cmid, 'competencyid' => $competency->get_id()))); }