Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace VALUE_OPTIONAL with VALUE_DEFAULT in get_chapters_parameters() #41

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/notification/classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class external extends \external_api {
*/
public static function get_chapters_parameters() {
return new \external_function_parameters(
array('mod' => new \external_value(PARAM_INT, 'Book module cmid ', VALUE_OPTIONAL))
array('mod' => new \external_value(PARAM_INT, 'Book module cmid ', VALUE_DEFAULT))
);
}

Expand Down
186 changes: 186 additions & 0 deletions actions/notification/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

namespace pulseaction_notification\privacy;

use core_privacy\local\metadata\collection;
use core_privacy\local\request\approved_contextlist;
use core_privacy\local\request\approved_userlist;
use core_privacy\local\request\contextlist;
use core_privacy\local\request\userlist;
use core_privacy\local\request\writer;

/**
* Privacy provider.
*
* @package pulseaction_notification
* @author vithushakethiri <[email protected]>
* @copyright 2024 Catalyst IT
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\data_provider {
/**
* Returns meta data about this system.
*
* @param collection $collection
* @return collection
*/
public static function get_metadata(collection $collection): collection {
// We store time spent in a course per linked to a user.
$collection->add_database_table(
'pulseaction_notification_sch',
[
'userid' => 'privacy:metadata:pulseaction_notification_sch:userid',
'status' => 'privacy:metadata:pulseaction_notification_sch:status',
'timecreated' => 'privacy:metadata:pulseaction_notification_sch:timecreated',
],
'privacy:metadata:pulseaction_notification'
);
return $collection;
}

/**
* Get the list of contexts that contain user information for the specified user.
*
* @param int $userid The user to search.
* @return contextlist $contextlist The list of contexts used in this plugin.
*/

public static function get_contexts_for_userid(int $userid) : \core_privacy\local\request\contextlist {
$contextlist = new \core_privacy\local\request\contextlist();

$sql = "SELECT c.id
FROM {context} c
JOIN {pulseaction_notification_sch} pl ON c.instanceid = pl.userid
JOIN {user} u ON u.id = :userid
WHERE c.contextlevel = :contextlevel";

$params = [
'userid' => $userid,
'contextlevel' => CONTEXT_USER,
];

$contextlist->add_from_sql($sql, $params);

return $contextlist;
}
/**
* Get the list of users who have data within a context.
*
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
*/

public static function get_users_in_context(userlist $userlist) {
$context = $userlist->get_context();

if (!$context instanceof \context_course) {
return;
}

$sql = "SELECT ts.userid
FROM {pulseaction_notification_sch} ts
WHERE ts.courseid = :courseid";

$params = [
'courseid' => $context->instanceid,
];
$userlist->add_from_sql('userid', $sql, $params);

}

/**
* Export all user data for the specified user, in the specified contexts, using the supplied exporter instance.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function export_user_data(approved_contextlist $contextlist) {
global $DB;

$userid = $contextlist->get_user()->id;

foreach ($contextlist->get_contexts() as $context) {
if ($context->contextlevel != CONTEXT_COURSE) {
// Only support course context.
continue;
}

$data = $DB->get_record('pulseaction_notification_sch', ['userid' => $userid, 'courseid' => $context->instanceid]);
writer::with_context($context)->export_data(
[get_string('privacy:metadata:pulseaction_notification', 'pulseaction_notification'), 'pulseaction_notification'],
$data
);
}

return $contextlist;
}

/**
* Delete all personal data for all users in the specified context.
*
* @param context $context Context to delete data from.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
global $DB;

if ($context->contextlevel != CONTEXT_COURSE) {
return;
}

$DB->delete_records('pulseaction_notification_sch', ['courseid' => $context->instanceid]);
}

/**
* Delete user within a single context.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function delete_data_for_user(approved_contextlist $contextlist) {
global $DB;

$userid = $contextlist->get_user()->id;

foreach ($contextlist->get_contexts() as $context) {
if ($context->contextlevel != CONTEXT_COURSE) {
// Only support course context.
continue;
}

$DB->delete_records('pulseaction_notification_sch', ['userid' => $userid, 'courseid' => $context->instanceid]);
}
}

/**
* Delete multiple users within a single context.
*
* @param approved_userlist $userlist The approved context and user information to delete information for.
*/
public static function delete_data_for_users(approved_userlist $userlist) {
global $DB;
$context = $userlist->get_context();

// Sanity check that context is at the course context level.
if ($context->contextlevel !== CONTEXT_COURSE) {
return;
}

list($userinsql, $userinparams) = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED);
$params = array_merge(['courseid' => $context->instanceid], $userinparams);
$sql = "courseid = :courseid AND userid {$userinsql}";

$DB->delete_records_select('pulseaction_notification_sch', $sql, $params);
}

}
5 changes: 5 additions & 0 deletions actions/notification/lang/en/pulseaction_notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,8 @@
// ...Reports filter string.
$string['automationinstance'] = 'Automation instance';
$string['automationtemplate'] = 'Automation template';

$string['privacy:metadata:pulseaction_notification'] = 'Information about the user to send the notification';
$string['privacy:metadata:pulseaction_notification_sch:userid'] = 'The ID of the user is tracked.';
$string['privacy:metadata:pulseaction_notification_sch:status'] = 'The status of the user is tracked.';
$string['privacy:metadata:pulseaction_notification_sch:timecreated'] = 'The created time of the user is tracked.';
39 changes: 39 additions & 0 deletions conditions/activity/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* Privacy provider.
*
* @package pulsecondition_activity
* @author vithushakethiri <[email protected]>
* @copyright 2024 Catalyst IT
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace pulsecondition_activity\privacy;

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

class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata:pulsecondition_activity';
}
}
2 changes: 2 additions & 0 deletions conditions/activity/lang/en/pulsecondition_activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
$string['selectactivity_help'] = "The <b>Select Activities</b> setting allows you to choose from all available activities within
your course that have completion configured. This selection determines which specific activities will trigger the automation
when their completion conditions are met.";

$string['privacy:metadata:pulsecondition_activity'] = 'The plugin does not store any personal data.';
39 changes: 39 additions & 0 deletions conditions/cohort/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* Privacy provider.
*
* @package pulsecondition_cohort
* @author vithushakethiri <[email protected]>
* @copyright 2024 Catalyst IT
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace pulsecondition_cohort\privacy;

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

class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata:pulsecondition_cohort';
}
}
3 changes: 3 additions & 0 deletions conditions/cohort/lang/en/pulsecondition_cohort.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
selected cohorts.The options for cohort membership include:<br><b>Disabled:</b> Cohort membership condition is disabled.<br>
<b>All:</b> Cohort membership condition applies to all enrolled users.<br><b>Upcoming:</b> Cohort membership condition only
applies to future enrolments';

$string['privacy:metadata:pulsecondition_cohort'] = 'The plugin does not store any personal data.';

39 changes: 39 additions & 0 deletions conditions/course/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* Privacy provider.
*
* @package pulsecondition_course
* @author vithushakethiri <[email protected]>
* @copyright 2024 Catalyst IT
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace pulsecondition_course\privacy;

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

class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata:pulsecondition_course';
}
}
2 changes: 2 additions & 0 deletions conditions/course/lang/en/pulsecondition_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
$string['pluginname'] = 'Course completion';
$string['coursecompletion'] = 'Course completion';
$string['coursecompletion_help'] = '<b>Course Completion:</b> This automation will be triggered when the course is marked as completed, where this instance is used.<br><b>Disabled:</b> Course completion condition is disabled.<br><b>All:</b> Course completion condition applies to all enrolled users.<br><b>Upcoming:</b> Course completion condition only applies to future enrolments.';

$string['privacy:metadata:pulsecondition_course'] = 'The plugin does not store any personal data.';
39 changes: 39 additions & 0 deletions conditions/enrolment/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.

/**
* Privacy provider.
*
* @package pulsecondition_enrolment
* @author vithushakethiri <[email protected]>
* @copyright 2024 Catalyst IT
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace pulsecondition_enrolment\privacy;

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

class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata:pulsecondition_enrolment';
}
}
2 changes: 2 additions & 0 deletions conditions/enrolment/lang/en/pulsecondition_enrolment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
$string['pluginname'] = 'User enrolment';
$string['enrolment'] = 'User enrolment';
$string['enrolment_help'] = '<b>Enrolments:</b> This automation will be triggered when a user is enrolled in the course where this instance is located.<br><b>Disabled:</b> Enrolment condition is disabled.<br><b>All:</b> Enrolment condition applies to all enrolments.<br><b>Upcoming:</b> Enrolment condition only applies to future enrolments.';

$string['privacy:metadata:pulsecondition_enrolment'] = 'The plugin does not store any personal data.';
Loading