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?".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/'.$_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook')
);
}
$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");
?>
';
Display::display_footer();
} else {
// if not admin of course
api_not_allowed(true);
}
?>