MDL_53523 tool_lp: Mark fields 'scale/scaleconfiguration' as required
This commit is contained in:
committed by
Frederic Massart
parent
c48ab9c124
commit
65abd20d8c
@@ -70,11 +70,12 @@ class competency_framework extends persistent {
|
||||
$scaleid = $mform->addElement('select', 'scaleid', get_string('scale', 'tool_lp'), $scales);
|
||||
$mform->setType('scaleid', PARAM_INT);
|
||||
$mform->addHelpButton('scaleid', 'scale', 'tool_lp');
|
||||
$mform->addRule('scaleid', null, 'required', null, 'client');
|
||||
if ($framework && $framework->has_user_competencies()) {
|
||||
// The scale is used so we "freeze" the element. Though, the javascript code for the scale
|
||||
// configuration requires this field so we only disable it. It is fine as setting the value
|
||||
// as a constant will ensure that nobody can change it. And it's validated in the persistent anyway.
|
||||
$scaleid->updateAttributes(array('disabled' => 'disabled'));
|
||||
$scaleid->updateAttributes(array('readonly' => 'readonly'));
|
||||
$mform->setConstant('scaleid', $framework->get_scaleid());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}scalevalue, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}default, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}proficient, tool_lp{{/str}}</th>
|
||||
<th scope="col">{{#str}}default, tool_lp{{/str}}{{#pix }} req, core, {{#str}}requiredelement, form{{/str}} {{/pix }}</th>
|
||||
<th scope="col">{{#str}}proficient, tool_lp{{/str}}{{#pix }} req, core, {{#str}}requiredelement, form{{/str}}{{/pix }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -84,6 +84,10 @@ class behat_tool_lp_data_generators extends behat_base {
|
||||
'usercompetencies' => array(
|
||||
'datagenerator' => 'user_competency',
|
||||
'required' => array('user', 'competency')
|
||||
),
|
||||
'usercompetencyplans' => array(
|
||||
'datagenerator' => 'user_competency_plan',
|
||||
'required' => array('user', 'competency', 'plan')
|
||||
)
|
||||
);
|
||||
|
||||
@@ -300,7 +304,7 @@ class behat_tool_lp_data_generators extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt creating user_evidence from user username.
|
||||
* Adapt creating user_competency from user name and competency shortname.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
@@ -323,4 +327,34 @@ class behat_tool_lp_data_generators extends behat_base {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt creating user_competency_plan from user name, competency shortname and plan name.
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function preprocess_user_competency_plan($data) {
|
||||
global $DB;
|
||||
|
||||
if (isset($data['user'])) {
|
||||
$user = $DB->get_record('user', array('username' => $data['user']), '*', MUST_EXIST);
|
||||
$data['userid'] = $user->id;
|
||||
}
|
||||
unset($data['user']);
|
||||
|
||||
if (isset($data['competency'])) {
|
||||
$competency = $DB->get_record('tool_lp_competency', array('shortname' => $data['competency']), '*', MUST_EXIST);
|
||||
$data['competencyid'] = $competency->id;
|
||||
}
|
||||
unset($data['competency']);
|
||||
|
||||
if (isset($data['plan'])) {
|
||||
$plan = $DB->get_record('tool_lp_plan', array('name' => $data['plan']), '*', MUST_EXIST);
|
||||
$data['planid'] = $plan->id;
|
||||
}
|
||||
unset($data['plan']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,4 +70,64 @@ Feature: Manage competency frameworks
|
||||
And "Confirm" "dialogue" should be visible
|
||||
When I click on "Delete" "button"
|
||||
Then I should not see "Science Year-4"
|
||||
And I should not see "sc-y-4"
|
||||
And I should not see "sc-y-4"
|
||||
|
||||
Scenario: Edit a framework with competencies in user competency
|
||||
Given the following lp "frameworks" exist:
|
||||
| shortname | idnumber |
|
||||
| Science Year-5 | sc-y-5 |
|
||||
And the following lp "competencies" exist:
|
||||
| shortname | framework |
|
||||
| Comp1 | sc-y-5 |
|
||||
| Comp2 | sc-y-5 |
|
||||
And the following lp "plans" exist:
|
||||
| name | user | description |
|
||||
| Plan Science-5 | admin | Plan description |
|
||||
And the following lp "plancompetencies" exist:
|
||||
| plan | competency |
|
||||
| Plan Science-5 | Comp1 |
|
||||
| Plan Science-5 | Comp2 |
|
||||
And the following lp "usercompetencies" exist:
|
||||
| user | competency |
|
||||
| admin | Comp1 |
|
||||
| admin | Comp2 |
|
||||
And I follow "Competency Frameworks"
|
||||
And I should see "Science Year-5"
|
||||
And I click on "Edit" of edit menu in the "Science Year-5" row
|
||||
And the field "Name" matches value "Science Year-5 "
|
||||
And I set the field "Name" to "Science Year-5 Edited"
|
||||
And the "scaleid" "select" should be readonly
|
||||
When I press "Save changes"
|
||||
Then I should see "Competency framework updated"
|
||||
And I should see "Science Year-5 Edited"
|
||||
And I should see "sc-y-5"
|
||||
|
||||
Scenario: Edit a framework with competencies in user competency plan
|
||||
Given the following lp "frameworks" exist:
|
||||
| shortname | idnumber |
|
||||
| Science Year-6 | sc-y-6 |
|
||||
And the following lp "competencies" exist:
|
||||
| shortname | framework |
|
||||
| Comp1 | sc-y-6 |
|
||||
| Comp2 | sc-y-6 |
|
||||
And the following lp "plans" exist:
|
||||
| name | user | description |
|
||||
| Plan Science-6 | admin | Plan description |
|
||||
And the following lp "plancompetencies" exist:
|
||||
| plan | competency |
|
||||
| Plan Science-6 | Comp1 |
|
||||
| Plan Science-6 | Comp2 |
|
||||
And the following lp "usercompetencyplans" exist:
|
||||
| user | competency | plan |
|
||||
| admin | Comp1 | Plan Science-6 |
|
||||
| admin | Comp2 | Plan Science-6 |
|
||||
And I follow "Competency Frameworks"
|
||||
And I should see "Science Year-6"
|
||||
And I click on "Edit" of edit menu in the "Science Year-6" row
|
||||
And the field "Name" matches value "Science Year-6 "
|
||||
And I set the field "Name" to "Science Year-6 Edited"
|
||||
And the "scaleid" "select" should be readonly
|
||||
When I press "Save changes"
|
||||
Then I should see "Competency framework updated"
|
||||
And I should see "Science Year-6 Edited"
|
||||
And I should see "sc-y-6"
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$plugin->version = 2016020920; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2016020921; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014110400; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
Reference in New Issue
Block a user