Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace Packback\Lti1p3;
4
 
5
use Packback\Lti1p3\Concerns\JsonStringable;
6
 
7
class LtiGrade
8
{
9
    use JsonStringable;
10
    private $score_given;
11
    private $score_maximum;
12
    private $comment;
13
    private $activity_progress;
14
    private $grading_progress;
15
    private $timestamp;
16
    private $user_id;
17
    private $submission_review;
18
    private $canvas_extension;
19
 
20
    public function __construct(?array $grade = null)
21
    {
22
        $this->score_given = $grade['scoreGiven'] ?? null;
23
        $this->score_maximum = $grade['scoreMaximum'] ?? null;
24
        $this->comment = $grade['comment'] ?? null;
25
        $this->activity_progress = $grade['activityProgress'] ?? null;
26
        $this->grading_progress = $grade['gradingProgress'] ?? null;
27
        $this->timestamp = $grade['timestamp'] ?? null;
28
        $this->user_id = $grade['userId'] ?? null;
29
        $this->submission_review = $grade['submissionReview'] ?? null;
30
        $this->canvas_extension = $grade['https://canvas.instructure.com/lti/submission'] ?? null;
31
    }
32
 
33
    public function getArray(): array
34
    {
35
        return [
36
            'scoreGiven' => $this->score_given,
37
            'scoreMaximum' => $this->score_maximum,
38
            'comment' => $this->comment,
39
            'activityProgress' => $this->activity_progress,
40
            'gradingProgress' => $this->grading_progress,
41
            'timestamp' => $this->timestamp,
42
            'userId' => $this->user_id,
43
            'submissionReview' => $this->submission_review,
44
            'https://canvas.instructure.com/lti/submission' => $this->canvas_extension,
45
        ];
46
    }
47
 
48
    /**
49
     * Static function to allow for method chaining without having to assign to a variable first.
50
     */
51
    public static function new(): self
52
    {
53
        return new LtiGrade();
54
    }
55
 
56
    public function getScoreGiven()
57
    {
58
        return $this->score_given;
59
    }
60
 
61
    public function setScoreGiven($value): self
62
    {
63
        $this->score_given = $value;
64
 
65
        return $this;
66
    }
67
 
68
    public function getScoreMaximum()
69
    {
70
        return $this->score_maximum;
71
    }
72
 
73
    public function setScoreMaximum($value): self
74
    {
75
        $this->score_maximum = $value;
76
 
77
        return $this;
78
    }
79
 
80
    public function getComment()
81
    {
82
        return $this->comment;
83
    }
84
 
85
    public function setComment($comment): self
86
    {
87
        $this->comment = $comment;
88
 
89
        return $this;
90
    }
91
 
92
    public function getActivityProgress()
93
    {
94
        return $this->activity_progress;
95
    }
96
 
97
    public function setActivityProgress($value): self
98
    {
99
        $this->activity_progress = $value;
100
 
101
        return $this;
102
    }
103
 
104
    public function getGradingProgress()
105
    {
106
        return $this->grading_progress;
107
    }
108
 
109
    public function setGradingProgress($value): self
110
    {
111
        $this->grading_progress = $value;
112
 
113
        return $this;
114
    }
115
 
116
    public function getTimestamp()
117
    {
118
        return $this->timestamp;
119
    }
120
 
121
    public function setTimestamp($value): self
122
    {
123
        $this->timestamp = $value;
124
 
125
        return $this;
126
    }
127
 
128
    public function getUserId()
129
    {
130
        return $this->user_id;
131
    }
132
 
133
    public function setUserId($value): self
134
    {
135
        $this->user_id = $value;
136
 
137
        return $this;
138
    }
139
 
140
    public function getSubmissionReview()
141
    {
142
        return $this->submission_review;
143
    }
144
 
145
    public function setSubmissionReview($value): self
146
    {
147
        $this->submission_review = $value;
148
 
149
        return $this;
150
    }
151
 
152
    public function getCanvasExtension()
153
    {
154
        return $this->canvas_extension;
155
    }
156
 
157
    /**
158
     * Add custom extensions for Canvas.
159
     *
160
     * Disclaimer: You should only set this if your LMS is Canvas.
161
     *             Some LMS (e.g. Schoology) include validation logic that will throw if there
162
     *             is unexpected data. And, the type of LMS cannot simply be inferred by their URL.
163
     *
164
     * @see https://documentation.instructure.com/doc/api/score.html
165
     */
166
    public function setCanvasExtension($value): self
167
    {
168
        $this->canvas_extension = $value;
169
 
170
        return $this;
171
    }
172
}