Skip to content

Commit

Permalink
MDL-53700 competency: Migrating data generator to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent 767f66c commit 922634d
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 157 deletions.
110 changes: 55 additions & 55 deletions admin/tool/lp/tests/api_test.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function the_following_lp_exist($elementname, TableNode $data) {
}

$datagenerator = testing_util::get_data_generator();
$this->datageneratorlp = $datagenerator->get_plugin_generator('tool_lp');
$this->datageneratorlp = $datagenerator->get_plugin_generator('core_competency');

$elementdatagenerator = self::$elements[$elementname]['datagenerator'];
$requiredfields = self::$elements[$elementname]['required'];
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/lp/tests/competency_rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function test_rule_all_matching() {
$this->resetAfterTest(true);

$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$u1 = $this->getDataGenerator()->create_user();

// Set up the framework and competencies.
Expand Down Expand Up @@ -97,7 +97,7 @@ public function test_rule_points_validation() {
$this->resetAfterTest(true);
$this->setAdminUser();

$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();
$framework2 = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
Expand Down Expand Up @@ -227,7 +227,7 @@ public function test_rule_points_matching() {
$this->resetAfterTest(true);

$this->setAdminUser();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$u1 = $this->getDataGenerator()->create_user();

// Set up the framework and competencies.
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/course_competency_settings_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function test_who_can_change_settings() {

$syscontext = context_system::instance();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');
$role = create_role('Settings changer role', 'settingschanger', 'Someone who can change course competency settings');
assign_capability('moodle/competency:coursecompetencyconfigure', CAP_ALLOW, $role, $syscontext->id);
assign_capability('moodle/competency:competencygrade', CAP_ALLOW, $role, $syscontext->id);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/course_competency_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function test_get_courses_with_competency_and_user() {

$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$c1 = $dg->create_course();
$c2 = $dg->create_course();
Expand Down
88 changes: 44 additions & 44 deletions admin/tool/lp/tests/event_test.php

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions admin/tool/lp/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function test_update_competency_frameworks_with_manage_permissions_in_cat

public function test_update_framework_scale() {
$this->setUser($this->creator);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

$s1 = $this->getDataGenerator()->create_scale();

Expand Down Expand Up @@ -651,7 +651,7 @@ public function test_list_and_count_competency_frameworks_with_manage_permission

public function list_competency_frameworks_with_query() {
$this->setUser($this->creator);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework1 = $lpg->create_framework(array(
'shortname' => 'shortname_beetroot',
'idnumber' => 'idnumber_cinnamon',
Expand Down Expand Up @@ -1046,7 +1046,7 @@ public function test_update_competency_with_read_permissions() {
public function test_count_competencies_with_filters() {
$this->setUser($this->creator);

$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$f1 = $lpg->create_framework();
$f2 = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
Expand Down Expand Up @@ -1465,7 +1465,7 @@ public function test_delete_plans() {
public function test_delete_plan_removes_relations() {
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$user = $dg->create_user();
$plan = $lpg->create_plan(array('userid' => $user->id));
Expand Down Expand Up @@ -1494,7 +1494,7 @@ public function test_list_plan_competencies() {
$this->setUser($this->creator);

$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$f1 = $lpg->create_framework();
$f2 = $lpg->create_framework();
Expand Down Expand Up @@ -1602,7 +1602,7 @@ public function test_add_competency_to_template() {
public function test_remove_competency_from_template() {
$syscontext = context_system::instance();
$this->setUser($this->creator);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

// Create a template.
$template = $this->create_template(1, true);
Expand Down Expand Up @@ -2195,7 +2195,7 @@ public function test_add_related_competency() {
global $DB;
$this->setUser($this->creator);

$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();
$framework2 = $lpg->create_framework();
$competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
Expand Down Expand Up @@ -2286,7 +2286,7 @@ public function test_add_related_competency() {
public function test_remove_related_competency() {
$this->setUser($this->creator);

$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
Expand Down Expand Up @@ -2322,7 +2322,7 @@ public function test_remove_related_competency() {
public function test_search_competencies_including_related() {
$this->setUser($this->creator);

$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();
$c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
$c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
Expand Down Expand Up @@ -2350,7 +2350,7 @@ public function test_search_competencies_including_related() {
public function test_add_competency_to_plan() {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$usermanage = $dg->create_user();
$user = $dg->create_user();

Expand Down Expand Up @@ -2412,7 +2412,7 @@ public function test_add_competency_to_plan() {
public function test_remove_competency_from_plan() {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$usermanage = $dg->create_user();
$user = $dg->create_user();

Expand Down Expand Up @@ -2457,7 +2457,7 @@ public function test_remove_competency_from_plan() {
public function test_reorder_plan_competency() {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$usermanage = $dg->create_user();
$user = $dg->create_user();

Expand Down Expand Up @@ -2528,7 +2528,7 @@ public function test_reorder_plan_competency() {
*/
public function test_fix_sortorder_when_creating_competency() {
$this->resetAfterTest(true);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$framework = $lpg->create_framework();

$c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
Expand All @@ -2546,7 +2546,7 @@ public function test_fix_sortorder_when_creating_competency() {
public function test_fix_sortorder_when_delete_competency() {
$this->resetAfterTest(true);
$this->setUser($this->creator);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

$framework = $lpg->create_framework();

Expand Down Expand Up @@ -2599,7 +2599,7 @@ public function test_fix_sortorder_when_delete_competency() {
public function test_fix_sortorder_when_moving_competency() {
$this->resetAfterTest(true);
$this->setUser($this->creator);
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');

$framework = $lpg->create_framework();

Expand Down Expand Up @@ -2926,7 +2926,7 @@ public function test_grade_competency_in_plan() {
$this->setUser($this->creator);

$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$f1 = $lpg->create_framework();

Expand Down Expand Up @@ -2957,7 +2957,7 @@ public function test_data_for_user_competency_summary_in_plan() {
$this->setUser($this->creator);

$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$f1 = $lpg->create_framework();

Expand Down Expand Up @@ -3101,7 +3101,7 @@ public function test_list_course_modules_using_competency() {
$this->setAdminUser();

$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$course = $dg->create_course();
$cm1 = $dg->create_module('assign', array('course' => $course->id));
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/lp/tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function test_comment_add_user_competency() {
global $DB;
$this->resetAfterTest();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$u1 = $dg->create_user();
$u2 = $dg->create_user();
Expand Down Expand Up @@ -189,7 +189,7 @@ public function test_comment_add_user_competency() {
public function test_comment_add_plan() {
$this->resetAfterTest();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$u1 = $dg->create_user();
$u2 = $dg->create_user();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/plan_persistent_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function test_get_by_user_and_competency() {
$this->setAdminUser();

$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$u1 = $dg->create_user();
$u2 = $dg->create_user();
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/plan_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function test_validate_duedate() {
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $this->getDataGenerator()->get_plugin_generator('tool_lp');
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
$user = $dg->create_user();

$record = array('userid' => $user->id,
Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lp/tests/task_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function test_sync_plans_from_cohorts_task() {
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

// Sql to simulate the execution in time.
$cmsql = "UPDATE {cohort_members} SET timeadded = :currenttime WHERE cohortid = :cohortid AND userid = :userid";
Expand Down Expand Up @@ -160,7 +160,7 @@ public function test_sync_plans_from_cohorts_with_templateduedate_task() {
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$user1 = $dg->create_user();
$user2 = $dg->create_user();
Expand Down Expand Up @@ -241,7 +241,7 @@ public function test_sync_plans_from_cohorts_with_passed_duedate() {
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$user1 = $dg->create_user();
$user2 = $dg->create_user();
Expand Down Expand Up @@ -278,7 +278,7 @@ public function test_complete_plans_task() {
$this->resetAfterTest(true);
$this->setAdminUser();
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$user = $dg->create_user();

Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/template_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function test_validate_duedate() {
global $DB;

$this->resetAfterTest();
$tpl = $this->getDataGenerator()->get_plugin_generator('tool_lp')->create_template();
$tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();

// No due date -> pass.
$tpl->set_duedate(0);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/tests/user_evidence_competency_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function test_get_user_competencies_by_userevidenceid() {

$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$lpg = $dg->get_plugin_generator('core_competency');

$u1 = $dg->create_user();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Tool LP data generator.
* Competency data generator.
*
* @package tool_lp
* @package core_competency
* @category test
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -27,31 +27,31 @@
use core_competency\competency_framework;
use core_competency\course_competency;
use core_competency\course_module_competency;
use tool_lp\external;
use core_competency\evidence;
use core_competency\plan;
use core_competency\plan_competency;
use core_competency\related_competency;
use core_competency\template;
use core_competency\template_cohort;
use core_competency\template_competency;
use core_competency\user_competency;
use core_competency\user_competency_course;
use core_competency\user_competency_plan;
use core_competency\plan_competency;
use core_competency\evidence;
use core_competency\user_evidence;
use core_competency\user_evidence_competency;
use tool_lp\external;

defined('MOODLE_INTERNAL') || die();

/**
* Tool LP data generator.
* Competency data generator class.
*
* @package tool_lp
* @package core_competency
* @category test
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_lp_generator extends component_generator_base {
class core_competency_generator extends component_generator_base {

/** @var int Number of created competencies. */
protected $competencycount = 0;
Expand Down
Loading

0 comments on commit 922634d

Please sign in to comment.