1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement; |
6
|
|
|
|
7
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioComment as PortfolioCommentActivity; |
8
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User; |
9
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Scored; |
10
|
|
|
use Xabbuh\XApi\Model\Result; |
11
|
|
|
use Xabbuh\XApi\Model\Score; |
12
|
|
|
use Xabbuh\XApi\Model\Statement; |
13
|
|
|
|
14
|
|
|
class PortfolioCommentScored extends PortfolioComment |
15
|
|
|
{ |
16
|
|
|
use PortfolioAttachmentsTrait; |
17
|
|
|
|
18
|
|
|
public function generate(): Statement |
19
|
|
|
{ |
20
|
|
|
$user = api_get_user_entity(api_get_user_id()); |
21
|
|
|
|
22
|
|
|
$maxScore = (float) api_get_course_setting('portfolio_max_score'); |
23
|
|
|
$rawScore = $this->comment->getScore(); |
24
|
|
|
$scaled = $maxScore ? ($rawScore / $maxScore) : 0; |
25
|
|
|
|
26
|
|
|
$actor = new User($user); |
27
|
|
|
$verb = new Scored(); |
28
|
|
|
$object = new PortfolioCommentActivity($this->comment); |
29
|
|
|
$context = $this->generateContext(); |
30
|
|
|
$attachments = $this->generateAttachmentsForComment($this->comment); |
31
|
|
|
$score = new Score($scaled, $rawScore, 0, $maxScore); |
32
|
|
|
$result = new Result($score); |
33
|
|
|
|
34
|
|
|
return new Statement( |
35
|
|
|
$this->generateStatementId('portfolio-comment'), |
36
|
|
|
$actor->generate(), |
37
|
|
|
$verb->generate(), |
38
|
|
|
$object->generate(), |
39
|
|
|
$result, |
40
|
|
|
null, |
41
|
|
|
api_get_utc_datetime(null, false, true), |
42
|
|
|
null, |
43
|
|
|
$context, |
44
|
|
|
$attachments |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|