mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-74911-master' of https://github.com/matthewhilton/moodle
This commit is contained in:
commit
f0be30af14
1 changed files with 78 additions and 54 deletions
|
@ -52,6 +52,9 @@ if (!$assignment->can_view_submission($userid)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'pollconversions') {
|
if ($action === 'pollconversions') {
|
||||||
|
// Poll conversions does not require session lock.
|
||||||
|
\core\session\manager::write_close();
|
||||||
|
|
||||||
$draft = true;
|
$draft = true;
|
||||||
if (!has_capability('mod/assign:grade', $context)) {
|
if (!has_capability('mod/assign:grade', $context)) {
|
||||||
// A student always sees the readonly version.
|
// A student always sees the readonly version.
|
||||||
|
@ -65,6 +68,21 @@ if ($action === 'pollconversions') {
|
||||||
$draft = false;
|
$draft = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a lock for the PDF/Image conversion of the assignment files.
|
||||||
|
$lockfactory = \core\lock\lock_config::get_lock_factory('assignfeedback_editpdf_pollconversions');
|
||||||
|
$resource = "user:${userid},assignmentid:${assignmentid},attemptnumber:${attemptnumber}";
|
||||||
|
$lock = $lockfactory->get_lock($resource, 0);
|
||||||
|
|
||||||
|
// Could not get lock, send back JSON to poll again.
|
||||||
|
if (!$lock) {
|
||||||
|
echo json_encode([
|
||||||
|
'status' => 0
|
||||||
|
]);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtained lock, now process the assignment conversion.
|
||||||
|
try {
|
||||||
$response = (object) [
|
$response = (object) [
|
||||||
'status' => -1,
|
'status' => -1,
|
||||||
'filecount' => 0,
|
'filecount' => 0,
|
||||||
|
@ -136,8 +154,14 @@ if ($action === 'pollconversions') {
|
||||||
$files = $fs->get_directory_files($context->id, $component, $filearea, $grade->id, $filepath);
|
$files = $fs->get_directory_files($context->id, $component, $filearea, $grade->id, $filepath);
|
||||||
$response->pageready = count($files);
|
$response->pageready = count($files);
|
||||||
}
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
// Release lock, and re-throw exception.
|
||||||
|
$lock->release();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
|
$lock->release();
|
||||||
die();
|
die();
|
||||||
} else if ($action == 'savepage') {
|
} else if ($action == 'savepage') {
|
||||||
require_capability('mod/assign:grade', $context);
|
require_capability('mod/assign:grade', $context);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue