Skip to content

Commit

Permalink
MDL-53700 competency: Migrate main classes to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent 36a43db commit 67bc0ea
Show file tree
Hide file tree
Showing 152 changed files with 768 additions and 724 deletions.
2 changes: 1 addition & 1 deletion admin/tool/lp/amd/build/competency_rule_all.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/tool/lp/amd/build/competency_rule_points.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/tool/lp/amd/src/competency_rule_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ define(['jquery',
* @method getType
*/
Rule.prototype.getType = function() {
return 'tool_lp\\competency_rule_all';
return 'core_competency\\competency_rule_all';
};

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/amd/src/competency_rule_points.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ define(['jquery',
* @method getType
*/
Rule.prototype.getType = function() {
return 'tool_lp\\competency_rule_points';
return 'core_competency\\competency_rule_points';
};

/**
Expand Down
16 changes: 8 additions & 8 deletions admin/tool/lp/backup/moodle2/backup_tool_lp_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function define_course_plugin_structure() {
$pluginwrapper->add_child($coursecompetencysettings);

$sql = 'SELECT s.pushratingstouserplans
FROM {' . \tool_lp\course_competency_settings::TABLE . '} s
FROM {' . \core_competency\course_competency_settings::TABLE . '} s
WHERE s.courseid = :courseid';
$coursecompetencysettings->set_source_sql($sql, array('courseid' => backup::VAR_COURSEID));

Expand All @@ -65,9 +65,9 @@ protected function define_course_plugin_structure() {
$coursecompetencies->add_child($competency);

$sql = 'SELECT c.idnumber, cc.ruleoutcome, cc.sortorder, f.idnumber AS frameworkidnumber
FROM {' . \tool_lp\course_competency::TABLE . '} cc
JOIN {' . \tool_lp\competency::TABLE . '} c ON c.id = cc.competencyid
JOIN {' . \tool_lp\competency_framework::TABLE . '} f ON f.id = c.competencyframeworkid
FROM {' . \core_competency\course_competency::TABLE . '} cc
JOIN {' . \core_competency\competency::TABLE . '} c ON c.id = cc.competencyid
JOIN {' . \core_competency\competency_framework::TABLE . '} f ON f.id = c.competencyframeworkid
WHERE cc.courseid = :courseid
ORDER BY cc.sortorder';
$competency->set_source_sql($sql, array('courseid' => backup::VAR_COURSEID));
Expand All @@ -94,9 +94,9 @@ protected function define_module_plugin_structure() {
$coursecompetencies->add_child($competency);

$sql = 'SELECT c.idnumber, cmc.ruleoutcome, cmc.sortorder, f.idnumber AS frameworkidnumber
FROM {' . \tool_lp\course_module_competency::TABLE . '} cmc
JOIN {' . \tool_lp\competency::TABLE . '} c ON c.id = cmc.competencyid
JOIN {' . \tool_lp\competency_framework::TABLE . '} f ON f.id = c.competencyframeworkid
FROM {' . \core_competency\course_module_competency::TABLE . '} cmc
JOIN {' . \core_competency\competency::TABLE . '} c ON c.id = cmc.competencyid
JOIN {' . \core_competency\competency_framework::TABLE . '} f ON f.id = c.competencyframeworkid
WHERE cmc.cmid = :coursemoduleid
ORDER BY cmc.sortorder';
$competency->set_source_sql($sql, array('coursemoduleid' => backup::VAR_MODID));
Expand All @@ -111,7 +111,7 @@ protected function define_module_plugin_structure() {
*/
protected function get_include_condition() {
$result = '';
if (\tool_lp\course_competency::record_exists_select('courseid = ?', array($this->task->get_courseid()))) {
if (\core_competency\course_competency::record_exists_select('courseid = ?', array($this->task->get_courseid()))) {
$result = 'include';
};
return array('sqlparam' => $result);
Expand Down
20 changes: 10 additions & 10 deletions admin/tool/lp/backup/moodle2/restore_tool_lp_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function process_course_competency_settings($data) {

$data = (object) $data;
$courseid = $this->task->get_courseid();
$exists = \tool_lp\course_competency_settings::get_record(array('courseid' => $courseid));
$exists = \core_competency\course_competency_settings::get_record(array('courseid' => $courseid));

// Now update or insert.
if ($exists) {
Expand All @@ -79,7 +79,7 @@ public function process_course_competency_settings($data) {
return $settings->update();
} else {
$data = (object) array('courseid' => $courseid, 'pushratingstouserplans' => $data->pushratingstouserplans);
$settings = new \tool_lp\course_competency_settings(0, $data);
$settings = new \core_competency\course_competency_settings(0, $data);
return !empty($settings->create());
}
}
Expand All @@ -93,11 +93,11 @@ public function process_course_competency($data) {
$data = (object) $data;

// Mapping the competency by ID numbers.
$framework = \tool_lp\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber));
$framework = \core_competency\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber));
if (!$framework) {
return;
}
$competency = \tool_lp\competency::get_record(array('idnumber' => $data->idnumber,
$competency = \core_competency\competency::get_record(array('idnumber' => $data->idnumber,
'competencyframeworkid' => $framework->get_id()));
if (!$competency) {
return;
Expand All @@ -108,13 +108,13 @@ public function process_course_competency($data) {
'courseid' => $this->task->get_courseid()
);
$query = 'competencyid = :competencyid AND courseid = :courseid';
$existing = \tool_lp\course_competency::record_exists_select($query, $params);
$existing = \core_competency\course_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;
$coursecompetency = new \tool_lp\course_competency(0, $record);
$coursecompetency = new \core_competency\course_competency(0, $record);
$coursecompetency->create();
}

Expand All @@ -129,11 +129,11 @@ public function process_course_module_competency($data) {
$data = (object) $data;

// Mapping the competency by ID numbers.
$framework = \tool_lp\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber));
$framework = \core_competency\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber));
if (!$framework) {
return;
}
$competency = \tool_lp\competency::get_record(array('idnumber' => $data->idnumber,
$competency = \core_competency\competency::get_record(array('idnumber' => $data->idnumber,
'competencyframeworkid' => $framework->get_id()));
if (!$competency) {
return;
Expand All @@ -144,13 +144,13 @@ public function process_course_module_competency($data) {
'cmid' => $this->task->get_moduleid()
);
$query = 'competencyid = :competencyid AND cmid = :cmid';
$existing = \tool_lp\course_module_competency::record_exists_select($query, $params);
$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 \tool_lp\course_module_competency(0, $record);
$coursemodulecompetency = new \core_competency\course_module_competency(0, $record);
$coursemodulecompetency->create();
}

Expand Down
Loading

0 comments on commit 67bc0ea

Please sign in to comment.