read($fromExercise); } $nameTools = get_lang('QuestionPool'); $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices')); $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name); $displayMessage = ""; // messag to be displayed if actions succesfull if ($is_allowedToEdit) { //Duplicating a Question if (!isset($_POST['recup']) && $copy_question != 0 && isset($fromExercise)) { $origin_course_id = intval($_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); if ($old_question_obj) { $old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy')); //Duplicating the source question, in the current course $new_id = $old_question_obj->duplicate($current_course); //Reading new question $new_question_obj = Question::read($new_id); $new_question_obj->addToList($fromExercise); //Reading Answers obj of the current course $new_answer_obj = new Answer($old_question_id, $origin_course_id); $new_answer_obj->read(); //Duplicating the Answers in the current 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); } Session::write('objExercise', $objExercise); } $displayMessage = get_lang('ItemAdded'); } // deletes a question from the database 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 $objQuestionTmp = Question :: read($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); Session::write('objExercise',$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 $course_id => $question_data) { $origin_course_id = intval($course_id); $origin_course_info = api_get_course_info_by_id($origin_course_id); $current_course = api_get_course_info(); foreach ($question_data as $old_question_id) { /* $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); */ //Reading the source question $old_question_obj = Question::read($old_question_id, $origin_course_id); if ($old_question_obj) { $old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy')); //Duplicating the source question, in the current course $new_id = $old_question_obj->duplicate($current_course); //Reading new question $new_question_obj = Question::read($new_id); $new_question_obj->addToList($fromExercise); //Reading Answers obj of the current course $new_answer_obj = new Answer($old_question_id, $origin_course_id); $new_answer_obj->read(); //Duplicating the Answers in the current 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); } } } } Session::write('objExercise',$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')); } // if admin of course if (!$is_allowedToEdit) { api_not_allowed(true); } $confirmYourChoice = addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); $htmlHeadXtra[] = " "; Display::display_header($nameTools,'Exercise'); // Menu echo '