1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
namespace JsonApi\Schemas\Courseware;
use JsonApi\Schemas\SchemaProvider;
use Neomerx\JsonApi\Contracts\Schema\ContextInterface;
use Neomerx\JsonApi\Schema\Link;
class PeerReviewProcess extends SchemaProvider
{
const TYPE = 'courseware-peer-review-processes';
const REL_COURSE = 'course';
const REL_OWNER = 'owner';
const REL_PEER_REVIEWS = 'reviews';
const REL_TASK_GROUP = 'task-group';
/**
* {@inheritdoc}
*/
public function getId($resource): ?string
{
return $resource->id;
}
/**
* {@inheritdoc}
*/
public function getAttributes($resource, ContextInterface $context): iterable
{
return [
'configuration' => $resource['configuration']->getIterator(),
'review-start' => date('c', $resource['review_start']),
'review-end' => date('c', $resource['review_end']),
'mkdate' => date('c', $resource['mkdate']),
'chdate' => date('c', $resource['chdate']),
];
}
/**
* {@inheritdoc}
*/
public function getRelationships($resource, ContextInterface $context): iterable
{
$relationships = [];
$course = $resource->getCourse();
$relationships[self::REL_COURSE] = [
self::RELATIONSHIP_LINKS => [
Link::RELATED => $this->createLinkToResource($course),
],
self::RELATIONSHIP_DATA => $course,
];
$relationships[self::REL_OWNER] = [
self::RELATIONSHIP_LINKS => [
Link::RELATED => $this->createLinkToResource($resource->owner),
],
self::RELATIONSHIP_DATA => $resource->owner,
];
$relationships[self::REL_PEER_REVIEWS] = [
self::RELATIONSHIP_LINKS => [
Link::RELATED => $this->getRelationshipRelatedLink($resource, self::REL_PEER_REVIEWS),
],
];
$relationships[self::REL_TASK_GROUP] = [
self::RELATIONSHIP_LINKS => [
Link::RELATED => $this->createLinkToResource($resource->task_group),
],
self::RELATIONSHIP_DATA => $resource->task_group,
];
return $relationships;
}
}
|