Skip to content
Browse files

MDL-8342 PHP5 migration thing causing string offset fatal error when …

…data not present in XML file. Added some checks.
  • Loading branch information...
1 parent dc5ea21 commit 877d109b017e7711fdb186d3c3d60d3909482362 thepurpleblob committed
Showing with 16 additions and 4 deletions.
  1. +16 −4 question/format/blackboard/format.php
View
20 question/format/blackboard/format.php
@@ -266,9 +266,9 @@ function process_fib($xml, &$questions) {
else {
return;
}
+
for ($i = 0; $i < sizeof ($fibquestions); $i++) {
-
$question = $this->defaultquestion();
$question->qtype = SHORTANSWER;
@@ -291,11 +291,23 @@ function process_fib($xml, &$questions) {
$question->answer[] = addslashes($answer);
$question->fraction[] = 1;
- $question->feedback[0] = addslashes(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
- $question->feedback[1] = addslashes(trim(@$thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
+ $question->feedback = array();
+
+ if (is_array( $thisquestion['#']['GRADABLE'][0]['#'] )) {
+ $question->feedback[0] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]));
+ }
+ else {
+ $question->feedback[0] = '';
+ }
+ if (is_array( $thisquestion["#"]["GRADABLE"][0]["#"] )) {
+ $question->feedback[1] = addslashes(trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]));
+ }
+ else {
+ $question->feedback[1] = '';
+ }
$questions[] = $question;
- }
+ }
}
//----------------------------------------

0 comments on commit 877d109

Please sign in to comment.
Something went wrong with that request. Please try again.