Skip to content

Commit f7bf28d

Browse files
committed
Fix the xml export and import
1 parent c513c8d commit f7bf28d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

questiontype.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,12 @@ public function import_from_xml($data, $question, qformat_xml $format, $extra=nu
353353
if (is_array($extraanswersfields)) {
354354
array_shift($extraanswersfields);
355355
}
356-
xdebug_break();
357-
if (isset($data['#']['sampleresponses'])) {
358-
$x=1;
356+
if (isset($data['#']['sampleresponse'])) {
357+
$sampleresponses = $data['#']['sampleresponse'];
358+
foreach ($sampleresponses as $key => $srxml) {
359+
$qo->sampleresponses[$key] = $format->getpath($srxml, ['#','response',0,'#'],0);
360+
}
359361
}
360-
361-
362362
return $qo;
363363
}
364364
/**
@@ -395,14 +395,14 @@ public function export_to_xml($question, qformat_xml $format, $extra = null) {
395395
$output .= " <$field>".$format->xml_escape($value)."</$field>\n";
396396
}
397397
}
398-
$output .= " <sampleresponses>\n";
398+
//$output .= " <sampleresponses>\n";
399399
foreach ($question->options->sampleresponses as $sampleresponse) {
400400
$output .= " <sampleresponse>\n";
401401
$output .= ' <question>' . $sampleresponse->question . "</question>\n";
402402
$output .= ' <response>' . $sampleresponse->response . "</response>\n";
403403
$output .= " </sampleresponse>\n";
404404
}
405-
$output .= " </sampleresponses>\n";
405+
//$output .= " </sampleresponses>\n";
406406
return $output;
407407
}
408408
/**

0 commit comments

Comments
 (0)