XAPI: fix queue for statements generated by hooks

pull/4035/head
Angel Fernando Quiroz Campos 4 years ago
parent fea6e3877b
commit fdf9c301e4
  1. 4
      plugin/xapi/src/ToolExperience/Statement/BaseStatement.php
  2. 2
      plugin/xapi/src/ToolExperience/Statement/LearningPathCompleted.php
  3. 2
      plugin/xapi/src/ToolExperience/Statement/LearningPathItemViewed.php
  4. 5
      plugin/xapi/src/ToolExperience/Statement/PortfolioItemCommented.php
  5. 3
      plugin/xapi/src/ToolExperience/Statement/PortfolioItemShared.php
  6. 2
      plugin/xapi/src/ToolExperience/Statement/QuizCompleted.php
  7. 2
      plugin/xapi/src/ToolExperience/Statement/QuizQuestionAnswered.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);

@ -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(),

@ -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(),

@ -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())

@ -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(),

@ -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(),

@ -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(),

Loading…
Cancel
Save