diff --git a/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php b/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php index 9ef9e68a8e..5b630c6020 100644 --- a/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php +++ b/plugin/xapi/src/ToolExperience/Statement/BaseStatement.php @@ -28,11 +28,11 @@ abstract class BaseStatement { abstract public function generate(): Statement; - protected function generateStatementId(string $type, string $value): StatementId + protected function generateStatementId(string $type): StatementId { $uuid = Uuid::uuid5( XApiPlugin::create()->get(XApiPlugin::SETTING_UUID_NAMESPACE), - "$type/$value" + uniqid($type) ); return StatementId::fromUuid($uuid); diff --git a/plugin/xapi/src/ToolExperience/Statement/LearningPathCompleted.php b/plugin/xapi/src/ToolExperience/Statement/LearningPathCompleted.php index b2d48c61f5..7629a9a8ff 100644 --- a/plugin/xapi/src/ToolExperience/Statement/LearningPathCompleted.php +++ b/plugin/xapi/src/ToolExperience/Statement/LearningPathCompleted.php @@ -43,7 +43,7 @@ class LearningPathCompleted extends BaseStatement $lpActivity = new LearningPathActivity($this->lp); return new Statement( - null, + $this->generateStatementId('learning-path'), $userActor->generate(), $completedVerb->generate(), $lpActivity->generate(), diff --git a/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php b/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php index 7a23708aac..f2cc3942df 100644 --- a/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php +++ b/plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php @@ -59,7 +59,7 @@ class LearningPathItemViewed extends BaseStatement ->withAddedGroupingActivity($lpActivity->generate()); return new Statement( - null, + $this->generateStatementId('learning-path-item'), $userActor->generate(), $viewedVerb->generate(), $lpItemActivity->generate(), diff --git a/plugin/xapi/src/ToolExperience/Statement/PortfolioItemCommented.php b/plugin/xapi/src/ToolExperience/Statement/PortfolioItemCommented.php index ae2399a0fe..8997cdde51 100644 --- a/plugin/xapi/src/ToolExperience/Statement/PortfolioItemCommented.php +++ b/plugin/xapi/src/ToolExperience/Statement/PortfolioItemCommented.php @@ -31,6 +31,8 @@ class PortfolioItemCommented extends BaseStatement $portfolioItem = $this->comment->getItem(); $commentParent = $this->comment->getParent(); + $statementId = $this->generateStatementId('portfolio-comment'); + $userActor = new UserActor($this->comment->getAuthor()); $statementResult = new Result(null, null, null, $this->comment->getContent()); @@ -55,7 +57,7 @@ class PortfolioItemCommented extends BaseStatement ->withAddedGroupingActivity($itemActivity->generate()); return new Statement( - null, + $statementId, $userActor->generate(), $repliedVerb->generate(), $parentCommentActivity->generate(), @@ -72,6 +74,7 @@ class PortfolioItemCommented extends BaseStatement $commentedVerb = new CommentedVerb(); return $itemShared->generate() + ->withId($statementId) ->withActor($userActor->generate()) ->withVerb($commentedVerb->generate()) ->withStored($this->comment->getDate()) diff --git a/plugin/xapi/src/ToolExperience/Statement/PortfolioItemShared.php b/plugin/xapi/src/ToolExperience/Statement/PortfolioItemShared.php index abdf27de4e..25b2cae645 100644 --- a/plugin/xapi/src/ToolExperience/Statement/PortfolioItemShared.php +++ b/plugin/xapi/src/ToolExperience/Statement/PortfolioItemShared.php @@ -11,6 +11,7 @@ use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioItem as Portfolio use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User as UserActor; use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Shared as SharedVerb; use Xabbuh\XApi\Model\Statement; +use Xabbuh\XApi\Model\StatementId; /** * Class PortfolioItemShared. @@ -60,7 +61,7 @@ class PortfolioItemShared extends BaseStatement ); return new Statement( - null, + $this->generateStatementId('portfolio-item'), $userActor->generate(), $sharedVerb->generate(), $itemActivity->generate(), diff --git a/plugin/xapi/src/ToolExperience/Statement/QuizCompleted.php b/plugin/xapi/src/ToolExperience/Statement/QuizCompleted.php index 2ed3439db4..2a4e9ba517 100644 --- a/plugin/xapi/src/ToolExperience/Statement/QuizCompleted.php +++ b/plugin/xapi/src/ToolExperience/Statement/QuizCompleted.php @@ -50,7 +50,7 @@ class QuizCompleted extends BaseStatement $duration = $this->exe->getExeDuration(); return new Statement( - null, + $this->generateStatementId('exercise'), $userActor->generate(), $completedVerb->generate(), $quizActivity->generate(), diff --git a/plugin/xapi/src/ToolExperience/Statement/QuizQuestionAnswered.php b/plugin/xapi/src/ToolExperience/Statement/QuizQuestionAnswered.php index 20b5736b24..d1f5a04e42 100644 --- a/plugin/xapi/src/ToolExperience/Statement/QuizQuestionAnswered.php +++ b/plugin/xapi/src/ToolExperience/Statement/QuizQuestionAnswered.php @@ -61,7 +61,7 @@ class QuizQuestionAnswered extends BaseStatement ->withAddedGroupingActivity($quizActivity->generate()); return new Statement( - null, + $this->generateStatementId('exercise-question'), $userActor->generate(), $answeredVerb->generate(), $questionActivity->generate(),