Affects Version/s: 3.1.1
Fix Version/s: 3.1.2
Create an assignment submission using online text. Use this text:
Verify when grading the submission that the text appears correctly in the editpdf panel.
Pull from Repository:
Pull Master Branch:
HTML files created for converting online submissions to pdf for feedback/annotation (unoconv) are wrongly encoded (See attachment).
To reproduce (unoconv must be configured correctly on your moodle instance) :
- As a teacher, create an online text assignment
- As a student, submit a text with special characters like 'éèÉàÀ'
- As the teacher, go to the grade form of this student's assignment.
You should see that the text in the annotation is wrongly encoded
Dug the code a bit and found out what the problem is :
- The method called strip_image in "/mod/assign/feedback/editpdf/classes/document_services.php" is using DOMDocument::loadHTML which causes the problem.
- It seems that by default, DOMDOcument::loadHTML treat the string as being in ISO-8859-1 and not UTF-8. See http://stackoverflow.com/questions/8218230/php-domdocument-loadhtml-not-encoding-utf-8-correctly
Function format_text in "lib/weblib.php" is doing one of the proposed solution by appending "'<?xml version="1.0" encoding="UTF-8" ?>' ." to the string, to force loadHTML to work in UTF-8.
The following code modif would fix the issue :