MDL-53700 competency: Migrating settings to core

This commit is contained in:
Frederic Massart 2016-04-06 12:22:34 +08:00
parent 5a1a685c28
commit 6be1373ee0
14 changed files with 99 additions and 36 deletions

View File

@ -0,0 +1,50 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File.
*
* @package core_competency
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// Save processing when the user will not be able to access anything.
if (has_capability('moodle/site:config', $systemcontext)) {
$parentname = 'competencies';
// Settings page.
$settings = new admin_settingpage('competencysettings', new lang_string('competenciessettings', 'core_competency'),
'moodle/site:config', false);
$ADMIN->add($parentname, $settings);
// Load the full tree of settings.
if ($ADMIN->fulltree) {
$setting = new admin_setting_configcheckbox('core_competency/enabled',
new lang_string('enablecompetencies', 'core_competency'),
new lang_string('enablecompetencies_desc', 'core_competency'), 1);
$settings->add($setting);
$setting = new admin_setting_configcheckbox('core_competency/pushcourseratingstouserplans',
new lang_string('pushcourseratingstouserplans', 'core_competency'),
new lang_string('pushcourseratingstouserplans_desc', 'core_competency'), 1);
$settings->add($setting);
}
}

View File

@ -30,6 +30,7 @@ if ($hassiteconfig) {
$ADMIN->add('root', new admin_category('users', new lang_string('users','admin')));
$ADMIN->add('root', new admin_category('courses', new lang_string('courses','admin')));
$ADMIN->add('root', new admin_category('grades', new lang_string('grades')));
$ADMIN->add('root', new admin_category('competencies', new lang_string('competencies', 'core_competency')));
$ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empty($CFG->enablebadges)));
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
$ADMIN->add('root', new admin_category('language', new lang_string('language')));

View File

@ -344,7 +344,7 @@ class page_helper {
$frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
$PAGE->navigation->override_active_url($frameworksurl);
$title = get_string('competencies', 'tool_lp');
$title = get_string('competencies', 'core_competency');
if (empty($id)) {
$pagetitle = get_string('competencyframeworks', 'tool_lp');
$pagesubtitle = get_string('addnewcompetencyframework', 'tool_lp');

View File

@ -40,7 +40,7 @@ if (!\core_competency\competency_framework::can_read_context($context)) {
throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
}
$title = get_string('competencies', 'tool_lp');
$title = get_string('competencies', 'core_competency');
$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
// Set up the page.

View File

@ -38,7 +38,7 @@ if (!\core_competency\competency_framework::can_read_context($context)) {
throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
}
$title = get_string('competencies', 'tool_lp');
$title = get_string('competencies', 'core_competency');
$pagetitle = get_string('competencyframeworks', 'tool_lp');
$pagesubtitle = get_string('listcompetencyframeworkscaption', 'tool_lp');

View File

@ -48,12 +48,9 @@ $string['cannotcreateuserplanswhentemplatehidden'] = 'New user plans can not be
$string['category'] = 'Category';
$string['chooserating'] = 'Choose a rating...';
$string['cohortssyncedtotemplate'] = 'Cohorts synced to this template';
$string['competencies'] = 'Competencies';
$string['competenciesarenotenabled'] = 'The competencies module is not enabled.';
$string['competenciesforframework'] = 'Competencies for {$a}';
$string['competenciesmostoftennotproficient'] = 'Competencies most often not proficient in completed plans';
$string['competenciesmostoftennotproficientincourse'] = 'Competencies most often not proficient in this course';
$string['competenciessettings'] = 'Competencies settings';
$string['competencycannotbedeleted'] = 'The competency \'{$a}\' can not be deleted';
$string['competencycreated'] = 'Competency created';
$string['competencyframework'] = 'Competency framework';
@ -113,8 +110,6 @@ $string['edittemplate'] = 'Edit learning plan template';
$string['editthisplan'] = 'Edit this learning plan';
$string['editthisuserevidence'] = 'Edit this evidence';
$string['edituserevidence'] = 'Edit evidence';
$string['enablecompetencies'] = 'Enable competencies';
$string['enablecompetencies_desc'] = 'When unticked the competencies module will be disabled.';
$string['eventcompetencyframeworkcreated'] = 'Competency framework created.';
$string['eventcompetencyframeworkdeleted'] = 'Competency framework deleted.';
$string['eventcompetencyframeworkupdated'] = 'Competency framework updated.';
@ -254,8 +249,6 @@ $string['pointsgivenfor'] = 'Points given for \'{$a}\'';
$string['pointsrequiredaremet'] = 'Points required are met';
$string['proficient'] = 'Proficient';
$string['progress'] = 'Progress';
$string['pushcourseratingstouserplans'] = 'Push course ratings to individual learning plans';
$string['pushcourseratingstouserplans_desc'] = 'Default value for the course setting to update individual learning plans when course competencies are rated.';
$string['rate'] = 'Rate';
$string['ratecomment'] = 'Evidence notes';
$string['rating'] = 'Rating';

View File

@ -442,7 +442,7 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) {
return;
}
$mform->addElement('header', 'competenciessection', get_string('competencies', 'tool_lp'));
$mform->addElement('header', 'competenciessection', get_string('competencies', 'core_competency'));
MoodleQuickForm::registerElementType('course_competencies',
"$CFG->dirroot/admin/tool/lp/classes/course_competencies_form_element.php",

View File

@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Links and settings
* Links and settings.
*
* This file contains links and settings used by tool_lp
* This file contains links and settings used by tool_lp.
*
* @package tool_lp
* @copyright 2015 Damyon Wiese
@ -25,9 +25,7 @@
*/
defined('MOODLE_INTERNAL') || die();
$parentname = 'toollprootpage';
$category = new admin_category($parentname, get_string('competencies', 'tool_lp'));
$ADMIN->add('root', $category, 'badges');
$parentname = 'competencies';
// If the plugin is enabled we add the pages.
if (\core_competency\api::is_enabled()) {
@ -50,15 +48,3 @@ if (\core_competency\api::is_enabled()) {
);
$ADMIN->add($parentname, $temp);
}
// Settings.
$settings = new admin_settingpage('toollpsettingspage', get_string('competenciessettings', 'tool_lp'), 'moodle/site:config', false);
$ADMIN->add($parentname, $settings);
if ($ADMIN->fulltree) {
$setting = new admin_setting_configcheckbox('tool_lp/enabled', get_string('enablecompetencies', 'tool_lp'),
get_string('enablecompetencies_desc', 'tool_lp'), 1);
$settings->add($setting);
$setting = new admin_setting_configcheckbox('tool_lp/pushcourseratingstouserplans', get_string('pushcourseratingstouserplans', 'tool_lp'),
get_string('pushcourseratingstouserplans_desc', 'tool_lp'), 1);
$settings->add($setting);
}

View File

@ -37,7 +37,7 @@
<a href="{{pluginbaseurl}}/editcompetencyframework.php?id={{framework.id}}&pagecontextid={{pagecontextid}}&return=competencies">{{#pix}}t/edit, core, {{#str}}editcompetencyframework, tool_lp{{/str}}{{/pix}}</a>
{{/canmanage}}
</h2>
<h3>{{#str}}competencies, tool_lp{{/str}}</h3>
<h3>{{#str}}competencies, core_competency{{/str}}</h3>
<div class="row-fluid">
<div class="span6">
<p>

View File

@ -43,7 +43,7 @@
<thead>
<tr>
<th scope="col">{{#str}}competencyframeworkname, tool_lp{{/str}}</th>
<th scope="col">{{#str}}competencies, tool_lp{{/str}}</th>
<th scope="col">{{#str}}competencies, core_competency{{/str}}</th>
<th scope="col">{{#str}}category, tool_lp{{/str}}</th>
<th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
</tr>

View File

@ -52,7 +52,7 @@ class api {
* @return boolean True when enabled.
*/
public static function is_enabled() {
return get_config('tool_lp', 'enabled');
return get_config('core_competency', 'enabled');
}
/**
@ -63,7 +63,7 @@ class api {
*/
public static function require_enabled() {
if (!static::is_enabled()) {
throw new moodle_exception('competenciesarenotenabled', 'tool_lp');
throw new moodle_exception('competenciesarenotenabled', 'core_competency');
}
}

View File

@ -52,7 +52,7 @@ class course_competency_settings extends persistent {
'pushratingstouserplans' => array(
'type' => PARAM_BOOL,
'default' => function() {
return get_config('tool_lp', 'pushcourseratingstouserplans');
return get_config('core_competency', 'pushcourseratingstouserplans');
}
),
);

View File

@ -74,12 +74,12 @@ class core_competency_course_competency_settings_testcase extends advanced_testc
$this->setUser($u2);
set_config('pushcourseratingstouserplans', true, 'tool_lp');
set_config('pushcourseratingstouserplans', true, 'core_competency');
$coursesettings = course_competency_settings::get_by_courseid($c1->id);
$this->assertTrue((boolean)$coursesettings->get_pushratingstouserplans());
set_config('pushcourseratingstouserplans', false, 'tool_lp');
set_config('pushcourseratingstouserplans', false, 'core_competency');
$coursesettings = course_competency_settings::get_by_courseid($c1->id);
$this->assertFalse((boolean)$coursesettings->get_pushratingstouserplans());
@ -88,7 +88,7 @@ class core_competency_course_competency_settings_testcase extends advanced_testc
$coursesettings = course_competency_settings::get_by_courseid($c1->id);
$this->assertTrue((boolean)$coursesettings->get_pushratingstouserplans());
set_config('pushcourseratingstouserplans', true, 'tool_lp');
set_config('pushcourseratingstouserplans', true, 'core_competency');
api::update_course_competency_settings($c1->id, (object) array('pushratingstouserplans' => false));
$coursesettings = course_competency_settings::get_by_courseid($c1->id);
$this->assertFalse((boolean)$coursesettings->get_pushratingstouserplans());

33
lang/en/competency.php Normal file
View File

@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency language file.
*
* @package core_competency
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['competencies'] = 'Competencies';
$string['competenciesarenotenabled'] = 'The competencies module is not enabled.';
$string['competenciessettings'] = 'Competencies settings';
$string['enablecompetencies'] = 'Enable competencies';
$string['enablecompetencies_desc'] = 'When unticked the competencies module will be disabled.';
$string['pushcourseratingstouserplans'] = 'Push course ratings to individual learning plans';
$string['pushcourseratingstouserplans_desc'] = 'Default value for the course setting to update individual learning plans when course competencies are rated.';