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

Dowload report fails when images contained in assignment feedback. #24

Open
danmarsden opened this issue May 22, 2024 · 4 comments
Open

Comments

@danmarsden
Copy link
Contributor

If a teacher has added an image to the feedback on an assignment, viewing the grading report shows a broken image, but attempting to download the report throws a fatal error:
Exception - File @@PluginFile@@/filename.png not found!

line 352 of /report/advancedgrading/locallib.php: call to PhpOffice\PhpSpreadsheet\Reader\Html->loadFromString()
line 147 of /report/advancedgrading/locallib.php: call to download()
line 64 of /report/advancedgrading/rubric.php: call to send_output()

probably a few different methods to fix that - maybe doing a strip tags on the output might be an easy option.

@danmarsden danmarsden changed the title Dowload repot fails when images contained in assignment feedback. Dowload report fails when images contained in assignment feedback. May 22, 2024
@marcusgreen
Copy link
Owner

I thought of strip tags before I completed reading your post. I will look into it.

@marcusgreen
Copy link
Owner

I have reproduced this. I thought strip_tags would be the way to go, but the second parameter is for which tags you want to allow through, and I want something that lists the tags to strip. I just triesdd this instead
$spreadsheet = preg_replace('/<(\s*)img[^<>]*>/i', '', $spreadsheet);
On line 351 of locallib.php
Seems to work at first testing but am trying to think if there could be any reason good for ever having an img in the output.
What do you think?

@danmarsden
Copy link
Contributor Author

I can't think of a good reason to have images in the exported data but I'm not a teacher :-)

@marcusgreen
Copy link
Owner

I will apply the fix I described. I have been a teacher and I wouldn't add images. And if I did it would be acceptable for them not to come out in that report.

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

2 participants