|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement; |
|
6
|
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Entity\PortfolioAttachment; |
|
8
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioComment as PortfolioCommentActivity; |
|
9
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioItem as PortfolioItemActivity; |
|
10
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User as UserActor; |
|
11
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Commented as CommentedVerb; |
|
12
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Replied as RepliedVerb; |
|
13
|
|
|
use Xabbuh\XApi\Model\Result; |
|
14
|
|
|
use Xabbuh\XApi\Model\Statement; |
|
15
|
|
|
|
|
16
|
|
|
class PortfolioItemCommented extends PortfolioComment |
|
17
|
|
|
{ |
|
18
|
|
|
use PortfolioAttachmentsTrait; |
|
19
|
|
|
|
|
20
|
|
|
public function generate(): Statement |
|
21
|
|
|
{ |
|
22
|
|
|
$statementId = $this->generateStatementId('portfolio-comment'); |
|
23
|
|
|
|
|
24
|
|
|
$userActor = new UserActor($this->comment->getAuthor()); |
|
25
|
|
|
$statementResult = new Result(null, null, null, $this->comment->getContent()); |
|
26
|
|
|
|
|
27
|
|
|
$context = $this->generateContext(); |
|
28
|
|
|
|
|
29
|
|
|
$em = \Database::getManager(); |
|
30
|
|
|
$commentAttachments = $em->getRepository(PortfolioAttachment::class)->findFromComment($this->comment); |
|
31
|
|
|
|
|
32
|
|
|
$attachments = $this->generateAttachments( |
|
33
|
|
|
$commentAttachments, |
|
34
|
|
|
$this->comment->getAuthor() |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
if ($this->parentComment) { |
|
38
|
|
|
$repliedVerb = new RepliedVerb(); |
|
39
|
|
|
|
|
40
|
|
|
$itemActivity = new PortfolioItemActivity($this->item); |
|
41
|
|
|
$parentCommentActivity = new PortfolioCommentActivity($this->parentComment); |
|
42
|
|
|
|
|
43
|
|
|
$contextActivities = $context |
|
44
|
|
|
->getContextActivities() |
|
45
|
|
|
->withAddedGroupingActivity($itemActivity->generate()); |
|
46
|
|
|
|
|
47
|
|
|
return new Statement( |
|
48
|
|
|
$statementId, |
|
49
|
|
|
$userActor->generate(), |
|
50
|
|
|
$repliedVerb->generate(), |
|
51
|
|
|
$parentCommentActivity->generate(), |
|
52
|
|
|
$statementResult, |
|
53
|
|
|
null, |
|
54
|
|
|
$this->comment->getDate(), |
|
55
|
|
|
null, |
|
56
|
|
|
$context->withContextActivities($contextActivities), |
|
57
|
|
|
$attachments |
|
58
|
|
|
); |
|
59
|
|
|
} else { |
|
60
|
|
|
$itemShared = new PortfolioItemShared($this->item); |
|
61
|
|
|
|
|
62
|
|
|
$commentedVerb = new CommentedVerb(); |
|
63
|
|
|
|
|
64
|
|
|
return $itemShared->generate() |
|
65
|
|
|
->withId($statementId) |
|
66
|
|
|
->withActor($userActor->generate()) |
|
67
|
|
|
->withVerb($commentedVerb->generate()) |
|
68
|
|
|
->withStored($this->comment->getDate()) |
|
69
|
|
|
->withResult($statementResult) |
|
70
|
|
|
->withContext($context) |
|
71
|
|
|
->withAttachments($attachments); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|