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

Assignfeedback_editpdf sending infinite request when page ready is not equal to page number of combined pdf

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7.2, 3.8, 3.9
    • Fix Version/s: None
    • Component/s: Assignment
    • Testing Instructions:
      Hide

      Environment:

      1. Ghostscript. If it's not installed, you can execute the following commands from the console:

        $ apt-get update
        $ apt-get install ghostscript
        

      Testing instructions:

      1. Login as admin.
      2. Access to "Site administration / Server / System paths", set "Path to ghostscript" to '/usr/bin/gs' or the corresponding to your environment and Save changes.
      3. Check a green check is displayed near the "Path to ghostscript" field.
      4. Access to "Site administration / Plugins / Activity modules / Assignment / Feedback plugins / Annotate PDF" and check "Annotate PDF" feedback plugin is enabled.
      5. Create a student.
      6. Create a course.
      7. Create an assignment with Annotate PDF feedback ticked.
      8. Enrol the student into the course.
      9. Login as the student.
      10. Submit the attached file (excerpts.pdf) to the assignment.
      11. Hack the code and add lines between these two brackets https://github.com/golenkovm/moodle/blob/master-MDL-66626/mod/assign/feedback/editpdf/classes/document_services.php#L466-L467 :

        if ($i == 5) {
            mtrace("Please, terminate me now!");
            sleep(10);
        }
        

      12. Open terminal and run scheduled task:

        php admin/tool/task/cli/schedule_task.php --execute='\assignfeedback_editpdf\task\convert_submissions'

      13. Wait for "Please, terminate me now." message and terminate the script (Ctrl+C or close the terminal).

        root@c69335460f7f:/siteroot# php admin/tool/task/cli/schedule_task.php --execute='\assignfeedback_editpdf\task\convert_submissions'
        Execute scheduled task: Prepare submissions for annotation (assignfeedback_editpdf\task\convert_submissions)
        Convert 1 submission attempt(s) for assignment 1
        Please, terminate me now!
        ^C
        root@c69335460f7f:/siteroot#

      14. Run SQL:

        select filearea, itemid, filepath, filename, filesize from mdl_files where filearea = 'pages' order by timecreated desc;

      15. Confirm, the number of pages is less than 16 (the total number of pages in submitted pdf):

         filearea | itemid | filepath |    filename     | filesize 
        ----------+--------+----------+-----------------+----------
         pages    |      1 | /        | image_page0.png |    34823
         pages    |      1 | /        | .               |        0
         pages    |      1 | /        | image_page1.png |    47312
         pages    |      1 | /        | image_page2.png |    78120
         pages    |      1 | /        | image_page3.png |    76542
         pages    |      1 | /        | image_page4.png |    57169
         pages    |      1 | /        | image_page5.png |   122690
        (7 rows)
        

      16. Remove the hack added in 11.
      17. Login as a teacher (admin) and grade submission.
      18. Confirm, that PDF Annotate viewer displays the same number of pages as the original document has (16).
      19. Run SQL:

        select filearea, itemid, filepath, filename, filesize from mdl_files where filearea = 'pages' order by timecreated desc;
        

      20. Confirm, that pages have been re-generated (there are 16 pages with newer timecreated):

         filearea | itemid | filepath |     filename     | filesize 
        ----------+--------+----------+------------------+----------
         pages    |      1 | /        | image_page0.png  |    34823
         pages    |      1 | /        | .                |        0
         pages    |      1 | /        | image_page1.png  |    47312
         pages    |      1 | /        | image_page2.png  |    78120
         pages    |      1 | /        | image_page3.png  |    76542
         pages    |      1 | /        | image_page4.png  |    57169
         pages    |      1 | /        | image_page5.png  |   122690
         pages    |      1 | /        | image_page6.png  |    83458
         pages    |      1 | /        | image_page7.png  |    80188
         pages    |      1 | /        | image_page8.png  |   160127
         pages    |      1 | /        | image_page9.png  |    65057
         pages    |      1 | /        | image_page10.png |    74191
         pages    |      1 | /        | image_page11.png |    68087
         pages    |      1 | /        | image_page12.png |    66612
         pages    |      1 | /        | image_page13.png |    72495
         pages    |      1 | /        | image_page14.png |    70981
         pages    |      1 | /        | image_page15.png |    55567
        (17 rows)
        

      Show
      Environment: Ghostscript. If it's not installed, you can execute the following commands from the console: $ apt-get update $ apt-get install ghostscript Testing instructions: Login as admin. Access to "Site administration / Server / System paths", set "Path to ghostscript" to '/usr/bin/gs' or the corresponding to your environment and Save changes. Check a green check is displayed near the "Path to ghostscript" field. Access to "Site administration / Plugins / Activity modules / Assignment / Feedback plugins / Annotate PDF" and check "Annotate PDF" feedback plugin is enabled. Create a student. Create a course. Create an assignment with Annotate PDF feedback ticked. Enrol the student into the course. Login as the student. Submit the attached file (excerpts.pdf) to the assignment. Hack the code and add lines between these two brackets https://github.com/golenkovm/moodle/blob/master-MDL-66626/mod/assign/feedback/editpdf/classes/document_services.php#L466-L467  : if ($i == 5 ) { mtrace( "Please, terminate me now!" ); sleep( 10 ); } Open terminal and run scheduled task: php admin/tool/task/cli/schedule_task.php --execute= '\assignfeedback_editpdf\task\convert_submissions' Wait for "Please, terminate me now." message and terminate the script (Ctrl+C or close the terminal). root @c69335460f7f :/siteroot# php admin/tool/task/cli/schedule_task.php --execute= '\assignfeedback_editpdf\task\convert_submissions' Execute scheduled task: Prepare submissions for annotation (assignfeedback_editpdf\task\convert_submissions) Convert 1 submission attempt(s) for assignment 1 Please, terminate me now! ^C root @c69335460f7f :/siteroot# Run SQL: select filearea, itemid, filepath, filename, filesize from mdl_files where filearea = 'pages' order by timecreated desc; Confirm , the number of pages is less than 16 (the total number of pages in submitted pdf): filearea | itemid | filepath | filename | filesize ----------+--------+----------+-----------------+---------- pages | 1 | / | image_page0.png | 34823 pages | 1 | / | . | 0 pages | 1 | / | image_page1.png | 47312 pages | 1 | / | image_page2.png | 78120 pages | 1 | / | image_page3.png | 76542 pages | 1 | / | image_page4.png | 57169 pages | 1 | / | image_page5.png | 122690 ( 7 rows) Remove the hack added in 11. Login as a teacher (admin) and grade submission. Confirm , that PDF Annotate viewer displays the same number of pages as the original document has (16). Run SQL: select filearea, itemid, filepath, filename, filesize from mdl_files where filearea = 'pages' order by timecreated desc; Confirm , that pages have been re-generated (there are 16 pages with newer timecreated): filearea | itemid | filepath | filename | filesize ----------+--------+----------+------------------+---------- pages | 1 | / | image_page0.png | 34823 pages | 1 | / | . | 0 pages | 1 | / | image_page1.png | 47312 pages | 1 | / | image_page2.png | 78120 pages | 1 | / | image_page3.png | 76542 pages | 1 | / | image_page4.png | 57169 pages | 1 | / | image_page5.png | 122690 pages | 1 | / | image_page6.png | 83458 pages | 1 | / | image_page7.png | 80188 pages | 1 | / | image_page8.png | 160127 pages | 1 | / | image_page9.png | 65057 pages | 1 | / | image_page10.png | 74191 pages | 1 | / | image_page11.png | 68087 pages | 1 | / | image_page12.png | 66612 pages | 1 | / | image_page13.png | 72495 pages | 1 | / | image_page14.png | 70981 pages | 1 | / | image_page15.png | 55567 ( 17 rows)
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Pull 3.7 Branch:
      MOODLE_37_MDL-66626
    • Pull 3.8 Branch:
      MOODLE_38_MDL-66626
    • Pull Master Branch:
      master-MDL-66626

      Description

      Grading screen (/mod/assign/view.php?id=2&rownum=0&action=grader&userid=3) sometimes can show less pages then original document has.

      We also noticed that grager page runs into infinite requests /mod/assign/feedback/editpdf/ajax_progress.php?sesskey=411DWR792Y&action=conversionstatus&userid=3&attemptnumber=0&assignmentid=1 because "pageready" is less than page count. This request keeps returning the number of page ready, and the grading screen never self-correct/recover the missing pages. 

      This can happen when '\assignfeedback_editpdf\task\convert_submissions' scheduled task is aborted in the middle of creating document images, eg when the cron node (docker container) dies or gets terminated.

        Attachments

        1. excerpts.pdf
          287 kB
        2. excerpts.pdf
          287 kB

          Issue Links

            Activity

              People

              Assignee:
              mikhailgolenkov Mikhail Golenkov
              Reporter:
              yao9394 John Yao
              Peer reviewer:
              Peter Dias
              Integrator:
              Jun Pataleta
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

                Dates

                Created:
                Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 52 minutes
                  2h 52m