| Línea 12... |
Línea 12... |
| 12 |
// GNU General Public License for more details.
|
12 |
// GNU General Public License for more details.
|
| 13 |
//
|
13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
| Línea 16... |
Línea -... |
| 16 |
|
- |
|
| 17 |
/**
|
- |
|
| 18 |
* Unit tests for privacy.
|
- |
|
| 19 |
*
|
- |
|
| 20 |
* @package core_analytics
|
- |
|
| 21 |
* @copyright 2018 David Monllaó {@link http://www.davidmonllao.com}
|
- |
|
| 22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
- |
|
| 23 |
*/
|
16 |
|
| Línea 24... |
Línea -... |
| 24 |
namespace core_analytics\privacy;
|
- |
|
| 25 |
|
- |
|
| 26 |
use core_analytics\privacy\provider;
|
- |
|
| 27 |
use core_privacy\local\request\transform;
|
- |
|
| 28 |
use core_privacy\local\request\writer;
|
17 |
namespace core_analytics\privacy;
|
| - |
|
18 |
|
| Línea 29... |
Línea 19... |
| 29 |
use core_privacy\local\request\approved_contextlist;
|
19 |
use core_privacy\local\request\approved_userlist;
|
| Línea 30... |
Línea 20... |
| 30 |
use core_privacy\local\request\approved_userlist;
|
20 |
use core_analytics\tests\mlbackend_helper_trait;
|
| 31 |
|
21 |
|
| Línea 41... |
Línea 31... |
| 41 |
*
|
31 |
*
|
| 42 |
* @package core_analytics
|
32 |
* @package core_analytics
|
| 43 |
* @copyright 2018 David Monllaó {@link http://www.davidmonllao.com}
|
33 |
* @copyright 2018 David Monllaó {@link http://www.davidmonllao.com}
|
| 44 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
34 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 45 |
*/
|
35 |
*/
|
| 46 |
class provider_test extends \core_privacy\tests\provider_testcase {
|
36 |
final class provider_test extends \core_privacy\tests\provider_testcase {
|
| - |
|
37 |
use mlbackend_helper_trait;
|
| Línea 47... |
Línea 38... |
| 47 |
|
38 |
|
| 48 |
/** @var \core_analytics\model Store Model 1. */
|
39 |
/** @var \core_analytics\model Store Model 1. */
|
| Línea 49... |
Línea 40... |
| 49 |
protected $model1;
|
40 |
protected $model1;
|
| Línea 79... |
Línea 70... |
| 79 |
protected $u7;
|
70 |
protected $u7;
|
| Línea 80... |
Línea 71... |
| 80 |
|
71 |
|
| 81 |
/** @var \stdClass $u8 User 8 record. */
|
72 |
/** @var \stdClass $u8 User 8 record. */
|
| Línea -... |
Línea 73... |
| - |
|
73 |
protected $u8;
|
| - |
|
74 |
|
| - |
|
75 |
/** @var \stdClass $u9 User 9 record. */
|
| - |
|
76 |
protected $u9;
|
| - |
|
77 |
|
| - |
|
78 |
/** @var \stdClass $u10 User 10 record. */
|
| 82 |
protected $u8;
|
79 |
protected $u10;
|
| 83 |
|
80 |
|
| Línea 84... |
Línea 81... |
| 84 |
/** @var \stdClass $c1 Course 1 record. */
|
81 |
/** @var \stdClass $c1 Course 1 record. */
|
| 85 |
protected $c1;
|
82 |
protected $c1;
|
| Línea 86... |
Línea 83... |
| 86 |
|
83 |
|
| - |
|
84 |
/** @var \stdClass $c2 Course 2 record. */
|
| - |
|
85 |
protected $c2;
|
| - |
|
86 |
|
| - |
|
87 |
public function setUp(): void {
|
| - |
|
88 |
if (!self::is_mlbackend_python_configured()) {
|
| Línea 87... |
Línea 89... |
| 87 |
/** @var \stdClass $c2 Course 2 record. */
|
89 |
$this->markTestSkipped('mlbackend_python is not configured.');
|
| 88 |
protected $c2;
|
90 |
}
|
| Línea 89... |
Línea 91... |
| 89 |
|
91 |
|
| Línea 115... |
Línea 117... |
| 115 |
$this->u4 = $this->getDataGenerator()->create_user(['firstname' => 'b444444444444', 'lastname' => 'b']);
|
117 |
$this->u4 = $this->getDataGenerator()->create_user(['firstname' => 'b444444444444', 'lastname' => 'b']);
|
| 116 |
$this->u5 = $this->getdatagenerator()->create_user(['firstname' => 'a555555555555', 'lastname' => 'a']);
|
118 |
$this->u5 = $this->getdatagenerator()->create_user(['firstname' => 'a555555555555', 'lastname' => 'a']);
|
| 117 |
$this->u6 = $this->getdatagenerator()->create_user(['firstname' => 'a666666666666', 'lastname' => 'a']);
|
119 |
$this->u6 = $this->getdatagenerator()->create_user(['firstname' => 'a666666666666', 'lastname' => 'a']);
|
| 118 |
$this->u7 = $this->getdatagenerator()->create_user(['firstname' => 'b777777777777', 'lastname' => 'b']);
|
120 |
$this->u7 = $this->getdatagenerator()->create_user(['firstname' => 'b777777777777', 'lastname' => 'b']);
|
| 119 |
$this->u8 = $this->getDataGenerator()->create_user(['firstname' => 'b888888888888', 'lastname' => 'b']);
|
121 |
$this->u8 = $this->getDataGenerator()->create_user(['firstname' => 'b888888888888', 'lastname' => 'b']);
|
| - |
|
122 |
$this->u9 = $this->getDataGenerator()->create_user(['firstname' => 'a999999999999', 'lastname' => 'a']);
|
| - |
|
123 |
$this->u10 = $this->getDataGenerator()->create_user(['firstname' => 'b000000000000', 'lastname' => 'a']);
|
| Línea 120... |
Línea 124... |
| 120 |
|
124 |
|
| 121 |
$this->c1 = $this->getDataGenerator()->create_course(['visible' => false]);
|
125 |
$this->c1 = $this->getDataGenerator()->create_course(['visible' => false]);
|
| Línea -... |
Línea 126... |
| - |
|
126 |
$this->c2 = $this->getDataGenerator()->create_course();
|
| 122 |
$this->c2 = $this->getDataGenerator()->create_course();
|
127 |
|
| 123 |
|
128 |
// Enrol users to course 1.
|
| 124 |
$this->getDataGenerator()->enrol_user($this->u1->id, $this->c1->id, 'student');
|
129 |
$this->getDataGenerator()->enrol_user($this->u1->id, $this->c1->id, 'student');
|
| 125 |
$this->getDataGenerator()->enrol_user($this->u2->id, $this->c1->id, 'student');
|
130 |
$this->getDataGenerator()->enrol_user($this->u2->id, $this->c1->id, 'student');
|
| 126 |
$this->getDataGenerator()->enrol_user($this->u3->id, $this->c1->id, 'student');
|
131 |
$this->getDataGenerator()->enrol_user($this->u3->id, $this->c1->id, 'student');
|
| 127 |
$this->getDataGenerator()->enrol_user($this->u4->id, $this->c1->id, 'student');
|
132 |
$this->getDataGenerator()->enrol_user($this->u4->id, $this->c1->id, 'student');
|
| 128 |
$this->getDataGenerator()->enrol_user($this->u5->id, $this->c1->id, 'student');
|
133 |
$this->getDataGenerator()->enrol_user($this->u5->id, $this->c1->id, 'student');
|
| 129 |
$this->getDataGenerator()->enrol_user($this->u6->id, $this->c1->id, 'student');
|
134 |
$this->getDataGenerator()->enrol_user($this->u6->id, $this->c1->id, 'student');
|
| - |
|
135 |
$this->getDataGenerator()->enrol_user($this->u7->id, $this->c1->id, 'student');
|
| - |
|
136 |
$this->getDataGenerator()->enrol_user($this->u8->id, $this->c1->id, 'student');
|
| - |
|
137 |
$this->getDataGenerator()->enrol_user($this->u9->id, $this->c1->id, 'student');
|
| 130 |
$this->getDataGenerator()->enrol_user($this->u7->id, $this->c1->id, 'student');
|
138 |
$this->getDataGenerator()->enrol_user($this->u10->id, $this->c1->id, 'student');
|
| 131 |
$this->getDataGenerator()->enrol_user($this->u8->id, $this->c1->id, 'student');
|
139 |
// Enrol users to course 2.
|
| 132 |
$this->getDataGenerator()->enrol_user($this->u1->id, $this->c2->id, 'student');
|
140 |
$this->getDataGenerator()->enrol_user($this->u1->id, $this->c2->id, 'student');
|
| 133 |
$this->getDataGenerator()->enrol_user($this->u2->id, $this->c2->id, 'student');
|
141 |
$this->getDataGenerator()->enrol_user($this->u2->id, $this->c2->id, 'student');
|
| 134 |
$this->getDataGenerator()->enrol_user($this->u3->id, $this->c2->id, 'student');
|
142 |
$this->getDataGenerator()->enrol_user($this->u3->id, $this->c2->id, 'student');
|
| 135 |
$this->getDataGenerator()->enrol_user($this->u4->id, $this->c2->id, 'student');
|
143 |
$this->getDataGenerator()->enrol_user($this->u4->id, $this->c2->id, 'student');
|
| 136 |
$this->getDataGenerator()->enrol_user($this->u5->id, $this->c2->id, 'student');
|
144 |
$this->getDataGenerator()->enrol_user($this->u5->id, $this->c2->id, 'student');
|
| 137 |
$this->getDataGenerator()->enrol_user($this->u6->id, $this->c2->id, 'student');
|
145 |
$this->getDataGenerator()->enrol_user($this->u6->id, $this->c2->id, 'student');
|
| - |
|
146 |
$this->getDataGenerator()->enrol_user($this->u7->id, $this->c2->id, 'student');
|
| - |
|
147 |
$this->getDataGenerator()->enrol_user($this->u8->id, $this->c2->id, 'student');
|
| Línea 138... |
Línea 148... |
| 138 |
$this->getDataGenerator()->enrol_user($this->u7->id, $this->c2->id, 'student');
|
148 |
$this->getDataGenerator()->enrol_user($this->u9->id, $this->c2->id, 'student');
|
| Línea 139... |
Línea 149... |
| 139 |
$this->getDataGenerator()->enrol_user($this->u8->id, $this->c2->id, 'student');
|
149 |
$this->getDataGenerator()->enrol_user($this->u10->id, $this->c2->id, 'student');
|
| 140 |
|
150 |
|
| Línea 165... |
Línea 175... |
| 165 |
$component = 'core_analytics';
|
175 |
$component = 'core_analytics';
|
| 166 |
$course1context = \context_course::instance($this->c1->id);
|
176 |
$course1context = \context_course::instance($this->c1->id);
|
| 167 |
$course2context = \context_course::instance($this->c2->id);
|
177 |
$course2context = \context_course::instance($this->c2->id);
|
| 168 |
$systemcontext = \context_system::instance();
|
178 |
$systemcontext = \context_system::instance();
|
| 169 |
$expected = [$this->u1->id, $this->u2->id, $this->u3->id, $this->u4->id, $this->u5->id, $this->u6->id,
|
179 |
$expected = [$this->u1->id, $this->u2->id, $this->u3->id, $this->u4->id, $this->u5->id, $this->u6->id,
|
| 170 |
$this->u7->id, $this->u8->id];
|
180 |
$this->u7->id, $this->u8->id, $this->u9->id, $this->u10->id];
|
| Línea 171... |
Línea 181... |
| 171 |
|
181 |
|
| 172 |
// Check users exist in the relevant contexts.
|
182 |
// Check users exist in the relevant contexts.
|
| 173 |
$userlist = new \core_privacy\local\request\userlist($course1context, $component);
|
183 |
$userlist = new \core_privacy\local\request\userlist($course1context, $component);
|
| 174 |
provider::get_users_in_context($userlist);
|
184 |
provider::get_users_in_context($userlist);
|
| Línea 201... |
Línea 211... |
| 201 |
public function test_delete_context_data(): void {
|
211 |
public function test_delete_context_data(): void {
|
| 202 |
global $DB;
|
212 |
global $DB;
|
| Línea 203... |
Línea 213... |
| 203 |
|
213 |
|
| 204 |
// We have 4 predictions for model1 and 8 predictions for model2.
|
214 |
// We have 4 predictions for model1 and 8 predictions for model2.
|
| 205 |
$this->assertEquals(12, $DB->count_records('analytics_predictions'));
|
215 |
$this->assertEquals(12, $DB->count_records('analytics_predictions'));
|
| Línea 206... |
Línea 216... |
| 206 |
$this->assertEquals(26, $DB->count_records('analytics_indicator_calc'));
|
216 |
$this->assertEquals(32, $DB->count_records('analytics_indicator_calc'));
|
| 207 |
|
217 |
|
| Línea 208... |
Línea 218... |
| 208 |
// We have 1 prediction action.
|
218 |
// We have 1 prediction action.
|
| Línea 276... |
Línea 286... |
| 276 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
286 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
| 277 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
287 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
| 278 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
288 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
| 279 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
289 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
| 280 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
290 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
| - |
|
291 |
$this->u9->id => provider::get_contexts_for_userid($this->u9->id)->get_contextids(),
|
| - |
|
292 |
$this->u10->id => provider::get_contexts_for_userid($this->u10->id)->get_contextids(),
|
| 281 |
];
|
293 |
];
|
| Línea 282... |
Línea 294... |
| 282 |
|
294 |
|
| 283 |
foreach ($actualcontexts as $userid => $unused) {
|
295 |
foreach ($actualcontexts as $userid => $unused) {
|
| 284 |
sort($actualcontexts[$userid]);
|
296 |
sort($actualcontexts[$userid]);
|
| 285 |
$this->assertEquals($expectedcontexts, $actualcontexts[$userid]);
|
297 |
$this->assertEquals($expectedcontexts, $actualcontexts[$userid]);
|
| Línea 286... |
Línea 298... |
| 286 |
}
|
298 |
}
|
| 287 |
|
299 |
|
| 288 |
// Test initial record counts are as expected.
|
300 |
// Test initial record counts are as expected.
|
| 289 |
$this->assertEquals(12, $DB->count_records('analytics_predictions'));
|
301 |
$this->assertEquals(12, $DB->count_records('analytics_predictions'));
|
| Línea 290... |
Línea 302... |
| 290 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
302 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
| 291 |
$this->assertEquals(26, $DB->count_records('analytics_indicator_calc'));
|
303 |
$this->assertEquals(32, $DB->count_records('analytics_indicator_calc'));
|
| 292 |
|
304 |
|
| 293 |
// Delete u1 and u3 from system context.
|
305 |
// Delete u1 and u3 from system context.
|
| Línea 303... |
Línea 315... |
| 303 |
$this->u4->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
315 |
$this->u4->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| 304 |
$this->u5->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
316 |
$this->u5->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| 305 |
$this->u6->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
317 |
$this->u6->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| 306 |
$this->u7->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
318 |
$this->u7->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| 307 |
$this->u8->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
319 |
$this->u8->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| - |
|
320 |
$this->u9->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| - |
|
321 |
$this->u10->id => [$systemcontext->id, $course1context->id, $course2context->id],
|
| 308 |
];
|
322 |
];
|
| Línea 309... |
Línea 323... |
| 309 |
|
323 |
|
| 310 |
$actualcontexts = [
|
324 |
$actualcontexts = [
|
| 311 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
325 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
| Línea 314... |
Línea 328... |
| 314 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
328 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
| 315 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
329 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
| 316 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
330 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
| 317 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
331 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
| 318 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
332 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
| - |
|
333 |
$this->u9->id => provider::get_contexts_for_userid($this->u9->id)->get_contextids(),
|
| - |
|
334 |
$this->u10->id => provider::get_contexts_for_userid($this->u10->id)->get_contextids(),
|
| 319 |
];
|
335 |
];
|
| Línea 320... |
Línea 336... |
| 320 |
|
336 |
|
| 321 |
foreach ($actualcontexts as $userid => $unused) {
|
337 |
foreach ($actualcontexts as $userid => $unused) {
|
| 322 |
sort($expectedcontexts[$userid]);
|
338 |
sort($expectedcontexts[$userid]);
|
| Línea 325... |
Línea 341... |
| 325 |
}
|
341 |
}
|
| Línea 326... |
Línea 342... |
| 326 |
|
342 |
|
| 327 |
// Test expected number of records have been deleted.
|
343 |
// Test expected number of records have been deleted.
|
| 328 |
$this->assertEquals(11, $DB->count_records('analytics_predictions'));
|
344 |
$this->assertEquals(11, $DB->count_records('analytics_predictions'));
|
| 329 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
345 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
| Línea 330... |
Línea 346... |
| 330 |
$this->assertEquals(24, $DB->count_records('analytics_indicator_calc'));
|
346 |
$this->assertEquals(30, $DB->count_records('analytics_indicator_calc'));
|
| 331 |
|
347 |
|
| 332 |
// Delete for all 8 users in course 2 context.
|
348 |
// Delete for all 8 users in course 2 context.
|
| 333 |
$approveduserids = [$this->u1->id, $this->u2->id, $this->u3->id, $this->u4->id, $this->u5->id, $this->u6->id,
|
349 |
$approveduserids = [$this->u1->id, $this->u2->id, $this->u3->id, $this->u4->id, $this->u5->id, $this->u6->id,
|
| 334 |
$this->u7->id, $this->u8->id];
|
350 |
$this->u7->id, $this->u8->id, $this->u9->id, $this->u10->id];
|
| Línea 335... |
Línea 351... |
| 335 |
$approvedlist = new approved_userlist($course2context, $component, $approveduserids);
|
351 |
$approvedlist = new approved_userlist($course2context, $component, $approveduserids);
|
| 336 |
provider::delete_data_for_users($approvedlist);
|
352 |
provider::delete_data_for_users($approvedlist);
|
| Línea 343... |
Línea 359... |
| 343 |
$this->u4->id => [$systemcontext->id, $course1context->id],
|
359 |
$this->u4->id => [$systemcontext->id, $course1context->id],
|
| 344 |
$this->u5->id => [$systemcontext->id, $course1context->id],
|
360 |
$this->u5->id => [$systemcontext->id, $course1context->id],
|
| 345 |
$this->u6->id => [$systemcontext->id, $course1context->id],
|
361 |
$this->u6->id => [$systemcontext->id, $course1context->id],
|
| 346 |
$this->u7->id => [$systemcontext->id, $course1context->id],
|
362 |
$this->u7->id => [$systemcontext->id, $course1context->id],
|
| 347 |
$this->u8->id => [$systemcontext->id, $course1context->id],
|
363 |
$this->u8->id => [$systemcontext->id, $course1context->id],
|
| - |
|
364 |
$this->u9->id => [$systemcontext->id, $course1context->id],
|
| - |
|
365 |
$this->u10->id => [$systemcontext->id, $course1context->id],
|
| 348 |
];
|
366 |
];
|
| Línea 349... |
Línea 367... |
| 349 |
|
367 |
|
| 350 |
$actualcontexts = [
|
368 |
$actualcontexts = [
|
| 351 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
369 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
| Línea 354... |
Línea 372... |
| 354 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
372 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
| 355 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
373 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
| 356 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
374 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
| 357 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
375 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
| 358 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
376 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
| - |
|
377 |
$this->u9->id => provider::get_contexts_for_userid($this->u9->id)->get_contextids(),
|
| - |
|
378 |
$this->u10->id => provider::get_contexts_for_userid($this->u10->id)->get_contextids(),
|
| 359 |
];
|
379 |
];
|
| Línea 360... |
Línea 380... |
| 360 |
|
380 |
|
| 361 |
foreach ($actualcontexts as $userid => $unused) {
|
381 |
foreach ($actualcontexts as $userid => $unused) {
|
| 362 |
sort($actualcontexts[$userid]);
|
382 |
sort($actualcontexts[$userid]);
|
| Línea 365... |
Línea 385... |
| 365 |
}
|
385 |
}
|
| Línea 366... |
Línea 386... |
| 366 |
|
386 |
|
| 367 |
// Test expected number of records have been deleted.
|
387 |
// Test expected number of records have been deleted.
|
| 368 |
$this->assertEquals(7, $DB->count_records('analytics_predictions'));
|
388 |
$this->assertEquals(7, $DB->count_records('analytics_predictions'));
|
| 369 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
389 |
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions'));
|
| Línea 370... |
Línea 390... |
| 370 |
$this->assertEquals(16, $DB->count_records('analytics_indicator_calc'));
|
390 |
$this->assertEquals(20, $DB->count_records('analytics_indicator_calc'));
|
| 371 |
|
391 |
|
| 372 |
$approveduserids = [$this->u3->id];
|
392 |
$approveduserids = [$this->u3->id];
|
| Línea 381... |
Línea 401... |
| 381 |
$this->u4->id => [$systemcontext->id, $course1context->id],
|
401 |
$this->u4->id => [$systemcontext->id, $course1context->id],
|
| 382 |
$this->u5->id => [$systemcontext->id, $course1context->id],
|
402 |
$this->u5->id => [$systemcontext->id, $course1context->id],
|
| 383 |
$this->u6->id => [$systemcontext->id, $course1context->id],
|
403 |
$this->u6->id => [$systemcontext->id, $course1context->id],
|
| 384 |
$this->u7->id => [$systemcontext->id, $course1context->id],
|
404 |
$this->u7->id => [$systemcontext->id, $course1context->id],
|
| 385 |
$this->u8->id => [$systemcontext->id, $course1context->id],
|
405 |
$this->u8->id => [$systemcontext->id, $course1context->id],
|
| - |
|
406 |
$this->u9->id => [$systemcontext->id, $course1context->id],
|
| - |
|
407 |
$this->u10->id => [$systemcontext->id, $course1context->id],
|
| 386 |
];
|
408 |
];
|
| Línea 387... |
Línea 409... |
| 387 |
|
409 |
|
| 388 |
$actualcontexts = [
|
410 |
$actualcontexts = [
|
| 389 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
411 |
$this->u1->id => provider::get_contexts_for_userid($this->u1->id)->get_contextids(),
|
| Línea 392... |
Línea 414... |
| 392 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
414 |
$this->u4->id => provider::get_contexts_for_userid($this->u4->id)->get_contextids(),
|
| 393 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
415 |
$this->u5->id => provider::get_contexts_for_userid($this->u5->id)->get_contextids(),
|
| 394 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
416 |
$this->u6->id => provider::get_contexts_for_userid($this->u6->id)->get_contextids(),
|
| 395 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
417 |
$this->u7->id => provider::get_contexts_for_userid($this->u7->id)->get_contextids(),
|
| 396 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
418 |
$this->u8->id => provider::get_contexts_for_userid($this->u8->id)->get_contextids(),
|
| - |
|
419 |
$this->u9->id => provider::get_contexts_for_userid($this->u9->id)->get_contextids(),
|
| - |
|
420 |
$this->u10->id => provider::get_contexts_for_userid($this->u10->id)->get_contextids(),
|
| 397 |
];
|
421 |
];
|
| 398 |
foreach ($actualcontexts as $userid => $unused) {
|
422 |
foreach ($actualcontexts as $userid => $unused) {
|
| 399 |
sort($actualcontexts[$userid]);
|
423 |
sort($actualcontexts[$userid]);
|
| 400 |
sort($expectedcontexts[$userid]);
|
424 |
sort($expectedcontexts[$userid]);
|
| 401 |
$this->assertEquals($expectedcontexts[$userid], $actualcontexts[$userid]);
|
425 |
$this->assertEquals($expectedcontexts[$userid], $actualcontexts[$userid]);
|
| 402 |
}
|
426 |
}
|
| Línea 403... |
Línea 427... |
| 403 |
|
427 |
|
| 404 |
// Test expected number of records have been deleted.
|
428 |
// Test expected number of records have been deleted.
|
| 405 |
$this->assertEquals(6, $DB->count_records('analytics_predictions'));
|
429 |
$this->assertEquals(6, $DB->count_records('analytics_predictions'));
|
| 406 |
$this->assertEquals(0, $DB->count_records('analytics_prediction_actions'));
|
430 |
$this->assertEquals(0, $DB->count_records('analytics_prediction_actions'));
|
| 407 |
$this->assertEquals(15, $DB->count_records('analytics_indicator_calc'));
|
431 |
$this->assertEquals(19, $DB->count_records('analytics_indicator_calc'));
|
| Línea 408... |
Línea 432... |
| 408 |
}
|
432 |
}
|
| 409 |
|
433 |
|
| 410 |
/**
|
434 |
/**
|