read($fromExercise); } if(!($objExcercise instanceOf Exercise) && !empty($exerciseId)) { $objExercise = new Exercise(); $objExercise->read($exerciseId); } if($is_allowedToEdit) { // 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); } // gets an existing question and copies it into a new exercise elseif($recup && $fromExercise) { // 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?exerciseId=$fromExercise"); exit(); } } $nameTools=get_lang('QuestionPool'); $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')); // if admin of course if($is_allowedToEdit) { Display::display_header($nameTools,"Exercise"); ?>

0) { $sql="SELECT id,question,type FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($exerciseId)."' ORDER BY question_order"; } // if we have selected the option 'Orphan questions' in the list-box 'Filter' elseif($exerciseId == -1) { $sql='SELECT id, question, type, exercice_id FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id AND exercice_id IS NULL'; } // if we have not selected any option in the list-box 'Filter' else { $sql="SELECT id,question,type FROM $TBL_QUESTIONS"; // forces the value to 0 $exerciseId=0; } $result=api_sql_query($sql,__FILE__,__LINE__); $nbrQuestions=Database::num_rows($result); echo '', ''; if(!empty($fromExercise)) { echo '', ''; } else { echo '', '', ''; } echo ''; $i=1; //print_r($objExercise->questionList); while ($row = Database::fetch_array($result)) { // if we come from the exercise administration to get a question, // don't show the questions already used by that exercise /*if (!$fromExercise) {echo '1'; } if (!isset($objExercise)){echo '2';} if (!($objExercise instanceOf Exercise)){echo '3';} if (!$objExercise->isInList($row['id'])) {echo '4';} */ // original recipe - //if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (!$objExercise->isInList($row['id']))) if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (is_array($objExercise->questionList)) ) { echo ''; echo ' '; echo ' ', ''; } else { echo '',get_lang('Reuse'),''; echo ''; } echo ''; // skips the last question, that is only used to know if we have or not to create a link "Next page" if($i == $limitQuestPage) { break; } $i++; } } if(!$nbrQuestions) { echo '', '', ''; } echo '
:
', '', '', '', '
'; if(!empty($fromExercise)) { echo '<<',get_lang('GoBackToEx'),''; } else { echo '',get_lang('NewQu'),''; } echo ''; if(!empty($page)) { echo '<< ',get_lang('PreviousPage'),' |'; } elseif($nbrQuestions > $limitQuestPage) { echo '<< ',get_lang('PreviousPage'),' |'; } if($nbrQuestions > $limitQuestPage) { echo '',get_lang('NextPage'),' >>'; } elseif($page) { echo ' ',get_lang('NextPage'),' >>'; } echo '
',get_lang('Question'),'',get_lang('Reuse'),'',get_lang('Question'),'',get_lang('Modify'),'',get_lang('Delete'),'
',$row['question'],''; if (empty($fromExercise)) { echo '',get_lang('Modify'),'', '', '',get_lang('Delete'),'', '
',get_lang('NoQuestion'),'
', '
'; Display::display_footer(); } // if not admin of course else { api_not_allowed(true); } ?>