QTI questions importer produces Fatal error with the following message preventing questions being generated from QTI XML file

Fatal error: Call to undefined function questions_import_submit_qti12() in quiz/includes/questions_import/questions_import.admin.inc on line 385
CommentFileSizeAuthor
#1 quiz-544676-1.patch4.2 KBsivaji_ganesh_jojodae

Comments

sivaji_ganesh_jojodae’s picture

StatusFileSize
new4.2 KB

Digging into the code i found that function name has been changes and arguments where missing in QTI importer validation function. Attached is a patch which tries to fix it and allow questions being generated from QTI XML file. But still there are some warning message being generated by QueryPath function which looks as below

# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: htmlParseEntityRef: no name in Entity, line: 17 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.
# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : p in Entity, line: 11 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.
# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : p in Entity, line: 11 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.
# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : p in Entity, line: 1 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.
# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : p in Entity, line: 1 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.
# warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : html in Entity, line: 83 in /home/sivaji/Public/quiz4dev/sites/all/modules/contributions/modules/quiz/includes/questions_import/questions_import.admin.inc on line 596.

@mbutcher is it because of the recent changes made in qp lib ?

mbutcher’s picture

This is because QueryPath 2.0 is a lot stricter (by default) on HTML parsing. Fixing is easy, though. There is a parameter to QueryPath that tells it to ignore parser warnings. It can be set globally by doing:

QueryPathOptions::merge(array('ignore_parser_warnings'=>TRUE));

You will have to execute QueryPath with error suppression, though:

@qp(...);
sivaji_ganesh_jojodae’s picture

It makes no difference for me. Tested with stable 2.x and 2.x beta. I gone through the QP library code (beta version) could not find anything like array('ignore_parser_warnings' => TRUE).

The questions_import.admin.inc line 596 which causes this error has following statement

$doc = new DOMDocument();
$doc->loadHTML($bodytext);

Hope this will help you to track down further.

mbutcher’s picture

The ignore_parser_warnings was added in QueryPath 2.0.1, which is the current stable release.

In the code above, though, it sounds like what is actually causing the warnings are the two lines you quoted above. You might just change the second line to:

$doc = new DOMDocument();
@$doc->loadHTML($bodytext);
if ($doc == NULL) {
  // parse failed
}

That will suppress warnings (and errors too, unfortunately, so make sure to do a null check on $doc) that are encountered during parsing.

falcon’s picture

Status: Active » Closed (fixed)