Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions public/plugin/GradingElectronic/src/GradingElectronicPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static function create()
public function install()
{
$this->setUpExtraFields();
$this->setUpDatabaseTables();
}

/**
Expand Down Expand Up @@ -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'] ?? '';
Expand Down
37 changes: 37 additions & 0 deletions src/CoreBundle/Migrations/Schema/V210/Version20260611183000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

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

namespace Chamilo\CoreBundle\Migrations\Schema\V210;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

final class Version20260611183000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return 'Add learning path completion date support.';
}

public function up(Schema $schema): void
{
if (!$schema->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.
}
}
16 changes: 16 additions & 0 deletions src/CourseBundle/Entity/CLpView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading