@ -33,7 +33,7 @@
* the administrator
* the administrator
* @package dokeos.exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @author Olivier Brouckaert
* @version $Id: exercice_submit.php 14930 2008-04-16 21:41:35Z juliomontoya $
* @version $Id: exercice_submit.php 15251 2008-05-08 20:28:28Z yannoo $
*/
*/
@ -100,7 +100,7 @@ if ( empty ( $exerciseType ) ) {
$exerciseType = $_REQUEST['exerciseType'];
$exerciseType = $_REQUEST['exerciseType'];
}
}
if ( empty ( $exerciseId ) ) {
if ( empty ( $exerciseId ) ) {
$exerciseId = $_REQUEST['exerciseId'];
$exerciseId = intval( $_REQUEST['exerciseId']) ;
}
}
if ( empty ( $choice ) ) {
if ( empty ( $choice ) ) {
$choice = $_REQUEST['choice'];
$choice = $_REQUEST['choice'];
@ -114,6 +114,7 @@ if ( empty ( $nbrQuestions ) ) {
if ( empty ($buttonCancel) ) {
if ( empty ($buttonCancel) ) {
$buttonCancel = $_REQUEST['buttonCancel'];
$buttonCancel = $_REQUEST['buttonCancel'];
}
}
$error = '';
// if the user has clicked on the "Cancel" button
// if the user has clicked on the "Cancel" button
if($buttonCancel)
if($buttonCancel)
@ -199,24 +200,26 @@ if($formSent)
}
}
// if the object is not in the session
// if the object is not in the session
if(!isset($_SESSION['objExercise']) || $origin == 'learnpath')
if(!isset($_SESSION['objExercise']) || $origin == 'learnpath' || $_SESSION['objExercise']->id != $_REQUEST['exerciseId'] )
{
{
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset'."< br / > \n";}
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset'."< br / > \n";}
// construction of Exercise
// construction of Exercise
$objExercise=new Exercise();
$objExercise=new Exercise();
unset($_SESSION['questionList']);
#$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 the specified exercise doesn't exist or is disabled
if(!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() & & !$is_allowedToEdit & & ($origin != 'learnpath') ))
if(!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() & & !$is_allowedToEdit & & ($origin != 'learnpath') ))
{
{
die(get_lang('ExerciseNotFound'));
unset($objExercise);
$error = get_lang('ExerciseNotFound');
//die(get_lang('ExerciseNotFound'));
}
else
{
// saves the object into the session
api_session_register('objExercise');
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset - set now - end'."< br / > \n";}
}
}
// saves the object into the session
api_session_register('objExercise');
if($debug>0){echo str_repeat(' ',0).'$_SESSION[objExercise] was unset - set now - end'."< br / > \n";}
}
}
if(!isset($objExcercise) & & isset($_SESSION['objExercise'])){
if(!isset($objExcercise) & & isset($_SESSION['objExercise'])){
@ -410,7 +413,7 @@ else
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = " <?php echo $document_language ; ?> " lang = " <?php echo $document_language ; ?> " >
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = " <?php echo $document_language ; ?> " lang = " <?php echo $document_language ; ?> " >
< head >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" / >
< meta http-equiv = "Content-Type" content = "text/html; charset= <?php echo $charset ; ?> " />
< / head >
< / head >
< body >
< body >
@ -423,30 +426,46 @@ else
echo "< h3 > ".$exerciseTitle."< / h3 > ";
echo "< h3 > ".$exerciseTitle."< / h3 > ";
if(!empty($exerciseSound ))
if(!empty($error ))
{
{
echo "< a href = \"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\" target = \"_blank\" > ",
Display::display_error_message($error,false);
"< img src = \"../img/sound.gif\" border = \"0\" align = \"absmiddle\" alt = ",get_lang('Sound')." \ " / > < / a > ";
}
}
else
// Get number of hotspot questions for javascript validation
$number_of_hotspot_questions = 0;
$onsubmit = '';
$i=0;
foreach($questionList as $questionId)
{
{
$i++;
$objQuestionTmp = Question :: read($questionId);
// for sequential exercises
if(!empty($exerciseSound))
if($exerciseType == 2)
{
{
// if it is not the right question, goes to the next loop iteration
echo "< a href = \"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\" target = \"_blank\" > ",
if($questionNum != $i)
"< img src = \"../img/sound.gif\" border = \"0\" align = \"absmiddle\" alt = ",get_lang('Sound')." \ " / > < / a > ";
}
// Get number of hotspot questions for javascript validation
$number_of_hotspot_questions = 0;
$onsubmit = '';
$i=0;
foreach($questionList as $questionId)
{
$i++;
$objQuestionTmp = Question :: read($questionId);
// for sequential exercises
if($exerciseType == 2)
{
{
continue;
// if it is not the right question, goes to the next loop iteration
if($questionNum != $i)
{
continue;
}
else
{
if ($objQuestionTmp->selectType() == HOT_SPOT)
{
$number_of_hotspot_questions++;
}
break;
}
}
}
else
else
{
{
@ -454,119 +473,111 @@ foreach($questionList as $questionId)
{
{
$number_of_hotspot_questions++;
$number_of_hotspot_questions++;
}
}
break;
}
}
}
}
else
if($number_of_hotspot_questions > 0)
{
{
if ($objQuestionTmp->selectType() == HOT_SPOT)
$onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
{
$number_of_hotspot_questions++;
}
}
}
}
$s="< p > $exerciseDescription< / p > ";
if($number_of_hotspot_questions > 0)
if($origin == 'learnpath' & & $exerciseType==2){
{
$s2 = "&exerciseId=".$exerciseId;
$onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
}
}
$s.=" < form method = 'post' action = '".api_get_self()."?autocomplete=off".$s2."' name = 'frm_exercise' $ onsubmit >
$s="< p > $exerciseDescription< / p > ";
< input type = 'hidden' name = 'formSent' value = '1' / >
< input type = 'hidden' name = 'exerciseType' value = '".$exerciseType."' / >
if($origin == 'learnpath' & & $exerciseType==2){
< input type = 'hidden' name = 'questionNum' value = '".$questionNum."' / >
$s2 = "&exerciseId=".$exerciseId;
< input type = 'hidden' name = 'nbrQuestions' value = '".$nbrQuestions."' / >
}
< input type = 'hidden' name = 'origin' value = '".$origin."' / >
$s.=" < form method = 'post' action = '".api_get_self()."?autocomplete=off".$s2."' name = 'frm_exercise' $ onsubmit >
< input type = 'hidden' name = 'learnpath_id' value = '".$learnpath_id."' / >
< input type = 'hidden' name = 'formSent' value = '1' / >
< input type = 'hidden' name = 'learnpath_item_id' value = '".$learnpath_item_id."' / >
< input type = 'hidden' name = 'exerciseType' value = '".$exerciseType."' / >
< table width = '100%' border = '0' cellpadding = '1' cellspacing = '0' >
< input type = 'hidden' name = 'questionNum' value = '".$questionNum."' / >
< tr >
< input type = 'hidden' name = 'nbrQuestions' value = '".$nbrQuestions."' / >
< td >
< input type = 'hidden' name = 'origin' value = '".$origin."' / >
< table width = '100%' cellpadding = '3' cellspacing = '0' border = '0' > ";
< input type = 'hidden' name = 'learnpath_id' value = '".$learnpath_id."' / >
echo $s;
< input type = 'hidden' name = 'learnpath_item_id' value = '".$learnpath_item_id."' / >
< table width = '100%' border = '0' cellpadding = '1' cellspacing = '0' >
$i=0;
< tr >
< td >
foreach($questionList as $questionId)
< table width = '100%' cellpadding = '3' cellspacing = '0' border = '0' > ";
echo $s;
$i=0;
foreach($questionList as $questionId)
{
$i++;
// for sequential exercises
if($exerciseType == 2)
{
{
// if it is not the right question, goes to the next loop iteration
$i++;
if($questionNum != $i)
{
// for sequential exercises
continue;
if($exerciseType == 2)
}
else
{
{
// if the user has already answered this ques tion
// if it is not the right question, goes to the next loop iteration
if(isset($exerciseResult[$questionId]) )
if($questionNum != $i)
{
{
// construction of the Question object
continue;
$objQuestionTmp = Question::read($questionId);
}
else
$questionName=$objQuestionTmp->selectTitle();
{
// if the user has already answered this question
// destruction of the Question object
if(isset($exerciseResult[$questionId]))
unset($objQuestionTmp);
{
// construction of the Question object
echo '< tr > < td > '.get_lang('AlreadyAnswered').' " '.$questionName.'" < / td > < / tr > ';
$objQuestionTmp = Question::read($questionId);
break;
$questionName=$objQuestionTmp->selectTitle();
// destruction of the Question object
unset($objQuestionTmp);
echo '< tr > < td > '.get_lang('AlreadyAnswered').' " '.$questionName.'" < / td > < / tr > ';
break;
}
}
}
}
}
}
$s="< tr >
$s="< tr >
< td width = '3%' bgcolor = '#e6e6e6' > < img src = \"".api_get_path(WEB_IMG_PATH)."test.gif\" align = \"absmiddle\" > < / td >
< td width = '3%' bgcolor = '#e6e6e6' > < img src = \"".api_get_path(WEB_IMG_PATH)."test.gif\" align = \"absmiddle\" > < / td >
< td valign = 'middle' bgcolor = '#e6e6e6' >
< td valign = 'middle' bgcolor = '#e6e6e6' >
".get_lang('Question')." ";
".get_lang('Question')." ";
$s.=$i;
$s.=$i;
if($exerciseType == 2) $s.=' / '.$nbrQuestions;
if($exerciseType == 2) $s.=' / '.$nbrQuestions;
$s.='< / td > < / tr > ';
$s.='< / td > < / tr > ';
echo $s;
// shows the question and its answers
showQuestion($questionId, false, $origin);
// for sequential exercises
if($exerciseType == 2)
{
// quits the loop
break;
}
} // end foreach()
$s="< / table >
< / td >
< / tr >
< tr >
< td > < br / >
<!-- <input type='submit' name='buttonCancel' value=".get_lang('Cancel')." />
//-->
< input type = 'submit' name = 'submit' value = '";
if ($exerciseType == 1 || $nbrQuestions == $questionNum)
{
$s.=get_lang('ValidateAnswer');
}
else
{
$s.=get_lang('Next').' > ';
}
//$s.='\'> ';
$s.= '\' />';
$s.="< / td > < / tr > < / form > < / table > ";
$b=2;
echo $s;
echo $s;
}
// shows the question and its answers
showQuestion($questionId, false, $origin);
// for sequential exercises
if($exerciseType == 2)
{
// quits the loop
break;
}
} // end foreach()
$s="< / table >
< / td >
< / tr >
< tr >
< td > < br / >
<!-- <input type='submit' name='buttonCancel' value=".get_lang('Cancel')." />
//-->
< input type = 'submit' name = 'submit' value = '";
if ($exerciseType == 1 || $nbrQuestions == $questionNum)
{
$s.=get_lang('ValidateAnswer');
}
else
{
$s.=get_lang('Next').' > ';
}
//$s.='\'> ';
$s.= '\' />';
$s.="< / td > < / tr > < / form > < / table > ";
$b=2;
echo $s;
if ($origin != 'learnpath') { //so we are not in learnpath tool
if ($origin != 'learnpath') { //so we are not in learnpath tool
Display::display_footer();
Display::display_footer();