How can I test delete_data_for_users and get_users_in_context

How can I test delete_data_for_users and get_users_in_context

от Dorel Manolescu -
Number of replies: 2
Снимка на Plugin developers

Hi

I have a basic understanding on the privacy api and I can test the original functions, but I am out of ideas on how to test the new functions:

get_users_in_context 

delete_data_for_users

Who is triggering this 2 functions and when?

I understand for example 'delete_data_for_users' is triggered when an activity instance is deleted like a quiz or a survey or the user(s) is deleted and the data in the activity is deleted. Is my assumption correct?

Regards

In reply to Dorel Manolescu

Re: How can I test delete_data_for_users and get_users_in_context

от Andrew Lyons -
Снимка на Core developers Снимка на Moodle HQ Снимка на Particularly helpful Moodlers Снимка на Peer reviewers Снимка на Plugin developers Снимка на Testers

Hi Dorel,

These two functions are called by the core Privacy API in Moodle 3.6, 3.5.3, and 3.4.6.

They are used to identify which users have data in a context, and to delete data for multiple users. This allows facilitation of a staggered deletion so that different retention periods can be set for different types of users. For example to allow content belonging to Teachers to be kept for longer than for students.

The best way to test these is by writing unit tests.

At the moment I haven't written any utilities for this, though it would be relatively easy to do so.

Andrew


In reply to Andrew Lyons

Re: How can I test delete_data_for_users and get_users_in_context

от Troy Williams -
Снимка на Plugin developers

Hi Andrew,

I am having the same trouble with working out how to support the following method for a plugin I help maintain.

delete_data_for_users(approved_userlist $userlist)

The plugin (enrolment) has user data in two contexts USER and COURSE.   

What types of contexts get added to approved_userlist and passed to this method?

Do I just need to support a course context? I wouldn't expect a userlist with user context to be passed to delete_data_for_users() as a single user deletion would be handled by delete_data_for_user()?

Kind regards