Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-64431

Layers missing from PDFs in grading view

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_39_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • m41-mdl64431
    • m43-mdl64431
    • mdl64431
    • Hide
      Setup
      1. Make sure you have Ghostscript installed.
        • To check, run "which gs" on your terminal.
        • If nothing comes up, install Ghostscript. (e.g. on Ubuntu "sudo apt install ghostscript")
      2. Set the admin setting "Path to Ghostscript (pathtogs)" accordingly (use the output of "which gs").
      Test
      1. Create a test course with students that contains an assignment with file submissions enabled and 'Annotate PDF' as a feedback type.
      2. Login as a student from the test course and upload the sample.pdf file from the tracker to the assignment
      3. As an administrator or teacher, go to the assignment grading page and view the uploaded assignment
      4. Observe that the PDF annotations are visible

       

       

      Show
      Setup Make sure you have Ghostscript installed. To check, run " which gs " on your terminal. If nothing comes up, install Ghostscript. (e.g. on Ubuntu " sudo apt install ghostscript ") Set the admin setting " Path to Ghostscript (pathtogs) " accordingly (use the output of " which gs "). Test Create a test course with students that contains an assignment with file submissions enabled and 'Annotate PDF' as a feedback type. Login as a student from the test course and upload the sample.pdf file from the tracker to the assignment As an administrator or teacher, go to the assignment grading page and view the uploaded assignment Observe that the PDF annotations are visible    
    • 5

      When grading an assignment submitted as a PDF, some layers of the PDF may be missing.

      SETUP (Create a course where you are both instructor and student):

      1. Navigate to a course.
      2. Navigate to the Participants list.
      3. Enrol yourself as both a teacher or admin (so that you can edit the course) and as a student (so that you can submit assignments). Save.
      4. Go back to the course page and turn editing on.
      5. Add an activity or resource: Assignment
      6. Set the following, then Save & Display:
      • General/Assignment name: (arbitrary)
      • Submission types/Submission types: File submissions
      • Submission settings/Attempts reopened: Manually
      • Submission settings/Maximum attempts: Unlimited

      STEPS TO REPRODUCE (submit attached file, and grade it):

      1. In the file-submission assignment you created...
      2. Click "Add submission"
      3. Drag and drop the attached file "sample.pdf"
      4. Click "Save Changes" to return to the assignment main page.
      5. Click "View all submissions"
      6. You should see your own submission, with status "Submitted for grading", or "Draft (not submitted)". Click "Grade" beside your submission.
      7. In the default layout, wait until you see an image of the pdf submitted where you can add annotations.

      EXPECTED:
      This view should match the submitted pdf, as seen when you download the pdf by clicking the 'sample.pdf' filename link in the grade panel on the right.

      ACTUAL RESULT:
      The grading view does not show the parts of the pdf. Namely, the coloured annotations are missing. When downloaded and viewed in the browser or a system viewer, all layers of the pdf are visible (indicating that the pdf is stored correctly by Moodle).

      The most alarming part of this is that there is no error message, and the file may appear to be complete, even though significant content is missing.

      INVESTIGATION

      The annotations in the attached file were added using "PDF Expert", though other tools have been reported by our users to give similar results. I have seen the error with both pdf version 1.4 and version 1.7 documents. This is possibly related to https://tracker.moodle.org/browse/MDL-44426, however the issue here is not with Ghostscript. (I have seen the error on systems running Ghostscript version 9.06 and 9.10, and am currently testing with 9.18.) When viewed with Ghostscript from the command line, the pdf is displayed correctly. Furthermore, when "flattened" using Ghostscript

      $ gs -sDEVICE=pdfwrite -o flattened.pdf sample.pdf
      

      , the file can be resubmitted to the assignment, and then all parts appear.

      The issue may be with the FDPI library. When I upload the attached file to https://www.setasign.com/products/fpdi-pdf-parser/details/, the parser displays only the black layer, not the annotations. Per the FPDI Manual at https://manuals.setasign.com/fpdi-manual/v2/limitations/, "Dynamic content like link annotations, form fields or any other page annotations cannot be attached to a form XObject because they are related to the coordinates of the origin page. So FPDI is not able to import this kind of content."

      Since we are already using Ghostscript, would it be possible to flatten the file before it is processed with FPDI?

        1. 2022-09-24_19-12.png
          2022-09-24_19-12.png
          35 kB
        2. currentresult.png
          currentresult.png
          194 kB
        3. FontTest.pdf
          130 kB
        4. image-2021-11-30-12-02-57-436.png
          image-2021-11-30-12-02-57-436.png
          0.3 kB
        5. mcb_pdf_issue_no_annotations.png
          mcb_pdf_issue_no_annotations.png
          125 kB
        6. mcb_pdf_issue_w_annotations.jpg
          mcb_pdf_issue_w_annotations.jpg
          35 kB
        7. mcb_pdf_issue_w_annotations.pdf
          156 kB
        8. MDL-64431.jpg
          MDL-64431.jpg
          49 kB
        9. MDL-64431.png
          MDL-64431.png
          277 kB
        10. sample.pdf
          181 kB
        11. sample flattened.pdf
          452 kB

            Created:
            Updated:
            Resolved:

              Estimated:
              Original Estimate - 0 minutes
              0m
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 4 hours, 31 minutes
              4h 31m

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.