diff --git a/public/plugin/GradingElectronic/src/GradingElectronicPlugin.php b/public/plugin/GradingElectronic/src/GradingElectronicPlugin.php index 946334e9312..48e58380446 100644 --- a/public/plugin/GradingElectronic/src/GradingElectronicPlugin.php +++ b/public/plugin/GradingElectronic/src/GradingElectronicPlugin.php @@ -45,6 +45,7 @@ public static function create() public function install() { $this->setUpExtraFields(); + $this->setUpDatabaseTables(); } /** @@ -801,6 +802,79 @@ private function setDownExtraFields() } + /** + * Create plugin-specific migration support tables. + * + * These tables keep custom grading/tracking structures outside the core schema. + * They intentionally use generic plugin table names instead of the legacy table names. + */ + private function setUpDatabaseTables(): void + { + Database::query(<<<'SQL' +CREATE TABLE IF NOT EXISTS plugin_grading_electronic_lp_completion ( + id BIGINT AUTO_INCREMENT NOT NULL, + course_id INT NOT NULL, + user_id BIGINT NOT NULL, + lp_id INT NOT NULL, + completion_status VARCHAR(250) NOT NULL, + INDEX idx_pge_lp_completion_course_user_lp (course_id, user_id, lp_id), + INDEX idx_pge_lp_completion_lp (lp_id), + PRIMARY KEY(id) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC +SQL); + + Database::query(<<<'SQL' +CREATE TABLE IF NOT EXISTS plugin_grading_electronic_lp_schedule ( + id INT AUTO_INCREMENT NOT NULL, + course_id BIGINT NOT NULL, + lp_id BIGINT NOT NULL, + title VARCHAR(100) DEFAULT NULL, + week_day VARCHAR(100) DEFAULT NULL, + INDEX idx_pge_lp_schedule_course_lp (course_id, lp_id), + PRIMARY KEY(id) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC +SQL); + + Database::query(<<<'SQL' +CREATE TABLE IF NOT EXISTS plugin_grading_electronic_forum_thread_comment ( + id BIGINT AUTO_INCREMENT NOT NULL, + sender_user_id BIGINT NOT NULL, + receiver_user_id BIGINT NOT NULL, + forum_id BIGINT NOT NULL, + thread_id BIGINT NOT NULL, + comment BLOB NOT NULL, + INDEX idx_pge_forum_thread_comment_forum_thread (forum_id, thread_id), + INDEX idx_pge_forum_thread_comment_receiver (receiver_user_id), + INDEX idx_pge_forum_thread_comment_sender (sender_user_id), + PRIMARY KEY(id) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC +SQL); + + Database::query(<<<'SQL' +CREATE TABLE IF NOT EXISTS plugin_grading_electronic_user_session_tracking ( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id BIGINT NOT NULL, + session_time VARCHAR(200) NOT NULL, + is_active INT NOT NULL DEFAULT 1, + INDEX idx_pge_user_session_tracking_user_active (user_id, is_active), + PRIMARY KEY(id) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC +SQL); + + Database::query(<<<'SQL' +CREATE TABLE IF NOT EXISTS plugin_grading_electronic_unregistration_log ( + id BIGINT AUTO_INCREMENT NOT NULL, + user_id INT NOT NULL, + course_id INT NOT NULL, + deleted_at_legacy VARCHAR(500) NOT NULL, + last_access_legacy VARCHAR(500) NOT NULL, + INDEX idx_pge_unregistration_user_course (user_id, course_id), + PRIMARY KEY(id) +) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC +SQL); + } + + private function getCurrentPluginRegion(): string { $requestUri = $_SERVER['REQUEST_URI'] ?? ''; diff --git a/src/CoreBundle/Migrations/Schema/V210/Version20260611183000.php b/src/CoreBundle/Migrations/Schema/V210/Version20260611183000.php new file mode 100644 index 00000000000..3215e1736ac --- /dev/null +++ b/src/CoreBundle/Migrations/Schema/V210/Version20260611183000.php @@ -0,0 +1,37 @@ +hasTable('c_lp_view')) { + return; + } + + $table = $schema->getTable('c_lp_view'); + + if (!$table->hasColumn('compdate')) { + $this->addSql('ALTER TABLE c_lp_view ADD compdate DATE DEFAULT NULL'); + } + } + + public function down(Schema $schema): void + { + // Intentionally left empty. + // The completion date can be part of migrated tracking/legal evidence. + } +} diff --git a/src/CourseBundle/Entity/CLpView.php b/src/CourseBundle/Entity/CLpView.php index 83b4b90d650..f8b8ee81437 100644 --- a/src/CourseBundle/Entity/CLpView.php +++ b/src/CourseBundle/Entity/CLpView.php @@ -9,6 +9,7 @@ use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\User; +use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; /** @@ -51,6 +52,9 @@ class CLpView #[ORM\Column(name: 'progress', type: 'integer', nullable: true)] protected ?int $progress = null; + #[ORM\Column(name: 'compdate', type: 'date', nullable: true)] + protected ?DateTimeInterface $completionDate = null; + public function getIid(): ?int { return $this->iid; @@ -107,6 +111,18 @@ public function getProgress() return $this->progress; } + public function getCompletionDate(): ?DateTimeInterface + { + return $this->completionDate; + } + + public function setCompletionDate(?DateTimeInterface $completionDate): self + { + $this->completionDate = $completionDate; + + return $this; + } + public function getLp(): CLp { return $this->lp;