From 34c9463ba98956a66a01743dc1b240922c839f84 Mon Sep 17 00:00:00 2001 From: Ali Alam Date: Tue, 10 Mar 2026 10:03:29 +0800 Subject: [PATCH 1/5] integrated fileHandler class in module Free Learning --- .../units_browse_details_approvalProcess.php | 38 ++++++++++++++--- ..._browse_details_completePendingProcess.php | 41 ++++++++++++++++--- Free Learning/units_manage_addProcess.php | 13 ++++++ Free Learning/units_manage_editProcess.php | 22 +++++++++- 4 files changed, 101 insertions(+), 13 deletions(-) diff --git a/Free Learning/units_browse_details_approvalProcess.php b/Free Learning/units_browse_details_approvalProcess.php index 71d233d..6055e47 100644 --- a/Free Learning/units_browse_details_approvalProcess.php +++ b/Free Learning/units_browse_details_approvalProcess.php @@ -19,10 +19,11 @@ along with this program. If not, see . */ -use Gibbon\Http\Url; -use Gibbon\Domain\System\SettingGateway; -use Gibbon\Domain\System\DiscussionGateway; +use Gibbon\Contracts\Filesystem\FileHandler; use Gibbon\Domain\Markbook\MarkbookEntryGateway; +use Gibbon\Domain\System\DiscussionGateway; +use Gibbon\Domain\System\SettingGateway; +use Gibbon\Http\Url; use Gibbon\Module\FreeLearning\Domain\UnitStudentGateway; require_once '../../gibbon.php'; @@ -214,6 +215,7 @@ if ($exemplarWork == 'Y') { $attachment = $row['exemplarWorkThumb']; $time = time(); + $fileMetaData = null; // Move attached image file, if there is one if (!empty($_FILES['file']['tmp_name'])) { @@ -227,12 +229,15 @@ if (empty($attachment)) { $partialFail = true; + } else { + $fileMetaData = $fileUploader->getFileMetaData($attachment); } } } // Write to database $unitStudentGateway = $container->get(UnitStudentGateway::class); + $fileHandler = $container->get(FileHandler::class); $data = [ 'status' => $status, @@ -247,10 +252,33 @@ if ($collaborativeAssessment == 'Y' AND !empty($row['collaborationKey'])) { $updated = $unitStudentGateway->updateWhere(['collaborationKey' => $row['collaborationKey']], $data); + + // Record file tracking for ALL collaborators + if (!empty($fileMetaData)) { + $collaborators = $unitStudentGateway->selectBy(['collaborationKey' => $row['collaborationKey']])->fetchAll(); + + foreach ($collaborators as $collaborator) { + $gibbonFileID = $fileHandler->recordFileUpload($fileMetaData, 'freeLearningUnitStudent', $collaborator['freeLearningUnitStudentID'], 'exemplarWorkThumb'); + + if (empty($gibbonFileID)) { + $partialFail = true; + } + } + } } else { - $updated = $unitStudentGateway->update($urlParams["freeLearningUnitStudentID"], $data); - } + $freeLearningUnitStudentID = $urlParams['freeLearningUnitStudentID']; + $updated = $unitStudentGateway->update($freeLearningUnitStudentID, $data); + // Record file tracking for single student + if (!empty($fileMetaData) && !empty($freeLearningUnitStudentID)) { + $gibbonFileID = $fileHandler->recordFileUpload($fileMetaData, 'freeLearningUnitStudent', $freeLearningUnitStudentID, 'exemplarWorkThumb'); + + if (empty($gibbonFileID)) { + $partialFail = true; + } + } + } + // Attempt to notify the student and grant badges if ($statusOriginal != $status or $commentApprovalOriginal != $commentApproval) { // Only if status or comment has changed. $text = sprintf(__m('A teacher has approved your request for unit completion (%1$s).'), $urlParams["name"]); diff --git a/Free Learning/units_browse_details_completePendingProcess.php b/Free Learning/units_browse_details_completePendingProcess.php index 048b61a..1dcdc25 100644 --- a/Free Learning/units_browse_details_completePendingProcess.php +++ b/Free Learning/units_browse_details_completePendingProcess.php @@ -19,13 +19,14 @@ along with this program. If not, see . */ -use Gibbon\Http\Url; -use Gibbon\View\View; -use Gibbon\Services\Format; use Gibbon\Contracts\Comms\Mailer; -use Gibbon\Domain\System\SettingGateway; +use Gibbon\Contracts\Filesystem\FileHandler; use Gibbon\Domain\System\DiscussionGateway; +use Gibbon\Domain\System\SettingGateway; +use Gibbon\Http\Url; use Gibbon\Module\FreeLearning\Domain\UnitStudentGateway; +use Gibbon\Services\Format; +use Gibbon\View\View; require_once '../../gibbon.php'; @@ -146,6 +147,7 @@ } else { //Attempt file upload $partialFail = false; + $fileMetaData = null; //Move attached image file, if there is one if (!empty($_FILES['file']['tmp_name'])) { @@ -158,6 +160,8 @@ if (empty($location)) { $partialFail = true; + } else { + $fileMetaData = $fileUploader->getFileMetaData($location); } } else { @@ -174,6 +178,7 @@ } else { // Write to database $unitStudentGateway = $container->get(UnitStudentGateway::class); + $fileHandler = $container->get(FileHandler::class); $collaborativeAssessment = $settingGateway->getSettingByScope('Free Learning', 'collaborativeAssessment'); $data = [ @@ -183,12 +188,36 @@ 'evidenceLocation' => $location, 'timestampCompletePending' => date('Y-m-d H:i:s') ]; + if ($collaborativeAssessment == 'Y' AND !empty($row['collaborationKey'])) { $updated = $unitStudentGateway->updateWhere(['collaborationKey' => $row['collaborationKey']], $data); + + // Record file tracking for ALL collaborators + if (!empty($fileMetaData)) { + $collaborators = $unitStudentGateway->selectBy(['collaborationKey' => $row['collaborationKey']])->fetchAll(); + + foreach ($collaborators as $collaborator) { + $gibbonFileID = $fileHandler->recordFileUpload($fileMetaData, 'freeLearningUnitStudent', $collaborator['freeLearningUnitStudentID'], 'exemplarWorkThumb'); + + if (empty($gibbonFileID)) { + $partialFail = true; + } + } + } } else { - $updated = $unitStudentGateway->update($urlParams["freeLearningUnitStudentID"], $data); - } + $freeLearningUnitStudentID = $urlParams["freeLearningUnitStudentID"]; + $updated = $unitStudentGateway->update($freeLearningUnitStudentID, $data); + + // Record file tracking for single student + if (!empty($fileMetaData) && !empty($freeLearningUnitStudentID)) { + $gibbonFileID = $fileHandler->recordFileUpload($fileMetaData, 'freeLearningUnitStudent', $freeLearningUnitStudentID, 'exemplarWorkThumb'); + if (empty($gibbonFileID)) { + $partialFail = true; + } + } + } + // Insert discussion records $discussionGateway = $container->get(DiscussionGateway::class); diff --git a/Free Learning/units_manage_addProcess.php b/Free Learning/units_manage_addProcess.php index 2a8f4b9..945c7f8 100755 --- a/Free Learning/units_manage_addProcess.php +++ b/Free Learning/units_manage_addProcess.php @@ -19,6 +19,7 @@ along with this program. If not, see . */ +use Gibbon\Contracts\Filesystem\FileHandler; use Gibbon\Http\Url; require_once '../../gibbon.php'; @@ -82,6 +83,7 @@ //Move attached file, if there is one $attachment = null; + $fileMetaData = null; if (!empty($_FILES['file']['tmp_name'])) { $fileUploader = new Gibbon\FileUploader($pdo, $session); $fileUploader->getFileExtensions('Graphics/Design'); @@ -93,6 +95,8 @@ if (empty($attachment)) { $partialFail = true; + } else { + $fileMetaData = $fileUploader->getFileMetaData($attachment); } } if ($attachment != null) { @@ -112,6 +116,15 @@ $AI = str_pad($inserted, 10, '0', STR_PAD_LEFT); + // Record file tracking for logo (UL072) + if (!empty($fileMetaData) && !empty($AI)) { + $gibbonFileID = $container->get(FileHandler::class)->recordFileUpload($fileMetaData, 'freeLearningUnit', $AI, 'logo'); + + if (empty($gibbonFileID)) { + $partialFail = true; + } + } + // Write author to database $data = array('freeLearningUnitID' => $AI, 'gibbonPersonID' => $session->get('gibbonPersonID'), 'surname' => $session->get('surname'), 'preferredName' => $session->get('preferredName'), 'website' => $session->get('website') ?? ''); $sql = 'INSERT INTO freeLearningUnitAuthor SET freeLearningUnitID=:freeLearningUnitID, gibbonPersonID=:gibbonPersonID, surname=:surname, preferredName=:preferredName, website=:website'; diff --git a/Free Learning/units_manage_editProcess.php b/Free Learning/units_manage_editProcess.php index 739ae18..eb5bc24 100755 --- a/Free Learning/units_manage_editProcess.php +++ b/Free Learning/units_manage_editProcess.php @@ -19,9 +19,10 @@ along with this program. If not, see . */ -use Gibbon\Http\Url; -use Gibbon\Domain\User\UserGateway; +use Gibbon\Contracts\Filesystem\FileHandler; use Gibbon\Domain\System\SettingGateway; +use Gibbon\Domain\User\UserGateway; +use Gibbon\Http\Url; use Gibbon\Module\FreeLearning\Domain\UnitAuthorGateway; require_once '../../gibbon.php'; @@ -125,6 +126,7 @@ //Move attached file, if there is one $partialFail = false; $attachment = null; + $fileMetaData = null; if (!empty($_FILES['file']['tmp_name'])) { $fileUploader = new Gibbon\FileUploader($pdo, $session); @@ -137,6 +139,8 @@ if (empty($attachment)) { $partialFail = true; + } else { + $fileMetaData = $fileUploader->getFileMetaData($attachment); } if ($attachment != null) { @@ -164,6 +168,20 @@ header("Location: {$URL}"); exit(); } + + // Handle file deletion when user removes logo + if (empty($attachment) && !empty($row['logo'])) { + $deleted = $container->get(FileHandler::class)->deleteFile('freeLearningUnit', $freeLearningUnitID, 'logo'); + } + + // Record file tracking for logo + if (!empty($fileMetaData) && !empty($freeLearningUnitID)) { + $gibbonFileID = $container->get(FileHandler::class)->recordFileUpload($fileMetaData, 'freeLearningUnit', $freeLearningUnitID, 'logo'); + + if (empty($gibbonFileID)) { + $partialFail = true; + } + } // Update the authors $authorIDs = []; From 1403bb9e43b470631b9c21dd6574ec8bf67dd286 Mon Sep 17 00:00:00 2001 From: Ali Alam Date: Tue, 10 Mar 2026 14:59:31 +0800 Subject: [PATCH 2/5] commit changes --- Free Learning/units_manage_importProcess.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Free Learning/units_manage_importProcess.php b/Free Learning/units_manage_importProcess.php index 79ba6ab..e05ff38 100755 --- a/Free Learning/units_manage_importProcess.php +++ b/Free Learning/units_manage_importProcess.php @@ -47,6 +47,8 @@ exit; } + // NOTE: File tracking not implemented - ZIP is temporary, processed by UnitImporter class - Implement later + $fileUploader = new FileUploader($pdo, $session); $zipFile = $fileUploader->uploadFromPost($_FILES['file']); @@ -67,5 +69,4 @@ ? '&return=warning1' : '&return=success0'; header("Location: {$URL}"); - } From 4b20145937527808194d1371b822738025fa6195 Mon Sep 17 00:00:00 2001 From: Ali Alam Date: Fri, 13 Mar 2026 13:25:40 +0800 Subject: [PATCH 3/5] Added comprehensive file upload tracking system to monitor and manage all file uploads across the system --- Free Learning/CHANGEDB.php | 5 +++++ Free Learning/CHANGELOG.txt | 5 +++++ Free Learning/manifest.php | 2 +- Free Learning/version.php | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Free Learning/CHANGEDB.php b/Free Learning/CHANGEDB.php index 7ded801..01e1d07 100644 --- a/Free Learning/CHANGEDB.php +++ b/Free Learning/CHANGEDB.php @@ -2458,4 +2458,9 @@ //v5.29.12 ++$count; $sql[$count][0] = '5.29.12'; +$sql[$count][1] = ""; + +//v5.29.13 +++$count; +$sql[$count][0] = '5.29.13'; $sql[$count][1] = ""; \ No newline at end of file diff --git a/Free Learning/CHANGELOG.txt b/Free Learning/CHANGELOG.txt index a81515d..60b8571 100644 --- a/Free Learning/CHANGELOG.txt +++ b/Free Learning/CHANGELOG.txt @@ -1,5 +1,10 @@ CHANGELOG ========= + +v5.29.13 +------- +Added comprehensive file upload tracking system to monitor and manage all file uploads across the system + v5.29.12 ------- Adjusted the Manage Enrolment Assess All (Big Data School) feature to become Assess Ten diff --git a/Free Learning/manifest.php b/Free Learning/manifest.php index 0e4ae0b..3687881 100644 --- a/Free Learning/manifest.php +++ b/Free Learning/manifest.php @@ -27,7 +27,7 @@ $entryURL = 'units_browse.php'; $type = 'Additional'; $category = 'Learn'; -$version = '5.29.12'; +$version = '5.29.13'; $author = "Gibbon Foundation"; $url = "https://gibbonedu.org"; diff --git a/Free Learning/version.php b/Free Learning/version.php index 2f07801..7ca0def 100755 --- a/Free Learning/version.php +++ b/Free Learning/version.php @@ -22,5 +22,5 @@ /** * Sets version information. */ -$moduleVersion = '5.29.12'; +$moduleVersion = '5.29.13'; $coreVersion = '28.0.00'; From db86cc28174c50893edfc1304ea7de1861fbc055 Mon Sep 17 00:00:00 2001 From: Ali Alam Date: Fri, 13 Mar 2026 14:14:06 +0800 Subject: [PATCH 4/5] Free Learning: Added comprehensive file upload tracking system to monitor and manage all file uploads across the system --- Free Learning/CHANGEDB.php | 2 +- Free Learning/CHANGELOG.txt | 2 +- Free Learning/manifest.php | 2 +- Free Learning/version.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Free Learning/CHANGEDB.php b/Free Learning/CHANGEDB.php index 01e1d07..07e6193 100644 --- a/Free Learning/CHANGEDB.php +++ b/Free Learning/CHANGEDB.php @@ -2462,5 +2462,5 @@ //v5.29.13 ++$count; -$sql[$count][0] = '5.29.13'; +$sql[$count][0] = '5.30.00'; $sql[$count][1] = ""; \ No newline at end of file diff --git a/Free Learning/CHANGELOG.txt b/Free Learning/CHANGELOG.txt index 60b8571..66402ef 100644 --- a/Free Learning/CHANGELOG.txt +++ b/Free Learning/CHANGELOG.txt @@ -1,7 +1,7 @@ CHANGELOG ========= -v5.29.13 +v5.30.00 ------- Added comprehensive file upload tracking system to monitor and manage all file uploads across the system diff --git a/Free Learning/manifest.php b/Free Learning/manifest.php index 3687881..0a17f6f 100644 --- a/Free Learning/manifest.php +++ b/Free Learning/manifest.php @@ -27,7 +27,7 @@ $entryURL = 'units_browse.php'; $type = 'Additional'; $category = 'Learn'; -$version = '5.29.13'; +$version = '5.30.00'; $author = "Gibbon Foundation"; $url = "https://gibbonedu.org"; diff --git a/Free Learning/version.php b/Free Learning/version.php index 7ca0def..182cd29 100755 --- a/Free Learning/version.php +++ b/Free Learning/version.php @@ -22,5 +22,5 @@ /** * Sets version information. */ -$moduleVersion = '5.29.13'; +$moduleVersion = '5.30.00'; $coreVersion = '28.0.00'; From 935e48063035ae0acc16f403507a055f50d2eb72 Mon Sep 17 00:00:00 2001 From: Ali Alam Date: Fri, 13 Mar 2026 14:16:07 +0800 Subject: [PATCH 5/5] fixed typo --- Free Learning/CHANGEDB.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Free Learning/CHANGEDB.php b/Free Learning/CHANGEDB.php index 07e6193..1b42296 100644 --- a/Free Learning/CHANGEDB.php +++ b/Free Learning/CHANGEDB.php @@ -2460,7 +2460,7 @@ $sql[$count][0] = '5.29.12'; $sql[$count][1] = ""; -//v5.29.13 +//v5.30.00 ++$count; $sql[$count][0] = '5.30.00'; $sql[$count][1] = ""; \ No newline at end of file