• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oat-sa / lib-lti1p3-proctoring / 7297772460

22 Dec 2023 08:22AM UTC coverage: 99.721% (-0.3%) from 100.0%
7297772460

push

github

web-flow
Merge pull request #21 from oat-sa/feature/TR-5944/upgrade-dependencies

BREAKING CHANGE TR-5944 upgrade dependencies, removing `Http\Message\ResponseFactory` from dependencies

1 of 1 new or added line in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

357 of 358 relevant lines covered (99.72%)

5.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.53
/src/Model/AcsControl.php
1
<?php
2

3
/**
4
 * This program is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU General Public License
6
 * as published by the Free Software Foundation; under version 2
7
 * of the License (non-upgradable).
8
 *
9
 * This program 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 this program; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
 *
18
 * Copyright (c) 2021 (original work) Open Assessment Technologies SA;
19
 */
20

21
declare(strict_types=1);
22

23
namespace OAT\Library\Lti1p3Proctoring\Model;
24

25
use DateTimeInterface;
26
use InvalidArgumentException;
27
use OAT\Library\Lti1p3Core\Resource\LtiResourceLink\LtiResourceLinkInterface;
28

29
/**
30
 * @see https://www.imsglobal.org/spec/proctoring/v1p0#h.7p0gg8s6cj7h
31
 */
32
class AcsControl implements AcsControlInterface
33
{
34
    /** @var LtiResourceLinkInterface */
35
    private $resourceLink;
36

37
    /** @var string */
38
    private $userIdentifier;
39

40
    /** @var string */
41
    private $action;
42

43
    /** @var DateTimeInterface */
44
    private $incidentTime;
45

46
    /** @var int */
47
    private $attemptNumber;
48

49
    /** @var string|null */
50
    private $issuerIdentifier;
51

52
    /** @var int|null */
53
    private $extraTime;
54

55
    /** @var float|null */
56
    private $incidentSeverity;
57

58
    /** @var string|null */
59
    private $reasonCode;
60

61
    /** @var string|null */
62
    private $reasonMessage;
63

64
    public function __construct(
65
        LtiResourceLinkInterface $resourceLink,
66
        string $userIdentifier,
67
        string $action,
68
        DateTimeInterface $incidentTime,
69
        int $attemptNumber = 1,
70
        ?string $issuerIdentifier = null,
71
        ?int $extraTime = null,
72
        ?float $incidentSeverity = null,
73
        ?string $reasonCode = null,
74
        ?string $reasonMessage = null
75
    ) {
76
        $this->setAction($action);
29✔
77

78
        $this->resourceLink = $resourceLink;
29✔
79
        $this->userIdentifier = $userIdentifier;
29✔
80
        $this->incidentTime = $incidentTime;
29✔
81
        $this->attemptNumber = $attemptNumber;
29✔
82
        $this->issuerIdentifier = $issuerIdentifier;
29✔
83
        $this->extraTime = $extraTime;
29✔
84
        $this->incidentSeverity = $incidentSeverity;
29✔
85
        $this->reasonCode = $reasonCode;
29✔
86
        $this->reasonMessage = $reasonMessage;
29✔
87
    }
88

89
    public function getResourceLink(): LtiResourceLinkInterface
90
    {
91
        return $this->resourceLink;
5✔
92
    }
93

94
    public function setResourceLink(LtiResourceLinkInterface $resourceLink): AcsControlInterface
95
    {
96
        $this->resourceLink = $resourceLink;
1✔
97

98
        return $this;
1✔
99
    }
100

101
    public function getUserIdentifier(): string
102
    {
103
        return $this->userIdentifier;
5✔
104
    }
105

106
    public function setUserIdentifier(string $userIdentifier): AcsControlInterface
107
    {
108
        $this->userIdentifier = $userIdentifier;
1✔
109

110
        return $this;
1✔
111
    }
112

113
    public function getAction(): string
114
    {
115
        return $this->action;
8✔
116
    }
117

118
    /**
119
     * @throws InvalidArgumentException
120
     */
121
    public function setAction(string $action): AcsControlInterface
122
    {
123
        if (!in_array($action, self::SUPPORTED_ACTIONS)) {
29✔
124
            throw new InvalidArgumentException(sprintf('Control action %s is not supported', $action));
1✔
125
        }
126

127
        $this->action = $action;
29✔
128

129
        return $this;
29✔
130
    }
131

132
    public function getIncidentTime(): DateTimeInterface
133
    {
134
        return $this->incidentTime;
5✔
135
    }
136

137
    public function setIncidentTime(DateTimeInterface $incidentTime): AcsControlInterface
138
    {
139
        $this->incidentTime = $incidentTime;
1✔
140

141
        return $this;
1✔
142
    }
143

144
    public function getAttemptNumber(): int
145
    {
146
        return $this->attemptNumber;
5✔
147
    }
148

149
    public function setAttemptNumber(int $attemptNumber): AcsControlInterface
150
    {
151
        $this->attemptNumber = $attemptNumber;
1✔
152

153
        return $this;
1✔
154
    }
155

156
    public function getIssuerIdentifier(): ?string
157
    {
158
        return $this->issuerIdentifier;
10✔
159
    }
160

161
    public function setIssuerIdentifier(?string $issuerIdentifier): AcsControlInterface
162
    {
163
        $this->issuerIdentifier = $issuerIdentifier;
4✔
164

165
        return $this;
4✔
166
    }
167

168
    public function getExtraTime(): ?int
169
    {
170
        return $this->extraTime;
5✔
171
    }
172

173
    public function setExtraTime(?int $extraTime): AcsControlInterface
174
    {
175
        $this->extraTime = $extraTime;
3✔
176

177
        return $this;
3✔
178
    }
179

180
    public function getIncidentSeverity(): ?float
181
    {
182
        return $this->incidentSeverity;
5✔
183
    }
184

185
    public function setIncidentSeverity(?float $incidentSeverity): AcsControlInterface
186
    {
187
        $this->incidentSeverity = $incidentSeverity;
3✔
188

189
        return $this;
3✔
190
    }
191

192
    public function getReasonCode(): ?string
193
    {
194
        return $this->reasonCode;
5✔
195
    }
196

197
    public function setReasonCode(?string $reasonCode): AcsControlInterface
198
    {
199
        $this->reasonCode = $reasonCode;
3✔
200

201
        return $this;
3✔
202
    }
203

204
    public function getReasonMessage(): ?string
205
    {
206
        return $this->reasonMessage;
5✔
207
    }
208

209
    public function setReasonMessage(?string $reasonMessage): AcsControlInterface
210
    {
211
        $this->reasonMessage = $reasonMessage;
3✔
212

213
        return $this;
3✔
214
    }
215

216
    public function jsonSerialize(): array
217
    {
218
        $incidentTime = $this->incidentTime
12✔
219
            ? $this->incidentTime->format(DateTimeInterface::ATOM)
12✔
UNCOV
220
            : null;
×
221

222
        return array_filter(
12✔
223
            [
12✔
224
                'user' => [
12✔
225
                    'iss' => $this->issuerIdentifier,
12✔
226
                    'sub' => $this->userIdentifier,
12✔
227
                ],
12✔
228
                'resource_link' => [
12✔
229
                    'id' => $this->resourceLink->getIdentifier(),
12✔
230
                    'title' => $this->resourceLink->getTitle(),
12✔
231
                    'description' => $this->resourceLink->getText(),
12✔
232
                ],
12✔
233
                'attempt_number' => $this->attemptNumber,
12✔
234
                'action' => $this->action,
12✔
235
                'extra_time' => $this->extraTime,
12✔
236
                'incident_time' => $incidentTime,
12✔
237
                'incident_severity' => $this->incidentSeverity,
12✔
238
                'reason_code' => $this->reasonCode,
12✔
239
                'reason_msg' => $this->reasonMessage,
12✔
240
            ],
12✔
241
            static function ($element) {
12✔
242
                return $element !== null;
12✔
243
            }
12✔
244
        );
12✔
245
    }
246
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc