Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Answer sheet evaluation for the offlinequiz-plugin failed : division by zero #237

Open
opodeur opened this issue Feb 1, 2024 · 10 comments

Comments

@opodeur
Copy link

opodeur commented Feb 1, 2024

Hello,

The scheduled task failed with Division by zero error :
Execute scheduled task: Answer sheet evaluation for the offlinequiz-plugin (mod_offlinequiz\task\page_evaluation_task)
... started 20:22:02. Current memory use 24.3 MB.
Debugging increased temporarily due to faildelay of 60
job 5: evaluating /var/www/moodledata/temp/offlinequiz/import/1706728662589734444/Scae2-copie24013120140.pdf
... used 20 dbqueries
... used 0.029645919799805 seconds
Scheduled task failed: Answer sheet evaluation for the offlinequiz-plugin (mod_offlinequiz\task\page_evaluation_task),Division by zero
Backtrace:

  • line 168 of /mod/offlinequiz/cron.php: call to offlinequiz_page_scanner->load_image()
  • line 40 of /mod/offlinequiz/classes/task/page_evaluation_task.php: call to offlinequiz_evaluation_cron()
  • line 263 of /lib/cronlib.php: call to mod_offlinequiz\task\page_evaluation_task->execute()
  • line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
  • line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
  • line 178 of /admin/cli/cron.php: call to cron_run()

Moodle [4.1.6+
Offline Quiz v4.1.2
PHP Version 8.0.30

Regards,

Olivier

@opodeur
Copy link
Author

opodeur commented Feb 23, 2024

Hello,

The error "Division by 0" seems to be related to the pdf file. Indeed, I converted the file from pdf to png and the evaluation is working.
Is it a bug known ?

Regards,

Olivier

@helper1276
Copy link

Hello,

I have the same issue trying to import PDF for processing. PDF is well uploaded to the server but it fails when processed :

Execute scheduled task: Answer sheet evaluation for the offlinequiz-plugin (mod_offlinequiz\task\page_evaluation_task) ... started 10:30:01. Current memory use 34.3 MB. job 7: evaluating /usr/local/moodledata/temp/offlinequiz/import/1713428644907394215/0833_001.pdf ... used 25 dbqueries ... used 0.009965181350708 seconds Scheduled task failed: Answer sheet evaluation for the offlinequiz-plugin (mod_offlinequiz\task\page_evaluation_task),Division by zero

It's working well with png files. But I would prefere to be able to use pdf.
I'm running Moodle 4.3.3 with php 8.0.30, Imagick 3.7.0 on Ubuntu 20.04 LTS.

Thanks for support,
D.

@mwreichel
Copy link
Contributor

Hi @opodeur and @helper1276,
thank you for reporting this. Up to now we had no further messages to that apart from yours. In general the pdf format is supported.
We will try to check this behaviour. Please could you provide further information on that - how and which software do you use to scan and save the answer sheets?
If possible, please could you attach some dummy files which we could use for our tests too...?!

Thanks,
Martin

@opodeur
Copy link
Author

opodeur commented May 23, 2024

Hi mwreichel,
The PDF is scanned with KONICA MINOLTA C360i printer in compact PDF or PDF format.
I attached the dummy files.
Scae2-copie24052305361.pdf
Scae2-copie24052305360.pdf
Regards,
Olivier

@helper1276
Copy link

Hello,
On my side, PDF are created from a Canon printer imageRunner advance dx 4835i.

0831_001.pdf

Thanks,
Davy

@mwreichel
Copy link
Contributor

Hi @opodeur, @helper1276,
many thanks for your furhter information and the prepared dummy files.
We'll have a closer look on that...

All the best,
Martin

@univietw
Copy link
Contributor

univietw commented May 23, 2024

Hi,
i was looking a bit deeper into this issue.
First thanks to @opodeur and @helper1276, I checked your files and they seem to be working on our end, this includes the test system as well as my development system.
So there is some difference between our and your system.
Sadly I don't even know exactly where in the code this division by zero happens since the backtrace doesn't say the line, only the function.
The good news is: I have some ideas what the problem might be.
After uploading the file to offlinequiz the pdf gets separated into page-images and then added to the queue. If this fails the pdf is still added as a whole file into the queue to display the error to the user.
My guess is that this conversion into subfiles fails, because Ubuntu blocks it because of a security bug in "convert" (the program converting the pdf into images) many years ago:
https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion/59193253#59193253
WARNING: YOU SHOULD ONLY DELETE/COMMENT THE LINE WITH "PDF", otherwise you may put your Server at risk!
It's the only thing you need for this problem to be resolved.
Can anybody of you check if this helps?
If this fixes the issue I will try to make a more appropriate feedback for server administrators.

@opodeur
Copy link
Author

opodeur commented May 24, 2024 via email

@opodeur
Copy link
Author

opodeur commented May 24, 2024 via email

@univietw
Copy link
Contributor

Thank you for confirming that that's the issue.
The issue was fixed with Version 9.24, Version 10 was not released before this security-issue.
Redhat and SUSE don't ship imagemagick with this setting, I guess there is no reason not to use it with Ubuntu.
I would however not activate the others if you don't really need them, just to be safe.
Ghostscript is a script after all, 0-days might always come that you are not aware of ;)

For all the other, I will change the code to make the error more clear. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants