Merge branch 'master-MDL-66626' of https://github.com/golenkovm/moodle
authorAdrian Greeve <abgreeve@gmail.com>
Thu, 6 Aug 2020 01:05:57 +0000 (09:05 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Thu, 6 Aug 2020 01:05:57 +0000 (09:05 +0800)
mod/assign/feedback/editpdf/ajax.php
mod/assign/feedback/editpdf/classes/document_services.php

index fd9cd4c..432bcff 100644 (file)
@@ -125,14 +125,14 @@ if ($action === 'pollconversions') {
             $annotations = page_editor::get_annotations($grade->id, $index, $draft);
             $page->annotations = $annotations;
             $response->pages[] = $page;
-
-            $component = 'assignfeedback_editpdf';
-            $filearea = document_services::PAGE_IMAGE_FILEAREA;
-            $filepath = '/';
-            $fs = get_file_storage();
-            $files = $fs->get_directory_files($context->id, $component, $filearea, $grade->id, $filepath);
-            $response->pageready = count($files);
         }
+
+        $component = 'assignfeedback_editpdf';
+        $filearea = document_services::PAGE_IMAGE_FILEAREA;
+        $filepath = '/';
+        $fs = get_file_storage();
+        $files = $fs->get_directory_files($context->id, $component, $filearea, $grade->id, $filepath);
+        $response->pageready = count($files);
     }
 
     echo json_encode($response);
index 9c02a10..f417141 100644 (file)
@@ -576,7 +576,9 @@ EOD;
             }
         }
 
-        if (empty($pages)) {
+        $totalpagesforattempt = self::page_number_for_attempt($assignment, $userid, $attemptnumber, false);
+        // Here we are comparing the total number of images against the total number of pages from the combined PDF.
+        if (empty($pages) || count($pages) != $totalpagesforattempt) {
             if ($readonly) {
                 // This should never happen, there should be a version of the pages available
                 // whenever we are requesting the readonly version.