Skip to content

Commit

Permalink
MDL-53700 competency: Migrating other competency related plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent ca94bcd commit a6a722d
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 59 deletions.
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

use stdClass;
use context_system;
use tool_lp\invalid_persistent_exception;
use core_competency\invalid_persistent_exception;

/**
* Class for doing things with cohort roles.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/classes/cohort_role_assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace tool_cohortroles;

use lang_string;
use tool_lp\persistent;
use core_competency\persistent;

/**
* Class for loading/storing cohort_role_assignments from the DB.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/cohortroles/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function test_create_cohort_role_assignment_without_permission() {
}

public function test_create_cohort_role_assignment_with_invalid_data() {
$this->setExpectedException('tool_lp\invalid_persistent_exception');
$this->setExpectedException('core_competency\invalid_persistent_exception');
$this->setAdminUser();
$params = (object) array(
'userid' => $this->userassignto->id,
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lpmigrate/classes/framework_mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace tool_lpmigrate;
defined('MOODLE_INTERNAL') || die();

use tool_lp\api;
use core_competency\api;

/**
* Framework mapper class.
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lpmigrate/classes/framework_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

use coding_exception;
use moodle_exception;
use tool_lp\api;
use tool_lp\competency;
use tool_lp\course_competency;
use tool_lp\course_module_competency;
use core_competency\api;
use core_competency\competency;
use core_competency\course_competency;
use core_competency\course_module_competency;

/**
* Processor class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
use renderable;
use templatable;
use stdClass;
use tool_lp\competency;
use tool_lp\competency_framework;
use core_competency\competency;
use core_competency\competency_framework;
use core_competency\external\competency_exporter;
use core_competency\external\competency_framework_exporter;
use tool_lpmigrate\framework_processor;

/**
Expand Down Expand Up @@ -95,22 +97,22 @@ public function export_for_template(\renderer_base $output) {
$data->unmappedfrom = array();
$data->unmappedto = array();

$exporter = new \tool_lp\external\competency_framework_exporter($this->frameworkfrom);
$exporter = new competency_framework_exporter($this->frameworkfrom);
$data->frameworkfrom = $exporter->export($output);
$exporter = new \tool_lp\external\competency_framework_exporter($this->frameworkto);
$exporter = new competency_framework_exporter($this->frameworkto);
$data->frameworkto = $exporter->export($output);

$fromcontext = $this->frameworkfrom->get_context();
$tocontext = $this->frameworkto->get_context();

$compcontext = null;
foreach ($this->unmappedfrom as $comp) {
$exporter = new \tool_lp\external\competency_exporter($comp, array('context' => $fromcontext));
$exporter = new competency_exporter($comp, array('context' => $fromcontext));
$data->unmappedfrom[] = $exporter->export($output);
}

foreach ($this->unmappedto as $comp) {
$exporter = new \tool_lp\external\competency_exporter($comp, array('context' => $tocontext));
$exporter = new competency_exporter($comp, array('context' => $tocontext));
$data->unmappedto[] = $exporter->export($output);
}

Expand Down
3 changes: 2 additions & 1 deletion admin/tool/lpmigrate/frameworks.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
$unmappedfrom = $mapper->get_unmapped_objects_from();
$unmappedto = $mapper->get_unmapped_objects_to();
$renderable = new \tool_lpmigrate\output\migrate_framework_results($context, $processor,
\tool_lp\api::read_framework($data->from), \tool_lp\api::read_framework($data->to), $unmappedfrom, $unmappedto);
\core_competency\api::read_framework($data->from), \core_competency\api::read_framework($data->to),
$unmappedfrom, $unmappedto);
echo $output->render($renderable);

} else {
Expand Down
6 changes: 4 additions & 2 deletions admin/tool/lpmigrate/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
*/
defined('MOODLE_INTERNAL') || die();

if (\tool_lp\api::is_enabled()) {
if (\core_competency\api::is_enabled()) {

$parentname = 'competencies';

// Manage competency frameworks page.
$temp = new admin_externalpage(
Expand All @@ -32,6 +34,6 @@
new moodle_url('/admin/tool/lpmigrate/frameworks.php'),
array('tool/lpmigrate:frameworksmigrate')
);
$ADMIN->add('toollprootpage', $temp);
$ADMIN->add($parentname, $temp);

}
16 changes: 8 additions & 8 deletions admin/tool/lpmigrate/tests/processor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
defined('MOODLE_INTERNAL') || die();
global $CFG;

use \tool_lp\course_competency;
use \tool_lp\course_module_competency;
use \tool_lpmigrate\framework_mapper;
use \tool_lpmigrate\framework_processor;
use core_competency\course_competency;
use core_competency\course_module_competency;
use tool_lpmigrate\framework_mapper;
use tool_lpmigrate\framework_processor;

/**
* Framework processor testcase.
Expand All @@ -49,7 +49,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
public function setUp() {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$f1 = $lpg->create_framework(array('idnumber' => 'BIO2015'));
$f2 = $lpg->create_framework(array('idnumber' => 'BIO2016'));
Expand Down Expand Up @@ -313,7 +313,7 @@ public function test_course_start_date_from() {

public function test_destination_competency_exists() {
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

// Pre-add the new competency to course 1.
$lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get_id()));
Expand Down Expand Up @@ -361,7 +361,7 @@ public function test_destination_competency_exists() {

public function test_destination_competency_exists_remove_original() {
$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

// Pre-add the new competency to course 1.
$lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get_id()));
Expand Down Expand Up @@ -410,7 +410,7 @@ public function test_permission_exception() {

$dg->enrol_user($u->id, $this->c1->id, 'editingteacher');
$dg->enrol_user($u->id, $this->c2->id, 'editingteacher');
assign_capability('tool/lp:coursecompetencymanage', CAP_PROHIBIT, $role, $sysctx->id);
assign_capability('moodle/competency:coursecompetencymanage', CAP_PROHIBIT, $role, $sysctx->id);
role_assign($role, $u->id, context_course::instance($this->c1->id)->id);
role_assign($role, $u->id, context_module::instance($this->cms[$this->c2->id]['F1']->cmid)->id);

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lpmigrate/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
$plugin->requires = 2014110400; // Requires this Moodle version.
$plugin->component = 'tool_lpmigrate'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
'tool_lp' => 2016020904
'tool_lp' => ANY_VERSION
);
2 changes: 1 addition & 1 deletion blocks/lp/block_lp.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public function get_content() {
if (isset($this->content)) {
return $this->content;
}
$this->content = new stdClass();

$summary = new \block_lp\output\summary();
if (!$summary->has_content()) {
return $this->content;
}

$renderer = $this->page->get_renderer('block_lp');
$this->content = new stdClass();
$this->content->text = $renderer->render($summary);
$this->content->footer = '';

Expand Down
8 changes: 4 additions & 4 deletions blocks/lp/classes/output/competencies_to_review_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
use templatable;
use renderer_base;
use stdClass;
use tool_lp\api;
use tool_lp\external\competency_exporter;
use tool_lp\external\user_competency_exporter;
use tool_lp\external\user_summary_exporter;
use moodle_url;
use core_competency\api;
use core_competency\external\competency_exporter;
use core_competency\external\user_competency_exporter;
use core_competency\external\user_summary_exporter;

/**
* Competencies to review renderable class.
Expand Down
6 changes: 3 additions & 3 deletions blocks/lp/classes/output/plans_to_review_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
use templatable;
use renderer_base;
use stdClass;
use tool_lp\api;
use tool_lp\external\plan_exporter;
use tool_lp\external\user_summary_exporter;
use moodle_url;
use core_competency\api;
use core_competency\external\plan_exporter;
use core_competency\external\user_summary_exporter;

/**
* Plans to review renderable class.
Expand Down
13 changes: 7 additions & 6 deletions blocks/lp/classes/output/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
namespace block_lp\output;
defined('MOODLE_INTERNAL') || die();

use tool_lp\api;
use tool_lp\external\competency_exporter;
use tool_lp\external\plan_exporter;
use tool_lp\external\user_competency_exporter;
use tool_lp\external\user_summary_exporter;
use core_competency\api;
use core_competency\external\competency_exporter;
use core_competency\external\plan_exporter;
use core_competency\external\user_competency_exporter;
use core_competency\external\user_summary_exporter;
use core_competency\plan;
use renderable;
use renderer_base;
use templatable;
Expand Down Expand Up @@ -81,7 +82,7 @@ public function export_for_template(renderer_base $output) {
if (count($plans) >= 3) {
break;
}
if ($plan->get_status() == \tool_lp\plan::STATUS_ACTIVE) {
if ($plan->get_status() == plan::STATUS_ACTIVE) {
$plans[] = $plan;
}
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/lp/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
$plugin->requires = 2014110400;
$plugin->component = 'block_lp';
$plugin->dependencies = array(
'tool_lp' => 2015111035
'tool_lp' => ANY_VERSION
);
2 changes: 1 addition & 1 deletion report/competency/amd/build/grading_popup.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 report/competency/amd/src/grading_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
// Log the user competency viewed in course event.
requests[0].then(function(){
ajax.call([{
methodname : 'tool_lp_user_competency_viewed_in_course',
methodname : 'core_competency_user_competency_viewed_in_course',
args: { userid: userId, competencyid: competencyId, courseid: courseId },
fail: notification.exception
}]);
Expand Down
6 changes: 3 additions & 3 deletions report/competency/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
use external_multiple_structure;
use external_single_structure;
use external_value;
use core_competency\external\user_competency_course_exporter;
use core_competency\external\user_summary_exporter;
use tool_lp\external\competency_summary_exporter;
use tool_lp\external\course_summary_exporter;
use tool_lp\external\user_competency_course_exporter;
use tool_lp\external\user_summary_exporter;

/**
* This is the external API for this report.
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function data_for_report($courseid, $userid) {
);
$context = context_course::instance($params['courseid']);
self::validate_context($context);
if (!is_enrolled($context, $params['userid'], 'tool/lp:coursecompetencygradable')) {
if (!is_enrolled($context, $params['userid'], 'moodle/competency:coursecompetencygradable')) {
throw new coding_exception('invaliduser');
}

Expand Down
12 changes: 6 additions & 6 deletions report/competency/classes/output/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
namespace report_competency\output;

use context_course;
use tool_lp\external\competency_summary_exporter;
use tool_lp\external\course_summary_exporter;
use tool_lp\external\user_competency_course_exporter;
use tool_lp\external\user_summary_exporter;
use tool_lp\user_competency;
use renderable;
use core_user;
use templatable;
use renderer_base;
use moodle_url;
use stdClass;
use tool_lp\api;
use core_competency\api;
use core_competency\external\user_competency_course_exporter;
use core_competency\external\user_summary_exporter;
use core_competency\user_competency;
use tool_lp\external\competency_summary_exporter;
use tool_lp\external\course_summary_exporter;

/**
* Class containing data for learning plan template competencies page
Expand Down
6 changes: 3 additions & 3 deletions report/competency/classes/output/user_course_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use renderer_base;
use templatable;
use context_course;
use \tool_lp\external\user_summary_exporter;
use core_competency\external\user_summary_exporter;
use stdClass;

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ public function export_for_template(renderer_base $output) {
$data->baseurl = $this->baseurl;
$data->groupselector = '';

if (has_capability('tool/lp:coursecompetencymanage', $context)) {
if (has_capability('moodle/competency:coursecompetencymanage', $context)) {
$course = $DB->get_record('course', array('id' => $this->courseid));
$currentgroup = groups_get_course_group($course, true);
if ($currentgroup !== false) {
Expand All @@ -93,7 +93,7 @@ public function export_for_template(renderer_base $output) {
// Fetch current active group.
$groupmode = groups_get_course_groupmode($course);

$users = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup,
$users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup,
'u.*', null, 0, 0, $showonlyactiveenrol);

$data->users = array();
Expand Down
2 changes: 1 addition & 1 deletion report/competency/db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
'classpath' => '',
'description' => 'Load the data for the competency report in a course.',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
)
);
Expand Down
4 changes: 2 additions & 2 deletions report/competency/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
$groupmode = groups_get_course_groupmode($course);
$currentgroup = groups_get_course_group($course, true);
if (empty($currentuser)) {
$gradable = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1);
$gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1);
if (empty($gradable)) {
$currentuser = 0;
} else {
$currentuser = array_pop($gradable)->id;
}
} else {
$gradable = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup, 'u.id');
$gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id');
if (count($gradable) == 0) {
$currentuser = 0;
} else if (!in_array($currentuser, array_keys($gradable))) {
Expand Down
2 changes: 1 addition & 1 deletion report/competency/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @param stdClass $context The context of the course
*/
function report_competency_extend_navigation_course($navigation, $course, $context) {
if (has_capability('tool/lp:coursecompetencyview', $context)) {
if (has_capability('moodle/competency:coursecompetencyview', $context)) {
$url = new moodle_url('/report/competency/index.php', array('id' => $course->id));
$name = get_string('pluginname', 'report_competency');
$navigation->add($name, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
Expand Down

0 comments on commit a6a722d

Please sign in to comment.