Hi, I am in the process of writing my first Moodle plugin, a block. I've done my own projects in Java and PHP but found it difficult getting my head around integrating into Moodle. My plugin is very basic - just displays a 'leader board' of rewards/achievement points. This data is pulled from an external server - so the block sends the user ID in the request.
I've read the Privacy API notes and implemented a provider.php:
namespace block_rewardstally\privacy;
use core_privacy\local\metadata\collection;
defined('MOODLE_INTERNAL') || die();
/**
* Implements the Moodle privacy API
*/
class provider implements \core_privacy\local\metadata\provider {
/**
* Called by the Moodle Privacy API interface.
* @param collection $collection Moodle privacy collection object.
* @return collection The updated Moodle privacy collection object.
*/
public static function get_metadata(collection $collection): collection {
$collection->add_external_location_link('block_rewardstally_api', [
'userid' => 'privacy:metadata:rewards_api:userid',
], 'privacy:metadata:rewards_api');
return $collection;
}
}
and I have the language strings:
$string['privacy:metadata:rewards_api'] = 'In order to integrate with the remote data source providing the rewards data, user data needs to be exchanged with that service.';
$string['privacy:metadata:rewards_api:userid'] = 'The user ID is sent from Moodle to allow a user to see the total of their rewards points to date.';
but under Site admin -> Users -> Privacy and policies -> Plugin privacy registry my block has the red exclamation triangle and doesn't report as it should. My thanks to the Moodle moderator (David) who identified a typo with the language string on my initial commit; I've fixed this but it still doesn't work. Any help would be appreciated.
link to git: https://github.com/moodleuser101/moodle-block_rewardstally/blob/main/classes/privacy/provider.php