-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtesting.php
111 lines (86 loc) · 3.08 KB
/
testing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?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/>.
/**
* The plugin-specific library of functions used for testing.
*
* @package enrol_selma
* @copyright 2020 LearningWorks <selma@learningworks.ac.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use enrol_selma\local\course;
use enrol_selma\local\user;
require_once(dirname(__FILE__, 3) . '/config.php');
require_once(dirname(__FILE__, 3) . '/user/profile/lib.php');
require_login();
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/lib.php');
require_once(__DIR__ . '/locallib.php');
require_once(dirname(__FILE__, 3) . '/admin/tool/uploaduser/locallib.php');
require_once(dirname(__FILE__, 3) . '/user/lib.php');
require_once(dirname(__FILE__, 3) . '/group/lib.php');
global $DB;
(new enrol_selma_plugin)->unenrol_user_enrolment(28);
echo 'DONE!';
die();
// Enrolling.
$enrolled = enrol_selma_enrol_user(2, 10612954);
var_dump($enrolled);
die();
$course = new course();
$course->id = 41;
$course->fullname = "TestingUpdate";
$course->shortname = "FinalTestingUpdate";
$course->idnumber = "Hopefullyyy";
$course->customfield_test = 8;
$course->save();
var_dump($course);
// Configs.
var_dump(get_config('enrol_selma', 'faake'));
$selmauser = new user();
echo "Hello World!<br><hr><br>";
echo "<br>SELMA User<hr>";
var_dump(array_keys(get_object_vars($selmauser)));
echo "<br>Profile Mapping<hr>";
var_dump(enrol_selma_get_profile_mapping());
echo "<br>User object from selma data<hr>";
$selmauserdata['id'] = '9010';
$selmauserdata['dob'] = '19/12/2020';
$selmauserdata['email1'] = 'user3@email.invalid';
$selmauserdata['forename'] = 'Users';
$selmauserdata['gender'] = 'Males';
$selmauserdata['id'] = '12345678910';
$selmauserdata['lastname'] = 'Lastnames';
$selmauserdata['mobilephone'] = '9999999999';
$selmauserdata['nsn'] = '1231231231';
$selmauserdata['preferredname'] = 'zpottie2';
$selmauserdata['secondaryphone'] = '1201201201';
$selmauserdata['status'] = 'active2';
$selmauserdata['username'] = 'testingfile1';
$selmauser = enrol_selma_user_from_selma_data($selmauserdata);
var_dump($selmauser);
echo "<br>Get user<hr>";
$user = enrol_selma_user_from_id(34);
var_dump($user->lastname);
var_dump($user);
$user->lastname = "Ted";
var_dump($user);
echo "<br>Save user<hr>";
$newuser = $user->save();
var_dump($DB->get_record('user', array('id' => $newuser->id)));
echo "<br>Add user to intake<hr>";
$user = enrol_selma_add_user_to_intake(654321, 12312313);
var_dump($user);
die();