0){echo str_repeat(' ',0).'$formSent was set'."
\n";}
// initializing
if(!is_array($exerciseResult))
{
$exerciseResult=array();
$exerciseResultCoordinates=array();
}
// if the user has answered at least one question
if(is_array($choice))
{
if($debug>0){echo str_repeat(' ',0).'$choice is an array'."
\n";}
if($exerciseType == 1)
{
// $exerciseResult receives the content of the form.
// Each choice of the student is stored into the array $choice
$exerciseResult=$choice;
if (isset($_POST['hotspot']))
{
$exerciseResultCoordinates = $_POST['hotspot'];
}
}
else
{
// gets the question ID from $choice. It is the key of the array
list($key)=array_keys($choice);
// if the user didn't already answer this question
if(!isset($exerciseResult[$key]))
{
// stores the user answer into the array
$exerciseResult[$key]=$choice[$key];
if (isset($_POST['hotspot']))
{
$exerciseResultCoordinates[$key] = $_POST['hotspot'][$key];
}
}
}
if($debug>0){echo str_repeat(' ',0).'$choice is an array - end'."
\n";}
}
// the script "exercise_result.php" will take the variable $exerciseResult from the session
api_session_register('exerciseResult');
api_session_register('exerciseResultCoordinates');
// if it is the last question (only for a sequential exercise)
if($exerciseType == 1 || $questionNum >= $nbrQuestions)
{
if($debug>0){echo str_repeat(' ',0).'Redirecting to exercise_result.php - Remove debug option to let this happen'."
\n";}
// goes to the script that will show the result of the exercise
header("Location: exercise_result.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
exit();
}
if($debug>0){echo str_repeat(' ',0).'$formSent was set - end'."
\n";}
}
// if the object is not in the session
if(!isset($_SESSION['objExercise']))
{
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset'."
\n";}
// construction of Exercise
$objExercise=new Exercise();
#$sql="SELECT title,description,sound,type,random,active FROM `$TBL_EXERCICES` WHERE id='$exerciseId'";
// if the specified exercise doesn't exist or is disabled
if(!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() && !$is_allowedToEdit && ($origin != 'learnpath') ))
{
die(get_lang('ExerciseNotFound'));
}
// saves the object into the session
api_session_register('objExercise');
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset - set now - end'."
\n";}
}
if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
$objExercise = $_SESSION['objExercise'];
}
if(!is_object($objExercise))
{
header('Location: exercice.php');
exit();
}
$exerciseTitle=$objExercise->selectTitle();
$exerciseDescription=$objExercise->selectDescription();
$exerciseSound=$objExercise->selectSound();
$randomQuestions=$objExercise->isRandom();
$exerciseType=$objExercise->selectType();
if(!isset($_SESSION['questionList']))
{
if($debug>0){echo str_repeat(' ',0).'$_SESSION[questionList] was unset'."
\n";}
// selects the list of question ID
$questionList = ($randomQuestions?$objExercise->selectRandomList():$objExercise->selectQuestionList());
// saves the question list into the session
api_session_register('questionList');
if($debug>0){echo str_repeat(' ',0).'$_SESSION[questionList] was unset - set now - end'."
\n";}
}
if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
$questionList = $_SESSION['questionList'];
}
$nbrQuestions=sizeof($questionList);
// if questionNum comes from POST and not from GET
if(!$questionNum || $_POST['questionNum'])
{
// only used for sequential exercises (see $exerciseType)
if(!$questionNum)
{
$questionNum=1;
}
else
{
$questionNum++;
}
}
//$nameTools=get_lang('Exercice');
$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
$interbreadcrumb[]=array("url" => "#","name" => $exerciseTitle);
if ($origin != 'learnpath') { //so we are not in learnpath tool
$htmlHeadXtra[] = "
";
Display::display_header($nameTools,"Exercise");
}
else
{
if(empty($charset))
{
$charset = 'ISO-8859-15';
}
header('Content-Type: text/html; charset='. $charset);
@$document_language = Database::get_language_isocode($language_interface);
if(empty($document_language))
{
//if there was no valid iso-code, use the english one
$document_language = 'en';
}
/*
* HTML HEADER
*/
?>
$exerciseDescription