Skip to content

Commit 049de89

Browse files
Merge pull request #480 from ReCodEx/meta-views
Meta views
2 parents 83a2524 + 687e7e1 commit 049de89

File tree

78 files changed

+3722
-1034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3722
-1034
lines changed

app/V1Module/presenters/AssignmentSolutionReviewsPresenter.php

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
namespace App\V1Module\Presenters;
44

5+
use App\Helpers\MetaFormats\Attributes\Post;
6+
use App\Helpers\MetaFormats\Attributes\Query;
7+
use App\Helpers\MetaFormats\Attributes\Path;
8+
use App\Helpers\MetaFormats\Type;
9+
use App\Helpers\MetaFormats\Validators\VArray;
10+
use App\Helpers\MetaFormats\Validators\VBool;
11+
use App\Helpers\MetaFormats\Validators\VDouble;
12+
use App\Helpers\MetaFormats\Validators\VEmail;
13+
use App\Helpers\MetaFormats\Validators\VInt;
14+
use App\Helpers\MetaFormats\Validators\VMixed;
15+
use App\Helpers\MetaFormats\Validators\VString;
16+
use App\Helpers\MetaFormats\Validators\VTimestamp;
17+
use App\Helpers\MetaFormats\Validators\VUuid;
518
use App\Exceptions\BadRequestException;
619
use App\Exceptions\InternalServerException;
720
use App\Exceptions\InvalidArgumentException;
@@ -88,9 +101,9 @@ public function checkDefault(string $id)
88101
/**
89102
* Get detail of the solution and a list of review comments.
90103
* @GET
91-
* @param string $id identifier of the solution
92104
* @throws InternalServerException
93105
*/
106+
#[Path("id", new VString(), "identifier of the solution", required: true)]
94107
public function actionDefault(string $id)
95108
{
96109
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -111,11 +124,10 @@ public function checkUpdate(string $id)
111124
/**
112125
* Update the state of the review process of the solution.
113126
* @POST
114-
* @Param(type="post", name="close", validation="bool"
115-
* description="If true, the review is closed. If false, the review is (re)opened.")
116-
* @param string $id identifier of the solution
117127
* @throws InternalServerException
118128
*/
129+
#[Post("close", new VBool(), "If true, the review is closed. If false, the review is (re)opened.")]
130+
#[Path("id", new VString(), "identifier of the solution", required: true)]
119131
public function actionUpdate(string $id)
120132
{
121133
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -182,9 +194,9 @@ public function checkRemove(string $id)
182194
/**
183195
* Update the state of the review process of the solution.
184196
* @DELETE
185-
* @param string $id identifier of the solution
186197
* @throws InternalServerException
187198
*/
199+
#[Path("id", new VString(), "identifier of the solution", required: true)]
188200
public function actionRemove(string $id)
189201
{
190202
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -251,18 +263,29 @@ private function verifyCodeLocation(AssignmentSolution $solution, string $file,
251263
/**
252264
* Create a new comment within a review.
253265
* @POST
254-
* @Param(type="post", name="text", validation="string:1..65535", required=true, description="The comment itself.")
255-
* @Param(type="post", name="file", validation="string:0..256", required=true,
256-
* description="Identification of the file to which the comment is related to.")
257-
* @Param(type="post", name="line", validation="numericint", required=true,
258-
* description="Line in the designated file to which the comment is related to.")
259-
* @Param(type="post", name="issue", validation="bool", required=false,
260-
* description="Whether the comment is an issue (expected to be resolved by the student)")
261-
* @Param(type="post", name="suppressNotification", validation="bool", required=false,
262-
* description="If true, no email notification will be sent (only applies when the review has been closed)")
263-
* @param string $id identifier of the solution
264266
* @throws InternalServerException
265267
*/
268+
#[Post("text", new VString(1, 65535), "The comment itself.", required: true)]
269+
#[Post(
270+
"file",
271+
new VString(0, 256),
272+
"Identification of the file to which the comment is related to.",
273+
required: true,
274+
)]
275+
#[Post("line", new VInt(), "Line in the designated file to which the comment is related to.", required: true)]
276+
#[Post(
277+
"issue",
278+
new VBool(),
279+
"Whether the comment is an issue (expected to be resolved by the student)",
280+
required: false,
281+
)]
282+
#[Post(
283+
"suppressNotification",
284+
new VBool(),
285+
"If true, no email notification will be sent (only applies when the review has been closed)",
286+
required: false,
287+
)]
288+
#[Path("id", new VString(), "identifier of the solution", required: true)]
266289
public function actionNewComment(string $id)
267290
{
268291
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -320,15 +343,23 @@ public function checkEditComment(string $id, string $commentId)
320343
/**
321344
* Update existing comment within a review.
322345
* @POST
323-
* @Param(type="post", name="text", validation="string:1..65535", required=true, description="The comment itself.")
324-
* @Param(type="post", name="issue", validation="bool", required=false,
325-
* description="Whether the comment is an issue (expected to be resolved by the student)")
326-
* @Param(type="post", name="suppressNotification", validation="bool", required=false,
327-
* description="If true, no email notification will be sent (only applies when the review has been closed)")
328-
* @param string $id identifier of the solution
329-
* @param string $commentId identifier of the review comment
330346
* @throws InternalServerException
331347
*/
348+
#[Post("text", new VString(1, 65535), "The comment itself.", required: true)]
349+
#[Post(
350+
"issue",
351+
new VBool(),
352+
"Whether the comment is an issue (expected to be resolved by the student)",
353+
required: false,
354+
)]
355+
#[Post(
356+
"suppressNotification",
357+
new VBool(),
358+
"If true, no email notification will be sent (only applies when the review has been closed)",
359+
required: false,
360+
)]
361+
#[Path("id", new VString(), "identifier of the solution", required: true)]
362+
#[Path("commentId", new VString(), "identifier of the review comment", required: true)]
332363
public function actionEditComment(string $id, string $commentId)
333364
{
334365
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -386,9 +417,9 @@ public function checkDeleteComment(string $id, string $commentId)
386417
/**
387418
* Remove one comment from a review.
388419
* @DELETE
389-
* @param string $id identifier of the solution
390-
* @param string $commentId identifier of the review comment
391420
*/
421+
#[Path("id", new VString(), "identifier of the solution", required: true)]
422+
#[Path("commentId", new VString(), "identifier of the review comment", required: true)]
392423
public function actionDeleteComment(string $id, string $commentId)
393424
{
394425
$comment = $this->reviewComments->findOrThrow($commentId);
@@ -422,8 +453,8 @@ public function checkPending(string $id)
422453
* Return all solutions with pending reviews that given user teaches (is admin/supervisor in corresponding groups).
423454
* Along with that it returns all assignment entities of the corresponding solutions.
424455
* @GET
425-
* @param string $id of the user whose pending reviews are listed
426456
*/
457+
#[Path("id", new VString(), "of the user whose pending reviews are listed", required: true)]
427458
public function actionPending(string $id)
428459
{
429460
$user = $this->users->findOrThrow($id);

app/V1Module/presenters/AssignmentSolutionsPresenter.php

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
namespace App\V1Module\Presenters;
44

5+
use App\Helpers\MetaFormats\Attributes\Post;
6+
use App\Helpers\MetaFormats\Attributes\Query;
7+
use App\Helpers\MetaFormats\Attributes\Path;
8+
use App\Helpers\MetaFormats\Type;
9+
use App\Helpers\MetaFormats\Validators\VArray;
10+
use App\Helpers\MetaFormats\Validators\VBool;
11+
use App\Helpers\MetaFormats\Validators\VDouble;
12+
use App\Helpers\MetaFormats\Validators\VEmail;
13+
use App\Helpers\MetaFormats\Validators\VInt;
14+
use App\Helpers\MetaFormats\Validators\VMixed;
15+
use App\Helpers\MetaFormats\Validators\VString;
16+
use App\Helpers\MetaFormats\Validators\VTimestamp;
17+
use App\Helpers\MetaFormats\Validators\VUuid;
518
use App\Exceptions\BadRequestException;
619
use App\Exceptions\InternalServerException;
720
use App\Exceptions\InvalidArgumentException;
@@ -142,9 +155,9 @@ public function checkSolution(string $id)
142155
/**
143156
* Get information about solutions.
144157
* @GET
145-
* @param string $id Identifier of the solution
146158
* @throws InternalServerException
147159
*/
160+
#[Path("id", new VString(), "Identifier of the solution", required: true)]
148161
public function actionSolution(string $id)
149162
{
150163
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -172,11 +185,11 @@ public function checkUpdateSolution(string $id)
172185
/**
173186
* Update details about the solution (note, etc...)
174187
* @POST
175-
* @Param(type="post", name="note", validation="string:0..1024", description="A note by the author of the solution")
176-
* @param string $id Identifier of the solution
177188
* @throws NotFoundException
178189
* @throws InternalServerException
179190
*/
191+
#[Post("note", new VString(0, 1024), "A note by the author of the solution")]
192+
#[Path("id", new VString(), "Identifier of the solution", required: true)]
180193
public function actionUpdateSolution(string $id)
181194
{
182195
$req = $this->getRequest();
@@ -198,9 +211,9 @@ public function checkDeleteSolution(string $id)
198211
/**
199212
* Delete assignment solution with given identification.
200213
* @DELETE
201-
* @param string $id identifier of assignment solution
202214
* @throws ForbiddenRequestException
203215
*/
216+
#[Path("id", new VString(), "identifier of assignment solution", required: true)]
204217
public function actionDeleteSolution(string $id)
205218
{
206219
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -236,8 +249,8 @@ public function checkSubmissions(string $id)
236249
/**
237250
* Get list of all submissions of a solution
238251
* @GET
239-
* @param string $id Identifier of the solution
240252
*/
253+
#[Path("id", new VString(), "Identifier of the solution", required: true)]
241254
public function actionSubmissions(string $id)
242255
{
243256
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -271,10 +284,10 @@ public function checkSubmission(string $submissionId)
271284
/**
272285
* Get information about the evaluation of a submission
273286
* @GET
274-
* @param string $submissionId Identifier of the submission
275287
* @throws NotFoundException
276288
* @throws InternalServerException
277289
*/
290+
#[Path("submissionId", new VString(), "Identifier of the submission", required: true)]
278291
public function actionSubmission(string $submissionId)
279292
{
280293
$submission = $this->assignmentSolutionSubmissions->findOrThrow($submissionId);
@@ -301,8 +314,8 @@ public function checkDeleteSubmission(string $submissionId)
301314
/**
302315
* Remove the submission permanently
303316
* @DELETE
304-
* @param string $submissionId Identifier of the submission
305317
*/
318+
#[Path("submissionId", new VString(), "Identifier of the submission", required: true)]
306319
public function actionDeleteSubmission(string $submissionId)
307320
{
308321
$submission = $this->assignmentSolutionSubmissions->findOrThrow($submissionId);
@@ -327,15 +340,19 @@ public function checkSetBonusPoints(string $id)
327340
* Set new amount of bonus points for a solution (and optionally points override)
328341
* Returns array of solution entities that has been changed by this.
329342
* @POST
330-
* @Param(type="post", name="bonusPoints", validation="numericint",
331-
* description="New amount of bonus points, can be negative number")
332-
* @Param(type="post", name="overriddenPoints", required=false,
333-
* description="Overrides points assigned to solution by the system")
334-
* @param string $id Identifier of the solution
335343
* @throws NotFoundException
336344
* @throws InvalidArgumentException
337345
* @throws InvalidStateException
338346
*/
347+
#[Post("bonusPoints", new VInt(), "New amount of bonus points, can be negative number")]
348+
#[Post(
349+
"overriddenPoints",
350+
new VMixed(),
351+
"Overrides points assigned to solution by the system",
352+
required: false,
353+
nullable: true,
354+
)]
355+
#[Path("id", new VString(), "Identifier of the solution", required: true)]
339356
public function actionSetBonusPoints(string $id)
340357
{
341358
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -423,14 +440,13 @@ public function checkSetFlag(string $id, string $flag)
423440
/**
424441
* Set flag of the assignment solution.
425442
* @POST
426-
* @param string $id identifier of the solution
427-
* @param string $flag name of the flag which should to be changed
428-
* @Param(type="post", name="value", required=true, validation=boolean,
429-
* description="True or false which should be set to given flag name")
430443
* @throws NotFoundException
431444
* @throws \Nette\Application\AbortException
432445
* @throws \Exception
433446
*/
447+
#[Post("value", new VBool(), "True or false which should be set to given flag name", required: true)]
448+
#[Path("id", new VString(), "identifier of the solution", required: true)]
449+
#[Path("flag", new VString(), "name of the flag which should to be changed", required: true)]
434450
public function actionSetFlag(string $id, string $flag)
435451
{
436452
$req = $this->getRequest();
@@ -546,12 +562,12 @@ public function checkDownloadSolutionArchive(string $id)
546562
/**
547563
* Download archive containing all solution files for particular solution.
548564
* @GET
549-
* @param string $id of assignment solution
550565
* @throws ForbiddenRequestException
551566
* @throws NotFoundException
552567
* @throws \Nette\Application\BadRequestException
553568
* @throws \Nette\Application\AbortException
554569
*/
570+
#[Path("id", new VString(), "of assignment solution", required: true)]
555571
public function actionDownloadSolutionArchive(string $id)
556572
{
557573
$solution = $this->assignmentSolutions->findOrThrow($id);
@@ -573,10 +589,10 @@ public function checkFiles(string $id)
573589
/**
574590
* Get the list of submitted files of the solution.
575591
* @GET
576-
* @param string $id of assignment solution
577592
* @throws ForbiddenRequestException
578593
* @throws NotFoundException
579594
*/
595+
#[Path("id", new VString(), "of assignment solution", required: true)]
580596
public function actionFiles(string $id)
581597
{
582598
$solution = $this->assignmentSolutions->findOrThrow($id)->getSolution();
@@ -594,11 +610,11 @@ public function checkDownloadResultArchive(string $submissionId)
594610
/**
595611
* Download result archive from backend for particular submission.
596612
* @GET
597-
* @param string $submissionId
598613
* @throws NotFoundException
599614
* @throws InternalServerException
600615
* @throws \Nette\Application\AbortException
601616
*/
617+
#[Path("submissionId", new VString(), required: true)]
602618
public function actionDownloadResultArchive(string $submissionId)
603619
{
604620
$submission = $this->assignmentSolutionSubmissions->findOrThrow($submissionId);
@@ -628,10 +644,10 @@ public function checkEvaluationScoreConfig(string $submissionId)
628644
/**
629645
* Get score configuration associated with given submission evaluation
630646
* @GET
631-
* @param string $submissionId Identifier of the submission
632647
* @throws NotFoundException
633648
* @throws InternalServerException
634649
*/
650+
#[Path("submissionId", new VString(), "Identifier of the submission", required: true)]
635651
public function actionEvaluationScoreConfig(string $submissionId)
636652
{
637653
$submission = $this->assignmentSolutionSubmissions->findOrThrow($submissionId);
@@ -655,8 +671,8 @@ public function checkReviewRequests(string $id)
655671
* (is admin/supervisor in corresponding groups).
656672
* Along with that it returns all assignment entities of the corresponding solutions.
657673
* @GET
658-
* @param string $id of the user whose solutions with requested reviews are listed
659674
*/
675+
#[Path("id", new VString(), "of the user whose solutions with requested reviews are listed", required: true)]
660676
public function actionReviewRequests(string $id)
661677
{
662678
$user = $this->users->findOrThrow($id);

app/V1Module/presenters/AssignmentSolversPresenter.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
namespace App\V1Module\Presenters;
44

5+
use App\Helpers\MetaFormats\Attributes\Post;
6+
use App\Helpers\MetaFormats\Attributes\Query;
7+
use App\Helpers\MetaFormats\Attributes\Path;
8+
use App\Helpers\MetaFormats\Type;
9+
use App\Helpers\MetaFormats\Validators\VArray;
10+
use App\Helpers\MetaFormats\Validators\VBool;
11+
use App\Helpers\MetaFormats\Validators\VDouble;
12+
use App\Helpers\MetaFormats\Validators\VEmail;
13+
use App\Helpers\MetaFormats\Validators\VInt;
14+
use App\Helpers\MetaFormats\Validators\VMixed;
15+
use App\Helpers\MetaFormats\Validators\VString;
16+
use App\Helpers\MetaFormats\Validators\VTimestamp;
17+
use App\Helpers\MetaFormats\Validators\VUuid;
518
use App\Exceptions\BadRequestException;
619
use App\Model\Entity\AssignmentSolutionSubmission;
720
use App\Model\Repository\Assignments;
@@ -92,11 +105,15 @@ public function checkDefault(?string $assignmentId, ?string $groupId, ?string $u
92105
* Get a list of assignment solvers based on given parameters (assignment/group and solver user).
93106
* Either assignment or group ID must be set (group is ignored if assignment is set), user ID is optional.
94107
* @GET
95-
* @Param(type="query", name="assignmentId", required=false, validation="string:36")
96-
* @Param(type="query", name="groupId", required=false, validation="string:36",
97-
* description="An alternative for assignment ID, selects all assignments from a group.")
98-
* @Param(type="query", name="userId", required=false, validation="string:36")
99108
*/
109+
#[Query("assignmentId", new VUuid(), required: false)]
110+
#[Query(
111+
"groupId",
112+
new VUuid(),
113+
"An alternative for assignment ID, selects all assignments from a group.",
114+
required: false,
115+
)]
116+
#[Query("userId", new VUuid(), required: false)]
100117
public function actionDefault(?string $assignmentId, ?string $groupId, ?string $userId): void
101118
{
102119
$user = $userId ? $this->users->findOrThrow($userId) : null;

0 commit comments

Comments
 (0)