Skip to content

Commit

Permalink
Plugin: XApi: Use core entities instead of plugin entities
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jul 3, 2024
1 parent 3bc565e commit 4e2f0e6
Show file tree
Hide file tree
Showing 34 changed files with 82 additions and 1,662 deletions.
12 changes: 6 additions & 6 deletions public/plugin/xapi/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\Entity\XApi\LrsAuth;
use Chamilo\CoreBundle\Entity\XApiLrsAuth;
use Symfony\Component\HttpFoundation\Request;

$cidReset = true;
Expand All @@ -26,7 +26,7 @@
*
* @throws Exception
*/
function createForm(?LrsAuth $auth = null)
function createForm(?XApiLrsAuth $auth = null)
{
$pageBaseUrl = api_get_self();

Expand Down Expand Up @@ -63,7 +63,7 @@ function createForm(?LrsAuth $auth = null)
if ($form->validate()) {
$values = $form->exportValues();

$auth = new LrsAuth();
$auth = new XApiLrsAuth();
$auth
->setUsername($values['username'])
->setPassword($values['password'])
Expand Down Expand Up @@ -94,7 +94,7 @@ function createForm(?LrsAuth $auth = null)
break;

case 'edit':
$auth = $em->find(LrsAuth::class, $request->query->getInt('id'));
$auth = $em->find(XApiLrsAuth::class, $request->query->getInt('id'));

if (null == $auth) {
api_not_allowed(true);
Expand Down Expand Up @@ -135,7 +135,7 @@ function createForm(?LrsAuth $auth = null)
break;

case 'delete':
$auth = $em->find(LrsAuth::class, $request->query->getInt('id'));
$auth = $em->find(XApiLrsAuth::class, $request->query->getInt('id'));

if (null == $auth) {
api_not_allowed(true);
Expand All @@ -160,7 +160,7 @@ function createForm(?LrsAuth $auth = null)
);
$pageContent = Display::return_message(get_lang('NoData'), 'warning');

$auths = $em->getRepository(LrsAuth::class)->findAll();
$auths = $em->getRepository(XApiLrsAuth::class)->findAll();

if (count($auths) > 0) {
$row = 0;
Expand Down
4 changes: 2 additions & 2 deletions public/plugin/xapi/cmi5/launch.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\Entity\XApi\Cmi5Item;
use Chamilo\CoreBundle\Entity\XApiCmi5Item;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Xabbuh\XApi\Model\Account;
use Xabbuh\XApi\Model\Activity;
Expand Down Expand Up @@ -32,7 +32,7 @@

$em = Database::getManager();

$item = $em->find(Cmi5Item::class, $request->query->getInt('id'));
$item = $em->find(XApiCmi5Item::class, $request->query->getInt('id'));
$toolLaunch = $item->getTool();

if ($toolLaunch->getId() !== $request->query->getInt('tool')) {
Expand Down
18 changes: 8 additions & 10 deletions public/plugin/xapi/cmi5/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\Entity\XApi\Cmi5Item;
use Chamilo\PluginBundle\Entity\XApi\ToolLaunch;
use Chamilo\CoreBundle\Entity\XApiCmi5Item;
use Chamilo\CoreBundle\Entity\XApiToolLaunch;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Xabbuh\XApi\Model\LanguageMap;

Expand All @@ -19,7 +19,7 @@
$em = Database::getManager();

$toolLaunch = $em->find(
ToolLaunch::class,
XApiToolLaunch::class,
$request->query->getInt('id')
);

Expand All @@ -38,18 +38,16 @@
$user = api_get_user_entity(api_get_user_id());
$interfaceLanguage = api_get_interface_language();

$itemsRepo = $em->getRepository(Cmi5Item::class);
$itemsRepo = $em->getRepository(XApiCmi5Item::class);

$query = $em->createQueryBuilder()
->select('item')
->from(Cmi5Item::class, 'item')
->where('item.tool = :tool')
$query = $itemsRepo->createQueryBuilder('item');
$query
->where($query->expr()->eq('item.tool', ':tool'))
->setParameter('tool', $toolLaunch->getId())
->getQuery()
;

$tocHtml = $itemsRepo->buildTree(
$query->getArrayResult(),
$query->getQuery()->getArrayResult(),
[
'decorate' => true,
'rootOpen' => '<ul>',
Expand Down
5 changes: 2 additions & 3 deletions public/plugin/xapi/cron/send_statements.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* For licensing terms, see /license.txt */

use Chamilo\PluginBundle\Entity\XApi\SharedStatement;
use Chamilo\CoreBundle\Entity\XApiSharedStatement;
use Xabbuh\XApi\Common\Exception\ConflictException;
use Xabbuh\XApi\Common\Exception\XApiException;
use Xabbuh\XApi\Model\StatementId;
Expand All @@ -25,7 +25,7 @@
$statementSerializer = new StatementSerializer($serializer);

$notSentSharedStatements = $em
->getRepository(SharedStatement::class)
->getRepository(XApiSharedStatement::class)
->findBy(
['uuid' => null, 'sent' => false],
null,
Expand All @@ -39,7 +39,6 @@

$client = XApiPlugin::create()->getXapiStatementCronClient();

/** @var SharedStatement $notSentSharedStatement */
foreach ($notSentSharedStatements as $notSentSharedStatement) {
$notSentStatement = $statementSerializer->deserializeStatement(
json_encode($notSentSharedStatement->getStatement())
Expand Down
7 changes: 0 additions & 7 deletions public/plugin/xapi/install.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,12 @@ class StatementGetController
'cursor' => true,
];

protected $repository;
protected $statementSerializer;
protected $statementResultSerializer;
protected $statementsFilterFactory;

public function __construct(StatementRepositoryInterface $repository, StatementSerializerInterface $statementSerializer, StatementResultSerializerInterface $statementResultSerializer, StatementsFilterFactory $statementsFilterFactory)
{
$this->repository = $repository;
$this->statementSerializer = $statementSerializer;
$this->statementResultSerializer = $statementResultSerializer;
$this->statementsFilterFactory = $statementsFilterFactory;
}
public function __construct(
protected readonly StatementRepositoryInterface $repository,
protected readonly StatementSerializerInterface $statementSerializer,
protected readonly StatementResultSerializerInterface $statementResultSerializer,
protected readonly StatementsFilterFactory $statementsFilterFactory
) {}

/**
* @return Response
Expand Down
99 changes: 0 additions & 99 deletions public/plugin/xapi/src/Entity/ActivityProfile.php

This file was deleted.

118 changes: 0 additions & 118 deletions public/plugin/xapi/src/Entity/ActivityState.php

This file was deleted.

Loading

0 comments on commit 4e2f0e6

Please sign in to comment.