Skip to content

Commit

Permalink
Merge pull request #158 from danmarsden/fix156
Browse files Browse the repository at this point in the history
Fix #156 - use correct privacy class for new scorm tables.
  • Loading branch information
danmarsden authored Mar 15, 2024
2 parents 82626e8 + aa92355 commit 2958ec7
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ public static function export_user_data(approved_contextlist $contextlist) {
(object)[array_map([self::class, 'transform_db_row_to_session_data'], $records)]);
}

$records = $DB->get_records('local_recompletion_sst', $params);
$sql = "SELECT v.id, v.scoid, v.attemptid, e.element, v.courseid, t.timemodified
FROM {local_recompletion_ssv} v
JOIN {scorm_element} e ON e.id = v.elementid
WHERE v.courseid = :course AND v.userid = :userid";
$records = $DB->get_records_sql($sql, $params);
foreach ($records as $record) {
$context = \context_course::instance($record->course);
writer::with_context($context)->export_data(
Expand Down Expand Up @@ -432,7 +436,8 @@ public static function delete_data_for_all_users_in_context(\context $context) {
$DB->delete_records('local_recompletion_cmv', $params);
$DB->delete_records('local_recompletion_qa', $params);
$DB->delete_records('local_recompletion_qg', $params);
$DB->delete_records('local_recompletion_sst', $params);
$DB->delete_records('local_recompletion_ssv', $params);
$DB->delete_records('local_recompletion_sa', $params);
$DB->delete_records('local_recompletion_qr', $params);
$DB->delete_records('local_recompletion_cha', $params);
$DB->delete_records('local_recompletion_hvp', $params);
Expand Down Expand Up @@ -467,7 +472,10 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
$DB->delete_records('local_recompletion_cmv', $params);
$DB->delete_records('local_recompletion_qa', $params);
$DB->delete_records('local_recompletion_qg', $params);
$DB->delete_records('local_recompletion_sst', $params);
$DB->delete_records_select('local_recompletion_ssv', 'attemptid in (SELECT id
FROM {local_recompletion_sa}
WHERE userid = :userid AND courseid = :course');
$DB->delete_records('local_recompletion_sa', $params);
$DB->delete_records('local_recompletion_ltia', ['userid' => $userid]);
$DB->delete_records('local_recompletion_qr', $params);
$DB->delete_records('local_recompletion_cha', $params);
Expand Down Expand Up @@ -521,7 +529,7 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
$sql = "SELECT ctx.id
FROM {course} c
JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
JOIN {local_recompletion_sst} rc ON rc.course = c.id and rc.userid = :userid";
JOIN {local_recompletion_sa} rc ON rc.courseid = c.id and rc.userid = :userid";
$contextlist->add_from_sql($sql, $params);
$sql = "SELECT ctx.id
FROM {course} c
Expand Down Expand Up @@ -636,8 +644,8 @@ public static function get_users_in_context(userlist $userlist) {
$userlist->add_from_sql('userid', $sql, $params);

$sql = "SELECT rc.userid
FROM {local_recompletion_sst} rc
JOIN {course} c ON rc.course = c.id
FROM {local_recompletion_sa} rc
JOIN {course} c ON rc.courseid = c.id
JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
WHERE ctx.id = :contextid";
$userlist->add_from_sql('userid', $sql, $params);
Expand Down Expand Up @@ -780,11 +788,19 @@ public static function delete_data_for_users(approved_userlist $userlist) {
$DB->delete_records_select('local_recompletion_qg', "id $sql", $params);

$sql = "SELECT rc.id
FROM {local_recompletion_sst} rc
JOIN {course} c ON rc.course = c.id
FROM {local_recompletion_ssv} rc
JOIN {local_recompletion_sa} sa on sa.attemptid = rc.id
JOIN {course} c ON rc.courseid = c.id
JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
WHERE ctx.id = :contextid AND sa.userid $insql";
$DB->delete_records_select('local_recompletion_ssv', "id $sql", $params);

$sql = "SELECT rc.id
FROM {local_recompletion_sa} rc
JOIN {course} c ON rc.courseid = c.id
JOIN {context} ctx ON c.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
WHERE ctx.id = :contextid AND rc.userid $insql";
$DB->delete_records_select('local_recompletion_sst', "id $sql", $params);
$DB->delete_records_select('local_recompletion_sa', "id $sql", $params);

$sql = "SELECT rc.id
FROM {local_recompletion_ltia} rc
Expand Down

0 comments on commit 2958ec7

Please sign in to comment.