/** * Export the questions, as a succession of <items> * @author Amand Tihon <*****@*****.**> */ function export_questions() { $out = ""; foreach ($this->exercise->selectQuestionList() as $q) { $out .= export_question_qti($q, false); } return $out; }
$objQuestion = $objQuestion->swapSimpleAnswerTypes(); $_SESSION['objQuestion'] = $objQuestion; } $objAnswer = isset($_SESSION['objAnswer']) ? $_SESSION['objAnswer'] : null; // document path $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; // picture path $picturePath = $documentPath . '/images'; // audio path $audioPath = $documentPath . '/audio'; // the 5 types of answers $aType = array(get_lang('UniqueSelect'), get_lang('MultipleSelect'), get_lang('FillBlanks'), get_lang('Matching'), get_lang('FreeAnswer')); // tables used in the exercise tool if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) { require_once 'export/qti2/qti2_export.php'; $export = export_question_qti($_GET['questionId'], true); $qid = (int) $_GET['questionId']; $archive_path = api_get_path(SYS_ARCHIVE_PATH); $temp_dir_short = uniqid(); $temp_zip_dir = $archive_path . "/" . $temp_dir_short; if (!is_dir($temp_zip_dir)) { mkdir($temp_zip_dir, api_get_permissions_for_new_directories()); } $temp_zip_file = $temp_zip_dir . "/" . api_get_unique_id() . ".zip"; $temp_xml_file = $temp_zip_dir . "/qti2export_" . $qid . '.xml'; file_put_contents($temp_xml_file, $export); $zip_folder = new PclZip($temp_zip_file); $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH); $name = 'qti2_export_' . $qid . '.zip'; DocumentManager::file_send_for_download($temp_zip_file, true, $name); unlink($temp_zip_file);