Skip to content

Commit

Permalink
MDL-71471 assign: Remove submission from queue when converted in web
Browse files Browse the repository at this point in the history
  • Loading branch information
golenkovm committed Jun 4, 2021
1 parent 193a0a6 commit 4be14f2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mod/assign/feedback/editpdf/ajax.php
Expand Up @@ -82,9 +82,21 @@
$completestatuslist = [combined_document::STATUS_COMPLETE, combined_document::STATUS_FAILED];

if (in_array($response->status, $readystatuslist)) {
// It seems that the files for this submission haven't been combined by the
// "\assignfeedback_editpdf\task\convert_submissions" scheduled task.
// Try to combine them in the user session.
$combineddocument = document_services::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
$response->status = $combineddocument->get_status();
$response->filecount = $combineddocument->get_document_count();

// Check status of the combined document and remove the submission
// from the task queue if combination completed.
if (in_array($response->status, $completestatuslist)) {
$submission = $assignment->get_user_submission($userid, false, $attemptnumber);
if ($submission) {
$DB->delete_records('assignfeedback_editpdf_queue', array('submissionid' => $submission->id));
}
}
}

if (in_array($response->status, $completestatuslist)) {
Expand Down
18 changes: 18 additions & 0 deletions mod/assign/feedback/editpdf/db/upgrade.php
Expand Up @@ -80,5 +80,23 @@ function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
// Automatically generated Moodle v3.11.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2021051701) {
// Remove submissions from the processing queue that have been processed.
$sql = 'DELETE
FROM {assignfeedback_editpdf_queue}
WHERE EXISTS (SELECT 1
FROM {assign_submission} s,
{assign_grades} g
WHERE s.id = submissionid
AND s.assignment = g.assignment
AND s.userid = g.userid
AND s.attemptnumber = g.attemptnumber)';

$DB->execute($sql);

// Editpdf savepoint reached.
upgrade_plugin_savepoint(true, 2021051701, 'assignfeedback', 'editpdf');
}

return true;
}
2 changes: 1 addition & 1 deletion mod/assign/feedback/editpdf/version.php
Expand Up @@ -24,6 +24,6 @@

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

$plugin->version = 2021051700;
$plugin->version = 2021051701;
$plugin->requires = 2021051100;
$plugin->component = 'assignfeedback_editpdf';

0 comments on commit 4be14f2

Please sign in to comment.