mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-53452 competencies: Add course and admin setting to push competency ratings outside a course
This commit is contained in:
parent
65abd20d8c
commit
7ba074873c
148
admin/tool/lp/amd/src/course_competency_settings.js
Normal file
148
admin/tool/lp/amd/src/course_competency_settings.js
Normal file
@ -0,0 +1,148 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Change the course competency settings in a popup.
|
||||
*
|
||||
* @module tool_lp/configurecoursecompetencysettings
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery',
|
||||
'core/notification',
|
||||
'tool_lp/dialogue',
|
||||
'core/str',
|
||||
'core/ajax',
|
||||
'core/templates'],
|
||||
function($, notification, Dialogue, str, ajax, templates) {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param {String} selector - selector for the links to open the dialogue.
|
||||
*/
|
||||
var settingsMod = function(selector) {
|
||||
var links = $(selector).on('click', this.configureSettings.bind(this));
|
||||
};
|
||||
|
||||
/** @type {Dialogue} Reference to the dialogue that we opened. */
|
||||
settingsMod.prototype._dialogue = null;
|
||||
|
||||
/**
|
||||
* Open the configure settings dialogue.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @method configureSettings
|
||||
*/
|
||||
settingsMod.prototype.configureSettings = function(e) {
|
||||
var courseid = $(e.target).closest('a').data('courseid');
|
||||
var currentValue = $(e.target).closest('a').data('pushratingstouserplans');
|
||||
var context = {
|
||||
courseid: courseid,
|
||||
pushratingstouserplans: currentValue
|
||||
};
|
||||
e.preventDefault();
|
||||
|
||||
templates.render('tool_lp/course_competency_settings', context).done(function(html) {
|
||||
str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function (title) {
|
||||
this._dialogue = new Dialogue(
|
||||
title,
|
||||
html,
|
||||
this.addListeners.bind(this)
|
||||
);
|
||||
}.bind(this)).fail(notification.exception);
|
||||
}.bind(this)).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the save listener to the form.
|
||||
*
|
||||
* @method addSaveListener
|
||||
*/
|
||||
settingsMod.prototype.addListeners = function() {
|
||||
var save = this._find('[data-action="save"]');
|
||||
save.on('click', this.saveSettings.bind(this));
|
||||
var cancel = this._find('[data-action="cancel"]');
|
||||
cancel.on('click', this.cancelChanges.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel the changes.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @method cancelChanges
|
||||
*/
|
||||
settingsMod.prototype.cancelChanges = function(e) {
|
||||
e.preventDefault();
|
||||
this._dialogue.close();
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel the changes.
|
||||
*
|
||||
* @param {String} selector
|
||||
* @return {JQuery}
|
||||
*/
|
||||
settingsMod.prototype._find = function(selector) {
|
||||
return $('[data-region="coursecompetencysettings"]').find(selector);
|
||||
};
|
||||
|
||||
/**
|
||||
* Save the settings.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @method saveSettings
|
||||
*/
|
||||
settingsMod.prototype.saveSettings = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var newValue = this._find('input[name="pushratingstouserplans"]:checked').val();
|
||||
var courseId = this._find('input[name="courseid"]').val();
|
||||
|
||||
ajax.call([
|
||||
{ methodname: 'tool_lp_update_course_competency_settings',
|
||||
args: { courseid: courseId, pushratingstouserplans: newValue } }
|
||||
])[0].done(function() {
|
||||
this.refreshCourseCompetenciesPage();
|
||||
}.bind(this)).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Refresh the course competencies page.
|
||||
*
|
||||
* @param {Event} e
|
||||
* @method saveSettings
|
||||
*/
|
||||
settingsMod.prototype.refreshCourseCompetenciesPage = function() {
|
||||
var courseId = this._find('input[name="courseid"]').val();
|
||||
|
||||
ajax.call([
|
||||
{ methodname: 'tool_lp_data_for_course_competencies_page',
|
||||
args: { courseid: courseId } }
|
||||
])[0].done(function(context) {
|
||||
templates.render('tool_lp/course_competencies_page', context).done(function(html, js) {
|
||||
$('[data-region="coursecompetenciespage"]').replaceWith(html);
|
||||
templates.runTemplateJS(js);
|
||||
this._dialogue.close();
|
||||
}.bind(this)).fail(notification.exception);
|
||||
}.bind(this)).fail(notification.exception);
|
||||
|
||||
};
|
||||
|
||||
return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;
|
||||
});
|
@ -4855,4 +4855,56 @@ class api {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the competency settings for a course.
|
||||
*
|
||||
* Requires tool/lp:coursecompetencyread capability at the course context.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @return course_competency_settings
|
||||
*/
|
||||
public static function read_course_competency_settings($courseid) {
|
||||
static::require_enabled();
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!course_competency_settings::can_read($courseid)) {
|
||||
$context = context_course::instance($courseid);
|
||||
throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', '');
|
||||
}
|
||||
|
||||
return course_competency_settings::get_course_settings($courseid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the competency settings for a course.
|
||||
*
|
||||
* Requires tool/lp:coursecompetencyread capability at the course context.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param bool $pushratingstouserplans Push competency ratings to user plans immediately.
|
||||
* @return bool
|
||||
*/
|
||||
public static function update_course_competency_settings($courseid, $pushratingstouserplans) {
|
||||
static::require_enabled();
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!course_competency_settings::can_update($courseid)) {
|
||||
$context = context_course::instance($courseid);
|
||||
throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', '');
|
||||
}
|
||||
|
||||
$exists = course_competency_settings::get_record(array('courseid' => $courseid));
|
||||
|
||||
// Now update or insert.
|
||||
if ($exists) {
|
||||
$settings = $exists;
|
||||
$settings->set_pushratingstouserplans($pushratingstouserplans);
|
||||
return $settings->update();
|
||||
} else {
|
||||
$data = (object) array('courseid' => $courseid, 'pushratingstouserplans' => $pushratingstouserplans);
|
||||
$settings = new course_competency_settings(0, $data);
|
||||
return !empty($settings->create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
131
admin/tool/lp/classes/course_competency_settings.php
Normal file
131
admin/tool/lp/classes/course_competency_settings.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Class for course_competency_settings persistence.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp;
|
||||
|
||||
use lang_string;
|
||||
use context_course;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Class for course_competency_settings persistence.
|
||||
*
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class course_competency_settings extends persistent {
|
||||
|
||||
/** Table name for plan_competency persistency */
|
||||
const TABLE = 'tool_lp_coursecompsettings';
|
||||
|
||||
/**
|
||||
* Return the definition of the properties of this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function define_properties() {
|
||||
return array(
|
||||
'courseid' => array(
|
||||
'type' => PARAM_INT,
|
||||
),
|
||||
'pushratingstouserplans' => array(
|
||||
'type' => PARAM_BOOL,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a the course settings for a single course.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @return course_competency_settings
|
||||
*/
|
||||
public static function get_course_settings($courseid) {
|
||||
global $DB;
|
||||
|
||||
$params = array(
|
||||
'courseid' => $courseid
|
||||
);
|
||||
|
||||
$settings = new static(null, (object) $params);
|
||||
if ($record = $DB->get_record(self::TABLE, $params)) {
|
||||
$settings->from_record($record);
|
||||
} else {
|
||||
$settings->set_pushratingstouserplans(get_config('tool_lp', 'pushcourseratingstouserplans'));
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current user change competency settings for this course.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_read($courseid) {
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$capabilities = array('tool/lp:coursecompetencyread');
|
||||
|
||||
return has_any_capability($capabilities, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current user change competency settings for this course.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_update($courseid) {
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$capabilities = array('tool/lp:coursecompetencyconfigure');
|
||||
|
||||
return has_any_capability($capabilities, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate course ID.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @return true|lang_string
|
||||
*/
|
||||
protected function validate_courseid($data) {
|
||||
global $DB;
|
||||
if (!$DB->record_exists('course', array('id' => $data))) {
|
||||
return new lang_string('invalidcourseid', 'error');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context.
|
||||
*
|
||||
* @return context The context
|
||||
*/
|
||||
public function get_context() {
|
||||
return context_course::instance($this->get_courseid());
|
||||
}
|
||||
}
|
@ -1889,6 +1889,8 @@ class external extends external_api {
|
||||
'gradableuserid' => new external_value(PARAM_INT, 'Current user id, if the user is a gradable user.', VALUE_OPTIONAL),
|
||||
'canmanagecompetencyframeworks' => new external_value(PARAM_BOOL, 'User can manage competency frameworks'),
|
||||
'canmanagecoursecompetencies' => new external_value(PARAM_BOOL, 'User can manage linked course competencies'),
|
||||
'canconfigurecoursecompetencies' => new external_value(PARAM_BOOL, 'User can configure course competency settings'),
|
||||
'pushratingstouserplans' => new external_value(PARAM_BOOL, 'Couse competency setting pushratingstouserplans'),
|
||||
'competencies' => new external_multiple_structure(new external_single_structure(array(
|
||||
'competency' => competency_exporter::get_read_structure(),
|
||||
'coursecompetency' => course_competency_exporter::get_read_structure(),
|
||||
@ -5644,4 +5646,56 @@ class external extends external_api {
|
||||
return new external_value(PARAM_BOOL, 'True if the log of the view was successful');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of update_course_competency_settings() parameters.
|
||||
*
|
||||
* @return \external_function_parameters
|
||||
*/
|
||||
public static function update_course_competency_settings_parameters() {
|
||||
$courseid = new external_value(
|
||||
PARAM_INT,
|
||||
'Course id for the course to update',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$pushratingstouserplans = new external_value(
|
||||
PARAM_BOOL,
|
||||
'New value of the setting',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$params = array(
|
||||
'courseid' => $courseid,
|
||||
'pushratingstouserplans' => $pushratingstouserplans,
|
||||
);
|
||||
return new external_function_parameters($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the course competency settings
|
||||
*
|
||||
* @param int $id the course id
|
||||
* @param bool $pushratingstouserplans The new value of the setting
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function update_course_competency_settings($courseid, $pushratingstouserplans) {
|
||||
$params = self::validate_parameters(self::update_course_competency_settings_parameters(),
|
||||
array(
|
||||
'courseid' => $courseid,
|
||||
'pushratingstouserplans' => $pushratingstouserplans
|
||||
));
|
||||
|
||||
$context = context_course::instance($params['courseid']);
|
||||
self::validate_context($context);
|
||||
$result = api::update_course_competency_settings($params['courseid'], $params['pushratingstouserplans']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of update_course_competency_settings() result value.
|
||||
*
|
||||
* @return \external_value
|
||||
*/
|
||||
public static function update_course_competency_settings_returns() {
|
||||
return new external_value(PARAM_BOOL, 'True if the update was successful.');
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ class course_competencies_page implements renderable, templatable {
|
||||
$this->courseid = $courseid;
|
||||
$this->coursecompetencylist = api::list_course_competencies($courseid);
|
||||
$this->canmanagecoursecompetencies = has_capability('tool/lp:coursecompetencymanage', $this->context);
|
||||
$this->canconfigurecoursecompetencies = has_capability('tool/lp:coursecompetencyconfigure', $this->context);
|
||||
$this->coursecompetencysettings = api::read_course_competency_settings($courseid);
|
||||
|
||||
// Check the lowest level in which the user can manage the competencies.
|
||||
$this->manageurl = null;
|
||||
@ -172,6 +174,8 @@ class course_competencies_page implements renderable, templatable {
|
||||
|
||||
$data->canmanagecompetencyframeworks = $this->canmanagecompetencyframeworks;
|
||||
$data->canmanagecoursecompetencies = $this->canmanagecoursecompetencies;
|
||||
$data->canconfigurecoursecompetencies = $this->canconfigurecoursecompetencies;
|
||||
$data->pushratingstouserplans = $this->coursecompetencysettings->get_pushratingstouserplans();
|
||||
$data->manageurl = null;
|
||||
if ($this->canmanagecompetencyframeworks) {
|
||||
$data->manageurl = $this->manageurl->out(true);
|
||||
|
@ -44,14 +44,6 @@ $capabilities = array(
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:competencysuggestgrade' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE, // And CONTEXT_USER.
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW
|
||||
),
|
||||
),
|
||||
'tool/lp:competencygrade' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE, // And CONTEXT_USER.
|
||||
@ -70,6 +62,14 @@ $capabilities = array(
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:backup'
|
||||
),
|
||||
'tool/lp:coursecompetencyconfigure' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:backup'
|
||||
),
|
||||
'tool/lp:coursecompetencygradable' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
|
17
admin/tool/lp/db/install.xml
Executable file → Normal file
17
admin/tool/lp/db/install.xml
Executable file → Normal file
@ -32,6 +32,23 @@
|
||||
<INDEX NAME="ruleoutcome" UNIQUE="false" FIELDS="ruleoutcome"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_coursecompsettings" COMMENT="This table contains the course specific settings for competencies.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The course this setting is linked to."/>
|
||||
<FIELD NAME="pushratingstouserplans" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="Does this course push ratings to user plans?"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this setting was created."/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The time this setting was last modified."/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The user who last modified this setting"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="courseidlink" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Course foreign key."/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="courseiduniq" UNIQUE="true" FIELDS="courseid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_lp_competency_framework" COMMENT="List of competency frameworks.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
|
@ -899,5 +899,14 @@ $functions = array(
|
||||
'capabilities' => 'tool/lp:userevidencemanageown',
|
||||
'ajax' => true,
|
||||
),
|
||||
'tool_lp_update_course_competency_settings' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'update_course_competency_settings',
|
||||
'classpath' => '',
|
||||
'description' => 'Update the course competency settings',
|
||||
'type' => 'write',
|
||||
'capabilities' => 'tool/lp:coursecompetencyconfigure',
|
||||
'ajax' => true,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -832,5 +832,34 @@ function xmldb_tool_lp_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2016020917, 'tool', 'lp');
|
||||
}
|
||||
|
||||
if ($oldversion < 2016020919) {
|
||||
|
||||
// Define table tool_lp_coursecompsettings to be created.
|
||||
$table = new xmldb_table('tool_lp_coursecompsettings');
|
||||
|
||||
// Adding fields to table tool_lp_coursecompsettings.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('pushratingstouserplans', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
|
||||
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('usermodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
|
||||
|
||||
// Adding keys to table tool_lp_coursecompsettings.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Adding indexes to table tool_lp_coursecompsettings.
|
||||
$table->add_index('courseiduniq', XMLDB_INDEX_UNIQUE, array('courseid'));
|
||||
|
||||
// Conditionally launch create table for tool_lp_coursecompsettings.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Lp savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2016020919, 'tool', 'lp');
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -71,11 +71,15 @@ $string['completeplan'] = 'Complete this learning plan';
|
||||
$string['completeplanconfirm'] = 'Set the plan \'{$a}\' to completed? The current status of all the users competencies in this plan will be recorded, and the plan will become read only.';
|
||||
$string['completeplanstask'] = 'Complete plans which are due';
|
||||
$string['configurescale'] = 'Configure scales';
|
||||
$string['configurecoursecompetencysettings'] = 'Configure course competencies';
|
||||
$string['coursecompetencies'] = 'Course competencies';
|
||||
$string['coursecompetencyoutcome_complete'] = 'Complete the competency';
|
||||
$string['coursecompetencyoutcome_evidence'] = 'Attach an evidence';
|
||||
$string['coursecompetencyoutcome_none'] = 'Do nothing';
|
||||
$string['coursecompetencyoutcome_recommend'] = 'Send for review';
|
||||
$string['coursecompetencyratingsquestion'] = 'When a course competency is rated, does the rating update the competency in the users learning plans, or is it only applied to the course?';
|
||||
$string['coursecompetencyratingsarepushedtouserplans'] = 'Competency ratings in this course are immediately updated in user learning plans.';
|
||||
$string['coursecompetencyratingsarenotpushedtouserplans'] = 'Competency ratings in this course are not updated in user learning plans.';
|
||||
$string['coursemodulecompetencyoutcome_complete'] = 'Complete the competency';
|
||||
$string['coursemodulecompetencyoutcome_evidence'] = 'Attach an evidence';
|
||||
$string['coursemodulecompetencyoutcome_none'] = 'Do nothing';
|
||||
@ -202,10 +206,10 @@ $string['listtemplatescaption'] = 'List of learning plan templates';
|
||||
$string['loading'] = 'Loading...';
|
||||
$string['locatecompetency'] = 'Locate competency';
|
||||
$string['lp:competencymanage'] = 'Manage competency frameworks';
|
||||
$string['lp:competencysuggestgrade'] = 'Suggest competency grade';
|
||||
$string['lp:competencygrade'] = 'Set competency grade';
|
||||
$string['lp:competencyview'] = 'View competency frameworks';
|
||||
$string['lp:coursecompetencygradable'] = 'Receive competency marks';
|
||||
$string['lp:coursecompetencyconfigure'] = 'Configure a course competency settings';
|
||||
$string['lp:coursecompetencymanage'] = 'Manage course competencies';
|
||||
$string['lp:coursecompetencyview'] = 'View course competencies';
|
||||
$string['lp:plancomment'] = 'Comment on a learning plan';
|
||||
@ -286,9 +290,13 @@ $string['points'] = 'Points';
|
||||
$string['pointsgivenfor'] = 'Points given for \'{$a}\'';
|
||||
$string['pointsrequiredaremet'] = 'Points required are met';
|
||||
$string['proficient'] = 'Proficient';
|
||||
$string['pushcourseratingstouserplans'] = 'Push course ratings to user learning plans';
|
||||
$string['pushcourseratingstouserplans_desc'] = 'Default value for the course setting to update user learning plans when course competencies are rated.';
|
||||
$string['rate'] = 'Rate';
|
||||
$string['ratecomment'] = 'Evidence notes';
|
||||
$string['rating'] = 'Rating';
|
||||
$string['ratingaffectsonlycourse'] = 'Rating a competency only updates the competency in this course';
|
||||
$string['ratingaffectsuserplans'] = 'Rating a competency also updates the competency in all of the users learning plans';
|
||||
$string['reviewstatus'] = 'Review status';
|
||||
$string['requestreview'] = 'Request review';
|
||||
$string['reopenplan'] = 'Reopen this learning plan';
|
||||
@ -306,6 +314,7 @@ $string['selectuserstocreateplansfor'] = 'Select users to create plans for';
|
||||
$string['sendcompetenciestoreview'] = 'Send competencies for review';
|
||||
$string['sendallcompetenciestoreview'] = 'Send all competencies in review for evidence of prior learning \'{$a}\'';
|
||||
$string['shortname'] = 'Name';
|
||||
$string['sitedefault'] = ' (Site default) ';
|
||||
$string['startreview'] = 'Start review';
|
||||
$string['state'] = 'State';
|
||||
$string['status'] = 'Status';
|
||||
|
@ -58,4 +58,7 @@ 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);
|
||||
}
|
||||
|
@ -25,6 +25,23 @@
|
||||
{{/canmanagecoursecompetencies}}
|
||||
</div>
|
||||
</div>
|
||||
{{#canconfigurecoursecompetencies}}
|
||||
<div data-region="configurecoursecompetencies">
|
||||
<p class="alert">
|
||||
{{#pushratingstouserplans}}
|
||||
{{#str}}coursecompetencyratingsarepushedtouserplans, tool_lp{{/str}}
|
||||
{{/pushratingstouserplans}}
|
||||
{{^pushratingstouserplans}}
|
||||
{{#str}}coursecompetencyratingsarenotpushedtouserplans, tool_lp{{/str}}
|
||||
{{/pushratingstouserplans}}
|
||||
<a href="#"
|
||||
data-action="configure-course-competency-settings"
|
||||
data-courseid="{{courseid}}"
|
||||
data-pushratingstouserplans="{{pushratingstouserplans}}"
|
||||
>{{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}</a>
|
||||
</p>
|
||||
</div>
|
||||
{{/canconfigurecoursecompetencies}}
|
||||
<div data-region="coursecompetencies">
|
||||
<table class="generaltable fullwidth managecompetencies">
|
||||
<tbody class="drag-parentnode">
|
||||
@ -100,3 +117,10 @@ require(['tool_lp/competencies'], function(mod) {
|
||||
(new mod({{courseid}}, 'course', {{pagecontextid}}));
|
||||
});
|
||||
{{/js}}
|
||||
{{#canconfigurecoursecompetencies}}
|
||||
{{#js}}
|
||||
require(['tool_lp/course_competency_settings'], function(Mod) {
|
||||
(new Mod('[data-action=configure-course-competency-settings]'));
|
||||
});
|
||||
{{/js}}
|
||||
{{/canconfigurecoursecompetencies}}
|
||||
|
21
admin/tool/lp/templates/course_competency_settings.mustache
Normal file
21
admin/tool/lp/templates/course_competency_settings.mustache
Normal file
@ -0,0 +1,21 @@
|
||||
<form data-region="coursecompetencysettings">
|
||||
<input type="hidden" name="courseid" value="{{courseid}}"/>
|
||||
<fieldset>
|
||||
<p>{{#str}}coursecompetencyratingsquestion, tool_lp{{/str}}</p>
|
||||
<label><input type="radio" value="0" name="pushratingstouserplans"
|
||||
{{^pushratingstouserplans}}checked{{/pushratingstouserplans}}>
|
||||
{{#str}}ratingaffectsonlycourse, tool_lp{{/str}}
|
||||
</label>
|
||||
<label><input type="radio" value="1" name="pushratingstouserplans"
|
||||
{{#pushratingstouserplans}}checked{{/pushratingstouserplans}}>
|
||||
{{#str}}ratingaffectsuserplans, tool_lp{{/str}}
|
||||
</label>
|
||||
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<center>
|
||||
<input type="button" data-action="save" value="{{#str}}savechanges{{/str}}"/>
|
||||
<input type="button" data-action="cancel" value="{{#str}}cancel{{/str}}"/>
|
||||
</center>
|
||||
</fieldset>
|
||||
</form>
|
@ -35,6 +35,7 @@ use tool_lp\user_competency;
|
||||
use tool_lp\user_competency_plan;
|
||||
use tool_lp\plan_competency;
|
||||
use tool_lp\template_competency;
|
||||
use tool_lp\course_competency_settings;
|
||||
|
||||
/**
|
||||
* External learning plans webservice API tests.
|
||||
@ -118,12 +119,14 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
unassign_capability('tool/lp:templatemanage', $authrole->id);
|
||||
unassign_capability('tool/lp:templateview', $authrole->id);
|
||||
unassign_capability('moodle/cohort:manage', $authrole->id);
|
||||
unassign_capability('tool/lp:coursecompetencyconfigure', $authrole->id);
|
||||
|
||||
// Creating specific roles.
|
||||
$this->creatorrole = create_role('Creator role', 'creatorrole', 'learning plan creator role description');
|
||||
$this->userrole = create_role('User role', 'userrole', 'learning plan user role description');
|
||||
|
||||
assign_capability('tool/lp:competencymanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
|
||||
assign_capability('tool/lp:competencycompetencyconfigure', CAP_ALLOW, $this->creatorrole, $syscontext->id);
|
||||
assign_capability('tool/lp:competencyview', CAP_ALLOW, $this->userrole, $syscontext->id);
|
||||
assign_capability('tool/lp:planmanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
|
||||
assign_capability('tool/lp:planmanagedraft', CAP_ALLOW, $this->creatorrole, $syscontext->id);
|
||||
@ -3059,4 +3062,47 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update course competency settings.
|
||||
*/
|
||||
public function test_update_course_competency_settings() {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$dg = $this->getDataGenerator();
|
||||
|
||||
$course = $dg->create_course();
|
||||
$roleid = $dg->create_role();
|
||||
$noobroleid = $dg->create_role();
|
||||
$context = context_course::instance($course->id);
|
||||
$compmanager = $this->getDataGenerator()->create_user();
|
||||
$compnoob = $this->getDataGenerator()->create_user();
|
||||
|
||||
assign_capability('tool/lp:coursecompetencyconfigure', CAP_ALLOW, $roleid, $context->id, true);
|
||||
assign_capability('tool/lp:coursecompetencyview', CAP_ALLOW, $roleid, $context->id, true);
|
||||
assign_capability('tool/lp:coursecompetencyview', CAP_ALLOW, $noobroleid, $context->id, true);
|
||||
|
||||
role_assign($roleid, $compmanager->id, $context->id);
|
||||
role_assign($noobroleid, $compnoob->id, $context->id);
|
||||
$dg->enrol_user($compmanager->id, $course->id, $roleid);
|
||||
$dg->enrol_user($compnoob->id, $course->id, $noobroleid);
|
||||
|
||||
$this->setUser($compmanager);
|
||||
|
||||
// Start the test.
|
||||
$result = external::update_course_competency_settings($course->id, true);
|
||||
|
||||
$settings = course_competency_settings::get_course_settings($course->id);
|
||||
|
||||
$this->assertTrue((bool)$settings->get_pushratingstouserplans());
|
||||
|
||||
$result = external::update_course_competency_settings($course->id, false);
|
||||
|
||||
$settings = course_competency_settings::get_course_settings($course->id);
|
||||
|
||||
$this->assertFalse((bool)$settings->get_pushratingstouserplans());
|
||||
$this->setUser($compnoob);
|
||||
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$result = external::update_course_competency_settings($course->id, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user