MDL-34841 error importing questions with long names.

The problem was with the non-UTF-8-safe way that a question name
was being constructed from the question text.

I have done a proper fix with methods in the base class to
carefully construct a question name that is reasonable, and
which will fit in the database column. Then I have changed all
importers to use the new methods.

I also remembered not to break the lesson in the process.
This commit is contained in:
Tim Hunt
2012-09-11 15:04:00 +01:00
parent 935c3d5ed2
commit cacb8fa08a
15 changed files with 154 additions and 59 deletions
+3 -3
View File
@@ -166,9 +166,9 @@ class qformat_xml extends qformat_default {
$qo = $this->defaultquestion();
// Question name
$qo->name = $this->getpath($question,
$qo->name = $this->clean_question_name($this->getpath($question,
array('#', 'name', 0, '#', 'text', 0, '#'), '', true,
get_string('xmlimportnoname', 'qformat_xml'));
get_string('xmlimportnoname', 'qformat_xml')));
$qo->questiontext = $this->getpath($question,
array('#', 'questiontext', 0, '#', 'text', 0, '#'), '', true);
$qo->questiontextformat = $this->trans_format($this->getpath(
@@ -437,7 +437,7 @@ class qformat_xml extends qformat_default {
$qo->course = $this->course;
$qo->generalfeedback = '';
$qo->name = $this->import_text($question['#']['name'][0]['#']['text']);
$qo->name = $this->clean_question_name($this->import_text($question['#']['name'][0]['#']['text']));
$qo->questiontextformat = $questiontext['format'];
$qo->questiontext = $qo->questiontext['text'];
$qo->questiontextfiles = array();