Identical submissions do not require individual conversions from the document converter. Text passing through
format_text cannot be trusted and is likely to be unique each time, even for the same text.
This patch adds a check to make sure there is a converter available that
will be able to handle html->pdf conversion before adding onlinetext
submissions to the list of files to combine.
This lets us convert between common office formats. E.g. docx -> pdf
html -> pdf, html -> ods.
This commit also updates assignment editpdf plugin to use this converter
on all compatible submission files.
There was a big proliferation and reuse of $pdf variable
that was making the code hard to read/review. This commit
does change nothing but makes it more readable.
Also adds a couple of Close() calls, not strictly needed
because they don't have opened files. But think it makes
really clearer the scope of every variable. And, for sure
it frees some resources. That cannot be bad.
When a pdf object is instantiated and any file is loaded
with set_pdf() or load_pdf(), the files remain open until
the pdf is saved with pdf_save() or outputted with Output()..
In that cases is needed to perform an explicit Close() in
order to free resources, parsers and, ultimately, fclose()
the files.
Note that only the uses detected in the editpdf unit tests have
been fixed. I'd recommend to analyse every instance of the tcpdf
libs.
Also, there was one incorrecly reused pdf instance in then
generate_combined_pdf_for_attempt() method. Apparently it was not
leading to problems, but better use a separate instance (#246).
This includes a check to see if there are 0 pages in the combined pdf,
catching exceptions and suppressing php warnings and errors from bad pdf files.
Also - Use TCPDF directly to check if pdfs are compatible. The previous check was
letting dodgy PDFs through which then failed at generation time. This way dodgy
pdfs will get run through ghostscript early and cleaned up.