1 | <?php |
||||
2 | // This file is part of Moodle - http://moodle.org/ |
||||
3 | // |
||||
4 | // Moodle is free software: you can redistribute it and/or modify |
||||
5 | // it under the terms of the GNU General Public License as published by |
||||
6 | // the Free Software Foundation, either version 3 of the License, or |
||||
7 | // (at your option) any later version. |
||||
8 | // |
||||
9 | // Moodle is distributed in the hope that it will be useful, |
||||
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
12 | // GNU General Public License for more details. |
||||
13 | // |
||||
14 | // You should have received a copy of the GNU General Public License |
||||
15 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
||||
16 | |||||
17 | /** |
||||
18 | * Privacy class for requesting user data. |
||||
19 | * |
||||
20 | * @package assignsubmission_edulegit |
||||
21 | * @author Alex Crosby <[email protected]> |
||||
22 | * @copyright @2024 EduLegit.com |
||||
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
24 | */ |
||||
25 | |||||
26 | namespace assignsubmission_edulegit\privacy; |
||||
27 | |||||
28 | defined('MOODLE_INTERNAL') || die(); |
||||
29 | |||||
30 | require_once($CFG->dirroot . '/mod/assign/locallib.php'); |
||||
31 | |||||
32 | use core_privacy\local\metadata\collection; |
||||
0 ignored issues
–
show
|
|||||
33 | use core_privacy\local\request\writer; |
||||
0 ignored issues
–
show
The type
core_privacy\local\request\writer was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
34 | use core_privacy\local\request\contextlist; |
||||
0 ignored issues
–
show
The type
core_privacy\local\request\contextlist was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
35 | use mod_assign\privacy\assign_plugin_request_data; |
||||
0 ignored issues
–
show
The type
mod_assign\privacy\assign_plugin_request_data was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
36 | |||||
37 | /** |
||||
38 | * Privacy class for requesting user data. |
||||
39 | * |
||||
40 | * @package assignsubmission_edulegit |
||||
41 | * @author Alex Crosby <[email protected]> |
||||
42 | * @copyright @2024 EduLegit.com |
||||
43 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
44 | */ |
||||
45 | class provider implements |
||||
46 | \core_privacy\local\metadata\provider, |
||||
0 ignored issues
–
show
The type
core_privacy\local\metadata\provider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
47 | \mod_assign\privacy\assignsubmission_provider, |
||||
0 ignored issues
–
show
The type
mod_assign\privacy\assignsubmission_provider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
48 | \mod_assign\privacy\assignsubmission_user_provider { |
||||
0 ignored issues
–
show
The type
mod_assign\privacy\assignsubmission_user_provider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
49 | |||||
50 | /** |
||||
51 | * Return meta data about this plugin. |
||||
52 | * |
||||
53 | * @param collection $collection A list of information to add to. |
||||
54 | * @return collection Return the collection after adding to it. |
||||
55 | */ |
||||
56 | public static function get_metadata(collection $collection): collection { |
||||
57 | $detail = [ |
||||
58 | 'assignment' => 'privacy:metadata:assignmentpurpose', |
||||
59 | 'submission' => 'privacy:metadata:submissionpurpose', |
||||
60 | 'content' => 'privacy:metadata:textpurpose', |
||||
61 | ]; |
||||
62 | $collection->add_database_table('assignsubmission_edulegit', $detail, 'privacy:metadata:tablepurpose'); |
||||
63 | return $collection; |
||||
64 | } |
||||
65 | |||||
66 | /** |
||||
67 | * This is covered by mod_assign provider and the query on assign_submissions. |
||||
68 | * |
||||
69 | * @param int $userid The user ID that we are finding contexts for. |
||||
70 | * @param contextlist $contextlist A context list to add sql and params to for contexts. |
||||
71 | */ |
||||
72 | public static function get_context_for_userid_within_submission(int $userid, contextlist $contextlist) { |
||||
73 | // This is already fetched from mod_assign. |
||||
74 | } |
||||
75 | |||||
76 | /** |
||||
77 | * This is also covered by the mod_assign provider and it's queries. |
||||
78 | * |
||||
79 | * @param \mod_assign\privacy\useridlist $useridlist An object for obtaining user IDs of students. |
||||
80 | */ |
||||
81 | public static function get_student_user_ids(\mod_assign\privacy\useridlist $useridlist) { |
||||
0 ignored issues
–
show
The type
mod_assign\privacy\useridlist was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
82 | // No need. |
||||
83 | } |
||||
84 | |||||
85 | /** |
||||
86 | * If you have tables that contain userids and you can generate entries in your tables without creating an |
||||
87 | * entry in the assign_submission table then please fill in this method. |
||||
88 | * |
||||
89 | * @param \core_privacy\local\request\userlist $userlist The userlist object |
||||
90 | */ |
||||
91 | public static function get_userids_from_context(\core_privacy\local\request\userlist $userlist) { |
||||
0 ignored issues
–
show
The type
core_privacy\local\request\userlist was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
92 | // Not required. |
||||
93 | } |
||||
94 | |||||
95 | /** |
||||
96 | * Export all user data for this plugin. |
||||
97 | * |
||||
98 | * @param assign_plugin_request_data $exportdata Data used to determine which context and user to export and other useful |
||||
99 | * information to help with exporting. |
||||
100 | */ |
||||
101 | public static function export_submission_user_data(assign_plugin_request_data $exportdata) { |
||||
102 | // We currently don't show submissions to teachers when exporting their data. |
||||
103 | if ($exportdata->get_user() != null) { |
||||
104 | return null; |
||||
105 | } |
||||
106 | // Retrieve text for this submission. |
||||
107 | $context = $exportdata->get_context(); |
||||
108 | $assign = $exportdata->get_assign(); |
||||
109 | $plugin = $assign->get_plugin_by_type('assignsubmission', 'edulegit'); |
||||
110 | $submission = $exportdata->get_pluginobject(); |
||||
111 | $editortext = $plugin->get_editor_text('edulegit', $submission->id); |
||||
112 | if (!empty($editortext)) { |
||||
113 | $submissiontext = new \stdClass(); |
||||
114 | $currentpath = $exportdata->get_subcontext(); |
||||
115 | $currentpath[] = get_string('privacy:path', 'assignsubmission_edulegit'); |
||||
0 ignored issues
–
show
The function
get_string was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
116 | $submissiontext->text = $editortext; |
||||
117 | writer::with_context($context) |
||||
118 | // Add the text to the exporter. |
||||
119 | ->export_data($currentpath, $submissiontext); |
||||
120 | |||||
121 | // Handle plagiarism data. |
||||
122 | $coursecontext = $context->get_course_context(); |
||||
123 | $userid = $submission->userid; |
||||
124 | \core_plagiarism\privacy\provider::export_plagiarism_user_data($userid, $context, $currentpath, [ |
||||
0 ignored issues
–
show
The type
core_plagiarism\privacy\provider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
125 | 'cmid' => $context->instanceid, |
||||
126 | 'course' => $coursecontext->instanceid, |
||||
127 | 'userid' => $userid, |
||||
128 | 'content' => $editortext, |
||||
129 | 'assignment' => $submission->assignment, |
||||
130 | ]); |
||||
131 | } |
||||
132 | } |
||||
133 | |||||
134 | /** |
||||
135 | * Any call to this method should delete all user data for the context defined in the deletion_criteria. |
||||
136 | * |
||||
137 | * @param assign_plugin_request_data $requestdata Data useful for deleting user data from this sub-plugin. |
||||
138 | */ |
||||
139 | public static function delete_submission_for_context(assign_plugin_request_data $requestdata) { |
||||
140 | global $DB; |
||||
141 | |||||
142 | \core_plagiarism\privacy\provider::delete_plagiarism_for_context($requestdata->get_context()); |
||||
143 | |||||
144 | // Delete the records in the table. |
||||
145 | $DB->delete_records('assignsubmission_edulegit', ['assignment' => $requestdata->get_assignid()]); |
||||
146 | } |
||||
147 | |||||
148 | /** |
||||
149 | * A call to this method should delete user data (where practicle) from the userid and context. |
||||
150 | * |
||||
151 | * @param assign_plugin_request_data $deletedata Details about the user and context to focus the deletion. |
||||
152 | */ |
||||
153 | public static function delete_submission_for_userid(assign_plugin_request_data $deletedata) { |
||||
154 | global $DB; |
||||
155 | |||||
156 | \core_plagiarism\privacy\provider::delete_plagiarism_for_user($deletedata->get_user()->id, $deletedata->get_context()); |
||||
157 | |||||
158 | $submissionid = $deletedata->get_pluginobject()->id; |
||||
159 | |||||
160 | // Delete the records in the table. |
||||
161 | $DB->delete_records('assignsubmission_edulegit', ['assignment' => $deletedata->get_assignid(), |
||||
162 | 'submission' => $submissionid]); |
||||
163 | } |
||||
164 | |||||
165 | /** |
||||
166 | * Deletes all submissions for the submission ids / userids provided in a context. |
||||
167 | * assign_plugin_request_data contains: |
||||
168 | * - context |
||||
169 | * - assign object |
||||
170 | * - submission ids (pluginids) |
||||
171 | * - user ids |
||||
172 | * |
||||
173 | * @param assign_plugin_request_data $deletedata A class that contains the relevant information required for deletion. |
||||
174 | */ |
||||
175 | public static function delete_submissions(assign_plugin_request_data $deletedata) { |
||||
176 | global $DB; |
||||
177 | |||||
178 | \core_plagiarism\privacy\provider::delete_plagiarism_for_users($deletedata->get_userids(), $deletedata->get_context()); |
||||
179 | if (empty($deletedata->get_submissionids())) { |
||||
180 | return; |
||||
181 | } |
||||
182 | |||||
183 | $params['assignid'] = $deletedata->get_assignid(); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
184 | $params['submissionid'] = $deletedata->get_submissionids(); |
||||
185 | $DB->delete_records_select('assignsubmission_edulegit', "assignment = :assignid AND submission :submissionid", $params); |
||||
186 | } |
||||
187 | } |
||||
188 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths