From 06d3cc042213c62af4dfbfd8d338bc97d4dbd290 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:28:45 -0500 Subject: [PATCH 1/5] LTI: Add migration to check and table columns --- .../Schema/V200/Version20251002110000.php | 32 ++ .../Schema/V200/Version20251002110001.php | 280 ++++++++++++++++++ src/LtiBundle/Entity/ExternalTool.php | 102 +++---- src/LtiBundle/Entity/LineItem.php | 16 +- src/LtiBundle/Entity/Platform.php | 9 +- src/LtiBundle/Entity/Token.php | 15 +- 6 files changed, 384 insertions(+), 70 deletions(-) create mode 100644 src/CoreBundle/Migrations/Schema/V200/Version20251002110000.php create mode 100644 src/CoreBundle/Migrations/Schema/V200/Version20251002110001.php diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20251002110000.php b/src/CoreBundle/Migrations/Schema/V200/Version20251002110000.php new file mode 100644 index 00000000000..4506e23c59f --- /dev/null +++ b/src/CoreBundle/Migrations/Schema/V200/Version20251002110000.php @@ -0,0 +1,32 @@ +addSql("CREATE TABLE IF NOT EXISTS lti_lineitem (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); + + $this->addSql("CREATE TABLE IF NOT EXISTS lti_external_tool (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); + + $this->addSql("CREATE TABLE IF NOT EXISTS lti_token (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); + + $this->addSql("CREATE TABLE IF NOT EXISTS lti_platform (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); + } +} diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20251002110001.php b/src/CoreBundle/Migrations/Schema/V200/Version20251002110001.php new file mode 100644 index 00000000000..3525aa6a192 --- /dev/null +++ b/src/CoreBundle/Migrations/Schema/V200/Version20251002110001.php @@ -0,0 +1,280 @@ +getTable('lti_lineitem'); + + if ($lineItem->hasIndex('IDX_5C76B75D8F7B22CC')) { + $this->addSql("DROP INDEX IDX_5C76B75D8F7B22CC ON lti_lineitem"); + } + + if ($lineItem->hasForeignKey('FK_5C76B75D8F7B22CC')) { + $this->addSql("ALTER TABLE lti_lineitem DROP FOREIGN KEY FK_5C76B75D8F7B22CC"); + } + + if ($lineItem->hasColumn('tool_id')) { + $this->addSql('ALTER TABLE lti_lineitem DROP COLUMN tool_id'); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD tool_id INT NOT NULL"); + $this->addSql("ALTER TABLE lti_lineitem ADD CONSTRAINT FK_5C76B75D8F7B22CC FOREIGN KEY (tool_id) REFERENCES lti_external_tool (id) ON DELETE CASCADE"); + $this->addSql("CREATE INDEX IDX_5C76B75D8F7B22CC ON lti_lineitem (tool_id)"); + + if ($lineItem->hasIndex('UNIQ_5C76B75D1323A575')) { + $this->addSql("DROP INDEX UNIQ_5C76B75D1323A575 ON lti_lineitem"); + } + + if ($lineItem->hasForeignKey('FK_5C76B75D1323A575')) { + $this->addSql("ALTER TABLE lti_lineitem DROP FOREIGN KEY FK_5C76B75D1323A575"); + } + + if ($lineItem->hasColumn('evaluation')) { + $this->addSql("ALTER TABLE lti_lineitem DROP COLUMN evaluation"); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD evaluation INT NOT NULL"); + $this->addSql("ALTER TABLE lti_lineitem ADD CONSTRAINT FK_5C76B75D1323A575 FOREIGN KEY (evaluation) REFERENCES gradebook_evaluation (id) ON DELETE CASCADE"); + $this->addSql("CREATE UNIQUE INDEX UNIQ_5C76B75D1323A575 ON lti_lineitem (evaluation)"); + + if ($lineItem->hasColumn('resource_id')) { + $this->addSql("ALTER TABLE DROP COLUMN resource_id"); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD resource_id VARCHAR(255) DEFAULT NULL"); + + if ($lineItem->hasColumn('tag')) { + $this->addSql("ALTER TABLE DROP COLUMN tag"); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD tag VARCHAR(255) DEFAULT NULL"); + + if ($lineItem->hasColumn('start_date')) { + $this->addSql("ALTER TABLE DROP COLUMN start_date"); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD start_date DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)'"); + + if ($lineItem->hasColumn('end_date')) { + $this->addSql("ALTER TABLE DROP COLUMN end_date"); + } + + $this->addSql("ALTER TABLE lti_lineitem ADD end_date DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)'"); + + $externalTool = $schema->getTable('lti_external_tool'); + + if ($externalTool->hasIndex('UNIQ_DB0E04E41BAD783F')) { + $this->addSql("DROP INDEX UNIQ_DB0E04E41BAD783F ON lti_external_tool"); + } + + if ($externalTool->hasForeignKey('FK_DB0E04E41BAD783F')) { + $this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E41BAD783F"); + } + + if ($externalTool->hasColumn('resource_node_id')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN resource_node_id"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD resource_node_id INT DEFAULT NULL"); + $this->addSql('ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E41BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE'); + $this->addSql("CREATE UNIQUE INDEX UNIQ_DB0E04E41BAD783F ON lti_external_tool (resource_node_id)"); + + if ($externalTool->hasIndex('IDX_DB0E04E482F80D8B')) { + $this->addSql("DROP INDEX IDX_DB0E04E482F80D8B ON lti_external_tool"); + } + + if ($externalTool->hasForeignKey('FK_DB0E04E482F80D8B')) { + $this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E482F80D8B"); + } + + if ($externalTool->hasColumn('gradebook_eval_id')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN gradebook_eval_id"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD gradebook_eval_id INT DEFAULT NULL"); + $this->addSql("ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL"); + $this->addSql("CREATE INDEX IDX_DB0E04E482F80D8B ON lti_external_tool (gradebook_eval_id)"); + + if ($externalTool->hasColumn('title')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN title"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD title VARCHAR(255) NOT NULL"); + + if ($externalTool->hasColumn('description')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN description"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD description LONGTEXT DEFAULT NULL"); + + if ($externalTool->hasColumn('public_key')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN public_key"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD public_key LONGTEXT DEFAULT NULL"); + + if ($externalTool->hasColumn('launch_url')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN launch_url"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD launch_url VARCHAR(255) NOT NULL"); + + if ($externalTool->hasColumn('consumer_key')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN consumer_key"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD consumer_key VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('shared_secret')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN shared_secret"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD shared_secret VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('custom_params')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN custom_params"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD custom_params LONGTEXT DEFAULT NULL"); + + if ($externalTool->hasColumn('active_deep_linking')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN active_deep_linking"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD active_deep_linking TINYINT(1) DEFAULT 0 NOT NULL"); + + if ($externalTool->hasColumn('privacy')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN privacy"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD privacy LONGTEXT DEFAULT NULL"); + + if ($externalTool->hasColumn('client_id')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN client_id"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD client_id VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('login_url')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN login_url"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD login_url VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('redirect_url')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN redirect_url"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD redirect_url VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('jwks_url')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN jwks_url"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD jwks_url VARCHAR(255) DEFAULT NULL"); + + if ($externalTool->hasColumn('advantage_services')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN advantage_services"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD advantage_services JSON DEFAULT NULL COMMENT '(DC2Type:json)'"); + + if ($externalTool->hasColumn('version')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN version"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD version VARCHAR(255) DEFAULT 'lti1p3' NOT NULL"); + + if ($externalTool->hasColumn('launch_presentation')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN launch_presentation"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD launch_presentation JSON NOT NULL COMMENT '(DC2Type:json)'"); + + if ($externalTool->hasColumn('replacement_params')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN replacement_params"); + } + + $this->addSql("ALTER TABLE lti_external_tool ADD replacement_params JSON NOT NULL COMMENT '(DC2Type:json)'"); + + $token = $schema->getTable('lti_token'); + + if ($token->hasIndex('IDX_EA71C468F7B22CC')) { + $this->addSql("DROP INDEX IDX_EA71C468F7B22CC ON lti_token"); + } + + if ($token->hasForeignKey('FK_EA71C468F7B22CC')) { + $this->addSql("ALTER TABLE lti_token DROP FOREIGN KEY FK_EA71C468F7B22CC"); + } + + if ($token->hasColumn('tool_id')) { + $this->addSql("ALTER TABLE lti_token DROP COLUMN tool_id"); + } + + $this->addSql("ALTER TABLE lti_token ADD tool_id INT DEFAULT NULL"); + $this->addSql("ALTER TABLE lti_token ADD CONSTRAINT FK_EA71C468F7B22CC FOREIGN KEY (tool_id) REFERENCES lti_external_tool (id) ON DELETE CASCADE"); + $this->addSql("CREATE INDEX IDX_EA71C468F7B22CC ON lti_token (tool_id)"); + + if ($token->hasColumn('scope')) { + $this->addSql("ALTER TABLE lti_token DROP COLUMN scope"); + } + + $this->addSql("ALTER TABLE lti_token ADD scope JSON NOT NULL COMMENT '(DC2Type:json)'"); + + if ($token->hasColumn('hash')) { + $this->addSql("ALTER TABLE lti_token DROP COLUMN hash"); + } + + $this->addSql("ALTER TABLE lti_token ADD hash VARCHAR(255) NOT NULL"); + + if ($token->hasColumn('created_at')) { + $this->addSql("ALTER TABLE lti_token DROP COLUMN created_at"); + } + + $this->addSql("ALTER TABLE lti_token ADD created_at INT NOT NULL"); + + if ($token->hasColumn('expires_at')) { + $this->addSql("ALTER TABLE lti_token DROP COLUMN expires_at"); + } + + $this->addSql("ALTER TABLE lti_token ADD expires_at INT NOT NULL"); + + $platform = $schema->getTable('lti_platform'); + + if ($token->hasColumn('public_key')) { + $this->addSql("ALTER TABLE lti_platform DROP COLUMN public_key"); + } + + $this->addSql("ALTER TABLE lti_platform ADD public_key LONGTEXT NOT NULL"); + + if ($token->hasColumn('kid')) { + $this->addSql("ALTER TABLE lti_platform DROP COLUMN kid"); + } + + $this->addSql("ALTER TABLE lti_platform ADD kid VARCHAR(255) NOT NULL"); + + if ($token->hasColumn('private_key')) { + $this->addSql("ALTER TABLE lti_platform DROP COLUMN private_key"); + } + + $this->addSql("ALTER TABLE lti_platform ADD private_key LONGTEXT NOT NULL"); + } +} diff --git a/src/LtiBundle/Entity/ExternalTool.php b/src/LtiBundle/Entity/ExternalTool.php index 4aadea45d4f..b855d79ebfb 100644 --- a/src/LtiBundle/Entity/ExternalTool.php +++ b/src/LtiBundle/Entity/ExternalTool.php @@ -7,14 +7,17 @@ namespace Chamilo\LtiBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; -use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\GradebookEvaluation; use Chamilo\CoreBundle\Entity\ResourceInterface; +use Chamilo\CoreBundle\Entity\ResourceLink; +use Chamilo\CoreBundle\Entity\ResourceNode; use Chamilo\CoreBundle\Entity\ResourceToRootInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; +use LtiAssignmentGradesService; +use LtiNamesRoleProvisioningService; use Stringable; use UnserializeApi; @@ -25,9 +28,9 @@ class ExternalTool extends AbstractResource implements ResourceInterface, Resour public const V_1P1 = 'lti1p1'; public const V_1P3 = 'lti1p3'; - #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] #[ORM\GeneratedValue] + #[ORM\Column(name: 'id', type: 'integer')] protected ?int $id = null; #[ORM\Column(name: 'title', type: 'string')] @@ -36,6 +39,9 @@ class ExternalTool extends AbstractResource implements ResourceInterface, Resour #[ORM\Column(name: 'description', type: 'text', nullable: true)] protected ?string $description; + #[ORM\Column(name: 'public_key', type: 'text', nullable: true)] + public ?string $publicKey; + #[ORM\Column(name: 'launch_url', type: 'string')] protected string $launchUrl; @@ -54,37 +60,31 @@ class ExternalTool extends AbstractResource implements ResourceInterface, Resour #[ORM\Column(name: 'privacy', type: 'text', nullable: true, options: ['default' => null])] protected ?string $privacy; - #[ORM\ManyToOne(targetEntity: Course::class)] - #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id')] - protected ?Course $course; - #[ORM\ManyToOne(targetEntity: GradebookEvaluation::class)] #[ORM\JoinColumn(name: 'gradebook_eval_id', referencedColumnName: 'id', onDelete: 'SET NULL')] - protected ?GradebookEvaluation $gradebookEval; - - #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')] - #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id')] - protected ?ExternalTool $parent; - - #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] - protected Collection $children; + private ?GradebookEvaluation $gradebookEval; #[ORM\Column(name: 'client_id', type: 'string', nullable: true)] - private ?string $clientId = null; + private ?string $clientId; + #[ORM\Column(name: 'login_url', type: 'string', nullable: true)] - private ?string $loginUrl = null; + private ?string $loginUrl; #[ORM\Column(name: 'redirect_url', type: 'string', nullable: true)] - private ?string $redirectUrl = null; + private ?string $redirectUrl; + + #[ORM\Column(name: 'jwks_url', type: 'string', nullable: true)] + private ?string $jwksUrl; #[ORM\Column(name: 'advantage_services', type: 'json', nullable: true)] private ?array $advantageServices; - #[ORM\OneToMany(targetEntity: LineItem::class, mappedBy: 'tool')] + #[ORM\OneToMany(mappedBy: 'tool', targetEntity: LineItem::class)] private Collection $lineItems; - #[ORM\Column(name: 'version', type: 'string', options: ['default' => 'lti1p1'])] + #[ORM\Column(name: 'version', type: 'string', options: ['default' => self::V_1P3])] private string $version; + #[ORM\Column(name: 'launch_presentation', type: 'json')] private array $launchPresentation; @@ -96,17 +96,12 @@ public function __construct() $this->description = null; $this->customParams = null; $this->activeDeepLinking = false; - $this->course = null; $this->gradebookEval = null; $this->privacy = null; $this->consumerKey = null; $this->sharedSecret = null; - $this->parent = null; - $this->children = new ArrayCollection(); - $this->consumerKey = null; - $this->sharedSecret = null; $this->lineItems = new ArrayCollection(); - $this->version = self::V_1P1; + $this->version = self::V_1P3; $this->launchPresentation = [ 'document_target' => 'iframe', ]; @@ -118,7 +113,7 @@ public function __toString(): string return $this->getTitle(); } - public function getId(): int + public function getId(): ?int { return $this->id; } @@ -173,7 +168,9 @@ public function setCustomParams(?string $customParams): static public function isGlobal(): bool { - return null === $this->course; + $resourceNode = $this->resourceNode->getResourceLinks()->first(); + + return !$resourceNode; } public function encodeCustomParams(array $params): ?string @@ -245,18 +242,6 @@ public function setActiveDeepLinking(bool $activeDeepLinking): static return $this; } - public function getCourse(): ?Course - { - return $this->course; - } - - public function setCourse(?Course $course = null): static - { - $this->course = $course; - - return $this; - } - public function getGradebookEval(): ?GradebookEvaluation { return $this->gradebookEval; @@ -328,7 +313,7 @@ public function getToolParent(): ?self public function setToolParent(self $parent): static { - $this->parent = $parent; + $this->resourceNode->setParent($parent->getResourceNode()); $this->sharedSecret = $parent->getSharedSecret(); $this->consumerKey = $parent->getConsumerKey(); $this->privacy = $parent->getPrivacy(); @@ -336,18 +321,6 @@ public function setToolParent(self $parent): static return $this; } - public function getChildren(): Collection - { - return $this->children; - } - - public function setChildren(Collection $children): static - { - $this->children = $children; - - return $this; - } - public function getSharedSecret(): ?string { return $this->sharedSecret; @@ -389,6 +362,18 @@ public function getRedirectUrl(): ?string return $this->redirectUrl; } + public function getJwksUrl(): ?string + { + return $this->jwksUrl; + } + + public function setJwksUrl(?string $jwksUrl): static + { + $this->jwksUrl = $jwksUrl; + + return $this; + } + public function setRedirectUrl(?string $redirectUrl): static { $this->redirectUrl = $redirectUrl; @@ -506,7 +491,7 @@ public function setDocumenTarget(string $target): static return $this; } - public function getDocumentTarget() + public function getDocumentTarget(): string { return $this->launchPresentation['document_target'] ?: 'iframe'; } @@ -532,10 +517,13 @@ public function getReplacementForUserId(): ?string return null; } + // @TODO: move it to repository public function getChildrenInCourses(array $coursesId): Collection { - return $this->children->filter( - fn (self $child) => \in_array($child->getCourse()->getId(), $coursesId, true) + return $this->resourceNode->getChildren()->filter( + fn(ResourceNode $child) => $child->getResourceLinks()->exists( + fn(ResourceLink $link) => ($course = $link->getCourse()) && in_array($course->getId(), $coursesId) + ) ); } @@ -544,9 +532,9 @@ public function getResourceName(): string return $this->getTitle(); } - public function setResourceName(string $title): static + public function setResourceName(string $name): static { - return $this->setTitle($title); + return $this->setTitle($name); } public function getResourceIdentifier(): int diff --git a/src/LtiBundle/Entity/LineItem.php b/src/LtiBundle/Entity/LineItem.php index a654cf45b7f..d1e143d1906 100644 --- a/src/LtiBundle/Entity/LineItem.php +++ b/src/LtiBundle/Entity/LineItem.php @@ -19,22 +19,28 @@ class LineItem #[ORM\Id] #[ORM\GeneratedValue] protected ?int $id = null; + #[ORM\ManyToOne(targetEntity: ExternalTool::class, inversedBy: 'lineItems')] #[ORM\JoinColumn(name: 'tool_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] private ExternalTool $tool; + #[ORM\OneToOne(targetEntity: GradebookEvaluation::class)] #[ORM\JoinColumn(name: 'evaluation', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] private GradebookEvaluation $evaluation; + #[ORM\Column(name: 'resource_id', type: 'string', nullable: true)] - private string $resourceId; + private ?string $resourceId; + #[ORM\Column(name: 'tag', type: 'string', nullable: true)] - private string $tag; + private ?string $tag; + #[ORM\Column(name: 'start_date', type: 'datetime', nullable: true)] - private DateTime $startDate; + private ?DateTime $startDate; + #[ORM\Column(name: 'end_date', type: 'datetime', nullable: true)] - private DateTime $endDate; + private ?DateTime $endDate; - public function getId(): int + public function getId(): ?int { return $this->id; } diff --git a/src/LtiBundle/Entity/Platform.php b/src/LtiBundle/Entity/Platform.php index 510b68752d1..5c5701956ba 100644 --- a/src/LtiBundle/Entity/Platform.php +++ b/src/LtiBundle/Entity/Platform.php @@ -12,18 +12,21 @@ #[ORM\Entity] class Platform { - #[ORM\Column(name: 'public_key', type: 'text')] - public string $publicKey; #[ORM\Column(name: 'id', type: 'integer')] #[ORM\Id] #[ORM\GeneratedValue] protected ?int $id = null; + + #[ORM\Column(name: 'public_key', type: 'text')] + public string $publicKey; + #[ORM\Column(name: 'kid', type: 'string')] private string $kid; + #[ORM\Column(name: 'private_key', type: 'text')] private string $privateKey; - public function getId(): int + public function getId(): ?int { return $this->id; } diff --git a/src/LtiBundle/Entity/Token.php b/src/LtiBundle/Entity/Token.php index 4c45edd2462..9e8e4a7714c 100644 --- a/src/LtiBundle/Entity/Token.php +++ b/src/LtiBundle/Entity/Token.php @@ -18,29 +18,34 @@ class Token #[ORM\Id] #[ORM\GeneratedValue] protected ?int $id = null; + #[ORM\ManyToOne(targetEntity: ExternalTool::class)] #[ORM\JoinColumn(name: 'tool_id', referencedColumnName: 'id', onDelete: 'CASCADE')] - private ExternalTool $tool; + private ?ExternalTool $tool; + #[ORM\Column(name: 'scope', type: 'json')] private array $scope; + #[ORM\Column(name: 'hash', type: 'string')] private string $hash; + #[ORM\Column(name: 'created_at', type: 'integer')] private int $createdAt; + #[ORM\Column(name: 'expires_at', type: 'integer')] private int $expiresAt; - public function getId(): int + public function getId(): ?int { return $this->id; } - public function getTool(): ExternalTool + public function getTool(): ?ExternalTool { return $this->tool; } - public function setTool(ExternalTool $tool): static + public function setTool(?ExternalTool $tool): static { $this->tool = $tool; @@ -102,7 +107,7 @@ public function getScopeInString(): string public function generateHash(): static { - $this->hash = sha1(uniqid((string) random_int(0, mt_getrandmax()))); + $this->hash = sha1(uniqid((string) mt_rand())); return $this; } From 5244017f6fa5201f3ad6ba926240b14ec785ba71 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:29:06 -0500 Subject: [PATCH 2/5] LTI: Update plugin from 1.11.x --- public/plugin/ImsLti/Entity/ImsLtiTool.php | 626 ++++-------------- public/plugin/ImsLti/Entity/LineItem.php | 191 ++---- public/plugin/ImsLti/Entity/Platform.php | 13 +- public/plugin/ImsLti/Entity/Token.php | 9 +- public/plugin/ImsLti/ImsLtiPlugin.php | 29 +- public/plugin/ImsLti/admin.php | 6 +- public/plugin/ImsLti/auth.php | 8 +- public/plugin/ImsLti/configure.php | 6 +- public/plugin/ImsLti/create.php | 12 +- public/plugin/ImsLti/delete.php | 8 +- public/plugin/ImsLti/edit.php | 12 +- public/plugin/ImsLti/form.php | 4 +- .../plugin/ImsLti/gradebook/OutcomeForm.php | 20 +- public/plugin/ImsLti/gradebook/add_eval.php | 17 +- public/plugin/ImsLti/install.php | 2 + public/plugin/ImsLti/item_return.php | 8 +- public/plugin/ImsLti/item_return2.php | 2 +- public/plugin/ImsLti/jwks.php | 2 +- public/plugin/ImsLti/login.php | 2 +- public/plugin/ImsLti/multiply.php | 20 +- public/plugin/ImsLti/multiply_session.php | 20 +- public/plugin/ImsLti/outcome_service.php | 2 +- public/plugin/ImsLti/platform.php | 6 +- public/plugin/ImsLti/session.php | 14 +- .../src/ContentItem/LtiContentItemType.php | 2 +- .../src/ContentItem/LtiResourceLink.php | 2 +- public/plugin/ImsLti/src/Form/FrmAdd.php | 4 +- public/plugin/ImsLti/src/Form/FrmEdit.php | 4 +- public/plugin/ImsLti/src/ImsLti.php | 6 +- .../ImsLti/src/ImsLtiServiceDeleteRequest.php | 2 +- .../ImsLti/src/ImsLtiServiceReadRequest.php | 2 +- .../src/ImsLtiServiceReplaceRequest.php | 2 +- .../ImsLti/src/Request/LtiTokenRequest.php | 4 +- .../src/Service/LtiAdvantageService.php | 2 +- .../Service/LtiAssignmentGradesService.php | 4 +- .../LtiNamesRoleProvisioningService.php | 2 +- .../Resource/LtiAdvantageServiceResource.php | 4 +- .../Resource/LtiContextMembershipResource.php | 2 +- .../Service/Resource/LtiLineItemResource.php | 2 +- .../Service/Resource/LtiLineItemsResource.php | 5 +- .../Service/Resource/LtiResultsResource.php | 2 +- .../Service/Resource/LtiScoresResource.php | 6 +- public/plugin/ImsLti/start.php | 8 +- public/plugin/ImsLti/token.php | 2 +- public/plugin/ImsLti/tool_settings.php | 6 +- public/plugin/ImsLti/uninstall.php | 2 + public/plugin/ImsLti/view/add.tpl | 10 +- public/plugin/ImsLti/view/admin.tpl | 16 +- 48 files changed, 352 insertions(+), 788 deletions(-) diff --git a/public/plugin/ImsLti/Entity/ImsLtiTool.php b/public/plugin/ImsLti/Entity/ImsLtiTool.php index d51b45ac181..9e9df83b538 100644 --- a/public/plugin/ImsLti/Entity/ImsLtiTool.php +++ b/public/plugin/ImsLti/Entity/ImsLtiTool.php @@ -1,4 +1,5 @@ false])] + private bool $activeDeepLinking; + + #[ORM\Column(name: 'privacy', type: 'text', nullable: true, options: ['default' => null])] + private ?string $privacy; + + #[ORM\ManyToOne(targetEntity: Course::class)] + #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id')] + private ?Course $course; + + #[ORM\ManyToOne(targetEntity: Session::class)] + #[ORM\JoinColumn(name: 'session_id', referencedColumnName: 'id')] + private ?Session $session; + + #[ORM\ManyToOne(targetEntity: GradebookEvaluation::class)] + #[ORM\JoinColumn(name: 'gradebook_eval_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + private ?GradebookEvaluation $gradebookEval; + + #[ORM\ManyToOne(targetEntity: ImsLtiTool::class, inversedBy: 'children')] + #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + private ?ImsLtiTool $parent; + + #[ORM\OneToMany(mappedBy: 'parent', targetEntity: ImsLtiTool::class)] + private Collection $children; + + #[ORM\Column(name: 'client_id', type: 'string', nullable: true)] + private ?string $clientId; + + #[ORM\Column(name: 'login_url', type: 'string', nullable: true)] + private ?string $loginUrl; + + #[ORM\Column(name: 'redirect_url', type: 'string', nullable: true)] + private ?string $redirectUrl; + + #[ORM\Column(name: 'jwks_url', type: 'string', nullable: true)] + private ?string $jwksUrl; + + #[ORM\Column(name: 'advantage_services', type: 'json', nullable: true)] + private ?array $advantageServices; + + #[ORM\OneToMany(mappedBy: 'tool', targetEntity: LineItem::class)] + private Collection $lineItems; + + #[ORM\Column(name: 'version', type: 'string', options: ['default' => 'lti1p1'])] + private string $version; + + #[ORM\Column(name: 'launch_presentation', type: 'json')] + private array $launchPresentation; + + #[ORM\Column(name: 'replacement_params', type: 'json')] + private array $replacementParams; /** * ImsLtiTool constructor. @@ -197,106 +116,65 @@ public function __construct() $this->replacementParams = []; } - /** - * @return int - */ - public function getId() + public function getId(): ?int { return $this->id; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * @param string $name - * - * @return ImsLtiTool - */ - public function setName($name) + public function setName(string $name): static { $this->name = $name; return $this; } - /** - * @return string|null - */ - public function getDescription() + public function getDescription(): ?string { return $this->description; } - /** - * @param string|null $description - * - * @return ImsLtiTool - */ - public function setDescription($description) + public function setDescription(?string $description): static { $this->description = $description; return $this; } - /** - * @return string - */ - public function getLaunchUrl() + public function getLaunchUrl(): string { return $this->launchUrl; } - /** - * @param string $launchUrl - * - * @return ImsLtiTool - */ - public function setLaunchUrl($launchUrl) + public function setLaunchUrl(string $launchUrl): static { $this->launchUrl = $launchUrl; return $this; } - /** - * @return string|null - */ - public function getCustomParams() + public function getCustomParams(): ?string { return $this->customParams; } - /** - * @param string|null $customParams - * - * @return ImsLtiTool - */ - public function setCustomParams($customParams) + public function setCustomParams(?string $customParams): static { $this->customParams = $customParams; return $this; } - /** - * @return bool - */ - public function isGlobal() + public function isGlobal(): bool { return $this->course === null; } - /** - * @return string|null - */ - public function encodeCustomParams(array $params) + public function encodeCustomParams(array $params): ?string { if (empty($params)) { return null; @@ -311,10 +189,7 @@ public function encodeCustomParams(array $params) return implode("\n", $pairs); } - /** - * @return array - */ - public function getCustomParamsAsArray() + public function getCustomParamsAsArray(): array { $params = []; $lines = explode("\n", $this->customParams); @@ -332,10 +207,7 @@ public function getCustomParamsAsArray() return $params; } - /** - * @return array - */ - public function parseCustomParams() + public function parseCustomParams(): array { if (empty($this->customParams)) { return []; @@ -359,113 +231,61 @@ public function parseCustomParams() return $params; } - /** - * Get activeDeepLinking. - * - * @return bool - */ - public function isActiveDeepLinking() + public function isActiveDeepLinking(): bool { return $this->activeDeepLinking; } - /** - * Set activeDeepLinking. - * - * @param bool $activeDeepLinking - * - * @return ImsLtiTool - */ - public function setActiveDeepLinking($activeDeepLinking) + public function setActiveDeepLinking(bool $activeDeepLinking): static { $this->activeDeepLinking = $activeDeepLinking; return $this; } - /** - * Get course. - * - * @return Course|null - */ - public function getCourse() + public function getCourse(): ?Course { return $this->course; } - /** - * Set course. - * - * @return ImsLtiTool - */ - public function setCourse(Course $course = null) + public function setCourse(?Course $course): static { $this->course = $course; return $this; } - /** - * Get session. - * - * @return Session|null - */ - public function getSession() + public function getSession(): ?Session { return $this->session; } - /** - * Set session. - * - * @param Session|null $course - * - * @return ImsLtiTool - */ - public function setSession(Session $session = null) + public function setSession(?Session $session): static { $this->session = $session; return $this; } - /** - * Get gradebookEval. - * - * @return GradebookEvaluation|null - */ - public function getGradebookEval() + public function getGradebookEval(): ?GradebookEvaluation { return $this->gradebookEval; } - /** - * Set gradebookEval. - * - * @param GradebookEvaluation|null $gradebookEval - * - * @return ImsLtiTool - */ - public function setGradebookEval($gradebookEval) + public function setGradebookEval(?GradebookEvaluation $gradebookEval): static { $this->gradebookEval = $gradebookEval; return $this; } - /** - * @return bool - */ - public function isSharingName() + public function isSharingName(): bool { $unserialize = $this->unserializePrivacy(); return (bool) $unserialize['share_name']; } - /** - * @return mixed - */ public function unserializePrivacy() { return \UnserializeApi::unserialize('not_allowed_classes', $this->privacy); @@ -474,35 +294,26 @@ public function unserializePrivacy() /** * @return bool */ - public function isSharingEmail() + public function isSharingEmail(): bool { $unserialize = $this->unserializePrivacy(); return (bool) $unserialize['share_email']; } - /** - * @return bool - */ - public function isSharingPicture() + public function isSharingPicture(): bool { $unserialize = $this->unserializePrivacy(); return (bool) $unserialize['share_picture']; } - /** - * @return ImsLtiTool|null - */ public function getParent() { return $this->parent; } - /** - * @return ImsLtiTool - */ - public function setParent(ImsLtiTool $parent) + public function setParent(ImsLtiTool $parent): static { $this->parent = $parent; @@ -513,67 +324,40 @@ public function setParent(ImsLtiTool $parent) return $this; } - /** - * @return string - */ - public function getSharedSecret() + public function getSharedSecret(): ?string { return $this->sharedSecret; } - /** - * @param string $sharedSecret - * - * @return ImsLtiTool - */ - public function setSharedSecret($sharedSecret) + public function setSharedSecret(?string $sharedSecret): static { $this->sharedSecret = $sharedSecret; return $this; } - /** - * @return string - */ - public function getConsumerKey() + public function getConsumerKey(): ?string { return $this->consumerKey; } - /** - * @param string $consumerKey - * - * @return ImsLtiTool - */ - public function setConsumerKey($consumerKey) + public function setConsumerKey(?string $consumerKey): static { $this->consumerKey = $consumerKey; return $this; } - /** - * Get privacy. - * - * @return string|null - */ - public function getPrivacy() + public function getPrivacy(): ?string { return $this->privacy; } - /** - * Set privacy. - * - * @param bool $shareName - * @param bool $shareEmail - * @param bool $sharePicture - * - * @return ImsLtiTool - */ - public function setPrivacy($shareName = false, $shareEmail = false, $sharePicture = false) - { + public function setPrivacy( + bool $shareName = false, + bool $shareEmail = false, + bool $sharePicture = false + ): static { $this->privacy = serialize( [ 'share_name' => $shareName, @@ -585,108 +369,55 @@ public function setPrivacy($shareName = false, $shareEmail = false, $sharePictur return $this; } - /** - * Get loginUrl. - * - * @return string|null - */ - public function getLoginUrl() + public function getLoginUrl(): ?string { return $this->loginUrl; } - /** - * Set loginUrl. - * - * @param string|null $loginUrl - * - * @return ImsLtiTool - */ - public function setLoginUrl($loginUrl) + public function setLoginUrl(?string $loginUrl): static { $this->loginUrl = $loginUrl; return $this; } - /** - * Get redirectUlr. - * - * @return string|null - */ - public function getRedirectUrl() + public function getRedirectUrl(): ?string { return $this->redirectUrl; } - /** - * Set redirectUrl. - * - * @param string|null $redirectUrl - * - * @return ImsLtiTool - */ - public function setRedirectUrl($redirectUrl) + public function setRedirectUrl(?string $redirectUrl): static { $this->redirectUrl = $redirectUrl; return $this; } - /** - * Get jwksUrl. - * - * @return string|null - */ - public function getJwksUrl() + public function getJwksUrl(): ?string { return $this->jwksUrl; } - /** - * Set jwksUrl. - * - * @param string|null $jwksUrl - * - * @return ImsLtiTool - */ - public function setJwksUrl($jwksUrl) + public function setJwksUrl(?string $jwksUrl): static { $this->jwksUrl = $jwksUrl; return $this; } - /** - * Get clientId. - * - * @return string - */ - public function getClientId() + public function getClientId(): ?string { return $this->clientId; } - /** - * Set clientId. - * - * @param string $clientId - * - * @return ImsLtiTool - */ - public function setClientId($clientId) + public function setClientId(?string $clientId): static { $this->clientId = $clientId; return $this; } - /** - * Get advantageServices. - * - * @return array - */ - public function getAdvantageServices() + public function getAdvantageServices(): ?array { if (empty($this->advantageServices)) { $this->advantageServices = []; @@ -701,26 +432,14 @@ public function getAdvantageServices() ); } - /** - * Set advantageServices. - * - * @param array $advantageServices - * - * @return ImsLtiTool - */ - public function setAdvantageServices($advantageServices) + public function setAdvantageServices($advantageServices): static { $this->advantageServices = $advantageServices; return $this; } - /** - * Add LineItem to lineItems. - * - * @return $this - */ - public function addLineItem(LineItem $lineItem) + public function addLineItem(LineItem $lineItem): static { $lineItem->setTool($this); @@ -729,17 +448,13 @@ public function addLineItem(LineItem $lineItem) return $this; } - /** - * @param int $resourceLinkId - * @param int $resourceId - * @param string $tag - * @param int $limit - * @param int $page - * - * @return ArrayCollection - */ - public function getLineItems($resourceLinkId = 0, $resourceId = 0, $tag = '', $limit = 0, $page = 1) - { + public function getLineItems( + int $resourceLinkId = 0, + int $resourceId = 0, + string $tag = '', + int $limit = 0, + int $page = 1 + ): Collection { $criteria = Criteria::create(); if ($resourceLinkId) { @@ -754,9 +469,6 @@ public function getLineItems($resourceLinkId = 0, $resourceId = 0, $tag = '', $l $criteria->andWhere(Criteria::expr()->eq('tag', $tag)); } - $limit = (int) $limit; - $page = (int) $page; - if ($limit > 0) { $criteria->setMaxResults($limit); @@ -768,46 +480,26 @@ public function getLineItems($resourceLinkId = 0, $resourceId = 0, $tag = '', $l return $this->lineItems->matching($criteria); } - /** - * Set lineItems. - * - * @return $this - */ - public function setLineItems(ArrayCollection $lineItems) + public function setLineItems(ArrayCollection $lineItems): static { $this->lineItems = $lineItems; return $this; } - /** - * Get version. - * - * @return string - */ - public function getVersion() + public function getVersion(): string { return $this->version; } - /** - * Set version. - * - * @param string $version - * - * @return ImsLtiTool - */ - public function setVersion($version) + public function setVersion(string $version): static { $this->version = $version; return $this; } - /** - * @return string - */ - public function getVersionName() + public function getVersionName(): string { if (\ImsLti::V_1P1 === $this->version) { return 'LTI 1.0 / 1.1'; @@ -816,58 +508,36 @@ public function getVersionName() return 'LTI 1.3'; } - /** - * @return ArrayCollection - */ - public function getChildren() + public function getChildren(): Collection { return $this->children; } - /** - * @param string $target - * - * @return $this - */ - public function setDocumenTarget($target) + public function setDocumenTarget(string $target): static { $this->launchPresentation['document_target'] = in_array($target, ['iframe', 'window']) ? $target : 'iframe'; return $this; } - /** - * @return string - */ - public function getDocumentTarget() + public function getDocumentTarget(): string { return $this->launchPresentation['document_target'] ?: 'iframe'; } - /** - * @return array - */ - public function getLaunchPresentation() + public function getLaunchPresentation(): array { return $this->launchPresentation; } - /** - * @param string $replacement - * - * @return ImsLtiTool - */ - public function setReplacementForUserId($replacement) + public function setReplacementForUserId(string $replacement): static { $this->replacementParams['user_id'] = $replacement; return $this; } - /** - * @return string|null - */ - public function getReplacementForUserId() + public function getReplacementForUserId(): ?string { if (!empty($this->replacementParams['user_id'])) { return $this->replacementParams['user_id']; @@ -876,10 +546,7 @@ public function getReplacementForUserId() return null; } - /** - * @return ArrayCollection - */ - public function getChildrenInCourses(array $coursesId) + public function getChildrenInCourses(array $coursesId): Collection { return $this->children->filter( function (ImsLtiTool $child) use ($coursesId) { @@ -889,13 +556,9 @@ function (ImsLtiTool $child) use ($coursesId) { } /** - * Map the key from custom param. - * - * @param string $key - * - * @return string + * Map the key from custom params. */ - private static function filterSpecialChars($key) + private static function filterSpecialChars(string $key): string { $newKey = ''; $key = strtolower($key); @@ -916,12 +579,7 @@ private static function filterSpecialChars($key) return $newKey; } - /** - * @param string $value - * - * @return string - */ - private static function filterSpaces($value) + private static function filterSpaces(string $value): string { $newValue = preg_replace('/\s+/', ' ', $value); diff --git a/public/plugin/ImsLti/Entity/LineItem.php b/public/plugin/ImsLti/Entity/LineItem.php index 011007e0eef..e13a926887c 100644 --- a/public/plugin/ImsLti/Entity/LineItem.php +++ b/public/plugin/ImsLti/Entity/LineItem.php @@ -4,234 +4,133 @@ namespace Chamilo\PluginBundle\ImsLti\Entity; use Chamilo\CoreBundle\Entity\GradebookEvaluation; +use DateTime; +use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; -/** - * Class LineItem. - * - * @ORM\Table(name="plugin_ims_lti_lineitem") - * @ORM\Entity() - */ +#[ORM\Table(name: 'plugin_ims_lti_lineitem')] +#[ORM\Entity] class LineItem { - /** - * @var int - * - * @ORM\Column(name="id", type="integer") - * @ORM\Id - * @ORM\GeneratedValue - */ - protected $id; - /** - * @var ImsLtiTool - * - * @ORM\ManyToOne(targetEntity="Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool", inversedBy="lineItems") - * @ORM\JoinColumn(name="tool_id", referencedColumnName="id", nullable=false, onDelete="CASCADE") - */ - private $tool; - /** - * @var GradebookEvaluation - * - * @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\GradebookEvaluation") - * @ORM\JoinColumn(name="evaluation", referencedColumnName="id", nullable=false, onDelete="CASCADE") - */ - private $evaluation; - /** - * @var string - * - * @ORM\Column(name="resource_id", type="string", nullable=true) - */ - private $resourceId; - /** - * @var string - * - * @ORM\Column(name="tag", type="string", nullable=true) - */ - private $tag; - /** - * @var \DateTime - * - * @ORM\Column(name="start_date", type="datetime", nullable=true) - */ - private $startDate; - /** - * @var \DateTime - * - * @ORM\Column(name="end_date", type="datetime", nullable=true) - */ - private $endDate; - - /** - * Get id. - * - * @return int - */ - public function getId() + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(name: 'id', type: 'integer')] + protected ?int $id = null; + + #[ORM\ManyToOne(targetEntity: ImsLtiTool::class, inversedBy: 'lineItems')] + #[ORM\JoinColumn(name: 'tool_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + private ImsLtiTool $tool; + + #[ORM\OneToOne(inversedBy: 'lineItems', targetEntity: GradebookEvaluation::class)] + #[ORM\JoinColumn(name: 'evaluation', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] + private GradebookEvaluation $evaluation; + + #[ORM\Column(name: 'resource_id', type: 'string', nullable: true)] + private ?string $resourceId; + + #[ORM\Column(name: 'tag', type: 'string', nullable: true)] + private ?string $tag; + + #[ORM\Column(name: 'start_date', type: 'datetime', nullable: true)] + private ?DateTime $startDate; + #[ORM\Column(name: 'end_date', type: 'datetime', nullable: true)] + private ?DateTime $endDate; + + public function getId(): ?int { return $this->id; } - /** - * Get tool. - * - * @return ImsLtiTool - */ - public function getTool() + public function getTool(): ImsLtiTool { return $this->tool; } - /** - * Set tool. - * - * @param ImsLtiTool $tool - * - * @return LineItem - */ - public function setTool($tool) + public function setTool(ImsLtiTool $tool): static { $this->tool = $tool; return $this; } - /** - * Get evaluation. - * - * @return GradebookEvaluation - */ - public function getEvaluation() + public function getEvaluation(): GradebookEvaluation { return $this->evaluation; } - /** - * Set evaluation. - * - * @param GradebookEvaluation $evaluation - * - * @return LineItem - */ - public function setEvaluation($evaluation) + public function setEvaluation(GradebookEvaluation $evaluation): static { $this->evaluation = $evaluation; return $this; } - /** - * Get tag. - * - * @return string - */ - public function getTag() + public function getTag(): ?string { return $this->tag; } - /** - * Set tag. - * - * @param string $tag - * - * @return LineItem - */ - public function setTag($tag) + public function setTag(?string $tag): static { $this->tag = $tag; return $this; } - /** - * Get startDate. - * - * @return \DateTime - */ - public function getStartDate() + public function getStartDate(): ?DateTime { return $this->startDate; } - /** - * Set startDate. - * - * @param \DateTime $startDate - * - * @return LineItem - */ - public function setStartDate($startDate) + public function setStartDate(?DateTime$startDate): static { $this->startDate = $startDate; return $this; } - /** - * Get endDate. - * - * @return \DateTime - */ - public function getEndDate() + public function getEndDate(): ?DateTime { return $this->endDate; } - /** - * Set endDate. - * - * @param \DateTime $endDate - * - * @return LineItem - */ - public function setEndDate($endDate) + public function setEndDate(?DateTime $endDate): static { $this->endDate = $endDate; return $this; } - /** - * @return string - */ - public function getResourceId() + public function getResourceId(): ?string { return $this->resourceId; } - /** - * @param string $resourceId - * - * @return LineItem - */ - public function setResourceId($resourceId) + public function setResourceId($resourceId): static { $this->resourceId = $resourceId; return $this; } - /** - * @return array - */ - public function toArray() + public function toArray(): array { $baseTool = $this->tool->getParent() ?: $this->tool; $data = [ 'scoreMaximum' => $this->evaluation->getMax(), - 'label' => $this->evaluation->getName(), + 'label' => $this->evaluation->getTitle(), 'tag' => (string) $this->tag, 'resourceLinkId' => (string) $baseTool->getId(), 'resourceId' => (string) $this->resourceId, ]; if ($this->startDate) { - $data['startDateTime'] = $this->startDate->format(\DateTime::ATOM); + $data['startDateTime'] = $this->startDate->format(DateTimeInterface::ATOM); } if ($this->endDate) { - $data['endDateTime'] = $this->endDate->format(\DateTime::ATOM); + $data['endDateTime'] = $this->endDate->format(DateTimeInterface::ATOM); } return $data; diff --git a/public/plugin/ImsLti/Entity/Platform.php b/public/plugin/ImsLti/Entity/Platform.php index c633f4dea6f..3b59f7a05e4 100644 --- a/public/plugin/ImsLti/Entity/Platform.php +++ b/public/plugin/ImsLti/Entity/Platform.php @@ -1,4 +1,5 @@ kid; } - public function setKid(string $kid): void + public function setKid(string $kid): static { $this->kid = $kid; + + return $this; } public function getPrivateKey(): string diff --git a/public/plugin/ImsLti/Entity/Token.php b/public/plugin/ImsLti/Entity/Token.php index a4070253cc2..9172285059a 100644 --- a/public/plugin/ImsLti/Entity/Token.php +++ b/public/plugin/ImsLti/Entity/Token.php @@ -1,4 +1,5 @@ id; } - public function getTool(): ImsLtiTool + public function getTool(): ?ImsLtiTool { return $this->tool; } - public function setTool(ImsLtiTool $tool): static + public function setTool(?ImsLtiTool $tool): static { $this->tool = $tool; diff --git a/public/plugin/ImsLti/ImsLtiPlugin.php b/public/plugin/ImsLti/ImsLtiPlugin.php index aaf0e0a0496..b71d9be6968 100644 --- a/public/plugin/ImsLti/ImsLtiPlugin.php +++ b/public/plugin/ImsLti/ImsLtiPlugin.php @@ -5,11 +5,11 @@ use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CourseBundle\Entity\CTool; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; -use Chamilo\PluginBundle\ImsLti\Entity\LineItem; -use Chamilo\PluginBundle\ImsLti\Entity\Platform; -use Chamilo\PluginBundle\ImsLti\Entity\Token; -use Chamilo\CoreBundle\Entity\User; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\LineItem; +use Chamilo\PluginBundle\Entity\ImsLti\Platform; +use Chamilo\PluginBundle\Entity\ImsLti\Token; +use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\Tools\SchemaTool; use Firebase\JWT\JWK; @@ -60,7 +60,7 @@ public static function create() */ public function get_name() { - return 'ImsLti'; + return 'ims_lti'; } /** @@ -133,7 +133,7 @@ public function uninstall() public function findCourseToolByLink(Course $course, ImsLtiTool $ltiTool) { $em = Database::getManager(); - $toolRepo = $em->getRepository(CTool::class); + $toolRepo = $em->getRepository('ChamiloCourseBundle:CTool'); /** @var CTool $cTool */ $cTool = $toolRepo->findOneBy( @@ -620,7 +620,7 @@ protected function getConfigExtraText() $text = $this->get_lang('ImsLtiDescription'); $text .= sprintf( $this->get_lang('ManageToolButton'), - api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php' + api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php' ); return $text; @@ -630,13 +630,12 @@ protected function getConfigExtraText() * Creates the plugin tables on database. * * @throws \Doctrine\ORM\Tools\ToolsException - * @throws \Doctrine\DBAL\Exception */ private function createPluginTables() { $em = Database::getManager(); - if ($em->getConnection()->createSchemaManager()->tablesExist([self::TABLE_TOOL])) { + if ($em->getConnection()->getSchemaManager()->tablesExist([self::TABLE_TOOL])) { return; }; @@ -653,14 +652,12 @@ private function createPluginTables() /** * Drops the plugin tables on database. - * - * @throws \Doctrine\DBAL\Exception */ private function dropPluginTables() { $em = Database::getManager(); - if (!$em->getConnection()->createSchemaManager()->tablesExist([self::TABLE_TOOL])) { + if (!$em->getConnection()->getSchemaManager()->tablesExist([self::TABLE_TOOL])) { return; }; @@ -677,7 +674,7 @@ private function dropPluginTables() private function removeTools() { - $sql = "DELETE FROM c_tool WHERE link LIKE 'ImsLti/start.php%' AND category = 'plugin'"; + $sql = "DELETE FROM c_tool WHERE link LIKE 'ims_lti/start.php%' AND category = 'plugin'"; Database::query($sql); } @@ -688,7 +685,7 @@ private function setCourseSettings() { $button = Display::toolbarButton( $this->get_lang('ConfigureExternalTool'), - api_get_path(WEB_PLUGIN_PATH).'ImsLti/configure.php?'.api_get_cidreq(), + api_get_path(WEB_PLUGIN_PATH).'ims_lti/configure.php?'.api_get_cidreq(), 'cog', 'primary' ); @@ -707,7 +704,7 @@ private function setCourseSettings() */ private static function generateToolLink(ImsLtiTool $tool) { - return 'ImsLti/start.php?id='.$tool->getId(); + return 'ims_lti/start.php?id='.$tool->getId(); } /** diff --git a/public/plugin/ImsLti/admin.php b/public/plugin/ImsLti/admin.php index 90b15654efb..fe1bc4ac798 100644 --- a/public/plugin/ImsLti/admin.php +++ b/public/plugin/ImsLti/admin.php @@ -39,17 +39,17 @@ } } -$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; $htmlHeadXtra[] = api_get_css( - api_get_path(WEB_PLUGIN_PATH).'ImsLti/assets/style.css' + api_get_path(WEB_PLUGIN_PATH).'ims_lti/assets/style.css' ); $template = new Template($plugin->get_title()); $template->assign('tools', $tools); $template->assign('categories', $categoriesGradeBook); -$content = $template->fetch('ImsLti/view/admin.tpl'); +$content = $template->fetch('ims_lti/view/admin.tpl'); $template->assign('header', $plugin->get_title()); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/auth.php b/public/plugin/ImsLti/auth.php index ba63241e092..46f79ac6971 100644 --- a/public/plugin/ImsLti/auth.php +++ b/public/plugin/ImsLti/auth.php @@ -1,8 +1,8 @@ isSharingName()) { - $jwtContent['name'] = $user->getFullName(); + $jwtContent['name'] = $user->getFullname(); $jwtContent['given_name'] = $user->getFirstname(); $jwtContent['family_name'] = $user->getLastname(); } @@ -185,7 +185,7 @@ 'title' => $tool->getName(), 'text' => $tool->getDescription(), 'data' => "tool:{$tool->getId()}", - 'deep_link_return_url' => $webPluginPath.'ImsLti/item_return2.php', + 'deep_link_return_url' => $webPluginPath.'ims_lti/item_return2.php', ]; } else { $jwtContent['https://purl.imsglobal.org/spec/lti/claim/message_type'] = 'LtiResourceLinkRequest'; diff --git a/public/plugin/ImsLti/configure.php b/public/plugin/ImsLti/configure.php index 376588f7d7f..f77071440a9 100644 --- a/public/plugin/ImsLti/configure.php +++ b/public/plugin/ImsLti/configure.php @@ -2,7 +2,7 @@ /* For license terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; require_once __DIR__.'/../../main/inc/global.inc.php'; @@ -255,7 +255,7 @@ $template->assign('global_tools', $globalTools); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ImsLti/view/add.tpl'); +$content = $template->fetch('ims_lti/view/add.tpl'); $actions = Display::url( Display::return_icon('add.png', $plugin->get_lang('AddExternalTool'), [], ICON_SIZE_MEDIUM), @@ -264,7 +264,7 @@ if (!empty($categories)) { $actions .= Display::url( - Display::return_icon('gradebook.png', get_lang('Add to gradebook'), [], ICON_SIZE_MEDIUM), + Display::return_icon('gradebook.png', get_lang('MakeQualifiable'), [], ICON_SIZE_MEDIUM), './gradebook/add_eval.php?selectcat='.$categories[0]->get_id().'&'.api_get_cidreq() ); } diff --git a/public/plugin/ImsLti/create.php b/public/plugin/ImsLti/create.php index ddd330c866b..7a277b460ec 100644 --- a/public/plugin/ImsLti/create.php +++ b/public/plugin/ImsLti/create.php @@ -1,6 +1,6 @@ getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } @@ -94,21 +94,21 @@ Display::return_message($plugin->get_lang('ToolAdded'), 'success') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } $form->setDefaultValues(); -$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $pageTitle = $plugin->get_lang('AddExternalTool'); $template = new Template($pageTitle); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ImsLti/view/add.tpl'); +$content = $template->fetch('ims_lti/view/add.tpl'); $template->assign('header', $pageTitle); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/delete.php b/public/plugin/ImsLti/delete.php index c7a83c9d826..1d32240d72b 100644 --- a/public/plugin/ImsLti/delete.php +++ b/public/plugin/ImsLti/delete.php @@ -1,7 +1,7 @@ getId(); +$links[] = 'ims_lti/start.php?id='.$tool->getId(); if (!$tool->getParent()) { /** @var ImsLtiTool $child */ foreach ($tool->getChildren() as $child) { - $links[] = "ImsLti/start.php?id=".$child->getId(); + $links[] = "ims_lti/start.php?id=".$child->getId(); } } @@ -39,5 +39,5 @@ Display::return_message($plugin->get_lang('ToolDeleted'), 'success') ); -header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); +header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; diff --git a/public/plugin/ImsLti/edit.php b/public/plugin/ImsLti/edit.php index 9af94f14940..7e0f709fef4 100644 --- a/public/plugin/ImsLti/edit.php +++ b/public/plugin/ImsLti/edit.php @@ -1,7 +1,7 @@ get_lang('NoTool'), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } @@ -126,19 +126,19 @@ Display::return_message($plugin->get_lang('ToolEdited'), 'success') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } else { $form->setDefaultValues(); } -$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('EditExternalTool')); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ImsLti/view/add.tpl'); +$content = $template->fetch('ims_lti/view/add.tpl'); $template->assign('header', $plugin->get_title()); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/form.php b/public/plugin/ImsLti/form.php index eb519887a95..7f0a9bf065f 100644 --- a/public/plugin/ImsLti/form.php +++ b/public/plugin/ImsLti/form.php @@ -1,7 +1,7 @@ build_basic_form(); - $this->addButtonCreate(get_lang('Add this classroom activity to the assessment'), 'submit'); + $this->addButtonCreate(get_lang('AddAssessment'), 'submit'); } /** @@ -67,7 +67,7 @@ private function build_basic_form($edit = 0) $this->addText( 'name', - get_lang('Assessment'), + get_lang('EvaluationName'), true, [ 'maxlength' => '50', @@ -87,11 +87,11 @@ private function build_basic_form($edit = 0) $select_gradebook = $this->addElement( 'select', 'hid_category_id', - get_lang('Select assessment'), + get_lang('SelectGradebook'), [], ['id' => 'hid_category_id'] ); - $this->addRule('hid_category_id', get_lang('Required field'), 'nonzero'); + $this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'nonzero'); $default_weight = 0; if (!empty($all_categories)) { foreach ($all_categories as $my_cat) { @@ -135,7 +135,7 @@ private function build_basic_form($edit = 0) if (!$this->evaluation_object->has_results()) { $this->addText( 'max', - get_lang('Maximum score'), + get_lang('QualificationNumeric'), true, [ 'maxlength' => '5', @@ -144,7 +144,7 @@ private function build_basic_form($edit = 0) } else { $this->addText( 'max', - [get_lang('Maximum score'), get_lang('Cannot change the score')], + [get_lang('QualificationNumeric'), get_lang('CannotChangeTheMaxNote')], false, [ 'maxlength' => '5', @@ -155,7 +155,7 @@ private function build_basic_form($edit = 0) } else { $this->addText( 'max', - get_lang('Maximum score'), + get_lang('QualificationNumeric'), true, [ 'maxlength' => '5', @@ -167,12 +167,12 @@ private function build_basic_form($edit = 0) } $this->addElement('textarea', 'description', get_lang('Description')); - $this->addRule('hid_category_id', get_lang('Required field'), 'required'); + $this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'required'); $this->addElement('checkbox', 'visible', null, get_lang('Visible')); - $this->addRule('max', get_lang('Only numbers'), 'numeric'); + $this->addRule('max', get_lang('OnlyNumbers'), 'numeric'); $this->addRule( 'max', - get_lang('Negative value'), + get_lang('NegativeValue'), 'compare', '>=', 'server', diff --git a/public/plugin/ImsLti/gradebook/add_eval.php b/public/plugin/ImsLti/gradebook/add_eval.php index 102954b4512..b360ae4fdba 100644 --- a/public/plugin/ImsLti/gradebook/add_eval.php +++ b/public/plugin/ImsLti/gradebook/add_eval.php @@ -1,9 +1,12 @@ find(Course::class, api_get_course_int_id()); +/** @var \Chamilo\CoreBundle\Entity\Course $course */ +$course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id()); $ltiToolRepo = $em->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); $categories = Category::load(null, null, $course->getCode(), null, null, $sessionId); @@ -56,7 +59,7 @@ $form->removeElement('addresult'); $slcLtiTools = $form->createElement('select', 'name', get_lang('Tool')); $form->insertElementBefore($slcLtiTools, 'hid_category_id'); -$form->addRule('name', get_lang('Required field'), 'required'); +$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); $ltiTools = $ltiToolRepo->findBy(['course' => $course, 'gradebookEval' => null]); @@ -99,7 +102,7 @@ $eval->add(); /** @var GradebookEvaluation $gradebookEval */ - $gradebookEval = $em->find(GradebookEvaluation::class, $eval->get_id()); + $gradebookEval = $em->find('ChamiloCoreBundle:GradebookEvaluation', $eval->get_id()); $ltiTool->setGradebookEval($gradebookEval); $em->persist($ltiTool); @@ -135,7 +138,7 @@ }); '; -Display::display_header(get_lang('Add classroom activity')); +Display::display_header(get_lang('NewEvaluation')); $form->display(); diff --git a/public/plugin/ImsLti/install.php b/public/plugin/ImsLti/install.php index 8bdf7cb6842..fddf295c7df 100644 --- a/public/plugin/ImsLti/install.php +++ b/public/plugin/ImsLti/install.php @@ -3,6 +3,8 @@ /** * Install the MSI/LTI Plugin. + * + * @package chamilo.plugin.ims_lti */ if (!api_is_platform_admin()) { exit('You must have admin permissions to install plugins'); diff --git a/public/plugin/ImsLti/item_return.php b/public/plugin/ImsLti/item_return.php index 9b4dfac3df2..a62b241aa15 100644 --- a/public/plugin/ImsLti/item_return.php +++ b/public/plugin/ImsLti/item_return.php @@ -2,7 +2,7 @@ /* For license terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; require_once __DIR__.'/../../main/inc/global.inc.php'; @@ -18,7 +18,7 @@ $plugin = ImsLtiPlugin::create(); $em = Database::getManager(); /** @var Course $course */ -$course = $em->find(Course::class, api_get_course_int_id()); +$course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id()); /** @var ImsLtiTool|null $ltiTool */ $ltiTool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $toolId); @@ -32,7 +32,7 @@ ); $hmacMethod = new OAuthSignatureMethod_HMAC_SHA1(); -$request = OAuthRequest::from_request('POST', api_get_path(WEB_PLUGIN_PATH).'ImsLti/item_return.php'); +$request = OAuthRequest::from_request('POST', api_get_path(WEB_PLUGIN_PATH).'ims_lti/item_return.php'); $request->sign_request($hmacMethod, $consumer, ''); $signature = $request->get_parameter('oauth_signature'); @@ -55,7 +55,7 @@ } } -$currentUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/start.php?id='.$ltiTool->getId(); +$currentUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/start.php?id='.$ltiTool->getId(); ?> diff --git a/public/plugin/ImsLti/item_return2.php b/public/plugin/ImsLti/item_return2.php index bca3a92df68..03ac5e6b978 100644 --- a/public/plugin/ImsLti/item_return2.php +++ b/public/plugin/ImsLti/item_return2.php @@ -1,7 +1,7 @@ get('enabled') !== 'true') { - throw new Exception(get_lang('You are not allowed to see this page. Either your connection has expired or you are trying to access a page for which you do not have the sufficient privileges.')); + throw new Exception(get_lang('NotAllowed')); } $request = Request::createFromGlobals(); @@ -54,7 +54,7 @@ ['url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course', 'multiple' => true] ); $form->addCheckBox('all_courses', '', $plugin->get_lang('AddInAllCourses')); - $form->addCheckBox('tool_visible', get_lang('SetVisible'), get_lang('The tool is now visible.')); + $form->addCheckBox('tool_visible', get_lang('SetVisible'), get_lang('ToolIsNowVisible')); $form->addButtonExport(get_lang('Save')); if ($form->validate()) { @@ -76,7 +76,7 @@ /** @var ImsLtiTool $childInCourse */ foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { - $toolLinks[] = "ImsLti/start.php?id={$childInCourse->getId()}"; + $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; $em->remove($childInCourse); } @@ -116,10 +116,10 @@ } Display::addFlash( - Display::return_message(get_lang('Item updated')) + Display::return_message(get_lang('ItemUpdated')) ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } @@ -133,8 +133,8 @@ $content = $form->returnForm(); - $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInCourses')); $template->assign('header', $plugin->get_lang('AddInCourses')); @@ -145,5 +145,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); } diff --git a/public/plugin/ImsLti/multiply_session.php b/public/plugin/ImsLti/multiply_session.php index e72a937c2e0..30cbc5ffa2e 100644 --- a/public/plugin/ImsLti/multiply_session.php +++ b/public/plugin/ImsLti/multiply_session.php @@ -1,7 +1,7 @@ get('enabled') !== 'true') { - throw new Exception(get_lang('You are not allowed to see this page. Either your connection has expired or you are trying to access a page for which you do not have the sufficient privileges.')); + throw new Exception(get_lang('NotAllowed')); } $request = Request::createFromGlobals(); @@ -55,7 +55,7 @@ $selectedCoursesIds = array_keys($slctCourses); $form = new FormValidator('frm_multiply', 'post', api_get_self().'?id='.$tool->getId().'&session_id='.$sessionId); - $form->addLabel(get_lang('Session name'), $session); + $form->addLabel(get_lang('SessionName'), $session); $form->addLabel($plugin->get_lang('Tool'), $tool->getName()); $form->addSelectAjax( 'courses', @@ -88,7 +88,7 @@ /** @var ImsLtiTool $childInCourse */ foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { - $toolLinks[] = "ImsLti/start.php?id={$childInCourse->getId()}"; + $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; $em->remove($childInCourse); } @@ -130,10 +130,10 @@ } Display::addFlash( - Display::return_message(get_lang('Item updated')) + Display::return_message(get_lang('ItemUpdated')) ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); exit; } @@ -147,8 +147,8 @@ $content = $form->returnForm(); - $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInCourses')); $template->assign('header', $plugin->get_lang('AddInCourses')); @@ -159,5 +159,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); } diff --git a/public/plugin/ImsLti/outcome_service.php b/public/plugin/ImsLti/outcome_service.php index 8db406ac500..0f5b0bb8440 100644 --- a/public/plugin/ImsLti/outcome_service.php +++ b/public/plugin/ImsLti/outcome_service.php @@ -1,7 +1,7 @@ updateCellAttributes(1, 1, ['style' => 'font-family: monospace; font-size: 10px;']); $table->updateCellAttributes(1, 2, ['style' => 'font-family: monospace; font-size: 10px;']); -$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('PlatformKeys')); $template->assign('header', $plugin->get_lang('PlatformKeys')); diff --git a/public/plugin/ImsLti/session.php b/public/plugin/ImsLti/session.php index 0975834fc14..c4c659a57a7 100644 --- a/public/plugin/ImsLti/session.php +++ b/public/plugin/ImsLti/session.php @@ -1,7 +1,7 @@ query->getInt('id'); @@ -20,7 +20,7 @@ try { if ($plugin->get('enabled') !== 'true') { - throw new Exception(get_lang('You are not allowed here.')); + throw new Exception(get_lang('NotAllowed')); } /** @var ImsLtiTool $tool */ @@ -66,7 +66,7 @@ exit; } - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/multiply_session.php?id='.$formValues['tool_id'].'&session_id='.$formValues['sessions']); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/multiply_session.php?id='.$formValues['tool_id'].'&session_id='.$formValues['sessions']); exit; } @@ -75,8 +75,8 @@ $content = $form->returnForm(); - $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('Administration')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInSessions')); $template->assign('header', $plugin->get_lang('AddInSessions')); @@ -87,5 +87,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); } diff --git a/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php b/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php index 057e1eb9e13..1cea6138255 100644 --- a/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php +++ b/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; /** * Class LtiContentItemType. diff --git a/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php b/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php index fb448e9aab4..9745107ab24 100644 --- a/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php +++ b/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; /** * Class LtiContentItem. diff --git a/public/plugin/ImsLti/src/Form/FrmAdd.php b/public/plugin/ImsLti/src/Form/FrmAdd.php index 1dae58dfbf2..bfc13974463 100644 --- a/public/plugin/ImsLti/src/Form/FrmAdd.php +++ b/public/plugin/ImsLti/src/Form/FrmAdd.php @@ -4,7 +4,7 @@ namespace Chamilo\PluginBundle\ImsLti\Form; use Category; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; use Display; use FormValidator; use ImsLti; @@ -104,7 +104,7 @@ public function build() ); $this->addSelect( 'document_target', - get_lang("Link's target"), + get_lang('LinkTarget'), ['iframe' => 'iframe', 'window' => 'window'] ); diff --git a/public/plugin/ImsLti/src/Form/FrmEdit.php b/public/plugin/ImsLti/src/Form/FrmEdit.php index 90572c9881a..541efa71de1 100644 --- a/public/plugin/ImsLti/src/Form/FrmEdit.php +++ b/public/plugin/ImsLti/src/Form/FrmEdit.php @@ -4,7 +4,7 @@ namespace Chamilo\PluginBundle\Form; use Category; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; use Display; use Exception; use FormValidator; @@ -105,7 +105,7 @@ public function build($globalMode = true) ); $this->addSelect( 'document_target', - get_lang("Link's target"), + get_lang('LinkTarget'), ['iframe' => 'iframe', 'window' => 'window'] ); diff --git a/public/plugin/ImsLti/src/ImsLti.php b/public/plugin/ImsLti/src/ImsLti.php index 5dae928c52b..93d9395b401 100644 --- a/public/plugin/ImsLti/src/ImsLti.php +++ b/public/plugin/ImsLti/src/ImsLti.php @@ -3,8 +3,8 @@ use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; -use Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool; -use Chamilo\CoreBundle\Entity\User; +use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\UserBundle\Entity\User; /** * Class ImsLti. @@ -43,7 +43,7 @@ public static function getSubstitutableVariables( '$Person.sourcedId' => $isLti1p3 ? self::getPersonSourcedId($domain, $user) : "$domain:".ImsLtiPlugin::getLaunchUserIdClaim($tool, $user), - '$Person.name.full' => $user->getFullName(), + '$Person.name.full' => $user->getFullname(), '$Person.name.family' => $user->getLastname(), '$Person.name.given' => $user->getFirstname(), '$Person.address.street1' => $user->getAddress(), diff --git a/public/plugin/ImsLti/src/ImsLtiServiceDeleteRequest.php b/public/plugin/ImsLti/src/ImsLtiServiceDeleteRequest.php index ea84961deda..0cd180f8844 100644 --- a/public/plugin/ImsLti/src/ImsLtiServiceDeleteRequest.php +++ b/public/plugin/ImsLti/src/ImsLtiServiceDeleteRequest.php @@ -38,7 +38,7 @@ protected function processBody() $em = Database::getManager(); /** @var GradebookEvaluation $evaluation */ - $evaluation = $em->find(GradebookEvaluation::class, $sourcedParts['e']); + $evaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $sourcedParts['e']); /** @var User $user */ $user = $em->find('ChamiloUserBundle:User', $sourcedParts['u']); diff --git a/public/plugin/ImsLti/src/ImsLtiServiceReadRequest.php b/public/plugin/ImsLti/src/ImsLtiServiceReadRequest.php index 8cd00b03094..83aff51e24f 100644 --- a/public/plugin/ImsLti/src/ImsLtiServiceReadRequest.php +++ b/public/plugin/ImsLti/src/ImsLtiServiceReadRequest.php @@ -38,7 +38,7 @@ protected function processBody() $em = Database::getManager(); /** @var GradebookEvaluation $evaluation */ - $evaluation = $em->find(GradebookEvaluation::class, $sourcedParts['e']); + $evaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $sourcedParts['e']); /** @var User $user */ $user = $em->find('ChamiloUserBundle:User', $sourcedParts['u']); diff --git a/public/plugin/ImsLti/src/ImsLtiServiceReplaceRequest.php b/public/plugin/ImsLti/src/ImsLtiServiceReplaceRequest.php index 88ac913ec54..b9a09041696 100644 --- a/public/plugin/ImsLti/src/ImsLtiServiceReplaceRequest.php +++ b/public/plugin/ImsLti/src/ImsLtiServiceReplaceRequest.php @@ -57,7 +57,7 @@ protected function processBody() $em = Database::getManager(); /** @var GradebookEvaluation $evaluation */ - $evaluation = $em->find(GradebookEvaluation::class, $sourcedParts['e']); + $evaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $sourcedParts['e']); /** @var User $user */ $user = $em->find('ChamiloUserBundle:User', $sourcedParts['u']); diff --git a/public/plugin/ImsLti/src/Request/LtiTokenRequest.php b/public/plugin/ImsLti/src/Request/LtiTokenRequest.php index 116d0c974ca..ece5d023965 100644 --- a/public/plugin/ImsLti/src/Request/LtiTokenRequest.php +++ b/public/plugin/ImsLti/src/Request/LtiTokenRequest.php @@ -1,8 +1,8 @@ api_get_path(WEB_PLUGIN_PATH) - ."ImsLti/nrps2.php/{$this->course->getId()}/memberships?" + ."ims_lti/nrps2.php/{$this->course->getId()}/memberships?" .http_build_query( [ 't' => $this->tool->getId(), diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php index 6e21e89b0c1..47120842d26 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php @@ -1,7 +1,7 @@ set_visible(1); $eval->add(); - $evaluation = $em->find(GradebookEvaluation::class, $eval->get_id()); + $evaluation = $em->find('ChamiloCoreBundle:GradebookEvaluation', $eval->get_id()); $lineItem = new LineItem(); $lineItem diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php index ab541631e63..76be91cbb8e 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\GradebookResult; -use Chamilo\PluginBundle\ImsLti\Entity\LineItem; +use Chamilo\PluginBundle\Entity\ImsLti\LineItem; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\ORM\TransactionRequiredException; diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php index d910fd4e365..99631ae9d19 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php @@ -3,8 +3,8 @@ use Chamilo\CoreBundle\Entity\GradebookResult; use Chamilo\CoreBundle\Entity\GradebookResultLog; -use Chamilo\PluginBundle\ImsLti\Entity\LineItem; -use Chamilo\CoreBundle\Entity\User; +use Chamilo\PluginBundle\Entity\ImsLti\LineItem; +use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\ORM\TransactionRequiredException; @@ -144,7 +144,7 @@ private function processPost() $evaluation = $this->lineItem->getEvaluation(); $result = Database::getManager() - ->getRepository(GradebookResult::class) + ->getRepository('ChamiloCoreBundle:GradebookResult') ->findOneBy( [ 'userId' => $data['userId'], diff --git a/public/plugin/ImsLti/start.php b/public/plugin/ImsLti/start.php index e7d4081676d..dd0efdae72b 100644 --- a/public/plugin/ImsLti/start.php +++ b/public/plugin/ImsLti/start.php @@ -1,7 +1,7 @@ getLoginUrl()) && !empty($tool->getRedirectUrl()); if ($is1p3) { - $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/login.php?id='.$tool->getId(); + $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/login.php?id='.$tool->getId(); } else { - $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/form.php?'.http_build_query(['id' => $tool->getId()]); + $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/form.php?'.http_build_query(['id' => $tool->getId()]); } if ($tool->getDocumentTarget() == 'window') { @@ -43,7 +43,7 @@ $template->assign('launch_url', $launchUrl); -$content = $template->fetch('ImsLti/view/start.tpl'); +$content = $template->fetch('ims_lti/view/start.tpl'); $template->assign('header', $pageTitle); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/token.php b/public/plugin/ImsLti/token.php index 204effff2d3..51e5815ad94 100644 --- a/public/plugin/ImsLti/token.php +++ b/public/plugin/ImsLti/token.php @@ -1,7 +1,7 @@ get('enabled') !== 'true') { - throw new Exception(get_lang('Not allowed')); + throw new Exception(get_lang('Forbidden')); } /** @var ImsLtiTool $tool */ diff --git a/public/plugin/ImsLti/uninstall.php b/public/plugin/ImsLti/uninstall.php index 1dfbe91519a..1fb7c91e449 100644 --- a/public/plugin/ImsLti/uninstall.php +++ b/public/plugin/ImsLti/uninstall.php @@ -3,6 +3,8 @@ /** * Uninstall the MSI/LTI Plugin. + * + * @package chamilo.plugin.ims_lti */ if (!api_is_platform_admin()) { exit('You must have admin permissions to uninstall plugins'); diff --git a/public/plugin/ImsLti/view/add.tpl b/public/plugin/ImsLti/view/add.tpl index 5ccbe0feea8..3be9103f824 100644 --- a/public/plugin/ImsLti/view/add.tpl +++ b/public/plugin/ImsLti/view/add.tpl @@ -11,19 +11,19 @@
  • {% if tool.isActiveDeepLinking %} - + {{ 'settings.png'|img(22, 'Configure'|get_lang) }} {% endif %} {% if tool.version == 'lti1p3' %} - {{ 'webservices.png'|img(22, 'ConfigSettingsForTool'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} - + {{ 'edit.png'|img(22, 'Edit'|get_lang) }}
    @@ -44,11 +44,11 @@
  • {% if tool.isActiveDeepLinking %} - + {{ 'settings.png'|img(22, 'Configure'|get_lang) }} {% else %} - + {{ 'add.png'|img(22, 'Add'|get_lang) }} {% endif %} diff --git a/public/plugin/ImsLti/view/admin.tpl b/public/plugin/ImsLti/view/admin.tpl index ec3a46d3158..b445310c73f 100644 --- a/public/plugin/ImsLti/view/admin.tpl +++ b/public/plugin/ImsLti/view/admin.tpl @@ -22,20 +22,20 @@ {% if not is_child and tool.version == 'lti1p3' %} - {{ 'webservices.png'|img(22, 'ConfigSettingsForTool'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} {% if not is_child %} - + {{ 'multiplicate_survey.png'|img(22, 'AddInCourses'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} {% if not is_child %} - + {{ 'session.png'|img(22, 'AddInSessions'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} @@ -53,17 +53,17 @@ {% endif %} {% endif %} {% if url_eval_params is not null %} - + {{ 'gradebook.png'|img(22, 'MakeQualifiable'|get_lang) }} {% endif %} {% endfor %} {% endif %} - + {{ 'edit.png'|img(22, 'Edit'|get_lang) }} - + {{ 'delete.png'|img(22, 'Delete'|get_lang) }} @@ -74,10 +74,10 @@ {% autoescape 'html' %} From fe8b79869c232dd30ce73caa410683c05ceb4b3d Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:53:29 -0500 Subject: [PATCH 3/5] LTI: remove unused FK and columns after migration --- .../Schema/V200/Version20251002110002.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/CoreBundle/Migrations/Schema/V200/Version20251002110002.php diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20251002110002.php b/src/CoreBundle/Migrations/Schema/V200/Version20251002110002.php new file mode 100644 index 00000000000..ac99231c831 --- /dev/null +++ b/src/CoreBundle/Migrations/Schema/V200/Version20251002110002.php @@ -0,0 +1,50 @@ +getTable('lti_external_tool'); + + if ($externalTool->hasForeignKey('FK_DB0E04E491D79BD3')) { + $this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E491D79BD3"); + } + + if ($externalTool->hasForeignKey('FK_DB0E04E4727ACA70')) { + $this->addSql("ALTER TABLE lti_external_tool DROP FOREIGN KEY FK_DB0E04E4727ACA70"); + } + + if ($externalTool->hasIndex('IDX_DB0E04E4727ACA70')) { + $this->addSql("DROP INDEX IDX_DB0E04E4727ACA70 ON lti_external_tool"); + } + + if ($externalTool->hasIndex('IDX_DB0E04E491D79BD3')) { + $this->addSql("DROP INDEX IDX_DB0E04E491D79BD3 ON lti_external_tool"); + } + + if ($externalTool->hasColumn('c_id')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN c_id"); + } + + if ($externalTool->hasColumn('parent_id')) { + $this->addSql("ALTER TABLE lti_external_tool DROP COLUMN parent_id"); + } + } +} \ No newline at end of file From c54afe824f5c9fa3bf6141eaa187fd2191529787 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Fri, 3 Oct 2025 18:06:13 -0500 Subject: [PATCH 4/5] Plugin: LTI: Remove plugin entities to use LtiBundle entities --- public/plugin/ImsLti/Entity/ImsLtiTool.php | 588 ------------------ public/plugin/ImsLti/Entity/LineItem.php | 138 ---- public/plugin/ImsLti/Entity/Platform.php | 62 -- public/plugin/ImsLti/Entity/Token.php | 112 ---- public/plugin/ImsLti/ImsLtiPlugin.php | 58 +- public/plugin/ImsLti/admin.php | 3 +- public/plugin/ImsLti/auth.php | 11 +- public/plugin/ImsLti/configure.php | 13 +- public/plugin/ImsLti/create.php | 5 +- public/plugin/ImsLti/delete.php | 7 +- public/plugin/ImsLti/edit.php | 7 +- public/plugin/ImsLti/form.php | 6 +- public/plugin/ImsLti/gradebook/add_eval.php | 8 +- public/plugin/ImsLti/item_return.php | 6 +- public/plugin/ImsLti/item_return2.php | 6 +- public/plugin/ImsLti/jwks.php | 4 +- public/plugin/ImsLti/login.php | 6 +- public/plugin/ImsLti/multiply.php | 7 +- public/plugin/ImsLti/multiply_session.php | 7 +- public/plugin/ImsLti/outcome_service.php | 6 +- public/plugin/ImsLti/platform.php | 4 +- public/plugin/ImsLti/session.php | 6 +- .../src/ContentItem/LtiContentItemType.php | 4 +- .../src/ContentItem/LtiResourceLink.php | 11 +- public/plugin/ImsLti/src/Form/FrmAdd.php | 9 +- public/plugin/ImsLti/src/Form/FrmEdit.php | 9 +- public/plugin/ImsLti/src/ImsLti.php | 8 +- .../ImsLti/src/Request/LtiTokenRequest.php | 15 +- .../src/Service/LtiAdvantageService.php | 11 +- .../Resource/LtiAdvantageServiceResource.php | 14 +- .../Service/Resource/LtiLineItemResource.php | 9 +- .../Service/Resource/LtiLineItemsResource.php | 6 +- .../Service/Resource/LtiResultsResource.php | 9 +- .../Service/Resource/LtiScoresResource.php | 9 +- public/plugin/ImsLti/start.php | 6 +- public/plugin/ImsLti/token.php | 2 +- public/plugin/ImsLti/tool_settings.php | 6 +- 37 files changed, 130 insertions(+), 1068 deletions(-) delete mode 100644 public/plugin/ImsLti/Entity/ImsLtiTool.php delete mode 100644 public/plugin/ImsLti/Entity/LineItem.php delete mode 100644 public/plugin/ImsLti/Entity/Platform.php delete mode 100644 public/plugin/ImsLti/Entity/Token.php diff --git a/public/plugin/ImsLti/Entity/ImsLtiTool.php b/public/plugin/ImsLti/Entity/ImsLtiTool.php deleted file mode 100644 index 9e9df83b538..00000000000 --- a/public/plugin/ImsLti/Entity/ImsLtiTool.php +++ /dev/null @@ -1,588 +0,0 @@ - false])] - private bool $activeDeepLinking; - - #[ORM\Column(name: 'privacy', type: 'text', nullable: true, options: ['default' => null])] - private ?string $privacy; - - #[ORM\ManyToOne(targetEntity: Course::class)] - #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id')] - private ?Course $course; - - #[ORM\ManyToOne(targetEntity: Session::class)] - #[ORM\JoinColumn(name: 'session_id', referencedColumnName: 'id')] - private ?Session $session; - - #[ORM\ManyToOne(targetEntity: GradebookEvaluation::class)] - #[ORM\JoinColumn(name: 'gradebook_eval_id', referencedColumnName: 'id', onDelete: 'SET NULL')] - private ?GradebookEvaluation $gradebookEval; - - #[ORM\ManyToOne(targetEntity: ImsLtiTool::class, inversedBy: 'children')] - #[ORM\JoinColumn(name: 'parent_id', referencedColumnName: 'id', onDelete: 'CASCADE')] - private ?ImsLtiTool $parent; - - #[ORM\OneToMany(mappedBy: 'parent', targetEntity: ImsLtiTool::class)] - private Collection $children; - - #[ORM\Column(name: 'client_id', type: 'string', nullable: true)] - private ?string $clientId; - - #[ORM\Column(name: 'login_url', type: 'string', nullable: true)] - private ?string $loginUrl; - - #[ORM\Column(name: 'redirect_url', type: 'string', nullable: true)] - private ?string $redirectUrl; - - #[ORM\Column(name: 'jwks_url', type: 'string', nullable: true)] - private ?string $jwksUrl; - - #[ORM\Column(name: 'advantage_services', type: 'json', nullable: true)] - private ?array $advantageServices; - - #[ORM\OneToMany(mappedBy: 'tool', targetEntity: LineItem::class)] - private Collection $lineItems; - - #[ORM\Column(name: 'version', type: 'string', options: ['default' => 'lti1p1'])] - private string $version; - - #[ORM\Column(name: 'launch_presentation', type: 'json')] - private array $launchPresentation; - - #[ORM\Column(name: 'replacement_params', type: 'json')] - private array $replacementParams; - - /** - * ImsLtiTool constructor. - */ - public function __construct() - { - $this->description = null; - $this->customParams = null; - $this->activeDeepLinking = false; - $this->course = null; - $this->gradebookEval = null; - $this->privacy = null; - $this->children = new ArrayCollection(); - $this->consumerKey = null; - $this->sharedSecret = null; - $this->lineItems = new ArrayCollection(); - $this->version = \ImsLti::V_1P3; - $this->launchPresentation = [ - 'document_target' => 'iframe', - ]; - $this->replacementParams = []; - } - - public function getId(): ?int - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): static - { - $this->description = $description; - - return $this; - } - - public function getLaunchUrl(): string - { - return $this->launchUrl; - } - - public function setLaunchUrl(string $launchUrl): static - { - $this->launchUrl = $launchUrl; - - return $this; - } - - public function getCustomParams(): ?string - { - return $this->customParams; - } - - public function setCustomParams(?string $customParams): static - { - $this->customParams = $customParams; - - return $this; - } - - public function isGlobal(): bool - { - return $this->course === null; - } - - public function encodeCustomParams(array $params): ?string - { - if (empty($params)) { - return null; - } - - $pairs = []; - - foreach ($params as $key => $value) { - $pairs[] = "$key=$value"; - } - - return implode("\n", $pairs); - } - - public function getCustomParamsAsArray(): array - { - $params = []; - $lines = explode("\n", $this->customParams); - $lines = array_filter($lines); - - foreach ($lines as $line) { - list($key, $value) = explode('=', $line, 2); - - $key = self::filterSpecialChars($key); - $value = self::filterSpaces($value); - - $params[$key] = $value; - } - - return $params; - } - - public function parseCustomParams(): array - { - if (empty($this->customParams)) { - return []; - } - - $params = []; - $strings = explode("\n", $this->customParams); - - foreach ($strings as $string) { - if (empty($string)) { - continue; - } - - $pairs = explode('=', $string, 2); - $key = self::filterSpecialChars($pairs[0]); - $value = $pairs[1]; - - $params['custom_'.$key] = $value; - } - - return $params; - } - - public function isActiveDeepLinking(): bool - { - return $this->activeDeepLinking; - } - - public function setActiveDeepLinking(bool $activeDeepLinking): static - { - $this->activeDeepLinking = $activeDeepLinking; - - return $this; - } - - public function getCourse(): ?Course - { - return $this->course; - } - - public function setCourse(?Course $course): static - { - $this->course = $course; - - return $this; - } - - public function getSession(): ?Session - { - return $this->session; - } - - public function setSession(?Session $session): static - { - $this->session = $session; - - return $this; - } - - public function getGradebookEval(): ?GradebookEvaluation - { - return $this->gradebookEval; - } - - public function setGradebookEval(?GradebookEvaluation $gradebookEval): static - { - $this->gradebookEval = $gradebookEval; - - return $this; - } - - public function isSharingName(): bool - { - $unserialize = $this->unserializePrivacy(); - - return (bool) $unserialize['share_name']; - } - - public function unserializePrivacy() - { - return \UnserializeApi::unserialize('not_allowed_classes', $this->privacy); - } - - /** - * @return bool - */ - public function isSharingEmail(): bool - { - $unserialize = $this->unserializePrivacy(); - - return (bool) $unserialize['share_email']; - } - - public function isSharingPicture(): bool - { - $unserialize = $this->unserializePrivacy(); - - return (bool) $unserialize['share_picture']; - } - - public function getParent() - { - return $this->parent; - } - - public function setParent(ImsLtiTool $parent): static - { - $this->parent = $parent; - - $this->sharedSecret = $parent->getSharedSecret(); - $this->consumerKey = $parent->getConsumerKey(); - $this->privacy = $parent->getPrivacy(); - - return $this; - } - - public function getSharedSecret(): ?string - { - return $this->sharedSecret; - } - - public function setSharedSecret(?string $sharedSecret): static - { - $this->sharedSecret = $sharedSecret; - - return $this; - } - - public function getConsumerKey(): ?string - { - return $this->consumerKey; - } - - public function setConsumerKey(?string $consumerKey): static - { - $this->consumerKey = $consumerKey; - - return $this; - } - - public function getPrivacy(): ?string - { - return $this->privacy; - } - - public function setPrivacy( - bool $shareName = false, - bool $shareEmail = false, - bool $sharePicture = false - ): static { - $this->privacy = serialize( - [ - 'share_name' => $shareName, - 'share_email' => $shareEmail, - 'share_picture' => $sharePicture, - ] - ); - - return $this; - } - - public function getLoginUrl(): ?string - { - return $this->loginUrl; - } - - public function setLoginUrl(?string $loginUrl): static - { - $this->loginUrl = $loginUrl; - - return $this; - } - - public function getRedirectUrl(): ?string - { - return $this->redirectUrl; - } - - public function setRedirectUrl(?string $redirectUrl): static - { - $this->redirectUrl = $redirectUrl; - - return $this; - } - - public function getJwksUrl(): ?string - { - return $this->jwksUrl; - } - - public function setJwksUrl(?string $jwksUrl): static - { - $this->jwksUrl = $jwksUrl; - - return $this; - } - - public function getClientId(): ?string - { - return $this->clientId; - } - - public function setClientId(?string $clientId): static - { - $this->clientId = $clientId; - - return $this; - } - - public function getAdvantageServices(): ?array - { - if (empty($this->advantageServices)) { - $this->advantageServices = []; - } - - return array_merge( - [ - 'ags' => \LtiAssignmentGradesService::AGS_NONE, - 'nrps' => \LtiNamesRoleProvisioningService::NRPS_NONE, - ], - $this->advantageServices - ); - } - - public function setAdvantageServices($advantageServices): static - { - $this->advantageServices = $advantageServices; - - return $this; - } - - public function addLineItem(LineItem $lineItem): static - { - $lineItem->setTool($this); - - $this->lineItems[] = $lineItem; - - return $this; - } - - public function getLineItems( - int $resourceLinkId = 0, - int $resourceId = 0, - string $tag = '', - int $limit = 0, - int $page = 1 - ): Collection { - $criteria = Criteria::create(); - - if ($resourceLinkId) { - $criteria->andWhere(Criteria::expr()->eq('tool', $resourceId)); - } - - if ($resourceId) { - $criteria->andWhere(Criteria::expr()->eq('tool', $resourceId)); - } - - if (!empty($tag)) { - $criteria->andWhere(Criteria::expr()->eq('tag', $tag)); - } - - if ($limit > 0) { - $criteria->setMaxResults($limit); - - if ($page > 0) { - $criteria->setFirstResult($page * $limit); - } - } - - return $this->lineItems->matching($criteria); - } - - public function setLineItems(ArrayCollection $lineItems): static - { - $this->lineItems = $lineItems; - - return $this; - } - - public function getVersion(): string - { - return $this->version; - } - - public function setVersion(string $version): static - { - $this->version = $version; - - return $this; - } - - public function getVersionName(): string - { - if (\ImsLti::V_1P1 === $this->version) { - return 'LTI 1.0 / 1.1'; - } - - return 'LTI 1.3'; - } - - public function getChildren(): Collection - { - return $this->children; - } - - public function setDocumenTarget(string $target): static - { - $this->launchPresentation['document_target'] = in_array($target, ['iframe', 'window']) ? $target : 'iframe'; - - return $this; - } - - public function getDocumentTarget(): string - { - return $this->launchPresentation['document_target'] ?: 'iframe'; - } - - public function getLaunchPresentation(): array - { - return $this->launchPresentation; - } - - public function setReplacementForUserId(string $replacement): static - { - $this->replacementParams['user_id'] = $replacement; - - return $this; - } - - public function getReplacementForUserId(): ?string - { - if (!empty($this->replacementParams['user_id'])) { - return $this->replacementParams['user_id']; - } - - return null; - } - - public function getChildrenInCourses(array $coursesId): Collection - { - return $this->children->filter( - function (ImsLtiTool $child) use ($coursesId) { - return in_array($child->getCourse()->getId(), $coursesId); - } - ); - } - - /** - * Map the key from custom params. - */ - private static function filterSpecialChars(string $key): string - { - $newKey = ''; - $key = strtolower($key); - $split = str_split($key); - - foreach ($split as $char) { - if ( - ($char >= 'a' && $char <= 'z') || ($char >= '0' && $char <= '9') - ) { - $newKey .= $char; - - continue; - } - - $newKey .= '_'; - } - - return $newKey; - } - - private static function filterSpaces(string $value): string - { - $newValue = preg_replace('/\s+/', ' ', $value); - - return trim($newValue); - } -} diff --git a/public/plugin/ImsLti/Entity/LineItem.php b/public/plugin/ImsLti/Entity/LineItem.php deleted file mode 100644 index e13a926887c..00000000000 --- a/public/plugin/ImsLti/Entity/LineItem.php +++ /dev/null @@ -1,138 +0,0 @@ -id; - } - - public function getTool(): ImsLtiTool - { - return $this->tool; - } - - public function setTool(ImsLtiTool $tool): static - { - $this->tool = $tool; - - return $this; - } - - public function getEvaluation(): GradebookEvaluation - { - return $this->evaluation; - } - - public function setEvaluation(GradebookEvaluation $evaluation): static - { - $this->evaluation = $evaluation; - - return $this; - } - - public function getTag(): ?string - { - return $this->tag; - } - - public function setTag(?string $tag): static - { - $this->tag = $tag; - - return $this; - } - - public function getStartDate(): ?DateTime - { - return $this->startDate; - } - - public function setStartDate(?DateTime$startDate): static - { - $this->startDate = $startDate; - - return $this; - } - - public function getEndDate(): ?DateTime - { - return $this->endDate; - } - - public function setEndDate(?DateTime $endDate): static - { - $this->endDate = $endDate; - - return $this; - } - - public function getResourceId(): ?string - { - return $this->resourceId; - } - - public function setResourceId($resourceId): static - { - $this->resourceId = $resourceId; - - return $this; - } - - public function toArray(): array - { - $baseTool = $this->tool->getParent() ?: $this->tool; - - $data = [ - 'scoreMaximum' => $this->evaluation->getMax(), - 'label' => $this->evaluation->getTitle(), - 'tag' => (string) $this->tag, - 'resourceLinkId' => (string) $baseTool->getId(), - 'resourceId' => (string) $this->resourceId, - ]; - - if ($this->startDate) { - $data['startDateTime'] = $this->startDate->format(DateTimeInterface::ATOM); - } - - if ($this->endDate) { - $data['endDateTime'] = $this->endDate->format(DateTimeInterface::ATOM); - } - - return $data; - } -} diff --git a/public/plugin/ImsLti/Entity/Platform.php b/public/plugin/ImsLti/Entity/Platform.php deleted file mode 100644 index 3b59f7a05e4..00000000000 --- a/public/plugin/ImsLti/Entity/Platform.php +++ /dev/null @@ -1,62 +0,0 @@ -id; - } - - public function setId(int $id): static - { - $this->id = $id; - - return $this; - } - - public function getKid(): string - { - return $this->kid; - } - - public function setKid(string $kid): static - { - $this->kid = $kid; - - return $this; - } - - public function getPrivateKey(): string - { - return $this->privateKey; - } - - public function setPrivateKey(string $privateKey): static - { - $this->privateKey = $privateKey; - - return $this; - } -} diff --git a/public/plugin/ImsLti/Entity/Token.php b/public/plugin/ImsLti/Entity/Token.php deleted file mode 100644 index 9172285059a..00000000000 --- a/public/plugin/ImsLti/Entity/Token.php +++ /dev/null @@ -1,112 +0,0 @@ -id; - } - - public function getTool(): ?ImsLtiTool - { - return $this->tool; - } - - public function setTool(?ImsLtiTool $tool): static - { - $this->tool = $tool; - - return $this; - } - - public function getScope(): array - { - return $this->scope; - } - - public function setScope(array $scope): static - { - $this->scope = $scope; - - return $this; - } - - public function getHash(): string - { - return $this->hash; - } - - public function setHash(string $hash): static - { - $this->hash = $hash; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): static - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getExpiresAt(): int - { - return $this->expiresAt; - } - - public function setExpiresAt(int $expiresAt): static - { - $this->expiresAt = $expiresAt; - - return $this; - } - - public function getScopeInString(): string - { - return implode(' ', $this->scope); - } - - public function generateHash(): static - { - $this->hash = sha1(uniqid(mt_rand())); - - return $this; - } -} diff --git a/public/plugin/ImsLti/ImsLtiPlugin.php b/public/plugin/ImsLti/ImsLtiPlugin.php index b71d9be6968..e7d4aa639da 100644 --- a/public/plugin/ImsLti/ImsLtiPlugin.php +++ b/public/plugin/ImsLti/ImsLtiPlugin.php @@ -5,10 +5,10 @@ use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CourseBundle\Entity\CTool; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; -use Chamilo\PluginBundle\Entity\ImsLti\LineItem; -use Chamilo\PluginBundle\Entity\ImsLti\Platform; -use Chamilo\PluginBundle\Entity\ImsLti\Token; +use Chamilo\LtiBundle\Entity\ExternalTool; +use Chamilo\LtiBundle\Entity\LineItem; +use Chamilo\LtiBundle\Entity\Platform; +use Chamilo\LtiBundle\Entity\Token; use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\Tools\SchemaTool; use Firebase\JWT\JWK; @@ -88,7 +88,7 @@ public function performActionsAfterConfigure() /** @var Platform $platform */ $platform = $em - ->getRepository('ChamiloPluginBundle:ImsLti\Platform') + ->getRepository(Platform::class) ->findOneBy([]); if ($this->get('enabled') === 'true') { @@ -130,7 +130,7 @@ public function uninstall() /** * @return CTool */ - public function findCourseToolByLink(Course $course, ImsLtiTool $ltiTool) + public function findCourseToolByLink(Course $course, ExternalTool $ltiTool) { $em = Database::getManager(); $toolRepo = $em->getRepository('ChamiloCourseBundle:CTool'); @@ -149,7 +149,7 @@ public function findCourseToolByLink(Course $course, ImsLtiTool $ltiTool) /** * @throws \Doctrine\ORM\OptimisticLockException */ - public function updateCourseTool(CTool $courseTool, ImsLtiTool $ltiTool) + public function updateCourseTool(CTool $courseTool, ExternalTool $ltiTool) { $em = Database::getManager(); @@ -172,7 +172,7 @@ public function updateCourseTool(CTool $courseTool, ImsLtiTool $ltiTool) * * @throws \Doctrine\ORM\OptimisticLockException */ - public function addCourseTool(Course $course, ImsLtiTool $ltiTool, $isVisible = true) + public function addCourseTool(Course $course, ExternalTool $ltiTool, $isVisible = true) { $cTool = $this->createLinkToCourseTool( $ltiTool->getName(), @@ -198,7 +198,7 @@ public function addCourseTool(Course $course, ImsLtiTool $ltiTool, $isVisible = * * @throws \Doctrine\ORM\OptimisticLockException */ - public function addCourseSessionTool(Course $course, Session $session, ImsLtiTool $ltiTool, $isVisible = true) + public function addCourseSessionTool(Course $course, Session $session, ExternalTool $ltiTool, $isVisible = true) { $cTool = $this->createLinkToCourseTool( $ltiTool->getName(), @@ -304,7 +304,7 @@ public static function generateToolUserId($userId) /** * @return string */ - public static function getLaunchUserIdClaim(ImsLtiTool $tool, User $user) + public static function getLaunchUserIdClaim(ExternalTool $tool, User $user) { if (null !== $tool->getParent()) { $tool = $tool->getParent(); @@ -332,7 +332,7 @@ public static function getLaunchUserIdClaim(ImsLtiTool $tool, User $user) /** * @return string */ - public static function getRoleScopeMentor(User $currentUser, ImsLtiTool $tool) + public static function getRoleScopeMentor(User $currentUser, ExternalTool $tool) { $scope = self::getRoleScopeMentorAsArray($currentUser, $tool, true); @@ -346,7 +346,7 @@ public static function getRoleScopeMentor(User $currentUser, ImsLtiTool $tool) * * @return array */ - public static function getRoleScopeMentorAsArray(User $user, ImsLtiTool $tool, $generateIdForTool = false) + public static function getRoleScopeMentorAsArray(User $user, ExternalTool $tool, $generateIdForTool = false) { if (DRH !== $user->getStatus()) { return []; @@ -371,18 +371,18 @@ public static function getRoleScopeMentorAsArray(User $user, ImsLtiTool $tool, $ /** * @throws \Doctrine\ORM\OptimisticLockException */ - public function saveItemAsLtiLink(array $contentItem, ImsLtiTool $baseLtiTool, Course $course) + public function saveItemAsLtiLink(array $contentItem, ExternalTool $baseLtiTool, Course $course) { $em = Database::getManager(); - $ltiToolRepo = $em->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); + $ltiToolRepo = $em->getRepository(ExternalTool::class); $url = empty($contentItem['url']) ? $baseLtiTool->getLaunchUrl() : $contentItem['url']; - /** @var ImsLtiTool $newLtiTool */ + /** @var ExternalTool|null $newLtiTool */ $newLtiTool = $ltiToolRepo->findOneBy(['launchUrl' => $url, 'parent' => $baseLtiTool, 'course' => $course]); if (null === $newLtiTool) { - $newLtiTool = new ImsLtiTool(); + $newLtiTool = new ExternalTool(); $newLtiTool ->setLaunchUrl($url) ->setParent( @@ -449,9 +449,9 @@ public function processServiceRequest() public static function existsToolInCourse($toolId, Course $course) { $em = Database::getManager(); - $toolRepo = $em->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); + $toolRepo = $em->getRepository(ExternalTool::class); - /** @var ImsLtiTool $tool */ + /** @var ExternalTool|null $tool */ $tool = $toolRepo->findOneBy(['id' => $toolId, 'course' => $course]); return !empty($tool); @@ -509,7 +509,7 @@ public function trimParams(array &$params) /** * @return array */ - public function removeUrlParamsFromLaunchParams(ImsLtiTool $tool, array &$params) + public function removeUrlParamsFromLaunchParams(ExternalTool $tool, array &$params) { $urlQuery = parse_url($tool->getLaunchUrl(), PHP_URL_QUERY); @@ -538,12 +538,12 @@ public function doWhenDeletingCourse($courseId) $em = Database::getManager(); $q = $em ->createQuery( - 'DELETE FROM ChamiloPluginBundle:ImsLti\ImsLtiTool tool + 'DELETE FROM Chamilo\LtiBundle\ExternalTool tool WHERE tool.course = :c_id and tool.parent IS NOT NULL' ); $q->execute(['c_id' => (int) $courseId]); - $em->createQuery('DELETE FROM ChamiloPluginBundle:ImsLti\ImsLtiTool tool WHERE tool.course = :c_id') + $em->createQuery('DELETE FROM Chamilo\LtiBundle\ExternalTool tool WHERE tool.course = :c_id') ->execute(['c_id' => (int) $courseId]); } @@ -557,7 +557,7 @@ public static function getIssuerUrl() return trim($webPath, " /"); } - public static function getCoursesForParentTool(ImsLtiTool $tool, Session $session = null) + public static function getCoursesForParentTool(ExternalTool $tool, Session $session = null) { if ($tool->getParent()) { return []; @@ -566,7 +566,7 @@ public static function getCoursesForParentTool(ImsLtiTool $tool, Session $sessio $children = $tool->getChildren(); if ($session) { - $children = $children->filter(function (ImsLtiTool $tool) use ($session) { + $children = $children->filter(function (ExternalTool $tool) use ($session) { if (null === $tool->getSession()) { return false; } @@ -579,7 +579,7 @@ public static function getCoursesForParentTool(ImsLtiTool $tool, Session $sessio }); } - return $children->map(function (ImsLtiTool $tool) { + return $children->map(function (ExternalTool $tool) { return $tool->getCourse(); }); } @@ -587,11 +587,9 @@ public static function getCoursesForParentTool(ImsLtiTool $tool, Session $sessio /** * It gets the public key from jwks or rsa keys. * - * @param ImsLtiTool $tool - * * @return mixed|string|null */ - public static function getToolPublicKey(ImsLtiTool $tool) + public static function getToolPublicKey(ExternalTool $tool) { $publicKey = ''; if (!empty($tool->getJwksUrl())) { @@ -642,7 +640,7 @@ private function createPluginTables() $schemaTool = new SchemaTool($em); $schemaTool->createSchema( [ - $em->getClassMetadata(ImsLtiTool::class), + $em->getClassMetadata(ExternalTool::class), $em->getClassMetadata(LineItem::class), $em->getClassMetadata(Platform::class), $em->getClassMetadata(Token::class), @@ -664,7 +662,7 @@ private function dropPluginTables() $schemaTool = new SchemaTool($em); $schemaTool->dropSchema( [ - $em->getClassMetadata(ImsLtiTool::class), + $em->getClassMetadata(ExternalTool::class), $em->getClassMetadata(LineItem::class), $em->getClassMetadata(Platform::class), $em->getClassMetadata(Token::class), @@ -702,7 +700,7 @@ private function setCourseSettings() /** * @return string */ - private static function generateToolLink(ImsLtiTool $tool) + private static function generateToolLink(ExternalTool $tool) { return 'ims_lti/start.php?id='.$tool->getId(); } diff --git a/public/plugin/ImsLti/admin.php b/public/plugin/ImsLti/admin.php index fe1bc4ac798..f5b80b5b732 100644 --- a/public/plugin/ImsLti/admin.php +++ b/public/plugin/ImsLti/admin.php @@ -1,6 +1,7 @@ isNull('parent') ); -$tools = $em->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool')->matching($criteria); +$tools = $em->getRepository(ExternalTool::class)->matching($criteria); $categoriesGradeBook = []; foreach ($tools as $tool) { diff --git a/public/plugin/ImsLti/auth.php b/public/plugin/ImsLti/auth.php index 46f79ac6971..10e4cce688f 100644 --- a/public/plugin/ImsLti/auth.php +++ b/public/plugin/ImsLti/auth.php @@ -1,8 +1,8 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $ltiToolLogin); + ->find(ExternalTool::class, $ltiToolLogin); } catch (\Exception $e) { api_not_allowed(true); } @@ -88,9 +88,8 @@ throw LtiAuthException::unregisteredRedirectUri(); } - /** @var Platform|null $platform */ $platform = $em - ->getRepository('ChamiloPluginBundle:ImsLti\Platform') + ->getRepository(Platform::class) ->findOneBy([]); $session = api_get_session_entity(api_get_session_id()); $course = api_get_course_entity(api_get_course_int_id()); diff --git a/public/plugin/ImsLti/configure.php b/public/plugin/ImsLti/configure.php index f77071440a9..37421ba5bea 100644 --- a/public/plugin/ImsLti/configure.php +++ b/public/plugin/ImsLti/configure.php @@ -1,8 +1,7 @@ getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); +$toolsRepo = $em->getRepository(ExternalTool::class); -/** @var ImsLtiTool $baseTool */ +/** @var ExternalTool|null $baseTool */ $baseTool = isset($_REQUEST['type']) ? $toolsRepo->find(intval($_REQUEST['type'])) : null; $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : 'add'; @@ -44,7 +43,7 @@ if ($form->validate()) { $formValues = $form->getSubmitValues(); - $tool = new ImsLtiTool(); + $tool = new ExternalTool(); if ($baseTool) { $tool = clone $baseTool; @@ -157,11 +156,11 @@ $form->setDefaultValues(); break; case 'edit': - /** @var ImsLtiTool|null $tool */ + /** @var ExternalTool|null $tool */ $tool = null; if (!empty($_REQUEST['id'])) { - $tool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', (int) $_REQUEST['id']); + $tool = $em->find(ExternalTool::class, (int) $_REQUEST['id']); } if (empty($tool) || diff --git a/public/plugin/ImsLti/create.php b/public/plugin/ImsLti/create.php index 7a277b460ec..fc6338f4913 100644 --- a/public/plugin/ImsLti/create.php +++ b/public/plugin/ImsLti/create.php @@ -1,6 +1,7 @@ validate()) { $formValues = $form->exportValues(); - $externalTool = new ImsLtiTool(); + $externalTool = new ExternalTool(); $externalTool ->setName($formValues['name']) ->setDescription( diff --git a/public/plugin/ImsLti/delete.php b/public/plugin/ImsLti/delete.php index 1d32240d72b..62efdcc6253 100644 --- a/public/plugin/ImsLti/delete.php +++ b/public/plugin/ImsLti/delete.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', intval($_GET['id'])) : 0; +/** @var ExternalTool|null $tool */ +$tool = isset($_GET['id']) ? $em->find(ExternalTool::class, intval($_GET['id'])) : 0; if (!$tool) { api_not_allowed(true); @@ -22,7 +22,6 @@ $links[] = 'ims_lti/start.php?id='.$tool->getId(); if (!$tool->getParent()) { - /** @var ImsLtiTool $child */ foreach ($tool->getChildren() as $child) { $links[] = "ims_lti/start.php?id=".$child->getId(); } diff --git a/public/plugin/ImsLti/edit.php b/public/plugin/ImsLti/edit.php index 7e0f709fef4..7c226086f3c 100644 --- a/public/plugin/ImsLti/edit.php +++ b/public/plugin/ImsLti/edit.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $toolId); +/** @var ExternalTool|null $tool */ +$tool = $em->find(ExternalTool::class, $toolId); if (!$tool) { Display::addFlash( @@ -89,7 +89,6 @@ } if (null == $tool->getParent()) { - /** @var ImsLtiTool $child */ foreach ($tool->getChildren() as $child) { $child ->setLaunchUrl($tool->getLaunchUrl()) diff --git a/public/plugin/ImsLti/form.php b/public/plugin/ImsLti/form.php index 7f0a9bf065f..8526a4ca188 100644 --- a/public/plugin/ImsLti/form.php +++ b/public/plugin/ImsLti/form.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', (int) $_GET['id']) + ? $em->find(ExternalTool::class, (int) $_GET['id']) : null; if (!$tool) { diff --git a/public/plugin/ImsLti/gradebook/add_eval.php b/public/plugin/ImsLti/gradebook/add_eval.php index b360ae4fdba..6bf5b563551 100644 --- a/public/plugin/ImsLti/gradebook/add_eval.php +++ b/public/plugin/ImsLti/gradebook/add_eval.php @@ -6,7 +6,7 @@ */ use Chamilo\CoreBundle\Entity\GradebookEvaluation; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; require_once __DIR__.'/../../../main/inc/global.inc.php'; @@ -23,7 +23,7 @@ $em = Database::getManager(); /** @var \Chamilo\CoreBundle\Entity\Course $course */ $course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id()); -$ltiToolRepo = $em->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); +$ltiToolRepo = $em->getRepository(ExternalTool::class); $categories = Category::load(null, null, $course->getCode(), null, null, $sessionId); @@ -61,9 +61,9 @@ $form->insertElementBefore($slcLtiTools, 'hid_category_id'); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); +/** @var array $ltiTools */ $ltiTools = $ltiToolRepo->findBy(['course' => $course, 'gradebookEval' => null]); -/** @var ImsLtiTool $ltiTool */ foreach ($ltiTools as $ltiTool) { $slcLtiTools->addOption($ltiTool->getName(), $ltiTool->getId()); } @@ -71,7 +71,7 @@ if ($form->validate()) { $values = $form->exportValues(); - /** @var ImsLtiTool $ltiTool */ + /** @var ExternalTool|null $ltiTool */ $ltiTool = $ltiToolRepo->find($values['name']); if (!$ltiTool) { diff --git a/public/plugin/ImsLti/item_return.php b/public/plugin/ImsLti/item_return.php index a62b241aa15..efba42dde01 100644 --- a/public/plugin/ImsLti/item_return.php +++ b/public/plugin/ImsLti/item_return.php @@ -2,7 +2,7 @@ /* For license terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; require_once __DIR__.'/../../main/inc/global.inc.php'; @@ -19,8 +19,8 @@ $em = Database::getManager(); /** @var Course $course */ $course = $em->find('ChamiloCoreBundle:Course', api_get_course_int_id()); -/** @var ImsLtiTool|null $ltiTool */ -$ltiTool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $toolId); +/** @var ExternalTool|null $ltiTool */ +$ltiTool = $em->find(ExternalTool::class, $toolId); if (!$ltiTool) { api_not_allowed(); diff --git a/public/plugin/ImsLti/item_return2.php b/public/plugin/ImsLti/item_return2.php index 03ac5e6b978..743bfff528f 100644 --- a/public/plugin/ImsLti/item_return2.php +++ b/public/plugin/ImsLti/item_return2.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $toolId); + /** @var ExternalTool|null $ltiTool */ + $ltiTool = $em->find(ExternalTool::class, $toolId); if (empty($ltiTool)) { throw new Exception('LTI tool not found'); diff --git a/public/plugin/ImsLti/jwks.php b/public/plugin/ImsLti/jwks.php index 526867a21d5..f97080c8090 100644 --- a/public/plugin/ImsLti/jwks.php +++ b/public/plugin/ImsLti/jwks.php @@ -1,7 +1,7 @@ getRepository('ChamiloPluginBundle:ImsLti\Platform') + ->getRepository(Platform::class) ->findOneBy([]); if (!$platform) { diff --git a/public/plugin/ImsLti/login.php b/public/plugin/ImsLti/login.php index 9f4f12eefab..3e856e712db 100644 --- a/public/plugin/ImsLti/login.php +++ b/public/plugin/ImsLti/login.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $_GET['id']) + ? $em->find(ExternalTool::class, $_GET['id']) : null; if (!$tool) { diff --git a/public/plugin/ImsLti/multiply.php b/public/plugin/ImsLti/multiply.php index 3ef9818b488..dd6a848cd15 100644 --- a/public/plugin/ImsLti/multiply.php +++ b/public/plugin/ImsLti/multiply.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $request->query->getInt('id')); + /** @var ExternalTool|null $tool */ + $tool = $em->find(ExternalTool::class, $request->query->getInt('id')); if (!$tool) { throw new Exception($plugin->get_lang('NoTool')); @@ -74,7 +74,6 @@ if ($courseIdsToDelete) { $toolLinks = []; - /** @var ImsLtiTool $childInCourse */ foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; diff --git a/public/plugin/ImsLti/multiply_session.php b/public/plugin/ImsLti/multiply_session.php index 30cbc5ffa2e..75b87c753f7 100644 --- a/public/plugin/ImsLti/multiply_session.php +++ b/public/plugin/ImsLti/multiply_session.php @@ -1,7 +1,7 @@ query->getInt('id'); $sessionId = $request->query->getInt('session_id'); - /** @var ImsLtiTool $tool */ - $tool = $em->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $ltiToolId); + /** @var ExternalTool|null $tool */ + $tool = $em->find(ExternalTool::class, $ltiToolId); if (!$tool) { throw new Exception($plugin->get_lang('NoTool')); @@ -86,7 +86,6 @@ if ($courseIdsToDelete) { $toolLinks = []; - /** @var ImsLtiTool $childInCourse */ foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; diff --git a/public/plugin/ImsLti/outcome_service.php b/public/plugin/ImsLti/outcome_service.php index 0f5b0bb8440..987d9bcbaf4 100644 --- a/public/plugin/ImsLti/outcome_service.php +++ b/public/plugin/ImsLti/outcome_service.php @@ -1,7 +1,7 @@ getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool'); +$toolRepo = $em->getRepository(ExternalTool::class); $headers = OAuthUtil::get_headers(); @@ -31,7 +31,7 @@ $tools = $toolRepo->findBy(['consumerKey' => $authParams['oauth_consumer_key']]); $toolIsFound = false; -/** @var ImsLtiTool $tool */ +/** @var ExternalTool $tool */ foreach ($tools as $tool) { $consumer = new OAuthConsumer($tool->getConsumerKey(), $tool->getSharedSecret()); $hmacMethod = new OAuthSignatureMethod_HMAC_SHA1(); diff --git a/public/plugin/ImsLti/platform.php b/public/plugin/ImsLti/platform.php index 9b6c3c8dca0..7c4fe321d42 100644 --- a/public/plugin/ImsLti/platform.php +++ b/public/plugin/ImsLti/platform.php @@ -1,7 +1,7 @@ getRepository('ChamiloPluginBundle:ImsLti\Platform') + ->getRepository(Platform::class) ->findOneBy([]); $table = new HTML_Table(['class' => 'table table-striped']); diff --git a/public/plugin/ImsLti/session.php b/public/plugin/ImsLti/session.php index c4c659a57a7..d02a0d958b1 100644 --- a/public/plugin/ImsLti/session.php +++ b/public/plugin/ImsLti/session.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $ltiToolId); + /** @var ExternalTool|null $tool */ + $tool = $em->find(ExternalTool::class, $ltiToolId); if (!$tool) { throw new Exception($plugin->get_lang('NoTool')); diff --git a/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php b/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php index 1cea6138255..94c5847a64a 100644 --- a/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php +++ b/public/plugin/ImsLti/src/ContentItem/LtiContentItemType.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; /** * Class LtiContentItemType. @@ -19,7 +19,7 @@ public function __construct(stdClass $itemData) $this->validateItemData($itemData); } - abstract public function save(ImsLtiTool $baseTool, Course $course); + abstract public function save(ExternalTool $baseTool, Course $course); /** * @throws Exception diff --git a/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php b/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php index 9745107ab24..b284f521b89 100644 --- a/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php +++ b/public/plugin/ImsLti/src/ContentItem/LtiResourceLink.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; /** * Class LtiContentItem. @@ -52,10 +52,8 @@ class LtiResourceLink extends LtiContentItemType /** * @throws \Doctrine\ORM\OptimisticLockException - * - * @return ImsLtiTool */ - public function save(ImsLtiTool $baseTool, Course $course) + public function save(ExternalTool $baseTool, Course $course): ExternalTool { $newTool = $this->createTool($baseTool); $newTool->setActiveDeepLinking(false); @@ -119,10 +117,7 @@ protected function validateItemData(stdClass $itemData) } } - /** - * @return ImsLtiTool - */ - private function createTool(ImsLtiTool $baseTool) + private function createTool(ExternalTool $baseTool): ExternalTool { $newTool = clone $baseTool; $newTool->setParent($baseTool); diff --git a/public/plugin/ImsLti/src/Form/FrmAdd.php b/public/plugin/ImsLti/src/Form/FrmAdd.php index bfc13974463..d67442809db 100644 --- a/public/plugin/ImsLti/src/Form/FrmAdd.php +++ b/public/plugin/ImsLti/src/Form/FrmAdd.php @@ -4,7 +4,7 @@ namespace Chamilo\PluginBundle\ImsLti\Form; use Category; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; use Display; use FormValidator; use ImsLti; @@ -17,10 +17,7 @@ */ class FrmAdd extends FormValidator { - /** - * @var ImsLtiTool|null - */ - private $baseTool; + private ?ExternalTool $baseTool; /** * @var bool */ @@ -35,7 +32,7 @@ class FrmAdd extends FormValidator public function __construct( $name, $attributes = [], - ImsLtiTool $tool = null + ?ExternalTool $tool = null ) { parent::__construct($name, 'POST', '', '', $attributes, self::LAYOUT_HORIZONTAL, true); diff --git a/public/plugin/ImsLti/src/Form/FrmEdit.php b/public/plugin/ImsLti/src/Form/FrmEdit.php index 541efa71de1..815eb39f78d 100644 --- a/public/plugin/ImsLti/src/Form/FrmEdit.php +++ b/public/plugin/ImsLti/src/Form/FrmEdit.php @@ -4,7 +4,7 @@ namespace Chamilo\PluginBundle\Form; use Category; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; use Display; use Exception; use FormValidator; @@ -18,10 +18,7 @@ */ class FrmEdit extends FormValidator { - /** - * @var ImsLtiTool|null - */ - private $tool; + private ?ExternalTool $tool; /** * FrmAdd constructor. @@ -32,7 +29,7 @@ class FrmEdit extends FormValidator public function __construct( $name, $attributes = [], - ImsLtiTool $tool = null + ?ExternalTool $tool = null ) { parent::__construct($name, 'POST', '', '', $attributes, self::LAYOUT_HORIZONTAL, true); diff --git a/public/plugin/ImsLti/src/ImsLti.php b/public/plugin/ImsLti/src/ImsLti.php index 93d9395b401..2b71c348152 100644 --- a/public/plugin/ImsLti/src/ImsLti.php +++ b/public/plugin/ImsLti/src/ImsLti.php @@ -3,7 +3,7 @@ use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; +use Chamilo\LtiBundle\Entity\ExternalTool; use Chamilo\UserBundle\Entity\User; /** @@ -29,7 +29,7 @@ public static function getSubstitutableVariables( Session $session = null, $domain = '', $ltiVersion = self::V_1P1, - ImsLtiTool $tool + ExternalTool $tool ) { $isLti1p3 = $ltiVersion === self::V_1P3; @@ -99,7 +99,7 @@ public static function substituteVariablesInCustomParams( Session $session = null, $domain = '', $ltiVersion = self::V_1P1, - ImsLtiTool $tool + ExternalTool $tool ) { $substitutables = self::getSubstitutableVariables($user, $course, $session, $domain, $ltiVersion, $tool); $variables = array_keys($substitutables); @@ -182,7 +182,7 @@ public static function getCourseSectionSourcedId($domain, Course $course, Sessio * * @return array */ - public static function getAdvantageServices(ImsLtiTool $tool) + public static function getAdvantageServices(ExternalTool $tool) { return [ new LtiAssignmentGradesService($tool), diff --git a/public/plugin/ImsLti/src/Request/LtiTokenRequest.php b/public/plugin/ImsLti/src/Request/LtiTokenRequest.php index ece5d023965..cc9a44d6997 100644 --- a/public/plugin/ImsLti/src/Request/LtiTokenRequest.php +++ b/public/plugin/ImsLti/src/Request/LtiTokenRequest.php @@ -1,8 +1,8 @@ tool = Database::getManager() - ->getRepository('ChamiloPluginBundle:ImsLti\ImsLtiTool') + ->getRepository(ExternalTool::class) ->findOneBy(['clientId' => $claims['sub']]); if (!$this->tool || diff --git a/public/plugin/ImsLti/src/Service/LtiAdvantageService.php b/public/plugin/ImsLti/src/Service/LtiAdvantageService.php index b74c4e5cb97..861784410df 100644 --- a/public/plugin/ImsLti/src/Service/LtiAdvantageService.php +++ b/public/plugin/ImsLti/src/Service/LtiAdvantageService.php @@ -1,7 +1,7 @@ tool = $tool; } @@ -26,7 +23,7 @@ public function __construct(ImsLtiTool $tool) /** * @return LtiAdvantageService */ - public function setTool(ImsLtiTool $tool) + public function setTool(ExternalTool $tool) { $this->tool = $tool; diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiAdvantageServiceResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiAdvantageServiceResource.php index cbc7d9866f5..624bb4640e2 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiAdvantageServiceResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiAdvantageServiceResource.php @@ -2,8 +2,8 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; -use Chamilo\PluginBundle\Entity\ImsLti\ImsLtiTool; -use Chamilo\PluginBundle\Entity\ImsLti\Token; +use Chamilo\LtiBundle\Entity\ExternalTool; +use Chamilo\LtiBundle\Entity\Token; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\ORM\TransactionRequiredException; @@ -33,10 +33,8 @@ abstract class LtiAdvantageServiceResource * @var Course */ protected $course; - /** - * @var ImsLtiTool - */ - protected $tool; + + protected ExternalTool $tool; /** * LtiAdvantageServiceResource constructor. @@ -51,7 +49,7 @@ abstract class LtiAdvantageServiceResource public function __construct($toolId, $courseId) { $this->course = api_get_course_entity((int) $courseId); - $this->tool = Database::getManager()->find('ChamiloPluginBundle:ImsLti\ImsLtiTool', (int) $toolId); + $this->tool = Database::getManager()->find(ExternalTool::class, (int) $toolId); } /** @@ -100,7 +98,7 @@ protected function validateToken(array $allowedScopes) /** @var Token $token */ $token = Database::getManager() - ->getRepository('ChamiloPluginBundle:ImsLti\Token') + ->getRepository(Token::class) ->findOneBy(['hash' => $hash]); if (!$token) { diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php index 47120842d26..9780f59b2ee 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemResource.php @@ -1,7 +1,7 @@ lineItem = Database::getManager()->find('ChamiloPluginBundle:ImsLti\LineItem', (int) $lineItemId); + $this->lineItem = Database::getManager()->find(LineItem::class, (int) $lineItemId); } /** diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemsResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemsResource.php index 35eeeb6fec2..01b1a6995fb 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiLineItemsResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiLineItemsResource.php @@ -1,7 +1,7 @@ course->getCode()); /** @var Category $gradebookCategory */ diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php index 76be91cbb8e..16707232d2b 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiResultsResource.php @@ -2,7 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\GradebookResult; -use Chamilo\PluginBundle\Entity\ImsLti\LineItem; +use Chamilo\LtiBundle\Entity\LineItem; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; use Doctrine\ORM\TransactionRequiredException; @@ -20,10 +20,7 @@ class LtiResultsResource extends LtiAdvantageServiceResource { const URL_TEMPLATE = '/context_id/lineitems/line_item_id/results'; - /** - * @var LineItem|null - */ - private $lineItem; + private ?LineItem $lineItem; /** * LtiResultsResource constructor. @@ -40,7 +37,7 @@ public function __construct($toolId, $courseId, $lineItemId) { parent::__construct($toolId, $courseId); - $this->lineItem = Database::getManager()->find('ChamiloPluginBundle:ImsLti\LineItem', (int) $lineItemId); + $this->lineItem = Database::getManager()->find(LineItem::class, (int) $lineItemId); } /** diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php index 99631ae9d19..01ec43d54c0 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiScoresResource.php @@ -3,7 +3,7 @@ use Chamilo\CoreBundle\Entity\GradebookResult; use Chamilo\CoreBundle\Entity\GradebookResultLog; -use Chamilo\PluginBundle\Entity\ImsLti\LineItem; +use Chamilo\LtiBundle\Entity\LineItem; use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\OptimisticLockException; use Doctrine\ORM\ORMException; @@ -36,10 +36,7 @@ class LtiScoresResource extends LtiAdvantageServiceResource const GRADING_FAILED = 'Failed'; const GRADING_NOT_READY = 'NotReady'; - /** - * @var LineItem|null - */ - private $lineItem; + private ?LineItem $lineItem; /** * LtiScoresResource constructor. @@ -56,7 +53,7 @@ public function __construct($toolId, $courseId, $lineItemId) { parent::__construct($toolId, $courseId); - $this->lineItem = Database::getManager()->find('ChamiloPluginBundle:ImsLti\LineItem', (int) $lineItemId); + $this->lineItem = Database::getManager()->find(LineItem::class, (int) $lineItemId); } /** diff --git a/public/plugin/ImsLti/start.php b/public/plugin/ImsLti/start.php index dd0efdae72b..005b97b29b7 100644 --- a/public/plugin/ImsLti/start.php +++ b/public/plugin/ImsLti/start.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', intval($_GET['id'])) : null; +/** @var ExternalTool|null $tool */ +$tool = isset($_GET['id']) ? $em->find(ExternalTool::class, intval($_GET['id'])) : null; $user = api_get_user_entity( api_get_user_id() ); diff --git a/public/plugin/ImsLti/token.php b/public/plugin/ImsLti/token.php index 51e5815ad94..c2dff9500e8 100644 --- a/public/plugin/ImsLti/token.php +++ b/public/plugin/ImsLti/token.php @@ -1,7 +1,7 @@ find('ChamiloPluginBundle:ImsLti\ImsLtiTool', $request->query->get('id')); + /** @var ExternalTool|null $tool */ + $tool = $em->find(ExternalTool::class, $request->query->get('id')); if (!$tool) { throw new Exception($plugin->get_lang('NoTool')); From bd3f5f4ac16c2aae4aebe4ba106222c3f98e814d Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Fri, 3 Oct 2025 18:23:42 -0500 Subject: [PATCH 5/5] Plugin: LTI: Fix links --- public/plugin/ImsLti/ImsLtiPlugin.php | 12 ++++++------ public/plugin/ImsLti/admin.php | 4 ++-- public/plugin/ImsLti/auth.php | 2 +- public/plugin/ImsLti/configure.php | 2 +- public/plugin/ImsLti/create.php | 8 ++++---- public/plugin/ImsLti/delete.php | 6 +++--- public/plugin/ImsLti/edit.php | 8 ++++---- public/plugin/ImsLti/form.php | 2 +- public/plugin/ImsLti/item_return.php | 4 ++-- public/plugin/ImsLti/multiply.php | 10 +++++----- public/plugin/ImsLti/multiply_session.php | 10 +++++----- public/plugin/ImsLti/platform.php | 2 +- public/plugin/ImsLti/session.php | 8 ++++---- .../src/Service/LtiAssignmentGradesService.php | 4 ++-- .../Service/LtiNamesRoleProvisioningService.php | 2 +- .../Resource/LtiContextMembershipResource.php | 2 +- public/plugin/ImsLti/start.php | 6 +++--- public/plugin/ImsLti/tool_settings.php | 2 +- public/plugin/ImsLti/view/add.tpl | 10 +++++----- public/plugin/ImsLti/view/admin.tpl | 16 ++++++++-------- 20 files changed, 60 insertions(+), 60 deletions(-) diff --git a/public/plugin/ImsLti/ImsLtiPlugin.php b/public/plugin/ImsLti/ImsLtiPlugin.php index e7d4aa639da..75a7098d064 100644 --- a/public/plugin/ImsLti/ImsLtiPlugin.php +++ b/public/plugin/ImsLti/ImsLtiPlugin.php @@ -58,9 +58,9 @@ public static function create() /** * Get the plugin directory name. */ - public function get_name() + public function get_name(): string { - return 'ims_lti'; + return 'ImsLti'; } /** @@ -618,7 +618,7 @@ protected function getConfigExtraText() $text = $this->get_lang('ImsLtiDescription'); $text .= sprintf( $this->get_lang('ManageToolButton'), - api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php' + api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php' ); return $text; @@ -672,7 +672,7 @@ private function dropPluginTables() private function removeTools() { - $sql = "DELETE FROM c_tool WHERE link LIKE 'ims_lti/start.php%' AND category = 'plugin'"; + $sql = "DELETE FROM c_tool WHERE link LIKE 'ImsLti/start.php%' AND category = 'plugin'"; Database::query($sql); } @@ -683,7 +683,7 @@ private function setCourseSettings() { $button = Display::toolbarButton( $this->get_lang('ConfigureExternalTool'), - api_get_path(WEB_PLUGIN_PATH).'ims_lti/configure.php?'.api_get_cidreq(), + api_get_path(WEB_PLUGIN_PATH).'ImsLti/configure.php?'.api_get_cidreq(), 'cog', 'primary' ); @@ -702,7 +702,7 @@ private function setCourseSettings() */ private static function generateToolLink(ExternalTool $tool) { - return 'ims_lti/start.php?id='.$tool->getId(); + return 'ImsLti/start.php?id='.$tool->getId(); } /** diff --git a/public/plugin/ImsLti/admin.php b/public/plugin/ImsLti/admin.php index f5b80b5b732..869ebb99ee6 100644 --- a/public/plugin/ImsLti/admin.php +++ b/public/plugin/ImsLti/admin.php @@ -43,14 +43,14 @@ $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; $htmlHeadXtra[] = api_get_css( - api_get_path(WEB_PLUGIN_PATH).'ims_lti/assets/style.css' + api_get_path(WEB_PLUGIN_PATH).'ImsLti/assets/style.css' ); $template = new Template($plugin->get_title()); $template->assign('tools', $tools); $template->assign('categories', $categoriesGradeBook); -$content = $template->fetch('ims_lti/view/admin.tpl'); +$content = $template->fetch('ImsLti/view/admin.tpl'); $template->assign('header', $plugin->get_title()); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/auth.php b/public/plugin/ImsLti/auth.php index 10e4cce688f..7009d7e532b 100644 --- a/public/plugin/ImsLti/auth.php +++ b/public/plugin/ImsLti/auth.php @@ -184,7 +184,7 @@ 'title' => $tool->getName(), 'text' => $tool->getDescription(), 'data' => "tool:{$tool->getId()}", - 'deep_link_return_url' => $webPluginPath.'ims_lti/item_return2.php', + 'deep_link_return_url' => $webPluginPath.'ImsLti/item_return2.php', ]; } else { $jwtContent['https://purl.imsglobal.org/spec/lti/claim/message_type'] = 'LtiResourceLinkRequest'; diff --git a/public/plugin/ImsLti/configure.php b/public/plugin/ImsLti/configure.php index 37421ba5bea..a66b025ccd1 100644 --- a/public/plugin/ImsLti/configure.php +++ b/public/plugin/ImsLti/configure.php @@ -254,7 +254,7 @@ $template->assign('global_tools', $globalTools); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ims_lti/view/add.tpl'); +$content = $template->fetch('ImsLti/view/add.tpl'); $actions = Display::url( Display::return_icon('add.png', $plugin->get_lang('AddExternalTool'), [], ICON_SIZE_MEDIUM), diff --git a/public/plugin/ImsLti/create.php b/public/plugin/ImsLti/create.php index fc6338f4913..0b5250b6295 100644 --- a/public/plugin/ImsLti/create.php +++ b/public/plugin/ImsLti/create.php @@ -71,7 +71,7 @@ Display::return_message($e->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } @@ -95,21 +95,21 @@ Display::return_message($plugin->get_lang('ToolAdded'), 'success') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } $form->setDefaultValues(); $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $pageTitle = $plugin->get_lang('AddExternalTool'); $template = new Template($pageTitle); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ims_lti/view/add.tpl'); +$content = $template->fetch('ImsLti/view/add.tpl'); $template->assign('header', $pageTitle); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/delete.php b/public/plugin/ImsLti/delete.php index 62efdcc6253..6906d21b93d 100644 --- a/public/plugin/ImsLti/delete.php +++ b/public/plugin/ImsLti/delete.php @@ -19,11 +19,11 @@ } $links = []; -$links[] = 'ims_lti/start.php?id='.$tool->getId(); +$links[] = 'ImsLti/start.php?id='.$tool->getId(); if (!$tool->getParent()) { foreach ($tool->getChildren() as $child) { - $links[] = "ims_lti/start.php?id=".$child->getId(); + $links[] = "ImsLti/start.php?id=".$child->getId(); } } @@ -38,5 +38,5 @@ Display::return_message($plugin->get_lang('ToolDeleted'), 'success') ); -header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); +header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; diff --git a/public/plugin/ImsLti/edit.php b/public/plugin/ImsLti/edit.php index 7c226086f3c..bd77d5b3771 100644 --- a/public/plugin/ImsLti/edit.php +++ b/public/plugin/ImsLti/edit.php @@ -27,7 +27,7 @@ Display::return_message($plugin->get_lang('NoTool'), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } @@ -125,19 +125,19 @@ Display::return_message($plugin->get_lang('ToolEdited'), 'success') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } else { $form->setDefaultValues(); } $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('EditExternalTool')); $template->assign('form', $form->returnForm()); -$content = $template->fetch('ims_lti/view/add.tpl'); +$content = $template->fetch('ImsLti/view/add.tpl'); $template->assign('header', $plugin->get_title()); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/form.php b/public/plugin/ImsLti/form.php index 8526a4ca188..1a4cef86b6f 100644 --- a/public/plugin/ImsLti/form.php +++ b/public/plugin/ImsLti/form.php @@ -24,7 +24,7 @@ $course = api_get_course_entity(); $user = api_get_user_entity(api_get_user_id()); -$pluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; +$pluginPath = api_get_path(WEB_PLUGIN_PATH).'ImsLti/'; $toolUserId = ImsLtiPlugin::getLaunchUserIdClaim($tool, $user); $platformDomain = str_replace(['https://', 'http://'], '', api_get_setting('InstitutionUrl')); diff --git a/public/plugin/ImsLti/item_return.php b/public/plugin/ImsLti/item_return.php index efba42dde01..b52e3c40cb7 100644 --- a/public/plugin/ImsLti/item_return.php +++ b/public/plugin/ImsLti/item_return.php @@ -32,7 +32,7 @@ ); $hmacMethod = new OAuthSignatureMethod_HMAC_SHA1(); -$request = OAuthRequest::from_request('POST', api_get_path(WEB_PLUGIN_PATH).'ims_lti/item_return.php'); +$request = OAuthRequest::from_request('POST', api_get_path(WEB_PLUGIN_PATH).'ImsLti/item_return.php'); $request->sign_request($hmacMethod, $consumer, ''); $signature = $request->get_parameter('oauth_signature'); @@ -55,7 +55,7 @@ } } -$currentUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/start.php?id='.$ltiTool->getId(); +$currentUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/start.php?id='.$ltiTool->getId(); ?> diff --git a/public/plugin/ImsLti/multiply.php b/public/plugin/ImsLti/multiply.php index dd6a848cd15..2c50561cba5 100644 --- a/public/plugin/ImsLti/multiply.php +++ b/public/plugin/ImsLti/multiply.php @@ -11,7 +11,7 @@ api_protect_admin_script(); $plugin = ImsLtiPlugin::create(); -$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; +$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ImsLti/'; $em = Database::getManager(); @@ -75,7 +75,7 @@ $toolLinks = []; foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { - $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; + $toolLinks[] = "ImsLti/start.php?id={$childInCourse->getId()}"; $em->remove($childInCourse); } @@ -118,7 +118,7 @@ Display::return_message(get_lang('ItemUpdated')) ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } @@ -133,7 +133,7 @@ $content = $form->returnForm(); $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInCourses')); $template->assign('header', $plugin->get_lang('AddInCourses')); @@ -144,5 +144,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); } diff --git a/public/plugin/ImsLti/multiply_session.php b/public/plugin/ImsLti/multiply_session.php index 75b87c753f7..d000a38c1cd 100644 --- a/public/plugin/ImsLti/multiply_session.php +++ b/public/plugin/ImsLti/multiply_session.php @@ -11,7 +11,7 @@ api_protect_admin_script(); $plugin = ImsLtiPlugin::create(); -$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; +$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ImsLti/'; $em = Database::getManager(); @@ -87,7 +87,7 @@ $toolLinks = []; foreach ($tool->getChildrenInCourses($courseIdsToDelete) as $childInCourse) { - $toolLinks[] = "ims_lti/start.php?id={$childInCourse->getId()}"; + $toolLinks[] = "ImsLti/start.php?id={$childInCourse->getId()}"; $em->remove($childInCourse); } @@ -132,7 +132,7 @@ Display::return_message(get_lang('ItemUpdated')) ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); exit; } @@ -147,7 +147,7 @@ $content = $form->returnForm(); $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInCourses')); $template->assign('header', $plugin->get_lang('AddInCourses')); @@ -158,5 +158,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); } diff --git a/public/plugin/ImsLti/platform.php b/public/plugin/ImsLti/platform.php index 7c4fe321d42..7f684c69c16 100644 --- a/public/plugin/ImsLti/platform.php +++ b/public/plugin/ImsLti/platform.php @@ -31,7 +31,7 @@ $table->updateCellAttributes(1, 2, ['style' => 'font-family: monospace; font-size: 10px;']); $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; -$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; +$interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('PlatformKeys')); $template->assign('header', $plugin->get_lang('PlatformKeys')); diff --git a/public/plugin/ImsLti/session.php b/public/plugin/ImsLti/session.php index d02a0d958b1..510c1154ef7 100644 --- a/public/plugin/ImsLti/session.php +++ b/public/plugin/ImsLti/session.php @@ -11,7 +11,7 @@ api_protect_admin_script(); $plugin = ImsLtiPlugin::create(); -$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; +$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ImsLti/'; $request = Request::createFromGlobals(); $ltiToolId = $request->query->getInt('id'); @@ -66,7 +66,7 @@ exit; } - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/multiply_session.php?id='.$formValues['tool_id'].'&session_id='.$formValues['sessions']); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/multiply_session.php?id='.$formValues['tool_id'].'&session_id='.$formValues['sessions']); exit; } @@ -76,7 +76,7 @@ $content = $form->returnForm(); $interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'admin/index.php', 'name' => get_lang('PlatformAdmin')]; - $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php', 'name' => $plugin->get_title()]; + $interbreadcrumb[] = ['url' => api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php', 'name' => $plugin->get_title()]; $template = new Template($plugin->get_lang('AddInSessions')); $template->assign('header', $plugin->get_lang('AddInSessions')); @@ -87,5 +87,5 @@ Display::return_message($exception->getMessage(), 'error') ); - header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/admin.php'); + header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ImsLti/admin.php'); } diff --git a/public/plugin/ImsLti/src/Service/LtiAssignmentGradesService.php b/public/plugin/ImsLti/src/Service/LtiAssignmentGradesService.php index d1bfcfa75bb..7617a8b188e 100644 --- a/public/plugin/ImsLti/src/Service/LtiAssignmentGradesService.php +++ b/public/plugin/ImsLti/src/Service/LtiAssignmentGradesService.php @@ -106,7 +106,7 @@ public static function getResource(Request $request, JsonResponse $response) */ public static function getLineItemsUrl($contextId, $toolId, array $extraParams = []) { - $base = api_get_path(WEB_PLUGIN_PATH).'ims_lti/ags2.php'; + $base = api_get_path(WEB_PLUGIN_PATH).'ImsLti/ags2.php'; $resource = str_replace( 'context_id', $contextId, @@ -127,7 +127,7 @@ public static function getLineItemsUrl($contextId, $toolId, array $extraParams = */ public static function getLineItemUrl($contextId, $lineItemId, $toolId) { - $base = api_get_path(WEB_PLUGIN_PATH).'ims_lti/ags2.php'; + $base = api_get_path(WEB_PLUGIN_PATH).'ImsLti/ags2.php'; $resource = str_replace( ['context_id', 'line_item_id'], [$contextId, $lineItemId], diff --git a/public/plugin/ImsLti/src/Service/LtiNamesRoleProvisioningService.php b/public/plugin/ImsLti/src/Service/LtiNamesRoleProvisioningService.php index 616a84dd9aa..7265f04d966 100644 --- a/public/plugin/ImsLti/src/Service/LtiNamesRoleProvisioningService.php +++ b/public/plugin/ImsLti/src/Service/LtiNamesRoleProvisioningService.php @@ -69,7 +69,7 @@ public static function getResource(Request $request, JsonResponse $response) */ public static function getUrl($toolId, $courseId, $sessionId = 0, $extraParams = []) { - $base = api_get_path(WEB_PLUGIN_PATH).'ims_lti/nrps2.php'; + $base = api_get_path(WEB_PLUGIN_PATH).'ImsLti/nrps2.php'; $resource = str_replace( 'context_id', $courseId, diff --git a/public/plugin/ImsLti/src/Service/Resource/LtiContextMembershipResource.php b/public/plugin/ImsLti/src/Service/Resource/LtiContextMembershipResource.php index 0b2c798aed5..bcec23f10fc 100644 --- a/public/plugin/ImsLti/src/Service/Resource/LtiContextMembershipResource.php +++ b/public/plugin/ImsLti/src/Service/Resource/LtiContextMembershipResource.php @@ -222,7 +222,7 @@ private function getGetData(array $members) return [ 'id' => api_get_path(WEB_PLUGIN_PATH) - ."ims_lti/nrps2.php/{$this->course->getId()}/memberships?" + ."ImsLti/nrps2.php/{$this->course->getId()}/memberships?" .http_build_query( [ 't' => $this->tool->getId(), diff --git a/public/plugin/ImsLti/start.php b/public/plugin/ImsLti/start.php index 005b97b29b7..bd3d56b9a7f 100644 --- a/public/plugin/ImsLti/start.php +++ b/public/plugin/ImsLti/start.php @@ -28,9 +28,9 @@ !empty($tool->getLoginUrl()) && !empty($tool->getRedirectUrl()); if ($is1p3) { - $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/login.php?id='.$tool->getId(); + $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/login.php?id='.$tool->getId(); } else { - $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ims_lti/form.php?'.http_build_query(['id' => $tool->getId()]); + $launchUrl = api_get_path(WEB_PLUGIN_PATH).'ImsLti/form.php?'.http_build_query(['id' => $tool->getId()]); } if ($tool->getDocumentTarget() == 'window') { @@ -43,7 +43,7 @@ $template->assign('launch_url', $launchUrl); -$content = $template->fetch('ims_lti/view/start.tpl'); +$content = $template->fetch('ImsLti/view/start.tpl'); $template->assign('header', $pageTitle); $template->assign('content', $content); diff --git a/public/plugin/ImsLti/tool_settings.php b/public/plugin/ImsLti/tool_settings.php index 671f90b0a1c..5899aa2c790 100644 --- a/public/plugin/ImsLti/tool_settings.php +++ b/public/plugin/ImsLti/tool_settings.php @@ -12,7 +12,7 @@ api_block_anonymous_users(false); $plugin = ImsLtiPlugin::create(); -$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ims_lti/'; +$webPluginPath = api_get_path(WEB_PLUGIN_PATH).'ImsLti/'; $request = Request::createFromGlobals(); $response = new Response(); diff --git a/public/plugin/ImsLti/view/add.tpl b/public/plugin/ImsLti/view/add.tpl index 3be9103f824..5ccbe0feea8 100644 --- a/public/plugin/ImsLti/view/add.tpl +++ b/public/plugin/ImsLti/view/add.tpl @@ -11,19 +11,19 @@
  • {% if tool.isActiveDeepLinking %} - + {{ 'settings.png'|img(22, 'Configure'|get_lang) }} {% endif %} {% if tool.version == 'lti1p3' %} - {{ 'webservices.png'|img(22, 'ConfigSettingsForTool'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} - + {{ 'edit.png'|img(22, 'Edit'|get_lang) }}
    @@ -44,11 +44,11 @@
  • {% if tool.isActiveDeepLinking %} - + {{ 'settings.png'|img(22, 'Configure'|get_lang) }} {% else %} - + {{ 'add.png'|img(22, 'Add'|get_lang) }} {% endif %} diff --git a/public/plugin/ImsLti/view/admin.tpl b/public/plugin/ImsLti/view/admin.tpl index b445310c73f..ec3a46d3158 100644 --- a/public/plugin/ImsLti/view/admin.tpl +++ b/public/plugin/ImsLti/view/admin.tpl @@ -22,20 +22,20 @@ {% if not is_child and tool.version == 'lti1p3' %} - {{ 'webservices.png'|img(22, 'ConfigSettingsForTool'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} {% if not is_child %} - + {{ 'multiplicate_survey.png'|img(22, 'AddInCourses'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} {% if not is_child %} - + {{ 'session.png'|img(22, 'AddInSessions'|get_plugin_lang('ImsLtiPlugin')) }} {% endif %} @@ -53,17 +53,17 @@ {% endif %} {% endif %} {% if url_eval_params is not null %} - + {{ 'gradebook.png'|img(22, 'MakeQualifiable'|get_lang) }} {% endif %} {% endfor %} {% endif %} - + {{ 'edit.png'|img(22, 'Edit'|get_lang) }} - + {{ 'delete.png'|img(22, 'Delete'|get_lang) }} @@ -74,10 +74,10 @@ {% autoescape 'html' %}