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
|
|
|
* The assignsubmission_edulegit submission entity class. |
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; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class edulegit_submission_entity |
30
|
|
|
* |
31
|
|
|
* This class represents the submission entity for the EduLegit plugin. |
32
|
|
|
*/ |
33
|
|
|
class edulegit_submission_entity { |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var int|null The unique identifier for the submission entity. |
37
|
|
|
*/ |
38
|
|
|
public ?int $id = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var int The ID of the associated assignment. |
42
|
|
|
*/ |
43
|
|
|
public int $assignment = 0; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var int The ID of the submission. |
47
|
|
|
*/ |
48
|
|
|
public int $submission = 0; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string|null The title of the submission. |
52
|
|
|
*/ |
53
|
|
|
public ?string $title = null; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string|null The content of the submission. |
57
|
|
|
*/ |
58
|
|
|
public ?string $content = null; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var int|null The ID of the document stored in the EduLegit system. |
62
|
|
|
*/ |
63
|
|
|
public ?int $documentid = null; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var int|null The task ID related to this submission. |
67
|
|
|
*/ |
68
|
|
|
public ?int $taskid = null; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var int|null The task user ID associated with the submission. |
72
|
|
|
*/ |
73
|
|
|
public ?int $taskuserid = null; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var int|null The user ID of the submitter. |
77
|
|
|
*/ |
78
|
|
|
public ?int $userid = null; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @var string|null The user key for login access. |
82
|
|
|
*/ |
83
|
|
|
public ?string $userkey = null; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var string|null The base URL to access the document. |
87
|
|
|
*/ |
88
|
|
|
public ?string $baseurl = null; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @var string|null The URL of the submission. |
92
|
|
|
*/ |
93
|
|
|
public ?string $url = null; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @var string|null The authentication key for the submission. |
97
|
|
|
*/ |
98
|
|
|
public ?string $authkey = null; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @var float|null The score given to the submission. |
102
|
|
|
*/ |
103
|
|
|
public ?float $score = null; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @var float|null The plagiarism score of the submission. |
107
|
|
|
*/ |
108
|
|
|
public ?float $plagiarism = null; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @var float|null The AI rate for the submission. |
112
|
|
|
*/ |
113
|
|
|
public ?float $airate = null; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @var float|null The probability that AI tools were used. |
117
|
|
|
*/ |
118
|
|
|
public ?float $aiprobability = null; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @var int The current status of the submission. |
122
|
|
|
*/ |
123
|
|
|
public int $status = 0; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @var string|null Any error messages associated with the submission. |
127
|
|
|
*/ |
128
|
|
|
public ?string $error = null; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @var int|null The timestamp when the submission was created. |
132
|
|
|
*/ |
133
|
|
|
public ?int $createdat = null; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @var int|null The timestamp when the submission was last updated. |
137
|
|
|
*/ |
138
|
|
|
public ?int $updatedat = null; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Constructor for the submission entity. |
142
|
|
|
* |
143
|
|
|
* @param array|object $values An array or object of key-value pairs to initialize the entity. |
144
|
|
|
*/ |
145
|
|
|
public function __construct(array|object $values = []) { |
146
|
|
|
foreach ($values as $key => $value) { |
147
|
|
|
if (property_exists($this, $key)) { |
148
|
|
|
$this->{$key} = $value; |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Checks if the submission content is empty. |
155
|
|
|
* |
156
|
|
|
* @return bool True if the content is empty, false otherwise. |
157
|
|
|
*/ |
158
|
|
|
public function is_empty(): bool { |
159
|
|
|
return empty($this->content); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Retrieves the base URL for the document. |
164
|
|
|
* |
165
|
|
|
* @return string The base URL for the document. |
166
|
|
|
*/ |
167
|
|
|
public function get_baseurl(): string { |
168
|
|
|
return $this->baseurl ?: 'https://app.edulegit.com/document/' . $this->documentid; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Retrieves the URL to view the submission. |
173
|
|
|
* |
174
|
|
|
* @return string The URL to view the submission. |
175
|
|
|
*/ |
176
|
|
|
public function get_view_url(): string { |
177
|
|
|
return $this->url ?? ''; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Retrieves the URL for user login with a token. |
182
|
|
|
* |
183
|
|
|
* @return string The URL for user login with the user key. |
184
|
|
|
*/ |
185
|
|
|
public function get_user_login_url(): string { |
186
|
|
|
if (empty($this->userkey)) { |
187
|
|
|
return ''; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return $this->get_baseurl() . '?tt=' . $this->userkey; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Retrieves the URL to access the PDF version of the document. |
195
|
|
|
* |
196
|
|
|
* @return string The PDF access URL with the authentication key. |
197
|
|
|
*/ |
198
|
|
|
public function get_pdf_url(): string { |
199
|
|
|
return $this->get_baseurl() . '/pdf?key=' . $this->authkey; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Retrieves the URL to access the HTML version of the document. |
204
|
|
|
* |
205
|
|
|
* @return string The HTML access URL with the authentication key. |
206
|
|
|
*/ |
207
|
|
|
public function get_html_url(): string { |
208
|
|
|
return $this->get_baseurl() . '/html?key=' . $this->authkey; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Retrieves the URL to access the TXT version of the document. |
213
|
|
|
* |
214
|
|
|
* @return string The TXT access URL with the authentication key. |
215
|
|
|
*/ |
216
|
|
|
public function get_txt_url(): string { |
217
|
|
|
return $this->get_baseurl() . '/txt?key=' . $this->authkey; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Retrieves the URL to access the DOCX version of the document. |
222
|
|
|
* |
223
|
|
|
* @return string The DOCX access URL with the authentication key. |
224
|
|
|
*/ |
225
|
|
|
public function get_docx_url(): string { |
226
|
|
|
return $this->get_baseurl() . '/docx?key=' . $this->authkey; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
} |
230
|
|
|
|