Minor - Flint fixes - refs BT#16742

pull/3680/head
Angel Fernando Quiroz Campos 5 years ago
parent 58a9428564
commit 1121579057
  1. 2
      main/inc/ajax/exercise.ajax.php
  2. 2
      main/inc/lib/hook/HookLearningPathEnd.php
  3. 2
      main/inc/lib/hook/HookLearningPathItemViewed.php
  4. 2
      main/inc/lib/hook/HookQuizQuestionAnswered.php
  5. 24
      plugin/xapi/php-xapi/lrs-bundle/src/Controller/StatementGetController.php
  6. 1
      plugin/xapi/php-xapi/lrs-bundle/src/Controller/StatementPostController.php
  7. 4
      plugin/xapi/php-xapi/lrs-bundle/src/DependencyInjection/Configuration.php
  8. 2
      plugin/xapi/php-xapi/lrs-bundle/src/EventListener/AlternateRequestSyntaxListener.php
  9. 2
      plugin/xapi/php-xapi/lrs-bundle/src/Model/StatementsFilterFactory.php
  10. 5
      plugin/xapi/php-xapi/lrs-bundle/src/Response/AttachmentResponse.php
  11. 10
      plugin/xapi/php-xapi/lrs-bundle/src/Response/MultipartResponse.php
  12. 27
      plugin/xapi/src/Entity/SharedStatement.php
  13. 106
      plugin/xapi/src/Entity/ToolLaunch.php
  14. 6
      plugin/xapi/src/Hook/XApiActivityHookObserver.php
  15. 2
      plugin/xapi/src/Hook/XApiCreateCourseHookObserver.php
  16. 12
      plugin/xapi/src/Hook/XApiLearningPathEndHookObserver.php
  17. 18
      plugin/xapi/src/Hook/XApiLearningPathItemViewedHookObserver.php
  18. 10
      plugin/xapi/src/Hook/XApiQuizEndHookObserver.php
  19. 116
      plugin/xapi/src/Hook/XApiQuizQuestionAnsweredHookObserver.php
  20. 7
      plugin/xapi/src/Importer/AbstractImporter.php
  21. 5
      plugin/xapi/src/Importer/TinCanImporter.php
  22. 2
      plugin/xapi/src/Lrs/LrsRequest.php
  23. 3
      plugin/xapi/src/Parser/TinCanParser.php
  24. 5
      plugin/xapi/src/Traits/XApiStatementTrait.php
  25. 205
      plugin/xapi/src/XApiPlugin.php
  26. 4
      plugin/xapi/tincan/stats.php
  27. 2
      plugin/xapi/tincan/stats_attempts.ajax.php
  28. 2
      plugin/xapi/tincan/tool.php

@ -762,7 +762,7 @@ switch ($action) {
],
'question' => [
'id' => (int) $my_question_id,
'weight' => (float) $result['weight']
'weight' => (float) $result['weight'],
],
]
)

@ -18,7 +18,7 @@ class HookLearningPathEnd extends HookEvent implements HookLearningPathEndEventI
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hookLearningPathEnd()
{

@ -18,7 +18,7 @@ class HookLearningPathItemViewed extends HookEvent implements HookLearningPathIt
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function notifyLearningPathItemViewed()
{

@ -18,7 +18,7 @@ class HookQuizQuestionAnswered extends HookEvent implements HookQuizQuestionAnsw
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function notifyQuizQuestionAnswered()
{

@ -32,7 +32,7 @@ use XApi\Repository\Api\StatementRepositoryInterface;
*/
final class StatementGetController
{
private static $getParameters = array(
private static $getParameters = [
'statementId' => true,
'voidedStatementId' => true,
'agent' => true,
@ -47,7 +47,7 @@ final class StatementGetController
'format' => true,
'attachments' => true,
'ascending' => true,
);
];
private $repository;
private $statementSerializer;
@ -63,8 +63,6 @@ final class StatementGetController
}
/**
* @param Request $request
*
* @throws BadRequestHttpException if the query parameters does not comply with xAPI specification
*
* @return Response
@ -91,7 +89,7 @@ final class StatementGetController
$response = $this->buildMultiStatementsResponse($statements, $includeAttachments);
}
} catch (NotFoundException $e) {
$response = $this->buildMultiStatementsResponse(array());
$response = $this->buildMultiStatementsResponse([]);
}
$now = new \DateTime();
@ -101,8 +99,7 @@ final class StatementGetController
}
/**
* @param Statement $statement
* @param bool $includeAttachments true to include the attachments in the response, false otherwise
* @param bool $includeAttachments true to include the attachments in the response, false otherwise
*
* @return JsonResponse|MultipartResponse
*/
@ -110,10 +107,10 @@ final class StatementGetController
{
$json = $this->statementSerializer->serializeStatement($statement);
$response = new JsonResponse($json, 200, array(), true);
$response = new JsonResponse($json, 200, [], true);
if ($includeAttachments) {
$response = $this->buildMultipartResponse($response, array($statement));
$response = $this->buildMultipartResponse($response, [$statement]);
}
$response->setLastModified($statement->getStored());
@ -131,7 +128,7 @@ final class StatementGetController
{
$json = $this->statementResultSerializer->serializeStatementResult(new StatementResult($statements));
$response = new JsonResponse($json, 200, array(), true);
$response = new JsonResponse($json, 200, [], true);
if ($includeAttachments) {
$response = $this->buildMultipartResponse($response, $statements);
@ -141,14 +138,13 @@ final class StatementGetController
}
/**
* @param JsonResponse $statementResponse
* @param Statement[] $statements
* @param Statement[] $statements
*
* @return MultipartResponse
*/
protected function buildMultipartResponse(JsonResponse $statementResponse, array $statements)
{
$attachmentsParts = array();
$attachmentsParts = [];
foreach ($statements as $statement) {
foreach ((array) $statement->getAttachments() as $attachment) {
@ -162,8 +158,6 @@ final class StatementGetController
/**
* Validate the parameters.
*
* @param ParameterBag $query
*
* @throws BadRequestHttpException if the parameters does not comply with the xAPI specification
*/
private function validate(ParameterBag $query)

@ -24,7 +24,6 @@ final class StatementPostController
}
/**
* @param Request $request
* @param Statement[] $statements
*/
public function postStatements(Request $request, array $statements)

@ -17,13 +17,13 @@ final class Configuration implements ConfigurationInterface
$treeBuilder
->root('xapi_lrs')
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['type']) && in_array($v['type'], array('mongodb', 'orm')) && !isset($v['object_manager_service']); })
->ifTrue(function ($v) { return isset($v['type']) && in_array($v['type'], ['mongodb', 'orm']) && !isset($v['object_manager_service']); })
->thenInvalid('You need to configure the object manager service when the repository type is "mongodb" or orm".')
->end()
->children()
->enumNode('type')
->isRequired()
->values(array('in_memory', 'mongodb', 'orm'))
->values(['in_memory', 'mongodb', 'orm'])
->end()
->scalarNode('object_manager_service')->end()
->end()

@ -61,7 +61,7 @@ class AlternateRequestSyntaxListener
}
foreach ($request->request as $key => $value) {
if (in_array($key, array('Authorization', 'X-Experience-API-Version', 'Content-Type', 'Content-Length', 'If-Match', 'If-None-Match'), true)) {
if (in_array($key, ['Authorization', 'X-Experience-API-Version', 'Content-Type', 'Content-Length', 'If-Match', 'If-None-Match'], true)) {
$request->headers->set($key, $value);
} else {
$request->query->set($key, $value);

@ -31,8 +31,6 @@ class StatementsFilterFactory
}
/**
* @param ParameterBag $parameters
*
* @return StatementsFilter
*/
public function createFromParameterBag(ParameterBag $parameters)

@ -22,9 +22,6 @@ class AttachmentResponse extends Response
{
protected $attachment;
/**
* @param Attachment $attachment
*/
public function __construct(Attachment $attachment)
{
parent::__construct(null);
@ -70,7 +67,7 @@ class AttachmentResponse extends Response
/**
* {@inheritdoc}
*
* @return null|string
* @return string|null
*/
public function getContent()
{

@ -29,13 +29,11 @@ class MultipartResponse extends Response
protected $parts;
/**
* @param JsonResponse $statementPart
* @param AttachmentResponse[] $attachmentsParts
* @param int $status
* @param array $headers
* @param null|string $subtype
* @param string|null $subtype
*/
public function __construct(JsonResponse $statementPart, array $attachmentsParts = array(), $status = 200, array $headers = array(), $subtype = null)
public function __construct(JsonResponse $statementPart, array $attachmentsParts = [], $status = 200, array $headers = [], $subtype = null)
{
parent::__construct(null, $status, $headers);
@ -51,8 +49,6 @@ class MultipartResponse extends Response
}
/**
* @param AttachmentResponse $part
*
* @return $this
*/
public function addAttachmentPart(AttachmentResponse $part)
@ -71,7 +67,7 @@ class MultipartResponse extends Response
*/
public function setAttachmentsParts(array $attachmentsParts)
{
$this->parts = array($this->statementPart);
$this->parts = [$this->statementPart];
foreach ($attachmentsParts as $part) {
$this->addAttachmentPart($part);

@ -62,27 +62,16 @@ class SharedStatement
$this->sent = $sent;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string|null
*/
public function getUuid(): ?string
{
return $this->uuid;
}
/**
* @param string|null $uuid
*
* @return SharedStatement
*/
public function setUuid(?string $uuid): SharedStatement
{
$this->uuid = $uuid;
@ -90,19 +79,11 @@ class SharedStatement
return $this;
}
/**
* @return array
*/
public function getStatement(): array
{
return $this->statement;
}
/**
* @param array $statement
*
* @return SharedStatement
*/
public function setStatement(array $statement): SharedStatement
{
$this->statement = $statement;
@ -110,19 +91,11 @@ class SharedStatement
return $this;
}
/**
* @return bool
*/
public function isSent(): bool
{
return $this->sent;
}
/**
* @param bool $sent
*
* @return SharedStatement
*/
public function setSent(bool $sent): SharedStatement
{
$this->sent = $sent;

@ -94,7 +94,7 @@ class ToolLaunch
* @ORM\Column(name="lrs_auth_password", type="string", nullable=true)
*/
private $lrsAuthPassword;
/***
/*
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
@ -109,19 +109,11 @@ class ToolLaunch
$this->allowMultipleAttempts = true;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*
* @return ToolLaunch
*/
public function setId(int $id): ToolLaunch
{
$this->id = $id;
@ -129,19 +121,11 @@ class ToolLaunch
return $this;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @param string $title
*
* @return ToolLaunch
*/
public function setTitle(string $title): ToolLaunch
{
$this->title = $title;
@ -149,19 +133,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param string|null $description
*
* @return ToolLaunch
*/
public function setDescription(?string $description): ToolLaunch
{
$this->description = $description;
@ -169,19 +145,11 @@ class ToolLaunch
return $this;
}
/**
* @return \Chamilo\CoreBundle\Entity\Course
*/
public function getCourse(): Course
{
return $this->course;
}
/**
* @param \Chamilo\CoreBundle\Entity\Course $course
*
* @return ToolLaunch
*/
public function setCourse(Course $course): ToolLaunch
{
$this->course = $course;
@ -189,19 +157,11 @@ class ToolLaunch
return $this;
}
/**
* @return \Chamilo\CoreBundle\Entity\Session|null
*/
public function getSession(): ?Session
{
return $this->session;
}
/**
* @param \Chamilo\CoreBundle\Entity\Session|null $session
*
* @return ToolLaunch
*/
public function setSession(?Session $session): ToolLaunch
{
$this->session = $session;
@ -209,19 +169,11 @@ class ToolLaunch
return $this;
}
/**
* @return string
*/
public function getLaunchUrl(): string
{
return $this->launchUrl;
}
/**
* @param string $launchUrl
*
* @return ToolLaunch
*/
public function setLaunchUrl(string $launchUrl): ToolLaunch
{
$this->launchUrl = $launchUrl;
@ -229,19 +181,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getActivityId(): ?string
{
return $this->activityId;
}
/**
* @param string|null $activityId
*
* @return ToolLaunch
*/
public function setActivityId(?string $activityId): ToolLaunch
{
$this->activityId = $activityId;
@ -249,19 +193,11 @@ class ToolLaunch
return $this;
}
/**
* @return \DateTime
*/
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
/**
* @param \DateTime $createdAt
*
* @return ToolLaunch
*/
public function setCreatedAt(DateTime $createdAt): ToolLaunch
{
$this->createdAt = $createdAt;
@ -269,19 +205,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getActivityType(): ?string
{
return $this->activityType;
}
/**
* @param string|null $activityType
*
* @return ToolLaunch
*/
public function setActivityType(?string $activityType): ToolLaunch
{
$this->activityType = $activityType;
@ -289,19 +217,11 @@ class ToolLaunch
return $this;
}
/**
* @return bool
*/
public function isAllowMultipleAttempts(): bool
{
return $this->allowMultipleAttempts;
}
/**
* @param bool $allowMultipleAttempts
*
* @return ToolLaunch
*/
public function setAllowMultipleAttempts(bool $allowMultipleAttempts): ToolLaunch
{
$this->allowMultipleAttempts = $allowMultipleAttempts;
@ -309,19 +229,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getLrsUrl(): ?string
{
return $this->lrsUrl;
}
/**
* @param string|null $lrsUrl
*
* @return ToolLaunch
*/
public function setLrsUrl(?string $lrsUrl): ToolLaunch
{
$this->lrsUrl = $lrsUrl;
@ -329,19 +241,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getLrsAuthUsername(): ?string
{
return $this->lrsAuthUsername;
}
/**
* @param string|null $lrsAuthUsername
*
* @return ToolLaunch
*/
public function setLrsAuthUsername(?string $lrsAuthUsername): ToolLaunch
{
$this->lrsAuthUsername = $lrsAuthUsername;
@ -349,19 +253,11 @@ class ToolLaunch
return $this;
}
/**
* @return string|null
*/
public function getLrsAuthPassword(): ?string
{
return $this->lrsAuthPassword;
}
/**
* @param string|null $lrsAuthPassword
*
* @return ToolLaunch
*/
public function setLrsAuthPassword(?string $lrsAuthPassword): ToolLaunch
{
$this->lrsAuthPassword = $lrsAuthPassword;

@ -4,9 +4,7 @@
use Chamilo\PluginBundle\Entity\XApi\SharedStatement;
use Doctrine\ORM\OptimisticLockException;
use Xabbuh\XApi\Common\Exception\ConflictException;
use Xabbuh\XApi\Common\Exception\StatementIdAlreadyExistsException;
use Xabbuh\XApi\Common\Exception\XApiException;
use Xabbuh\XApi\Model\Context;
use Xabbuh\XApi\Model\ContextActivities;
use Xabbuh\XApi\Model\Statement;
@ -51,8 +49,6 @@ abstract class XApiActivityHookObserver extends HookObserver
}
/**
* @param \Xabbuh\XApi\Model\Statement $statement
*
* @return \Chamilo\PluginBundle\Entity\XApi\SharedStatement|null
*/
protected function saveSharedStatement(Statement $statement)
@ -159,8 +155,6 @@ abstract class XApiActivityHookObserver extends HookObserver
/**
* Serialize a statement to JSON.
*
* @param \Xabbuh\XApi\Model\Statement $statement
*
* @return string
*/
private function serializeStatement(Statement $statement)

@ -19,7 +19,7 @@ class XApiCreateCourseHookObserver extends HookObserver implements HookCreateCou
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hookCreateCourse(HookCreateCourseEventInterface $hookEvent)
{

@ -26,7 +26,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
private $lp;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function notifyLearningPathEnd(HookLearningPathEndEventInterface $event)
{
@ -49,7 +49,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function getActivityResult()
{
@ -65,7 +65,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivity()
{
@ -92,7 +92,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getId()
{
@ -103,7 +103,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActor()
{
@ -113,7 +113,7 @@ class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implement
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getVerb()
{

@ -12,9 +12,7 @@ use Xabbuh\XApi\Model\Result as ActivityResult;
/**
* Class XApiLearningPathItemViewedHookObserver.
*/
class XApiLearningPathItemViewedHookObserver
extends XApiActivityHookObserver
implements HookLearningPathItemViewedObserverInterface
class XApiLearningPathItemViewedHookObserver extends XApiActivityHookObserver implements HookLearningPathItemViewedObserverInterface
{
use XApiStatementTrait;
@ -32,7 +30,7 @@ class XApiLearningPathItemViewedHookObserver
private $lpView;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hookLearningPathItemViewed(HookLearningPathItemViewedEventInterface $event)
{
@ -61,7 +59,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActor()
{
@ -71,7 +69,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getVerb()
{
@ -82,7 +80,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivity()
{
@ -109,7 +107,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivityResult()
{
@ -129,7 +127,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getContext()
{
@ -148,7 +146,7 @@ class XApiLearningPathItemViewedHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getId()
{

@ -26,7 +26,7 @@ class XApiQuizEndHookObserver extends XApiActivityHookObserver implements HookQu
private $quiz;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hookQuizEnd(HookQuizEndEventInterface $hookEvent)
{
@ -51,7 +51,7 @@ class XApiQuizEndHookObserver extends XApiActivityHookObserver implements HookQu
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActor()
{
@ -61,7 +61,7 @@ class XApiQuizEndHookObserver extends XApiActivityHookObserver implements HookQu
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getVerb()
{
@ -72,7 +72,7 @@ class XApiQuizEndHookObserver extends XApiActivityHookObserver implements HookQu
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivity()
{
@ -102,7 +102,7 @@ class XApiQuizEndHookObserver extends XApiActivityHookObserver implements HookQu
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivityResult()
{

@ -3,11 +3,9 @@
/* For licensing terms, see /license.txt */
use Xabbuh\XApi\Model\Activity;
use Xabbuh\XApi\Model\ContextActivities;
use Xabbuh\XApi\Model\Definition;
use Xabbuh\XApi\Model\Interaction\ChoiceInteractionDefinition;
use Xabbuh\XApi\Model\Interaction\InteractionComponent;
use Xabbuh\XApi\Model\Interaction\InteractionDefinition;
use Xabbuh\XApi\Model\Interaction\LongFillInInteractionDefinition;
use Xabbuh\XApi\Model\Interaction\MatchingInteractionDefinition;
use Xabbuh\XApi\Model\Interaction\OtherInteractionDefinition;
@ -20,9 +18,7 @@ use Xabbuh\XApi\Model\Score;
/**
* Class XApiQuizQuestionAnsweredHook.
*/
class XApiQuizQuestionAnsweredHookObserver
extends XApiActivityHookObserver
implements HookQuizQuestionAnsweredObserverInterface
class XApiQuizQuestionAnsweredHookObserver extends XApiActivityHookObserver implements HookQuizQuestionAnsweredObserverInterface
{
use XApiStatementTrait;
@ -44,7 +40,7 @@ class XApiQuizQuestionAnsweredHookObserver
private $quizInfo;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function hookQuizQuestionAnswered(HookQuizQuestionAnsweredEventInterface $event)
{
@ -74,7 +70,7 @@ class XApiQuizQuestionAnsweredHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActor()
{
@ -84,7 +80,7 @@ class XApiQuizQuestionAnsweredHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getVerb()
{
@ -95,7 +91,7 @@ class XApiQuizQuestionAnsweredHookObserver
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function getActivity()
{
@ -110,6 +106,57 @@ class XApiQuizQuestionAnsweredHookObserver
);
}
/**
* {@inheritdoc}
*/
protected function getActivityResult()
{
$raw = $this->attempt->getMarks();
$max = $this->question->getPonderation();
$scaled = $raw / $max;
return new ActivityResult(
new Score($scaled, $raw, null, $max),
null,
true
);
}
/**
* {@inheritdoc}
*/
protected function getContext()
{
$languageIso = api_get_language_isocode($this->course->getCourseLanguage());
$id = $this->plugin->generateIri($this->quizInfo['id'], XApiPlugin::TYPE_QUIZ);
$quizActivity = new Activity(
$id,
new Definition(
LanguageMap::create([$languageIso => $this->quizInfo['title']]),
null,
IRI::fromString(XApiPlugin::IRI_QUIZ)
)
);
$context = parent::getContext();
$contextActivities = $context->getContextActivities()->withAddedGroupingActivity($quizActivity);
return $context->withContextActivities($contextActivities);
}
/**
* {@inheritdoc}
*/
protected function getId()
{
return $this->generateId(
XApiPlugin::DATA_TYPE_ATTEMPT,
$this->attempt->getId()
);
}
/**
* @return \Xabbuh\XApi\Model\Interaction\InteractionDefinition
*/
@ -240,55 +287,4 @@ class XApiQuizQuestionAnsweredHookObserver
);
}
}
/**
* @inheritDoc
*/
protected function getActivityResult()
{
$raw = $this->attempt->getMarks();
$max = $this->question->getPonderation();
$scaled = $raw / $max;
return new ActivityResult(
new Score($scaled, $raw, null, $max),
null,
true
);
}
/**
* @inheritDoc
*/
protected function getContext()
{
$languageIso = api_get_language_isocode($this->course->getCourseLanguage());
$id = $this->plugin->generateIri($this->quizInfo['id'], XApiPlugin::TYPE_QUIZ);
$quizActivity = new Activity(
$id,
new Definition(
LanguageMap::create([$languageIso => $this->quizInfo['title']]),
null,
IRI::fromString(XApiPlugin::IRI_QUIZ)
)
);
$context = parent::getContext();
$contextActivities = $context->getContextActivities()->withAddedGroupingActivity($quizActivity);
return $context->withContextActivities($contextActivities);
}
/**
* @inheritDoc
*/
protected function getId()
{
return $this->generateId(
XApiPlugin::DATA_TYPE_ATTEMPT,
$this->attempt->getId()
);
}
}

@ -41,9 +41,7 @@ abstract class AbstractImporter
/**
* AbstractImporter constructor.
*
* @param array $fileInfo
* @param string $toolDirectory
* @param \Chamilo\CoreBundle\Entity\Course $course
* @param string $toolDirectory
*/
protected function __construct(array $fileInfo, $toolDirectory, Course $course)
{
@ -59,9 +57,6 @@ abstract class AbstractImporter
}
/**
* @param array $fileInfo
* @param \Chamilo\CoreBundle\Entity\Course $course
*
* @return \Chamilo\PluginBundle\XApi\Importer\AbstractImporter
*/
abstract public static function create(array $fileInfo, Course $course);

@ -15,7 +15,7 @@ use Exception;
class TinCanImporter extends AbstractImporter
{
/**
* @inheritDoc
* {@inheritdoc}
*/
public static function create(array $fileInfo, Course $course)
{
@ -23,7 +23,7 @@ class TinCanImporter extends AbstractImporter
}
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function validPackage()
{
@ -43,5 +43,4 @@ class TinCanImporter extends AbstractImporter
throw new Exception('Incorrect package. Missing "tincan.xml" file');
}
}
}

@ -48,7 +48,7 @@ class LrsRequest
&& method_exists($controllerName, $methodName)
) {
/** @var HttpResponse $response */
$response = call_user_func([new $controllerName, $methodName]);
$response = call_user_func([new $controllerName(), $methodName]);
} else {
$response = HttpResponse::create('Not Found', HttpResponse::HTTP_NOT_FOUND);
}

@ -7,7 +7,6 @@ namespace Chamilo\PluginBundle\XApi\Parser;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\PluginBundle\Entity\XApi\ToolLaunch;
use Database;
use Symfony\Component\DomCrawler\Crawler;
/**
@ -77,8 +76,6 @@ class TinCanParser
}
/**
* @param \Symfony\Component\DomCrawler\Crawler $launchNode
*
* @return string
*/
private function parseLaunchUrl(Crawler $launchNode)

@ -21,8 +21,6 @@ use Xabbuh\XApi\Model\Verb;
trait XApiStatementTrait
{
/**
* @param UserEntity $user
*
* @return \Xabbuh\XApi\Model\Agent
*/
protected function generateActor(UserEntity $user)
@ -87,9 +85,6 @@ trait XApiStatementTrait
}
/**
* @param \Chamilo\CoreBundle\Entity\Course $course
* @param \Chamilo\CoreBundle\Entity\Session|null $session
*
* @return \Xabbuh\XApi\Model\Activity
*/
protected function generateActivityFromCourse(

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\PluginBundle\Entity\XApi\Cmi5Item;
use Chamilo\PluginBundle\Entity\XApi\SharedStatement;
use Chamilo\PluginBundle\Entity\XApi\ToolLaunch;
use Doctrine\ORM\EntityManager;
@ -105,7 +104,6 @@ class XApiPlugin extends Plugin implements HookPluginInterface
[
'xapi_shared_statement',
'xapi_tool_launch',
'xapi_cmi5_item',
'xapi_attachment',
'xapi_object',
@ -128,62 +126,6 @@ class XApiPlugin extends Plugin implements HookPluginInterface
$this->installHook();
}
/**
* @throws \Doctrine\ORM\Tools\ToolsException
*/
private function installPluginDbTables()
{
$em = Database::getManager();
$pluginEm = self::getEntityManager();
$schemaTool = new SchemaTool($em);
$schemaTool->createSchema(
[
$em->getClassMetadata(SharedStatement::class),
$em->getClassMetadata(ToolLaunch::class),
]
);
$pluginSchemaTool = new SchemaTool($pluginEm);
$pluginSchemaTool->createSchema(
[
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Attachment::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\StatementObject::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Result::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Verb::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Extensions::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Context::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Actor::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Statement::class),
]
);
}
/**
* @throws \Exception
*/
private function installUuid()
{
$uuidNamespace = Uuid::uuid1();
$pluginName = $this->get_name();
$urlId = api_get_current_access_url_id();
api_add_setting(
$uuidNamespace,
$pluginName.'_'.self::SETTING_UUID_NAMESPACE,
$pluginName,
'setting',
'Plugins',
$pluginName,
'',
'',
'',
$urlId,
1
);
}
/**
* Process to uninstall plugin.
*/
@ -195,7 +137,7 @@ class XApiPlugin extends Plugin implements HookPluginInterface
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function uninstallHook()
{
@ -271,29 +213,6 @@ class XApiPlugin extends Plugin implements HookPluginInterface
->getStateApiClient()->getDocument();
}
/**
* @param string|null $lrsUrl
* @param string|null $lrsAuthUsername
* @param string|null $lrsAuthPassword
*
* @return \Xabbuh\XApi\Client\XApiClientInterface
*/
private function createXApiClient($lrsUrl = null, $lrsAuthUsername = null, $lrsAuthPassword = null)
{
$baseUrl = $lrsUrl ?: $this->get(self::SETTING_LRS_URL);
$lrsAuthUsername = $lrsAuthUsername ?: $this->get(self::SETTING_LRS_AUTH_USERNAME);
$lrsAuthPassword = $lrsAuthPassword ?: $this->get(self::SETTING_LRS_AUTH_PASSWORD);
$clientBuilder = new XApiClientBuilder();
$clientBuilder
->setHttpClient(Client::createWithConfig([RequestOptions::VERIFY => false]))
->setRequestFactory(new GuzzleMessageFactory())
->setBaseUrl(trim($baseUrl, "/ \t\n\r\0\x0B"))
->setAuth(trim($lrsAuthUsername), trim($lrsAuthPassword));
return $clientBuilder->build();
}
/**
* Perform actions after save the plugin configuration.
*
@ -339,7 +258,7 @@ class XApiPlugin extends Plugin implements HookPluginInterface
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function installHook()
{
@ -402,27 +321,8 @@ class XApiPlugin extends Plugin implements HookPluginInterface
);
}
private function addCourseTools()
{
$courses = Database::getManager()
->createQuery('SELECT c.id FROM ChamiloCoreBundle:Course c')
->getResult();
foreach ($courses as $course) {
$this->addCourseToolForTinCan($course['id']);
}
}
private function deleteCourseTools()
{
Database::getManager()
->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.category = :category AND t.link LIKE :link')
->execute(['category' => 'plugin', 'link' => 'xapi/tincan/index.php%']);
}
/**
* @param \Xabbuh\XApi\Model\LanguageMap $languageMap
* @param string $language
* @param string $language
*
* @return mixed|string
*/
@ -500,7 +400,7 @@ class XApiPlugin extends Plugin implements HookPluginInterface
$em = Database::getManager();
$prefixes = [
__DIR__.'/../php-xapi/repository-doctrine-orm/metadata' => 'XApi\Repository\Doctrine\Mapping'
__DIR__.'/../php-xapi/repository-doctrine-orm/metadata' => 'XApi\Repository\Doctrine\Mapping',
];
$driver = new SimplifiedXmlDriver($prefixes);
@ -517,4 +417,101 @@ class XApiPlugin extends Plugin implements HookPluginInterface
return null;
}
/**
* @throws \Doctrine\ORM\Tools\ToolsException
*/
private function installPluginDbTables()
{
$em = Database::getManager();
$pluginEm = self::getEntityManager();
$schemaTool = new SchemaTool($em);
$schemaTool->createSchema(
[
$em->getClassMetadata(SharedStatement::class),
$em->getClassMetadata(ToolLaunch::class),
]
);
$pluginSchemaTool = new SchemaTool($pluginEm);
$pluginSchemaTool->createSchema(
[
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Attachment::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\StatementObject::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Result::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Verb::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Extensions::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Context::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Actor::class),
$pluginEm->getClassMetadata(\XApi\Repository\Doctrine\Mapping\Statement::class),
]
);
}
/**
* @throws \Exception
*/
private function installUuid()
{
$uuidNamespace = Uuid::uuid1();
$pluginName = $this->get_name();
$urlId = api_get_current_access_url_id();
api_add_setting(
$uuidNamespace,
$pluginName.'_'.self::SETTING_UUID_NAMESPACE,
$pluginName,
'setting',
'Plugins',
$pluginName,
'',
'',
'',
$urlId,
1
);
}
/**
* @param string|null $lrsUrl
* @param string|null $lrsAuthUsername
* @param string|null $lrsAuthPassword
*
* @return \Xabbuh\XApi\Client\XApiClientInterface
*/
private function createXApiClient($lrsUrl = null, $lrsAuthUsername = null, $lrsAuthPassword = null)
{
$baseUrl = $lrsUrl ?: $this->get(self::SETTING_LRS_URL);
$lrsAuthUsername = $lrsAuthUsername ?: $this->get(self::SETTING_LRS_AUTH_USERNAME);
$lrsAuthPassword = $lrsAuthPassword ?: $this->get(self::SETTING_LRS_AUTH_PASSWORD);
$clientBuilder = new XApiClientBuilder();
$clientBuilder
->setHttpClient(Client::createWithConfig([RequestOptions::VERIFY => false]))
->setRequestFactory(new GuzzleMessageFactory())
->setBaseUrl(trim($baseUrl, "/ \t\n\r\0\x0B"))
->setAuth(trim($lrsAuthUsername), trim($lrsAuthPassword));
return $clientBuilder->build();
}
private function addCourseTools()
{
$courses = Database::getManager()
->createQuery('SELECT c.id FROM ChamiloCoreBundle:Course c')
->getResult();
foreach ($courses as $course) {
$this->addCourseToolForTinCan($course['id']);
}
}
private function deleteCourseTools()
{
Database::getManager()
->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.category = :category AND t.link LIKE :link')
->execute(['category' => 'plugin', 'link' => 'xapi/tincan/index.php%']);
}
}

@ -36,7 +36,7 @@ $page = $request->query->getInt('page', 1);
$start = ($page - 1) * $length;
$countStudentList = CourseManager::get_student_list_from_course_code(
$course->getCode(),
!!$session,
(bool) $session,
$session ? $session->getId() : 0,
null,
null,
@ -71,7 +71,7 @@ $pagination->renderer = function ($data) use ($statsUrl) {
$students = CourseManager::get_student_list_from_course_code(
$course->getCode(),
!!$session,
(bool) $session,
$session ? $session->getId() : 0,
null,
null,

@ -45,7 +45,7 @@ if (!$toolLaunch || !$student) {
$userIsSubscribedToCourse = CourseManager::is_user_subscribed_in_course(
$student->getId(),
$course->getCode(),
!!$session,
(bool) $session,
$session ? $session->getId() : 0
);

@ -163,7 +163,6 @@ if ($stateDocument) {
$pageContent .= $table->toHtml();
}
$actions = Display::url(
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
'index.php?'.api_get_cidreq()
@ -180,4 +179,3 @@ $view->assign(
);
$view->assign('content', $pageContent);
$view->display_one_col_template();

Loading…
Cancel
Save