Skip to content
Open
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
5 changes: 5 additions & 0 deletions Free Learning/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -2458,4 +2458,9 @@
//v5.29.12
++$count;
$sql[$count][0] = '5.29.12';
$sql[$count][1] = "";

//v5.30.00
++$count;
$sql[$count][0] = '5.30.00';
$sql[$count][1] = "";
5 changes: 5 additions & 0 deletions Free Learning/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CHANGELOG
=========

v5.30.00
-------
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
Expand Down
2 changes: 1 addition & 1 deletion Free Learning/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$entryURL = 'units_browse.php';
$type = 'Additional';
$category = 'Learn';
$version = '5.29.12';
$version = '5.30.00';
$author = "Gibbon Foundation";
$url = "https://gibbonedu.org";

Expand Down
38 changes: 33 additions & 5 deletions Free Learning/units_browse_details_approvalProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
along with this program. If not, see <http:// www.gnu.org/licenses/>.
*/

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';
Expand Down Expand Up @@ -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'])) {
Expand All @@ -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,
Expand All @@ -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"]);
Expand Down
41 changes: 35 additions & 6 deletions Free Learning/units_browse_details_completePendingProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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';

Expand Down Expand Up @@ -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'])) {
Expand All @@ -158,6 +160,8 @@

if (empty($location)) {
$partialFail = true;
} else {
$fileMetaData = $fileUploader->getFileMetaData($location);
}
}
else {
Expand All @@ -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 = [
Expand All @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions Free Learning/units_manage_addProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Contracts\Filesystem\FileHandler;
use Gibbon\Http\Url;

require_once '../../gibbon.php';
Expand Down Expand Up @@ -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');
Expand All @@ -93,6 +95,8 @@

if (empty($attachment)) {
$partialFail = true;
} else {
$fileMetaData = $fileUploader->getFileMetaData($attachment);
}
}
if ($attachment != null) {
Expand All @@ -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';
Expand Down
22 changes: 20 additions & 2 deletions Free Learning/units_manage_editProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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';
Expand Down Expand Up @@ -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);
Expand All @@ -137,6 +139,8 @@

if (empty($attachment)) {
$partialFail = true;
} else {
$fileMetaData = $fileUploader->getFileMetaData($attachment);
}

if ($attachment != null) {
Expand Down Expand Up @@ -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 = [];
Expand Down
3 changes: 2 additions & 1 deletion Free Learning/units_manage_importProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -67,5 +69,4 @@
? '&return=warning1'
: '&return=success0';
header("Location: {$URL}");

}
2 changes: 1 addition & 1 deletion Free Learning/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
/**
* Sets version information.
*/
$moduleVersion = '5.29.12';
$moduleVersion = '5.30.00';
$coreVersion = '28.0.00';