Skip to content

Commit

Permalink
MDL-25192 and MDL-25194 import and saving images using instructions […
Browse files Browse the repository at this point in the history
…'files'] array
  • Loading branch information
ppichet committed Nov 15, 2010
1 parent dec3f21 commit ab152de
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions question/format/xml/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,13 @@ function import_numerical($question) {
$qo->instructions['format'] = $this->trans_format($this->getpath($instructions,
array('0', '@', 'format'), 'moodle_auto_format'));
$files = $this->getpath($instructions, array('0', '#', 'file'), array());
$qo->instructionsfiles = array();
$qo->instructions['files'] = array();
foreach ($files as $file) {
$data = new stdclass;
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$qo->instructionsfiles[] = $data;
$qo->instructions['files'][]= $data;
}
}
return $qo;
Expand Down Expand Up @@ -676,7 +676,7 @@ function import_calculated($question,$qtype) {
$qo->unitpenalty = $this->getpath($question, array('#','unitpenalty',0,'#'), 0 );
$qo->showunits = $this->getpath($question, array('#','showunits',0,'#'), 0 );
$qo->unitsleft = $this->getpath($question, array('#','unitsleft',0,'#'), 0 );
// $qo->instructions = $this->getpath( $question, array('#','instructions',0,'#','text',0,'#'), '', true );
$qo->instructions = $this->getpath( $question, array('#','instructions',0,'#','text',0,'#'), '', true );
if (!empty($instructions)) {
$qo->instructions = array();
$qo->instructions['text'] = $this->getpath($instructions,
Expand All @@ -685,20 +685,19 @@ function import_calculated($question,$qtype) {
array('0', '@', 'format'), 'moodle_auto_format'));
$files = $this->getpath($instructions,
array('0', '#', 'file'), array());
$qo->instructionsfiles = array();
$qo->instructions['files'] = array();
foreach ($files as $file) {
$data = new stdclass;
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$qo->instructionsfiles[] = $data;
$qo->instructions['files'][]= $data;
}
}

$files = $this->getpath($question, array('#', 'instructions', 0, '#', 'file', 0, '@'), '', false);

// get answers array
// echo "<pre> question";print_r($question);echo "</pre>";
$answers = $question['#']['answer'];
$qo->answers = array();
$qo->feedback = array();
Expand Down Expand Up @@ -746,13 +745,13 @@ function import_calculated($question,$qtype) {
array('0', '@', 'format'), 'moodle_auto_format'));
$files = $this->getpath($instructions,
array('0', '#', 'file'), array());
$qo->instructionsfiles = array();
$qo->instructions['files'] = array();
foreach ($files as $file) {
$data = new stdclass;
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$qo->instructionsfiles[] = $data;
$qo->instructions['files'][]= $data;
}
}
$datasets = $question['#']['dataset_definitions'][0]['#']['dataset_definition'];
Expand Down

0 comments on commit ab152de

Please sign in to comment.