read($fromExercise); } if(!($objExcercise instanceOf Exercise) && !empty($exerciseId)) { $objExercise = new Exercise(); $objExercise->read($exerciseId); } if ($is_allowedToEdit) { //Duplicating a Question if ($copy_question != 0 && isset($fromExercise)) { $origin_course_id = $_GET['course_id']; $origin_course_info = api_get_course_info_by_id($origin_course_id); $current_course = api_get_course_info(); $old_question_id = $copy_question; //Reading the source question $old_question_obj = Question::read($old_question_id, $origin_course_id); $old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy')); //Duplicating question in the current course $new_id = $old_question_obj->duplicate($current_course); $new_question_obj = Question::read($new_id); $new_question_obj->addToList($fromExercise); //Reading Answer obj from origin course $new_answer_obj = new Answer($old_question_id, $origin_course_id); $new_answer_obj->read(); //Duplicating the answers in this course $new_answer_obj->duplicate($new_id, $current_course); // destruction of the Question object unset($new_question_obj); unset($old_question_obj); if(!$objExcercise instanceOf Exercise) { $objExercise = new Exercise(); $objExercise->read($fromExercise); } // adds the question ID represented by $recup into the list of questions for the current exercise //$objExercise->addToList($new_id); api_session_register('objExercise'); exit; header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise"); exit(); } // deletes a question from the data base and all exercises if($delete) { // construction of the Question object // if the question exists if($objQuestionTmp = Question::read($delete)) { // deletes the question from all exercises $objQuestionTmp->delete(); } // destruction of the Question object unset($objQuestionTmp); } elseif($recup && $fromExercise) { // gets an existing question and copies it into a new exercise // if the question exists if($objQuestionTmp = Question :: read($recup)) { // adds the exercise ID represented by $fromExercise into the list of exercises for the current question $objQuestionTmp->addToList($fromExercise); } // destruction of the Question object unset($objQuestionTmp); if(!$objExcercise instanceOf Exercise) { $objExercise = new Exercise(); $objExercise->read($fromExercise); } // adds the question ID represented by $recup into the list of questions for the current exercise $objExercise->addToList($recup); api_session_register('objExercise'); header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise"); exit(); } else if( isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) { $list_recup = $_POST['recup']; foreach ($list_recup as $recup) { $recup = intval($recup); // if the question exists if($objQuestionTmp = Question :: read($recup)) { // adds the exercise ID represented by $fromExercise into the list of exercises for the current question $objQuestionTmp->addToList($fromExercise); } // destruction of the Question object unset($objQuestionTmp); if(!$objExcercise instanceOf Exercise) { $objExercise = new Exercise(); $objExercise->read($fromExercise); } // adds the question ID represented by $recup into the list of questions for the current exercise $objExercise->addToList($recup); } api_session_register('objExercise'); header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise"); exit(); } } if (isset($_SESSION['gradebook'])){ $gradebook= $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook')); } $nameTools=get_lang('QuestionPool'); $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); $selected_course = 0; // if admin of course if ($is_allowedToEdit) { $htmlHeadXtra[] = ' '; Display::display_header($nameTools,'Exercise'); echo '