$general_params = new stdClass(); $result['general']['params'] = $general_params; // call import with imptype and params $ob = new OB(); $ob->ClearAndSave(); $data = $import->Load($load_params); $result['load']['type'] = 'qti12'; $result['load']['params'] = $load_params; $result['load']['debug'] = $ob->GetContent(); $result['load']['warnings'] = $import->warnings; $result['load']['errors'] = $import->errors; $result['load']['data'] = $data; $ob->Restore(); // create object with save source $ob = new OB(); $ob->ClearAndSave(); $export->Save($save_params, $data); $result['save']['type'] = 'rogo'; $result['save']['params'] = $save_params; $result['save']['debug'] = $ob->GetContent(); $result['save']['warnings'] = $export->warnings; $result['save']['errors'] = $export->errors; $result['save']['data'] = $data; $ob->Restore(); ///////////////////////// // STORE RESULTS STUFF // ///////////////////////// // display result page include "tmpl/import_main.php"; $mainoutput = $ob->GetContent(); // store page that was presented to the user
function SaveTextBox(&$question) { // format the text for the question list($headertext, $title) = $this->MakeQuestionHeader($question); $this->AddWarning("Terms are not exported to QTI with this question type", $question->load_id); $ob = new OB(); $ob->ClearAndSave(); include "qti20/tmpl/textbox.php"; $this->output .= $ob->GetContent(); $ob->Restore(); }
function Load($params) { global $string; echo "<h4>{$string['params']}</h4>"; print_p($params); global $import_directory; $xml_files = array(); //print_p($params); $this->params = $params; $import_directory = $params->base_dir . $params->dir . "/"; $filename = $params->sourcefile; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if ($ext == "xml") { $xml_files[basename($filename)] = $filename; } else { if ($ext == "zip") { echo "Extracting zip<br />"; $zip = new ZipArchive(); $res = $zip->open($filename); if ($res === true) { $zip->extractTo($params->base_dir . $params->dir . "/"); for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); $filename = $stat['name']; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if ($ext == "xml") { $xml_files[$filename] = $params->base_dir . $params->dir . "/" . $filename; } } $zip->close(); } else { print "zip invalid "; switch ($res) { case ZipArchive::ER_EXISTS: $ErrMsg = "File already exists."; break; case ZipArchive::ER_INCONS: $ErrMsg = "Zip archive inconsistent."; break; case ZipArchive::ER_MEMORY: $ErrMsg = "Malloc failure."; break; case ZipArchive::ER_NOENT: $ErrMsg = "No such file."; break; case ZipArchive::ER_NOZIP: $ErrMsg = "Not a zip archive."; break; case ZipArchive::ER_OPEN: $ErrMsg = "Can't open file."; break; case ZipArchive::ER_READ: $ErrMsg = "Read error."; break; case ZipArchive::ER_SEEK: $ErrMsg = "Seek error."; break; default: $ErrMsg = "Unknown (Code {$rOpen})"; break; } print "Zip Error Message: " . $ErrMsg . "\r\n"; $this->AddError($string['invalidzip']); return; } } } $files['qti12'] = array(); // qti 1.2 files, each unrelated to the rest $files['manifest'] = array(); // manifest files $files['item'] = array(); // qti 2 questions $files['paper'] = array(); // qti 2 test files foreach ($xml_files as $filename => $fullpath) { $type = $this->DetectFileType($fullpath); $files[$type][$filename] = $fullpath; } if (count($files['qti12']) == 0) { $this->AddError($string['noqtiinzip']); return; } $result = new stdClass(); $result->questions = array(); // process qti 1.2 files foreach ($files['qti12'] as $filename => $fullpath) { $qti12 = new IE_QTI12_Load(); $params->sourcefile = $fullpath; $ob = new OB(); $ob->ClearAndSave(); $output = $qti12->Load($params); $this->debug .= $ob->GetContent(); $ob->Restore(); foreach ($qti12->warnings as $qid => $warnings) { foreach ($warnings as $warn) { $this->warnings[$qid][] = $warn; } } foreach ($qti12->errors as $qid => $errors) { foreach ($errors as $error) { $this->errors[$qid][] = $error; } } echo "<h4>{$string['fileoutput']}: {$filename}</h4>"; echo $this->debug; foreach ($output->questions as $id => $question) { $result->questions[$id] = $question; } if (!empty($output->papers)) { foreach ($output->papers as $id => $paper) { $result->papers[$id] = $paper; } } } return $result; }