Skip to content

Commit

Permalink
MDL-79307 assignfeedback_editpdf: more informative task failure.
Browse files Browse the repository at this point in the history
If ghostscript is not correctly configured the task will never
succeed, so error out earlier with a more informative exception
explaining this.
  • Loading branch information
paulholden committed Dec 5, 2023
1 parent caacef2 commit f4b502a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -20,7 +20,9 @@
use core\task\manager;
use assignfeedback_editpdf\document_services;
use assignfeedback_editpdf\combined_document;
use assignfeedback_editpdf\pdf;
use context_module;
use moodle_exception;
use assign;

/**
Expand All @@ -47,6 +49,13 @@ public function execute() {
return;
}

// Early exit if ghostscript isn't correctly configured.
$result = pdf::test_gs_path(false);
if ($result->status !== pdf::GSPATH_OK) {
$statusstring = get_string('test_' . $result->status, 'assignfeedback_editpdf');
throw new moodle_exception('pathtogserror', 'assignfeedback_editpdf', '', $statusstring, $result->status);
}

$cm = get_coursemodule_from_instance('assign', $submission->assignment, 0, false, MUST_EXIST);
$context = context_module::instance($cm->id);
$assign = new assign($context, null, null);
Expand Down
Expand Up @@ -59,6 +59,7 @@
$string['gotopage'] = 'Go to page';
$string['green'] = 'Green';
$string['gsimage'] = 'Ghostscript test image';
$string['pathtogserror'] = 'The configured path to ghostscript is not correctly set: {$a}';
$string['pathtogspathdesc'] = 'Please note that annotate PDF requires the path to ghostscript to be set in {$a}.';
$string['highlight'] = 'Highlight';
$string['jsrequired'] = 'JavaScript is required to annotate a PDF. Please enable JavaScript in your browser to use this feature.';
Expand Down

0 comments on commit f4b502a

Please sign in to comment.