V2.3 and AIKEN Question Import - Error writing to Database

Re: V2.3 and AIKEN Question Import - Error writing to Database

by Jean-Michel Védrine -
Number of replies: 0

Hello Bill,

This is in fact a problem in several question import formats: AIKEN, GIFT, ... They expect valid utf-8 encoded files but as they make no check that the imported file is utf-8 encoded, they can fail very ungracefully, for instance if the first illegal character in in the first answer of a multichoice question, a completely broken question is imported because only part of the question is written to the database, and if you latter try to edit or attempt this question you get an error but no warning is given if you include it in a quiz surprise.

I think that a general function to check encoding should be added and relevant formats should use it. This function could use either preg_match('//u', $string) or mb_check_encoding.

But it should be the format responsibility to call it or not as there are formats designed to import non utf-8 files (for instance my https://github.com/jmvedrine/moodle-qformat_qcmdirect )