Skip to content

Commit

Permalink
issue-39: fix privacy provider
Browse files Browse the repository at this point in the history
TODOs:
- 75: Field item does not exist in table verbalfeedback_response
- 297ff: Response has no "type" and api::QTYPE_RATED is not defined, helper::get_scale_values is not defined
-  234ff : verbalfeedback_question does not exist; verbalfeedback_i_criterion has no fields verbalfeedback or instanceid
  • Loading branch information
NJahreis committed May 23, 2024
1 parent 0bf38a7 commit 9291ee1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
80 changes: 40 additions & 40 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public static function get_metadata(collection $items) : collection {
$items->add_database_table(
'verbalfeedback_submission',
[
'verbalfeedback' => 'privacy:metadata:verbalfeedback',
'fromuser' => 'privacy:metadata:verbalfeedback_submission:fromuser',
'touser' => 'privacy:metadata:verbalfeedback_submission:touser',
'instanceid' => 'privacy:metadata:instanceid',
'fromuserid' => 'privacy:metadata:verbalfeedback_submission:fromuserid',
'touserid' => 'privacy:metadata:verbalfeedback_submission:touserid',
'status' => 'privacy:metadata:verbalfeedback_submission:status',
'remarks' => 'privacy:metadata:verbalfeedback_submission:remarks',
],
Expand All @@ -71,10 +71,10 @@ public static function get_metadata(collection $items) : collection {
$items->add_database_table(
'verbalfeedback_response',
[
'verbalfeedback' => 'privacy:metadata:verbalfeedback',
'instanceid' => 'privacy:metadata:instanceid',
'item' => 'privacy:metadata:verbalfeedback_item',
'fromuser' => 'privacy:metadata:verbalfeedback_submission:fromuser',
'touser' => 'privacy:metadata:verbalfeedback_submission:touser',
'fromuserid' => 'privacy:metadata:verbalfeedback_submission:fromuserid',
'touserid' => 'privacy:metadata:verbalfeedback_submission:touserid',
'value' => 'privacy:metadata:verbalfeedback_response:value',
],
'privacy:metadata:verbalfeedback_response'
Expand All @@ -100,14 +100,14 @@ public static function get_contexts_for_userid(int $userid) : contextlist {
INNER JOIN {verbalfeedback} t
ON t.id = cm.instance
INNER JOIN {verbalfeedback_submission} ts
ON ts.verbalfeedback = t.id
WHERE ts.fromuser = :fromuser OR ts.touser = :touser";
ON ts.instanceid = t.id
WHERE ts.fromuserid = :fromuserid OR ts.touserid = :touserid";

$params = [
'modname' => 'verbalfeedback',
'contextlevel' => CONTEXT_MODULE,
'fromuser' => $userid,
'touser' => $userid,
'fromuserid' => $userid,
'touserid' => $userid,
];
$contextlist = new contextlist();
$contextlist->add_from_sql($sql, $params);
Expand Down Expand Up @@ -159,8 +159,8 @@ protected static function export_submission_data($contextids, $user, $respondent
t.name as verbalfeedbackname,
ts.status,
ts.remarks,
ts.fromuser,
ts.touser
ts.fromuserid,
ts.touserid
FROM {context} ctx
JOIN {course_modules} cm
ON cm.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
Expand All @@ -169,16 +169,16 @@ protected static function export_submission_data($contextids, $user, $respondent
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_submission} ts
ON ts.verbalfeedback = t.id
ON ts.instanceid = t.id
WHERE ctx.id {$contextsql} %s
ORDER BY cmid ASC";

if ($respondent) {
$sqluser = 'fromuser';
$sqluser = 'fromuserid';
$userkey = 'recipient';
$parent = get_string('feedbackgiven', 'mod_verbalfeedback');
} else {
$sqluser = 'touser';
$sqluser = 'touserid';
$userkey = 'respondent';
$parent = get_string('feedbackreceived', 'mod_verbalfeedback');
}
Expand All @@ -196,9 +196,9 @@ protected static function export_submission_data($contextids, $user, $respondent
];
}
if ($respondent) {
$relateduser = transform::user($submission->touser);
$relateduser = transform::user($submission->touserid);
} else {
$relateduser = transform::user($submission->fromuser);
$relateduser = transform::user($submission->fromuserid);
}
$submissionsdata[$submission->cmid]['submissions'][$submission->id] = [
$userkey => $relateduser,
Expand Down Expand Up @@ -241,21 +241,21 @@ protected static function export_responses_data($contextids, $user, $respondent
tq.type,
tq.category,
tr.value,
tr.fromuser,
tr.touser
tr.fromuserid,
tr.touserid
FROM {context} ctx
JOIN {course_modules} cm
ON cm.id = ctx.instanceid AND ctx.contextlevel = :contextlevel
JOIN {modules} m
ON m.id = cm.module AND m.name = :modname
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_item} ti
JOIN {verbalfeedback_i_criterion} ti
ON ti.verbalfeedback = t.id
JOIN {verbalfeedback_question} tq
ON tq.id = ti.question
JOIN {verbalfeedback_response} tr
ON tr.verbalfeedback = t.id AND tr.item = ti.id
ON tr.instanceid = t.id AND tr.item = ti.id
WHERE ctx.id {$contextsql} %s
ORDER BY cmid ASC,
ti.position ASC,
Expand All @@ -264,11 +264,11 @@ protected static function export_responses_data($contextids, $user, $respondent
$params = ['modname' => 'verbalfeedback', 'contextlevel' => CONTEXT_MODULE, 'userid' => $user] + $contextparams;

if ($respondent) {
$sqluser = 'fromuser';
$sqluser = 'fromuserid';
$userkey = 'recipient';
$parent = get_string('feedbackgiven', 'mod_verbalfeedback');
} else {
$sqluser = 'touser';
$sqluser = 'touserid';
$userkey = 'respondent';
$parent = get_string('feedbackreceived', 'mod_verbalfeedback');
}
Expand Down Expand Up @@ -357,8 +357,8 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
continue;
}
$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
$select = 'verbalfeedback = :verbalfeedback AND (fromuser = :fromuser OR touser = :touser)';
$params = ['verbalfeedback' => $instanceid, 'fromuser' => $userid, 'touser' => $userid];
$select = 'verbalfeedback = :verbalfeedback AND (fromuser = :fromuserid OR touser = :touserid)';
$params = ['verbalfeedback' => $instanceid, 'fromuserid' => $userid, 'touserid' => $userid];
$DB->delete_records_select('verbalfeedback_response', $select, $params);
$DB->delete_records_select('verbalfeedback_submission', $select, $params);
}
Expand All @@ -383,53 +383,53 @@ public static function get_users_in_context(userlist $userlist) {

// Fetch all users who gave non-anonymous feedback to other users.
$fromsql = "
SELECT DISTINCT ts.fromuser
SELECT DISTINCT ts.fromuserid
FROM {course_modules} cm
JOIN {modules} m
ON m.id = cm.module AND m.name = :modname
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_submission} ts
ON ts.verbalfeedback = t.id
ON ts.instanceid = t.id
WHERE cm.id = :cmid";
$userlist->add_from_sql('fromuser', $fromsql, $params);
$userlist->add_from_sql('fromuserid', $fromsql, $params);

$fromsql = "
SELECT DISTINCT tr.fromuser
SELECT DISTINCT tr.fromuserid
FROM {course_modules} cm
JOIN {modules} m
ON m.id = cm.module AND m.name = :modname
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_response} tr
ON tr.verbalfeedback = t.id
WHERE cm.id = :cmid AND tr.fromuser <> 0";
$userlist->add_from_sql('fromuser', $fromsql, $params);
ON tr.instanceid = t.id
WHERE cm.id = :cmid AND tr.fromuserid <> 0";
$userlist->add_from_sql('fromuserid', $fromsql, $params);

// Fetch all users who received feedback from other users.
$tosql = "
SELECT DISTINCT ts.touser
SELECT DISTINCT ts.touserid
FROM {course_modules} cm
JOIN {modules} m
ON m.id = cm.module AND m.name = :modname
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_submission} ts
ON ts.verbalfeedback = t.id
ON ts.instanceid = t.id
WHERE cm.id = :cmid";
$userlist->add_from_sql('touser', $tosql, $params);
$userlist->add_from_sql('touserid', $tosql, $params);

$tosql = "
SELECT DISTINCT tr.touser
SELECT DISTINCT tr.touserid
FROM {course_modules} cm
JOIN {modules} m
ON m.id = cm.module AND m.name = :modname
JOIN {verbalfeedback} t
ON t.id = cm.instance
JOIN {verbalfeedback_response} tr
ON tr.verbalfeedback = t.id
ON tr.instanceid = t.id
WHERE cm.id = :cmid";
$userlist->add_from_sql('touser', $tosql, $params);
$userlist->add_from_sql('touserid', $tosql, $params);
}

/**
Expand All @@ -456,8 +456,8 @@ public static function delete_data_for_users(approved_userlist $userlist) {
$userids = $userlist->get_userids();
list($usersql, $userparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);

$fromselect = "verbalfeedback = :verbalfeedback AND fromuser $usersql";
$toselect = "verbalfeedback = :verbalfeedback AND touser $usersql";
$fromselect = "verbalfeedback = :verbalfeedback AND fromuserid $usersql";
$toselect = "verbalfeedback = :verbalfeedback AND touserid $usersql";
$params = ['verbalfeedback' => $cm->instance] + $userparams;
$DB->delete_records_select('verbalfeedback_submission', $fromselect, $params);
$DB->delete_records_select('verbalfeedback_submission', $toselect, $params);
Expand Down
6 changes: 3 additions & 3 deletions lang/de/verbalfeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@
$string['positive'] = 'Positiv';
$string['preserveids'] = 'Preserve IDs?';
$string['previewinfo'] = 'Vorschau des Fragebogens, klicken Sie <a href="{$a}">hier</a>, um zur vorherigen Ansicht zurückzukehren.';
$string['privacy:metadata:verbalfeedback'] = 'Die ID der Verbales Feedback-Instanz';
$string['privacy:metadata:instanceid'] = 'Die ID der Verbales Feedback-Instanz';
$string['privacy:metadata:verbalfeedback_item'] = 'Die ID des Verbales Feedback-Kriteriums';
$string['privacy:metadata:verbalfeedback_response'] = 'Diese Tabelle speichert die Antworten der Feedbackgeber auf die Feedbackfragen an den Feedbackempfänger';
$string['privacy:metadata:verbalfeedback_response:value'] = 'Der Wert der Antwort des Feedbackgebers auf die Feedbackfrage';
$string['privacy:metadata:verbalfeedback_submission'] = 'Diese Tabelle speichert die Informationen über den Status der verbalen Feedback-Abgaben zwischen den Teilnehmer/innen';
$string['privacy:metadata:verbalfeedback_submission:fromuser'] = 'Die Nutzer-ID der Person, die das Feedback gibt';
$string['privacy:metadata:verbalfeedback_submission:fromuserid'] = 'Die Nutzer-ID der Person, die das Feedback gibt';
$string['privacy:metadata:verbalfeedback_submission:remarks'] = 'Der Grund, warum der Befragte es abgelehnt hat, dem Feedback-Empfänger ein Feedback zu geben';
$string['privacy:metadata:verbalfeedback_submission:status'] = 'Der Status der Feedback-Abgabe';
$string['privacy:metadata:verbalfeedback_submission:touser'] = 'Die Nutzer-ID des Feedback-Empfängers';
$string['privacy:metadata:verbalfeedback_submission:touserid'] = 'Die Nutzer-ID des Feedback-Empfängers';
$string['privatecomment'] = 'Private Bemerkungen';
$string['providefeedback'] = 'Feedback geben';
$string['qtypecomment'] = 'Bemerkung';
Expand Down
6 changes: 3 additions & 3 deletions lang/en/verbalfeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@
$string['positive'] = 'Positive';
$string['preserveids'] = 'Preserve IDs?';
$string['previewinfo'] = 'Questionnaire preview, click <a href="{$a}">here</a> to return to the previous view.';
$string['privacy:metadata:verbalfeedback'] = 'The ID of the verbal feedback instance';
$string['privacy:metadata:instanceid'] = 'The ID of the verbal feedback instance';
$string['privacy:metadata:verbalfeedback_item'] = 'The ID of the verbal feedback item';
$string['privacy:metadata:verbalfeedback_response'] = 'This table stores the responses of the feedback respondent to the feedback questions to the feedback recipient';
$string['privacy:metadata:verbalfeedback_response:value'] = 'The value of the respondent\'s response to the feedback question';
$string['privacy:metadata:verbalfeedback_submission'] = 'This table stores the information about the statuses of verbal feedback submissions between the participants';
$string['privacy:metadata:verbalfeedback_submission:fromuser'] = 'The user ID of the person giving the feedback';
$string['privacy:metadata:verbalfeedback_submission:fromuserid'] = 'The user ID of the person giving the feedback';
$string['privacy:metadata:verbalfeedback_submission:remarks'] = 'The reason why the respondent declined to give feedback to the feedback recipient';
$string['privacy:metadata:verbalfeedback_submission:status'] = 'The status of the feedback submission';
$string['privacy:metadata:verbalfeedback_submission:touser'] = 'The user ID of the feedback recipient';
$string['privacy:metadata:verbalfeedback_submission:touserid'] = 'The user ID of the feedback recipient';
$string['privatecomment'] = 'Private comment';
$string['providefeedback'] = 'Provide feedback';
$string['qtypecomment'] = 'Comment';
Expand Down
6 changes: 3 additions & 3 deletions lang/fr/verbalfeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@
$string['positive'] = 'Positif';
$string['preserveids'] = 'Preserve IDs?';
$string['previewinfo'] = 'Prévisualisez le questionnaire, cliquez sur <a href="{$a}">ici</a> pour revenir à la vue précédente.';
$string['privacy:metadata:verbalfeedback'] = 'L\'ID de l\'instance de feedback verbal';
$string['privacy:metadata:instanceid'] = 'L\'ID de l\'instance de feedback verbal';
$string['privacy:metadata:verbalfeedback_item'] = 'L\'ID de l\'élément de feedback verbal';
$string['privacy:metadata:verbalfeedback_response'] = 'Ce tableau stocke les réponses du répondant aux questions de feedback au destinataire de la rétroaction';
$string['privacy:metadata:verbalfeedback_response:value'] = 'La valeur de la réponse du répondant à la question de feedback';
$string['privacy:metadata:verbalfeedback_submission'] = 'Ce tableau stocke les informations sur les statuts des réponses aux questions de feedback entre les participants';
$string['privacy:metadata:verbalfeedback_submission:fromuser'] = 'L\'ID utilisateur de la personne qui donne le feedback';
$string['privacy:metadata:verbalfeedback_submission:fromuserid'] = 'L\'ID utilisateur de la personne qui donne le feedback';
$string['privacy:metadata:verbalfeedback_submission:remarks'] = 'La raison pour laquelle la personne interrogée a refusé de donner un feedback au destinataire du feedback';
$string['privacy:metadata:verbalfeedback_submission:status'] = 'Le statut de la soumission du feedback';
$string['privacy:metadata:verbalfeedback_submission:touser'] = 'L\'ID utilisateur du destinataire du feedback';
$string['privacy:metadata:verbalfeedback_submission:touserid'] = 'L\'ID utilisateur du destinataire du feedback';
$string['privatecomment'] = 'Commentaire privé';
$string['providefeedback'] = 'Fournir un feedback';
$string['qtypecomment'] = 'Commentaire';
Expand Down

0 comments on commit 9291ee1

Please sign in to comment.