Merge branch 'MDL-82866-main' of https://github.com/lameze/moodle

This commit is contained in:
Sara Arjona 2025-01-14 14:22:20 +01:00
commit 8d429bc55b
No known key found for this signature in database
13 changed files with 297 additions and 169 deletions

View file

@ -0,0 +1,7 @@
issueNumber: MDL-82866
notes:
tool_lp:
- message: >-
behat_tool_lp_data_generators::the_following_lp_exist is deprecated. Use
the following "core_competency > [competency|framework|plan...]" exist:
type: deprecated

View file

@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/../../../../../lib/behat/behat_deprecated_base.php');
use Behat\Gherkin\Node\TableNode as TableNode;
use Behat\Behat\Tester\Exception\PendingException as PendingException;
@ -40,7 +40,7 @@ use core_competency\user_evidence;
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_tool_lp_data_generators extends behat_base {
class behat_tool_lp_deprecated extends behat_deprecated_base {
/**
* @var tool_lp data generator
@ -98,12 +98,21 @@ class behat_tool_lp_data_generators extends behat_base {
*
* @Given /^the following lp "(?P<element_string>(?:[^"]|\\")*)" exist:$/
*
* @todo MDL-78077 This will be deleted in Moodle 6.0.
* @deprecated since 5.0
*
* @throws Exception
* @throws PendingException
* @param string $elementname The name of the entity to add
* @param TableNode $data
*/
#[\core\attribute\deprecated('behat_tool_lp_data_generators::the_following_lp_exist', since: '5.0')]
public function the_following_lp_exist($elementname, TableNode $data) {
$this->deprecated_message([
'behat_tool_lp_data_generators::the_following_lp_exist is deprecated',
'Use: the following "core_competency > [competency|framework|plan...]" exist:',
]);
// Now that we need them require the data generators.
require_once(__DIR__.'/../../../../../lib/phpunit/classes/util.php');

View file

@ -4,11 +4,11 @@ Feature: See the competencies for an activity on the course competencies page.
In order to see only the competencies for an activity in the course competencies page.
Background:
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Test-Framework | ID-FW1 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| Test-Comp1 | ID-FW1 |
| Test-Comp2 | ID-FW1 |
Given the following "courses" exist:

View file

@ -29,7 +29,7 @@ Feature: Manage competency frameworks
And I should see "Science Year-1"
Scenario: Read a framework
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Science Year-2 | sc-y-2 |
And I navigate to "Competencies > Competency frameworks" in site administration
@ -38,7 +38,7 @@ Feature: Manage competency frameworks
Then I should see "Science Year-2"
Scenario: Edit a framework
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Science Year-3 | sc-y-3 |
And I navigate to "Competencies > Competency frameworks" in site administration
@ -52,7 +52,7 @@ Feature: Manage competency frameworks
And I should see "sc-y-3"
Scenario: Delete a framework
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Science Year-4 | sc-y-4 |
And I navigate to "Competencies > Competency frameworks" in site administration
@ -70,21 +70,21 @@ Feature: Manage competency frameworks
And I should not see "sc-y-4"
Scenario: Edit a framework with competencies in user competency
Given the following lp "frameworks" exist:
Given the following "core_competency > 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:
And the following "core_competency > competencies" exist:
| shortname | competencyframework | idnumber |
| Comp1 | sc-y-5 | Comp1 |
| Comp2 | sc-y-5 | Comp2 |
And the following "core_competency > plans" exist:
| name | user | description |
| Plan Science-5 | admin | Plan description |
And the following lp "plancompetencies" exist:
And the following "core_competency > plan_competency" exist:
| plan | competency |
| Plan Science-5 | Comp1 |
| Plan Science-5 | Comp2 |
And the following lp "usercompetencies" exist:
And the following "core_competency > user_competency" exist:
| user | competency |
| admin | Comp1 |
| admin | Comp2 |
@ -100,21 +100,21 @@ Feature: Manage competency frameworks
And I should see "sc-y-5"
Scenario: Edit a framework with competencies in user competency plan
Given the following lp "frameworks" exist:
Given the following "core_competency > 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:
And the following "core_competency > competencies" exist:
| shortname | competencyframework | idnumber |
| Comp1 | sc-y-6 | Comp1 |
| Comp2 | sc-y-6 | Comp2 |
And the following "core_competency > plans" exist:
| name | user | description |
| Plan Science-6 | admin | Plan description |
And the following lp "plancompetencies" exist:
And the following "core_competency > plan_competency" exist:
| plan | competency |
| Plan Science-6 | Comp1 |
| Plan Science-6 | Comp2 |
And the following lp "usercompetencyplans" exist:
And the following "core_competency > user_competency_plans" exist:
| user | competency | plan |
| admin | Comp1 | Plan Science-6 |
| admin | Comp2 | Plan Science-6 |
@ -130,11 +130,11 @@ Feature: Manage competency frameworks
And I should see "sc-y-6"
Scenario: Duplicate a competency framework
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| CF1 | CF1 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| C1 | CF1 |
And I navigate to "Competencies > Competency frameworks" in site administration
# Duplicate the selected competency framework

View file

@ -22,7 +22,7 @@ Feature: Manage plearning plan
And I should see "Science plan"
Scenario: Create a learning plan based on template
Given the following lp "templates" exist:
Given the following "core_competency > templates" exist:
| shortname | description |
| Science template | science template description |
And I am on homepage
@ -36,7 +36,7 @@ Feature: Manage plearning plan
And I should see "Admin User" in the "Science template" "table_row"
Scenario: Create a learning plan from template cohort
Given the following lp "templates" exist:
Given the following "core_competency > templates" exist:
| shortname | description |
| Science template cohort | science template description |
And the following "users" exist:
@ -62,7 +62,7 @@ Feature: Manage plearning plan
And I should see "Student 2"
Scenario: Read a learning plan
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description |
| Science plan Year-1 | admin | science plan description |
And I follow "Learning plans"
@ -72,14 +72,14 @@ Feature: Manage plearning plan
And I should see "Learning plan competencies"
Scenario: Manage a learning plan competencies
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description |
| Science plan Year-manage | admin | science plan description |
And the following lp "frameworks" exist:
And the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Framework 1 | sc-y-2 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| comp1 | sc-y-2 |
| comp2 | sc-y-2 |
And I follow "Learning plans"
@ -98,7 +98,7 @@ Feature: Manage plearning plan
And "comp1" "table_row" should not exist
Scenario: Edit a learning plan
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description |
| Science plan Year-2 | admin | science plan description |
| Science plan Year-3 | admin | science plan description |
@ -113,7 +113,7 @@ Feature: Manage plearning plan
And I should see "Science plan Year-3 Edited"
Scenario: Delete a learning plan
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description |
| Science plan Year-4 | admin | science plan description |
And I follow "Learning plans"
@ -130,14 +130,14 @@ Feature: Manage plearning plan
Then I should not see "Science plan Year-4"
Scenario: See a learning plan from a course
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description |
| Science plan Year-manage | admin | science plan description |
And the following lp "frameworks" exist:
And the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Framework 1 | sc-y-2 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| comp1 | sc-y-2 |
| comp2 | sc-y-2 |
And I follow "Learning plans"

View file

@ -31,18 +31,18 @@ Feature: Manage plan workflow
| user1 | usermanageowndraftplan | System | |
| user2 | usermanageownplan | System | |
| manager1 | manageplan | System | |
And the following lp "frameworks" exist:
And the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Test-Framework | ID-FW1 |
And the following lp "competencies" exist:
| shortname | framework |
| Test-Comp1 | ID-FW1 |
| Test-Comp2 | ID-FW1 |
And the following lp "plans" exist:
| name | user | description |
| Test-Plan1 | user1 | Description of plan for user 1 |
| Test-Plan2 | user2 | Description of plan for user 2 |
And the following lp "plancompetencies" exist:
And the following "core_competency > competencies" exist:
| shortname | competencyframework | idnumber |
| Test-Comp1 | ID-FW1 | Test-Comp1 |
| Test-Comp2 | ID-FW1 | Test-Comp2 |
And the following "core_competency > plans" exist:
| name | user | description | reviewer | status |
| Test-Plan1 | user1 | Description of plan for user 1 | user1 | draft |
| Test-Plan2 | user2 | Description of plan for user 2 | user2 | draft |
And the following "core_competency > plan_competency" exist:
| plan | competency |
| Test-Plan1 | Test-Comp1 |
| Test-Plan1 | Test-Comp2 |
@ -89,7 +89,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager can see learning plan with status waiting for review
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status |
| Test-Plan3 | user2 | Description of plan 3 for user 1 | waiting for review |
| Test-Plan4 | user1 | Description of plan 3 for user 1 | draft |
@ -99,7 +99,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager can start review of learning plan with status waiting for review
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | waiting for review |
And I log in as "manager1"
@ -111,7 +111,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager can reject a learning plan with status in review
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | in review | manager1 |
And I log in as "manager1"
@ -124,7 +124,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager can accept a learning plan with status in review
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | in review | manager1 |
And I log in as "manager1"
@ -137,7 +137,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager send back to draft an active learning plan
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
@ -153,7 +153,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager change an active learning plan to completed
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
@ -172,7 +172,7 @@ Feature: Manage plan workflow
And I log out
Scenario: Manager reopen a complete learning plan
Given the following lp "plans" exist:
Given the following "core_competency > plans" exist:
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | complete | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | complete | manager1 |

View file

@ -21,7 +21,7 @@ Feature: Manage plearning plan templates
And I should see "Science template"
Scenario: Read a learning plan template
Given the following lp "templates" exist:
Given the following "core_competency > templates" exist:
| shortname | description |
| Science template Year-2 | science template description |
And I navigate to "Competencies > Learning plan templates" in site administration
@ -31,7 +31,7 @@ Feature: Manage plearning plan templates
And I should see "Learning plan template competencies"
Scenario: Edit a learning plan template
Given the following lp "templates" exist:
Given the following "core_competency > templates" exist:
| shortname | description |
| Science template Year-3 | science template description |
And I navigate to "Competencies > Learning plan templates" in site administration
@ -44,7 +44,7 @@ Feature: Manage plearning plan templates
And I should see "Science template Year-3 Edited"
Scenario: Delete a learning plan template
Given the following lp "templates" exist:
Given the following "core_competency > templates" exist:
| shortname | description |
| Science template Year-4 | science template description |
And I navigate to "Competencies > Learning plan templates" in site administration

View file

@ -5,21 +5,21 @@ Feature: Manage competencies linked to evidence of prior learning
I need to link and unlink competencies from evidence of prior learning
Background:
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Test-Framework | ID-FW1 |
And the following lp "competencies" exist:
| shortname | framework |
| Test-Comp1 | ID-FW1 |
| Test-Comp2 | ID-FW1 |
And the following lp "plans" exist:
And the following "core_competency > competencies" exist:
| shortname | competencyframework | idnumber |
| Test-Comp1 | ID-FW1 | Test-Comp1 |
| Test-Comp2 | ID-FW1 | Test-Comp2 |
And the following "core_competency > plans" exist:
| name | user | description |
| Test-Plan | admin | Plan description |
And the following lp "plancompetencies" exist:
And the following "core_competency > plan_competency" exist:
| plan | competency |
| Test-Plan | Test-Comp1 |
| Test-Plan | Test-Comp2 |
And the following lp "userevidence" exist:
And the following "core_competency > user_evidence" exist:
| name | description | user |
| Test-Evidence | Description evidence | admin |
When I log in as "admin"
@ -51,11 +51,11 @@ Feature: Manage competencies linked to evidence of prior learning
Then "Test-Comp2" "table_row" should exist
Scenario: Unlink competency from evidence of prior learning
Given the following lp "userevidencecompetencies" exist:
Given the following "core_competency > user_evidence_competency" exist:
| userevidence | competency |
| Test-Evidence | Test-Comp1 |
| Test-Evidence | Test-Comp2 |
Given the following lp "usercompetencies" exist:
And the following "core_competency > user_competency" exist:
| user | competency |
| admin | Test-Comp1 |
| admin | Test-Comp2 |

View file

@ -24,7 +24,7 @@ Feature: Manage evidence of prior learning
And I should see "Evidence-1"
Scenario: Read an evidence of prior learning
Given the following lp "userevidence" exist:
Given the following "core_competency > user_evidence" exist:
| name | description | user |
| Evidence-2 | Evidence-2 description | user1 |
And I follow "Evidence of prior learning"
@ -34,7 +34,7 @@ Feature: Manage evidence of prior learning
Then I should see "Evidence-2"
Scenario: Edit an evidence of prior learning
Given the following lp "userevidence" exist:
Given the following "core_competency > user_evidence" exist:
| name | description | user |
| Evidence-3 | Evidence-3 description | user1 |
And I follow "Evidence of prior learning"
@ -47,7 +47,7 @@ Feature: Manage evidence of prior learning
And I should see "Evidence-3 Edited"
Scenario: Delete an evidence of prior learning
Given the following lp "userevidence" exist:
Given the following "core_competency > user_evidence" exist:
| name | description | user |
| Evidence-4 | Evidence-4 description | user1 |
And I follow "Evidence of prior learning"
@ -63,8 +63,8 @@ Feature: Manage evidence of prior learning
Scenario: List evidences of prior learning
Given the following "users" exist:
| username | firstname | lastname | email |
|user2 | User | 2 | user2@example.com |
And the following lp "userevidence" exist:
| user2 | User | 2 | user2@example.com |
And the following "core_competency > user_evidence" exist:
| name | description | user |
| Evidence-5 | Evidence-5 description | user1 |
| Evidence-6 | Evidence-6 description | user2 |

View file

@ -40,9 +40,9 @@ Feature: View competencies
| competency | relatedcompetency |
| desserts | cakes |
And the following "core_competency > plans" exist:
| name | description | competencies | user |
| Cookery | Cookery is important | salads, desserts, cakes | student1 |
| Literacy | Literacy is important | reading, writing | student1 |
| name | description | competencies | user | status |
| Cookery | Cookery is important | salads, desserts, cakes | student1 | active |
| Literacy | Literacy is important | reading, writing | student1 | active |
And the following "core_competency > course_competencies" exist:
| course | competency |
| C1 | salads |

View file

@ -14,11 +14,11 @@ Feature: Award badges based on competency completion
And the following "course enrolments" exist:
| user | course | role |
| user1 | C1 | student |
And the following lp "frameworks" exist:
And the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Framework 1 | sc-y-2 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| comp1 | sc-y-2 |
| comp2 | sc-y-2 |
And I log in as "admin"

View file

@ -57,7 +57,13 @@ class behat_core_competency_generator extends behat_generator_base {
'singular' => 'plan',
'datagenerator' => 'plan',
'required' => ['name'],
'switchids' => ['user' => 'userid'],
'switchids' => ['user' => 'userid', 'status' => 'status'],
],
'plan_competencies' => [
'singular' => 'plan_competency',
'datagenerator' => 'plan_competency',
'required' => ['plan', 'competency'],
'switchids' => ['competency' => 'competencyid', 'plan' => 'planid'],
],
'related_competencies' => [
'singular' => 'related_competency',
@ -83,14 +89,32 @@ class behat_core_competency_generator extends behat_generator_base {
'required' => ['plan', 'competency', 'user'],
'switchids' => ['plan' => 'planid', 'competency' => 'competencyid', 'user' => 'userid'],
],
'user_evidence' => [
'singular' => 'user_evidence',
'datagenerator' => 'user_evidence',
'required' => ['user', 'name'],
'switchids' => ['user' => 'userid'],
],
'user_evidence_competency' => [
'singular' => 'user_evidence_competency',
'datagenerator' => 'user_evidence_competency',
'required' => ['userevidence', 'competency'],
'switchids' => ['userevidence' => 'userevidenceid', 'competency' => 'competencyid'],
],
'templates' => [
'singular' => 'template',
'datagenerator' => 'template',
'required' => ['shortname'],
'switchids' => ['context' => 'contextid'],
],
];
}
/**
* Get the competecy framework id using an idnumber.
* Get the competency framework id using an idnumber.
*
* @param string $idnumber
* @return int The competecy framework id
* @return int The competency framework id
*/
protected function get_competencyframework_id(string $idnumber): int {
global $DB;
@ -103,10 +127,10 @@ class behat_core_competency_generator extends behat_generator_base {
}
/**
* Get the competecy id using an idnumber.
* Get the competency id using an idnumber.
*
* @param string $idnumber
* @return int The competecy id
* @return int The competency id
*/
protected function get_competency_id(string $idnumber): int {
global $DB;
@ -135,10 +159,10 @@ class behat_core_competency_generator extends behat_generator_base {
}
/**
* Get the related competecy id using an idnumber.
* Get the related competency id using an idnumber.
*
* @param string $idnumber
* @return int The related competecy id
* @return int The related competency id
*/
protected function get_relatedcompetency_id(string $idnumber): int {
return $this->get_competency_id($idnumber);
@ -208,6 +232,8 @@ class behat_core_competency_generator extends behat_generator_base {
* @return array Processed data.
*/
protected function preprocess_plan(array $data): array {
global $DB, $USER;
if (isset($data['competencies'])) {
$competencies = array_map('trim', str_getcsv($data['competencies'], escape: '\\'));
$data['competencyids'] = array_map([$this, 'get_competency_id'], $competencies);
@ -215,11 +241,20 @@ class behat_core_competency_generator extends behat_generator_base {
unset($data['competencies']);
}
global $USER;
if (isset($data['reviewer'])) {
if (is_number($data['reviewer'])) {
$data['reviewerid'] = $data['reviewer'];
} else {
if (!$userid = $DB->get_field('user', 'id', ['username' => $data['reviewer']])) {
throw new Exception('The specified user "' . $data['reviewer'] . '" could not be found.');
}
$data['reviewerid'] = $userid;
}
unset($data['reviewer']);
}
return $data + [
'userid' => $USER->id,
'status' => plan::STATUS_ACTIVE,
];
}
@ -258,4 +293,81 @@ class behat_core_competency_generator extends behat_generator_base {
protected function get_data_generator(): core_competency_generator {
return $this->componentdatagenerator;
}
/**
* Get the user evidence id using a name.
*
* @param string $name User evidence name.
* @return int The user evidence id
*/
protected function get_userevidence_id(string $name): int {
global $DB;
if (!$id = $DB->get_field('competency_userevidence', 'id', ['name' => $name])) {
throw new Exception('The specified user evidence with name "' . $name . '" could not be found.');
}
return $id;
}
/**
* Get the template competency id using a name.
*
* @param string $name Template competency name.
* @return int The template competency id
*/
protected function get_templatecompetency_id(string $name): int {
global $DB;
if (!$id = $DB->get_field('competency_template', 'id', ['name' => $name])) {
throw new Exception('The specified template competency with name "' . $name . '" could not be found.');
}
return $id;
}
/**
* Get the context id using a contextid.
*
* @param string $contextid Context id.
* @return int The context id
*/
protected function get_context_id(string $contextid): int {
global $DB;
if (!$id = $DB->get_field('context', 'id', ['id' => $contextid])) {
throw new Exception('The specified context with id "' . $contextid . '" could not be found.');
}
return $id;
}
/**
* Get the status id by status name.
*
* @param string $name Status name.
* @return int
*/
protected function get_status_id(string $name): int {
switch ($name) {
case 'draft':
$status = plan::STATUS_DRAFT;
break;
case 'in review':
$status = plan::STATUS_IN_REVIEW;
break;
case 'waiting for review':
$status = plan::STATUS_WAITING_FOR_REVIEW;
break;
case 'complete':
$status = plan::STATUS_COMPLETE;
break;
default:
$status = plan::STATUS_ACTIVE;
break;
}
return $status;
}
}

View file

@ -5,11 +5,11 @@ Feature: See the competencies for an activity
I need to see the competencies linked to one activity in the breakdown report.
Background:
Given the following lp "frameworks" exist:
Given the following "core_competency > frameworks" exist:
| shortname | idnumber |
| Test-Framework | ID-FW1 |
And the following lp "competencies" exist:
| shortname | framework |
And the following "core_competency > competencies" exist:
| shortname | competencyframework |
| Test-Comp1 | ID-FW1 |
| Test-Comp2 | ID-FW1 |
Given the following "courses" exist: