$val) { if(is_string($val)) { $_POST[$key]=stripslashes($val); } elseif(is_array($val)) { foreach($val as $key2=>$val2) { $_POST[$key][$key2]=stripslashes($val2); } } $GLOBALS[$key]=$_POST[$key]; } } // get vars from GET if ( empty ( $exerciseId ) ) { $exerciseId = $_GET['exerciseId']; } if ( empty ( $newQuestion ) ) { $newQuestion = $_GET['newQuestion']; } if ( empty ( $modifyAnswers ) ) { $modifyAnswers = $_GET['modifyAnswers']; } if ( empty ( $editQuestion ) ) { $editQuestion = $_GET['editQuestion']; } if ( empty ( $modifyQuestion ) ) { $modifyQuestion = $_GET['modifyQuestion']; } if ( empty ( $deleteQuestion ) ) { $deleteQuestion = $_GET['deleteQuestion']; } if ( empty ( $questionId ) ) { $questionId = $_SESSION['questionId']; } if ( empty ( $modifyExercise ) ) { $modifyExercise = $_GET['modifyExercise']; } // get from session $objExercise = $_SESSION['objExercise']; $objQuestion = $_SESSION['objQuestion']; $objAnswer = $_SESSION['objAnswer']; // 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 $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION); $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER); $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT); if($_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) { require_once('export/qti2/qti2_export.php'); $export = export_question((int)$_GET['questionId'],true); $qid = (int)$_GET['questionId']; require_once(api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php'); $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); $temp_zip_file = $temp_zip_dir."/".md5(time()).".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); unlink($temp_xml_file); rmdir($temp_zip_dir); //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml'); exit(); //otherwise following clicks may become buggy } // intializes the Exercise object if(!is_object($objExercise)) { // construction of the Exercise object $objExercise=new Exercise(); // creation of a new exercise if wrong or not specified exercise ID if($exerciseId) { $objExercise->read($exerciseId); } // saves the object into the session api_session_register('objExercise'); } // doesn't select the exercise ID if we come from the question pool if(!$fromExercise) { // gets the right exercise ID, and if 0 creates a new exercise if(!$exerciseId=$objExercise->selectId()) { $modifyExercise='yes'; } } $nbrQuestions=$objExercise->selectNbrQuestions(); // intializes the Question object if($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) { if($editQuestion || $newQuestion) { // reads question data if($editQuestion) { // question not found if(!$objQuestion = Question::read($editQuestion)) { die(get_lang('QuestionNotFound')); } // saves the object into the session api_session_register('objQuestion'); } } // checks if the object exists if(is_object($objQuestion)) { // gets the question ID $questionId=$objQuestion->selectId(); } } // if cancelling an exercise if($cancelExercise) { // existing exercise if($exerciseId) { unset($modifyExercise); } // new exercise else { // goes back to the exercise list header('Location: exercice.php'); exit(); } } // if cancelling question creation/modification if($cancelQuestion) { // if we are creating a new question from the question pool if(!$exerciseId && !$questionId) { // goes back to the question pool header('Location: question_pool.php'); exit(); } else { // goes back to the question viewing $editQuestion=$modifyQuestion; unset($newQuestion,$modifyQuestion); } } // if cancelling answer creation/modification if($cancelAnswers) { // goes back to the question viewing $editQuestion=$modifyAnswers; unset($modifyAnswers); } // modifies the query string that is used in the link of tool name if($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) { $nameTools=get_lang('QuestionManagement'); } if (isset($_SESSION['gradebook'])){ $gradebook= $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook') ); } $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); $interbreadcrumb[]=array("url" => "admin.php?exerciseId=".$objExercise->id,"name" => $objExercise->exercise); // shows a link to go back to the question pool if(!$exerciseId && $nameTools != get_lang('ExerciseManagement')){ $interbreadcrumb[]=array("url" => "question_pool.php?fromExercise=$fromExercise","name" => get_lang('QuestionPool')); } // if the question is duplicated, disable the link of tool name if($modifyIn == 'thisExercise') { if($buttonBack) { $modifyIn='allExercises'; } else { $noPHP_SELF=true; } } $htmlHeadXtra[] = " "; Display::display_header($nameTools,'Exercise'); echo '