read($fromExercise); } $nameTools = get_lang('QuestionPool'); $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices')); if (!empty($objExercise)) { $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name); } // message to be displayed if actions successful $displayMessage = ""; 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); $courseId = $current_course['real_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); $objExercise = new Exercise($courseId); $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 $objQuestionTmp = Question::read($delete); // if the question exists if ($objQuestionTmp) { // 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) { /* 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 (!$objExercise 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); } 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) { //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 (!$objExercise instanceOf Exercise) { $objExercise = new Exercise(); $objExercise->read($fromExercise); } } } } Session::write('objExercise',$objExercise); } } 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 '