Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

praxisdigital/moodle-opgaver#501 - Skip files larger than 100 MB #5

Open
wants to merge 5 commits into
base: MOODLE_400_STABLE
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,15 @@ function urkund_send_file_to_urkund($plagiarismfile, $plagiarismsettings, $file)
$DB->update_record('plagiarism_urkund_files', $plagiarismfile);
return true;
}

$filesize = (!empty($file->filepath)) ? filesize($file->filepath) : $file->get_filesize();
if ($filesize > 100 * 1024 ** 2) { // File is larger than 100 MB, marking to large and skipping.
mtrace("URKUND fileid:".$plagiarismfile->id. ' is to large, skipping...');
$plagiarismfile->statuscode = URKUND_STATUSCODE_TOO_LARGE;
$DB->update_record('plagiarism_urkund_files', $plagiarismfile);
return true;
}

mtrace("URKUND fileid:".$plagiarismfile->id. ' sending to URKUND');
if (!empty($plagiarismfile->relateduserid)) {
$useremail = $DB->get_field('user', 'email', array('id' => $plagiarismfile->relateduserid));
Expand Down
10 changes: 8 additions & 2 deletions urkund_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,14 @@

$table = new \plagiarism_urkund\output\debug_table('debugtable');

$userfields = get_all_user_name_fields(true, 'u');
$sqlfields = "t.*, ".$userfields.", m.name as moduletype, ".
//$userfields = get_all_user_name_fields(true, 'u');
use core_user\fields;

$userfieldsapi = fields::for_name();
$userfields = $userfieldsapi->get_required_fields();
$userfieldsstring = implode(',', $userfields);

$sqlfields = "t.*, ".$userfieldsstring.", m.name as moduletype, ".
"cm.course as courseid, cm.instance as cminstance, c.fullname, c.shortname";
$sqlfrom = "{plagiarism_urkund_files} t, {user} u, {modules} m, {course_modules} cm, {course} c ";
$sqlwhere = "m.id = cm.module AND cm.id = t.cm AND t.userid = u.id AND c.id = cm.course AND t.statuscode <> 'Analyzed'";
Expand Down
7 changes: 4 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023071900;
/** @var object $plugin */
$plugin->component = 'plagiarism_urkund';
$plugin->version = 2024110600;
$plugin->requires = 2022041900; // Requires 4.0.
$plugin->cron = 0; // Cron function no longer used.
$plugin->component = 'plagiarism_urkund';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '4.0.3';
$plugin->release = '4.0.4';