Skip to content

Commit

Permalink
MDL-53700 competency: Migrating the competency API to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent 72018c0 commit 767f66c
Show file tree
Hide file tree
Showing 51 changed files with 120 additions and 134 deletions.
4 changes: 2 additions & 2 deletions admin/tool/lp/classes/course_competencies_form_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

global $CFG;

use tool_lp\api;
use core_competency\api;
use core_competency\external\competency_exporter;
require_once($CFG->libdir . '/form/autocomplete.php');

Expand Down Expand Up @@ -62,7 +62,7 @@ public function __construct($elementName=null, $elementLabel=null, $options=arra
$courseid = $options['courseid'];

if (!empty($options['cmid'])) {
$current = \tool_lp\api::list_course_module_competencies_in_course_module($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());
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/lp/classes/course_competency_rule_form_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

global $CFG;

use tool_lp\api;
use core_competency\api;
use core_competency\external\competency_exporter;
use core_competency\course_module_competency;

Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct($elementName=null, $elementLabel=null, $options=arra
if (!empty($options['cmid'])) {
$cmid = $options['cmid'];

$current = \tool_lp\api::list_course_module_competencies_in_course_module($cmid);
$current = \core_competency\api::list_course_module_competencies_in_course_module($cmid);

// Note: We just pick the outcome set on the first course_module_competency - because in our UI are are
// forcing them to be all the same for each activity.
Expand Down
1 change: 1 addition & 0 deletions admin/tool/lp/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use invalid_parameter_exception;
use required_capability_exception;
use grade_scale;
use core_competency\api;
use core_competency\competency;
use core_competency\competency_framework;
use core_competency\course_competency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
namespace tool_lp\external;

use tool_lp\api;
use core_competency\api;
use context_course;
use renderer_base;
use stdClass;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/competency_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use templatable;
use renderer_base;
use stdClass;
use tool_lp\api;
use core_competency\api;
use tool_lp\external\competency_summary_exporter;

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/course_competencies_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use moodle_url;
use context_system;
use context_course;
use tool_lp\api;
use core_competency\api;
use tool_lp\course_competency_statistics;
use core_competency\competency;
use core_competency\course_competency;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/manage_competencies_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use stdClass;
use moodle_url;
use context_system;
use tool_lp\api;
use core_competency\api;
use core_competency\competency;
use core_competency\competency_framework;
use core_competency\external\competency_framework_exporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use moodle_url;
use context;
use context_system;
use tool_lp\api;
use core_competency\api;
use core_competency\competency_framework;
use core_competency\external\competency_framework_exporter;

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/manage_templates_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use stdClass;
use moodle_url;
use context_system;
use tool_lp\api;
use core_competency\api;
use core_competency\template;
use core_competency\external\template_exporter;

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/plan_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use templatable;
use stdClass;
use moodle_url;
use tool_lp\api;
use core_competency\api;
use core_competency\plan;
use core_competency\external\competency_exporter;
use core_competency\external\plan_exporter;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/plans_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use stdClass;
use single_button;
use moodle_url;
use tool_lp\api;
use core_competency\api;
use core_competency\external\plan_exporter;
use core_competency\plan;
use core_competency\user_evidence;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/related_competencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use renderer_base;
use stdClass;
use moodle_url;
use tool_lp\api;
use core_competency\api;
use core_competency\external\competency_exporter;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use moodle_url;
use core_competency\external\template_exporter;
use core_competency\template;
use tool_lp\api;
use core_competency\api;
use tool_lp\external\competency_summary_exporter;
use tool_lp\external\template_statistics_exporter;
use tool_lp\template_statistics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function export_for_template(renderer_base $output) {
$data->hasusers = false;
}

$coursecompetencies = \tool_lp\api::list_course_competencies($this->courseid);
$coursecompetencies = \core_competency\api::list_course_competencies($this->courseid);
$data->competencies = array();
$contextcache = array();
foreach ($coursecompetencies as $coursecompetency) {
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/user_competency_summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use renderer_base;
use renderable;
use templatable;
use tool_lp\api;
use core_competency\api;
use core_competency\user_competency;
use tool_lp\external\user_competency_summary_exporter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use renderable;
use renderer_base;
use templatable;
use tool_lp\api;
use core_competency\api;
use core_competency\user_competency;
use tool_lp\external\user_competency_summary_in_course_exporter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

use renderable;
use templatable;
use tool_lp\api;
use core_competency\api;
use tool_lp\external\user_competency_summary_in_plan_exporter;

/**
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/user_evidence_list_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use stdClass;
use single_button;
use moodle_url;
use tool_lp\api;
use core_competency\api;
use tool_lp\external\user_evidence_summary_exporter;
use core_competency\user_evidence;
use context_user;
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/output/user_evidence_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use renderable;
use templatable;
use stdClass;
use tool_lp\api;
use core_competency\api;
use tool_lp\external\user_evidence_summary_exporter;

/**
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/competencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
$search = optional_param('search', '', PARAM_RAW);

require_login();
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();

$pagecontext = context::instance_by_id($pagecontextid);
$framework = \tool_lp\api::read_framework($id);
$framework = \core_competency\api::read_framework($id);
$context = $framework->get_context();

if (!\core_competency\competency_framework::can_read_context($context)) {
Expand Down Expand Up @@ -62,6 +62,6 @@
echo $output->render($page);

// Log the framework viewed event after rendering the page.
\tool_lp\api::competency_framework_viewed($framework);
\core_competency\api::competency_framework_viewed($framework);

echo $output->footer();
2 changes: 1 addition & 1 deletion admin/tool/lp/competencyframeworks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$url->param('pagecontextid', $pagecontextid);

require_login();
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();

if (!\core_competency\competency_framework::can_read_context($context)) {
throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/coursecompetencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$course = $DB->get_record('course', $params, '*', MUST_EXIST);

require_login($course);
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();

$context = context_course::instance($course->id);
$urlparams = array('courseid' => $id);
Expand Down
12 changes: 6 additions & 6 deletions admin/tool/lp/editcompetency.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$parentid = optional_param('parentid', 0, PARAM_INT);

require_login();
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();

if (empty($competencyframeworkid) && empty($id)) {
throw new coding_exception('Competencyframeworkid param is required');
Expand All @@ -40,13 +40,13 @@
// Get competency framework.
$competencyframework = null;
if (!empty($competencyframeworkid)) {
$competencyframework = \tool_lp\api::read_framework($competencyframeworkid);
$competencyframework = \core_competency\api::read_framework($competencyframeworkid);
}

// Get competency.
$competency = null;
if (!empty($id)) {
$competency = \tool_lp\api::read_competency($id);
$competency = \core_competency\api::read_competency($id);
if (empty($competencyframework)) {
$competencyframework = $competency->get_framework();
}
Expand All @@ -57,7 +57,7 @@
if ($competency) {
$parent = $competency->get_parent();
} else if ($parentid) {
$parent = \tool_lp\api::read_competency($parentid);
$parent = \core_competency\api::read_competency($parentid);
}

// Get page URL.
Expand Down Expand Up @@ -90,10 +90,10 @@
$data = $form->get_data();
if ($data) {
if (empty($competency)) {
\tool_lp\api::create_competency($data);
\core_competency\api::create_competency($data);
$returnmsg = get_string('competencycreated', 'tool_lp');
} else {
\tool_lp\api::update_competency($data);
\core_competency\api::update_competency($data);
$returnmsg = get_string('competencyupdated', 'tool_lp');
}
redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/editcompetencyframework.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// We check that we have the permission to edit this framework, in its own context.
require_login();
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();
require_capability('moodle/competency:competencymanage', $context);

// Set up the framework page.
Expand All @@ -55,15 +55,15 @@
if (empty($data->id)) {
// Create new framework.
$data->contextid = $context->id;
$framework = \tool_lp\api::create_framework($data);
$framework = \core_competency\api::create_framework($data);
$frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array(
'pagecontextid' => $pagecontextid,
'competencyframeworkid' => $framework->get_id()
));
$messagesuccess = get_string('competencyframeworkcreated', 'tool_lp');
redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
} else {
\tool_lp\api::update_framework($data);
\core_competency\api::update_framework($data);
$messagesuccess = get_string('competencyframeworkupdated', 'tool_lp');
redirect($frameworksurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
}
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lp/editplan.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$returntype = optional_param('return', null, PARAM_ALPHA);

require_login(0, false);
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();

$url = new moodle_url('/admin/tool/lp/editplan.php', array('id' => $id, 'userid' => $userid, 'return' => $returntype));

Expand All @@ -39,7 +39,7 @@
$pagetitle = get_string('addnewplan', 'tool_lp');
list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_plan($userid, $url, null, $pagetitle, $returntype);
} else {
$plan = \tool_lp\api::read_plan($id);
$plan = \core_competency\api::read_plan($id);

// The userid parameter must be the same as the owner of the plan.
if ($userid != $plan->get_userid()) {
Expand Down Expand Up @@ -80,11 +80,11 @@

if ($data) {
if (empty($data->id)) {
$plan = \tool_lp\api::create_plan($data);
$plan = \core_competency\api::create_plan($data);
$returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get_id()]);
$returnmsg = get_string('plancreated', 'tool_lp');
} else {
\tool_lp\api::update_plan($data);
\core_competency\api::update_plan($data);
$returnmsg = get_string('planupdated', 'tool_lp');
}
redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lp/edittemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// We check that we have the permission to edit this framework, in its own context.
require_login(0, false);
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();
require_capability('moodle/competency:templatemanage', $context);

// We keep the original context in the URLs, so that we remain in the same context.
Expand All @@ -55,7 +55,7 @@
list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, null, $pagetitle,
$returntype);
} else {
$template = \tool_lp\api::read_template($id);
$template = \core_competency\api::read_template($id);
$pagetitle = get_string('edittemplate', 'tool_lp');
list($title, $subtitle, $returnurl) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template,
$pagetitle, $returntype);
Expand All @@ -69,14 +69,14 @@
$data = $form->get_data();
if ($data) {
if (empty($data->id)) {
$template = \tool_lp\api::create_template($data);
$template = \core_competency\api::create_template($data);
$returnurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', [
'templateid' => $template->get_id(),
'pagecontextid' => $pagecontextid
]);
$returnmsg = get_string('templatecreated', 'tool_lp');
} else {
\tool_lp\api::update_template($data);
\core_competency\api::update_template($data);
$returnmsg = get_string('templateupdated', 'tool_lp');
}
redirect($returnurl, $returnmsg, null, \core\output\notification::NOTIFY_SUCCESS);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/learningplans.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$context = context::instance_by_id($pagecontextid);

require_login(0, false);
\tool_lp\api::require_enabled();
\core_competency\api::require_enabled();
if (!\core_competency\template::can_read_context($context)) {
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
Expand Down
Loading

0 comments on commit 767f66c

Please sign in to comment.