Bläddra i källkod

[svn r10774] language vars
coding conventions
adding todo information
using table constansts (unfinished)

Patrick Cool 18 år sedan
förälder
incheckning
f284a3250b

+ 45 - 35
main/exercice/addlimits.php

@@ -1,6 +1,6 @@
 <?php
 <?php
 /**
 /**
- * @todo use database library 
+ * @todo use database library
  */
  */
 /*
 /*
 -----------------------------------------------------------
 -----------------------------------------------------------
@@ -35,7 +35,7 @@ define('FREE_ANSWER', 5);
 	Language
 	Language
 -----------------------------------------------------------
 -----------------------------------------------------------
 */
 */
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 /*
 /*
@@ -49,58 +49,71 @@ api_protect_course_script();
 
 
 /*
 /*
 -----------------------------------------------------------
 -----------------------------------------------------------
-	Table definitions 
+	Table definitions
 	@todo: use the Database :: get_course_table functions
 	@todo: use the Database :: get_course_table functions
 -----------------------------------------------------------
 -----------------------------------------------------------
 */
 */
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table('quiz_answer');
 $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
 $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
-$TABLETRACK_ATTEMPT = $_configuration['statistics_database']."`.`track_e_attempt"; 
+$TABLETRACK_ATTEMPT = $_configuration['statistics_database']."`.`track_e_attempt";
 $TABLETRACK_EXERCICES = $_configuration['statistics_database']."`.`track_e_exercices";
 $TABLETRACK_EXERCICES = $_configuration['statistics_database']."`.`track_e_exercices";
 
 
-$dsp_percent = false; 
+$dsp_percent = false;
 $debug=0;
 $debug=0;
-if($debug>0){echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);}
+if($debug>0)
+{
+	echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
+}
 // general parameters passed via POST/GET
 // general parameters passed via POST/GET
-if ( empty ( $origin ) ) {
+if ( empty ( $origin ) )
+{
     $origin = $_REQUEST['origin'];
     $origin = $_REQUEST['origin'];
 }
 }
-if ( empty ( $learnpath_id ) ) {
+if ( empty ( $learnpath_id ) )
+{
     $learnpath_id       = mysql_real_escape_string($_REQUEST['learnpath_id']);
     $learnpath_id       = mysql_real_escape_string($_REQUEST['learnpath_id']);
 }
 }
-if ( empty ( $learnpath_item_id ) ) {
+if ( empty ( $learnpath_item_id ) )
+{
     $learnpath_item_id  = mysql_real_escape_string($_REQUEST['learnpath_item_id']);
     $learnpath_item_id  = mysql_real_escape_string($_REQUEST['learnpath_item_id']);
 }
 }
-if ( empty ( $formSent ) ) {
+if ( empty ( $formSent ) )
+{
     $formSent= $_REQUEST['formSent'];
     $formSent= $_REQUEST['formSent'];
 }
 }
-if ( empty ( $exerciseResult ) ) {
+if ( empty ( $exerciseResult ) )
+{
     $exerciseResult = $_SESSION['exerciseResult'];
     $exerciseResult = $_SESSION['exerciseResult'];
 }
 }
-if ( empty ( $questionId ) ) {
+if ( empty ( $questionId ) )
+{
     $questionId = $_REQUEST['questionId'];
     $questionId = $_REQUEST['questionId'];
 }
 }
 if ( empty ( $choice ) ) {
 if ( empty ( $choice ) ) {
     $choice = $_REQUEST['choice'];
     $choice = $_REQUEST['choice'];
 }
 }
-if ( empty ( $questionNum ) ) {
+if ( empty ( $questionNum ) )
+{
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
-if ( empty ( $nbrQuestions ) ) {
+}
+if ( empty ( $nbrQuestions ) )
+{
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
 }
-if ( empty ( $questionList ) ) {
+if ( empty ( $questionList ) )
+{
     $questionList = $_SESSION['questionList'];
     $questionList = $_SESSION['questionList'];
 }
 }
-if ( empty ( $objExercise ) ) {
+if ( empty ( $objExercise ) )
+{
     $objExercise = $_SESSION['objExercise'];
     $objExercise = $_SESSION['objExercise'];
 }
 }
 $exercise_id = $_GET['exercise_id'];
 $exercise_id = $_GET['exercise_id'];
-$is_allowedToEdit=$is_courseAdmin;	
+$is_allowedToEdit=$is_courseAdmin;
 
 
 
 
 $nameTools=get_lang('Exercice');
 $nameTools=get_lang('Exercice');
@@ -117,7 +130,7 @@ Display::display_header($nameTools,"Exercise");
 include('../inc/global.inc.php');
 include('../inc/global.inc.php');
 if (isset($_POST['ok']))
 if (isset($_POST['ok']))
 {
 {
-	$message = "Test limits added";
+	$message = get_lang('TestLimitsAdded');
 	Display::display_normal_message($message);
 	Display::display_normal_message($message);
 }
 }
 ?>
 ?>
@@ -127,26 +140,23 @@ if (isset($_POST['ok']))
   <script type="text/javascript">
   <script type="text/javascript">
   function selectlimited()
   function selectlimited()
   {
   {
-  document.getElementById('limited').checked="checked";
+  	document.getElementById('limited').checked="checked";
   }
   }
    function selectattempts()
    function selectattempts()
   {
   {
-  document.getElementById('attemptlimited').checked="checked";
+  	document.getElementById('attemptlimited').checked="checked";
   }
   }
   </script>
   </script>
-  <h3>
-  <?php 
-  echo "AddLimits"; ?>
-</h3>
+  <h3><?php  echo get_lang('AddLimits'); ?></h3>
 <br>
 <br>
 <form action="addlimits.php" name="frmlimit" method="post">
 <form action="addlimits.php" name="frmlimit" method="post">
 <h4>
 <h4>
 Time :
 Time :
 </h4>
 </h4>
 <input type="hidden" name="exe_id" value="<?php echo $exercise_id; ?>" />
 <input type="hidden" name="exe_id" value="<?php echo $exercise_id; ?>" />
-<input type="radio" name="limit" checked="checked" value="0" id="unlimit"> Unlimited
+<input type="radio" name="limit" checked="checked" value="0" id="unlimit"><?php echo get_lang('Unlimited'); ?>
 <br>
 <br>
-<input type="radio" name="limit" value="1" id="limited"> Limited: Each question of the test should be answered in
+<input type="radio" name="limit" value="1" id="limited"><?php echo get_lang('LimitedTime'); ?>
 <select name="minutes" onfocus="selectlimited();" >
 <select name="minutes" onfocus="selectlimited();" >
   <option selected="selected">1</option>
   <option selected="selected">1</option>
   <option>2</option>
   <option>2</option>
@@ -165,13 +175,13 @@ Time :
   <option>40</option>
   <option>40</option>
   <option>50</option>
   <option>50</option>
   <option>60</option>
   <option>60</option>
-</select> minute(s).
+</select><?php echo get_lang('Minutes'); ?>.
 <h4>
 <h4>
-Attempts :
+<?php echo get_lang('Attempts'); ?>:
 </h4>
 </h4>
-<input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"> Unlimited
+<input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"><?php echo get_lang('Unlimited'); ?>
 <br>
 <br>
-<input type="radio" name="attempt" value="1" id="attemptlimited"> Limited: The test can be taken only
+<input type="radio" name="attempt" value="1" id="attemptlimited"><?php echo get_lang('LimitedAttempts'); ?>
 <select name="attempts" onfocus="selectattempts();">
 <select name="attempts" onfocus="selectattempts();">
   <option selected="selected">1</option>
   <option selected="selected">1</option>
   <option>2</option>
   <option>2</option>
@@ -183,10 +193,10 @@ Attempts :
   <option>8</option>
   <option>8</option>
   <option>9</option>
   <option>9</option>
   <option>10</option>
   <option>10</option>
-  </select> time(s).
+  </select><?php echo get_lang('Times'); ?>.
 
 
 <br> <br>
 <br> <br>
-<input type="submit" name="ok" value="Ok">
+<input type="submit" name="ok" value="<?php echo get_lang('Ok'); ?>">
 </form>
 </form>
 <?php
 <?php
 /**
 /**

+ 36 - 29
main/exercice/admin.php

@@ -1,4 +1,4 @@
-<?php // $Id: admin.php 10691 2007-01-12 12:16:28Z elixir_inter $
+<?php // $Id: admin.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -75,7 +75,7 @@ include('question.class.php');
 include('answer.class.php');
 include('answer.class.php');
 
 
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 include("../inc/global.inc.php");
 include("../inc/global.inc.php");
@@ -109,28 +109,36 @@ if($_SERVER['REQUEST_METHOD'] == 'POST')
 }
 }
 
 
 // get vars from GET
 // get vars from GET
-if ( empty ( $exerciseId ) ) {
+if ( empty ( $exerciseId ) )
+{
     $exerciseId = mysql_real_escape_string($_GET['exerciseId']);
     $exerciseId = mysql_real_escape_string($_GET['exerciseId']);
 }
 }
-if ( empty ( $newQuestion ) ) {
+if ( empty ( $newQuestion ) )
+{
     $newQuestion = $_GET['newQuestion'];
     $newQuestion = $_GET['newQuestion'];
 }
 }
-if ( empty ( $modifyAnswers ) ) {
+if ( empty ( $modifyAnswers ) )
+{
     $modifyAnswers = $_GET['modifyAnswers'];
     $modifyAnswers = $_GET['modifyAnswers'];
 }
 }
-if ( empty ( $editQuestion ) ) {
+if ( empty ( $editQuestion ) )
+{
     $editQuestion = $_GET['editQuestion'];
     $editQuestion = $_GET['editQuestion'];
 }
 }
-if ( empty ( $modifyQuestion ) ) {
+if ( empty ( $modifyQuestion ) )
+{
     $modifyQuestion = $_GET['modifyQuestion'];
     $modifyQuestion = $_GET['modifyQuestion'];
 }
 }
-if ( empty ( $deleteQuestion ) ) {
+if ( empty ( $deleteQuestion ) )
+{
     $deleteQuestion = $_GET['deleteQuestion'];
     $deleteQuestion = $_GET['deleteQuestion'];
 }
 }
-if ( empty ( $questionId ) ) {
+if ( empty ( $questionId ) )
+{
     $questionId = $_SESSION['questionId'];
     $questionId = $_SESSION['questionId'];
 }
 }
-if ( empty ( $modifyExercise ) ) {
+if ( empty ( $modifyExercise ) )
+{
     $modifyExercise = $_GET['modifyExercise'];
     $modifyExercise = $_GET['modifyExercise'];
 }
 }
 
 
@@ -161,8 +169,8 @@ $aType=array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('FillB
 // tables used in the exercise tool
 // tables used in the exercise tool
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 $TBL_DOCUMENT          = $_course['dbNameGlu']."document";
 $TBL_DOCUMENT          = $_course['dbNameGlu']."document";
 
 
 if(!$is_allowedToEdit)
 if(!$is_allowedToEdit)
@@ -179,8 +187,7 @@ if(!is_object($objExercise))
 	// creation of a new exercise if wrong or not specified exercise ID
 	// creation of a new exercise if wrong or not specified exercise ID
 	if($exerciseId)
 	if($exerciseId)
 	{
 	{
-	
-    $objExercise->read($exerciseId);
+	    $objExercise->read($exerciseId);
 	}
 	}
 
 
 	// saves the object into the session
 	// saves the object into the session
@@ -282,12 +289,12 @@ else
 	$nameTools=get_lang('ExerciseManagement');
 	$nameTools=get_lang('ExerciseManagement');
 }
 }
 
 
-$interbreadcrump[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
+$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
 
 
 // shows a link to go back to the question pool
 // shows a link to go back to the question pool
 if(!$exerciseId && $nameTools != get_lang('ExerciseManagement'))
 if(!$exerciseId && $nameTools != get_lang('ExerciseManagement'))
 {
 {
-	$interbreadcrump[]=array("url" => "question_pool.php?fromExercise=$fromExercise","name" => get_lang('QuestionPool'));
+	$interbreadcrumb[]=array("url" => "question_pool.php?fromExercise=$fromExercise","name" => get_lang('QuestionPool'));
 }
 }
 
 
 // if the question is duplicated, disable the link of tool name
 // if the question is duplicated, disable the link of tool name
@@ -326,7 +333,7 @@ Function VBGetSwfVer(i)
   on error resume next
   on error resume next
   Dim swControl, swVersion
   Dim swControl, swVersion
   swVersion = 0
   swVersion = 0
-  
+
   set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
   set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
   if (IsObject(swControl)) then
   if (IsObject(swControl)) then
     swVersion = swControl.GetVariable(\"\$version\")
     swVersion = swControl.GetVariable(\"\$version\")
@@ -372,46 +379,46 @@ function JSGetSwfVer(i){
 	else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
 	else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
 	// Can't detect in all other cases
 	// Can't detect in all other cases
 	else {
 	else {
-		
+
 		flashVer = -1;
 		flashVer = -1;
 	}
 	}
 	return flashVer;
 	return flashVer;
-} 
+}
 // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
 // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
-function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
+function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
 {
 {
  	reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  	reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
-   	// loop backwards through the versions until we find the newest version	
-	for (i=25;i>0;i--) {	
+   	// loop backwards through the versions until we find the newest version
+	for (i=25;i>0;i--) {
 		if (isIE && isWin && !isOpera) {
 		if (isIE && isWin && !isOpera) {
 			versionStr = VBGetSwfVer(i);
 			versionStr = VBGetSwfVer(i);
 		} else {
 		} else {
 			versionStr = JSGetSwfVer(i);
 			versionStr = JSGetSwfVer(i);
 		}
 		}
-		if (versionStr == -1 ) { 
+		if (versionStr == -1 ) {
 			return false;
 			return false;
 		} else if (versionStr != 0) {
 		} else if (versionStr != 0) {
 			if(isIE && isWin && !isOpera) {
 			if(isIE && isWin && !isOpera) {
 				tempArray         = versionStr.split(\" \");
 				tempArray         = versionStr.split(\" \");
 				tempString        = tempArray[1];
 				tempString        = tempArray[1];
-				versionArray      = tempString .split(\",\");				
+				versionArray      = tempString .split(\",\");
 			} else {
 			} else {
 				versionArray      = versionStr.split(\".\");
 				versionArray      = versionStr.split(\".\");
 			}
 			}
 			versionMajor      = versionArray[0];
 			versionMajor      = versionArray[0];
 			versionMinor      = versionArray[1];
 			versionMinor      = versionArray[1];
 			versionRevision   = versionArray[2];
 			versionRevision   = versionArray[2];
-			
+
 			versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 			versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 			versionNum        = parseFloat(versionString);
 			versionNum        = parseFloat(versionString);
         	// is the major.revision >= requested major.revision AND the minor version >= requested minor
         	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 				return true;
 				return true;
 			} else {
 			} else {
-				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
+				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
 			}
 			}
 		}
 		}
-	}	
+	}
 }
 }
 // -->
 // -->
 </script>";
 </script>";
@@ -428,7 +435,7 @@ if($newQuestion || $editQuestion)
 {
 {
 	// statement management
 	// statement management
 	$type = $_REQUEST['answerType'];
 	$type = $_REQUEST['answerType'];
-	?><input type="hidden" name="Type" value="<?php echo $type; ?>" /> 
+	?><input type="hidden" name="Type" value="<?php echo $type; ?>" />
 	<?php
 	<?php
 	include('question_admin.inc.php');
 	include('question_admin.inc.php');
 }
 }
@@ -440,7 +447,7 @@ if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspota
 {
 {
 	// question list management
 	// question list management
 	include('question_list_admin.inc.php');
 	include('question_list_admin.inc.php');
-	
+
 }
 }
 
 
 
 

+ 8 - 7
main/exercice/adminhp.php

@@ -1,4 +1,4 @@
-<?php // $Id: adminhp.php 10204 2006-11-26 20:46:53Z pcool $
+<?php // $Id: adminhp.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -34,7 +34,7 @@ include('answer.class.php');
 
 
 include('exercise.lib.php');
 include('exercise.lib.php');
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 include('../inc/global.inc.php');
 include('../inc/global.inc.php');
@@ -44,7 +44,7 @@ if(isset($_REQUEST["cancel"]))
 {
 {
 	if($_REQUEST["cancel"]==get_lang('Cancel'))
 	if($_REQUEST["cancel"]==get_lang('Cancel'))
 	{
 	{
-				header("Location: exercice.php");		
+				header("Location: exercice.php");
 	}
 	}
 }
 }
 
 
@@ -57,7 +57,7 @@ define(UNIQUE_ANSWER,	1);
 define(MULTIPLE_ANSWER,	2);
 define(MULTIPLE_ANSWER,	2);
 define(FILL_IN_BLANKS,	3);
 define(FILL_IN_BLANKS,	3);
 define(MATCHING,		4);
 define(MATCHING,		4);
-define(FREE_ANSWER,     5); 
+define(FREE_ANSWER,     5);
 
 
 // allows script inclusions
 // allows script inclusions
 define(ALLOWED_TO_INCLUDE,1);
 define(ALLOWED_TO_INCLUDE,1);
@@ -94,6 +94,7 @@ $nameTools = get_lang('adminHP');
 
 
 Display::display_header($nameTools,"Exercise");
 Display::display_header($nameTools,"Exercise");
 
 
+/** @todo probably wrong !!!! */
 require_once(api_get_path(SYS_PATH).'claroline/exercice/hotpotatoes.lib.php');
 require_once(api_get_path(SYS_PATH).'claroline/exercice/hotpotatoes.lib.php');
 
 
 ?>
 ?>
@@ -105,12 +106,12 @@ require_once(api_get_path(SYS_PATH).'claroline/exercice/hotpotatoes.lib.php');
 <?php
 <?php
 if(isset($newName))
 if(isset($newName))
 {
 {
-		if($newName!="")		
+		if($newName!="")
 		{
 		{
 			//alter database record for that test
 			//alter database record for that test
 			SetComment($hotpotatoesName,$newName);
 			SetComment($hotpotatoesName,$newName);
 			echo "<script language='Javascript' type='text/javascript'> window.location='exercice.php'; </script>";
 			echo "<script language='Javascript' type='text/javascript'> window.location='exercice.php'; </script>";
-		}		
+		}
 }
 }
 
 
 echo "<form action=\"{$_SERVER['PHP_SELF']}\" method='post' name='form1'>";
 echo "<form action=\"{$_SERVER['PHP_SELF']}\" method='post' name='form1'>";
@@ -125,7 +126,7 @@ if($lstrComment=="")
 if($lstrComment=="")
 if($lstrComment=="")
 	$lstrComment = GetFileName($hotpotatoesName,$documentPath);
 	$lstrComment = GetFileName($hotpotatoesName,$documentPath);
 
 
-echo $lstrComment;	
+echo $lstrComment;
 echo "\" size=40>&nbsp;";
 echo "\" size=40>&nbsp;";
 echo "<input type=\"submit\" name=\"submit\" value=\"".get_lang('Ok')."\">&nbsp;";
 echo "<input type=\"submit\" name=\"submit\" value=\"".get_lang('Ok')."\">&nbsp;";
 echo "<input type=\"button\" name=\"cancel\" value=\"".get_lang('Cancel')."\" onclick=\"javascript:document.form1.newName.value='';\">";
 echo "<input type=\"button\" name=\"cancel\" value=\"".get_lang('Cancel')."\" onclick=\"javascript:document.form1.newName.value='';\">";

+ 27 - 27
main/exercice/answer.class.php

@@ -1,25 +1,25 @@
-<?php // $Id: answer.class.php 10594 2007-01-05 13:54:24Z elixir_inter $
+<?php // $Id: answer.class.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 
 
 if(!class_exists('Answer')):
 if(!class_exists('Answer')):
@@ -112,13 +112,13 @@ class Answer
 	function read()
 	function read()
 	{
 	{
 		global $_course;
 		global $_course;
-		$TBL_ANSWER = Database::get_course_table('quiz_answer');
+		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 		$questionId=$this->questionId;
 		$questionId=$this->questionId;
 		//$answerType=$this->selectType();
 		//$answerType=$this->selectType();
-				
-		$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type FROM $TBL_ANSWER WHERE question_id='$questionId' ORDER BY position";			
-		
+
+		$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type FROM $TBL_ANSWER WHERE question_id='$questionId' ORDER BY position";
+
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 
 
 		$i=1;
 		$i=1;
@@ -147,24 +147,24 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 */
 	 */
 	function readOrderedBy($field,$order=ASC)
 	function readOrderedBy($field,$order=ASC)
 	{
 	{
-		global $_course;		
+		global $_course;
 		$field = mysql_real_escape_string($field);
 		$field = mysql_real_escape_string($field);
 		if(empty($field)){
 		if(empty($field)){
 			$field = 'position';
 			$field = 'position';
 		}
 		}
 		if($order != 'ASC' and $order!='DESC'){
 		if($order != 'ASC' and $order!='DESC'){
 			$order = 'ASC';
 			$order = 'ASC';
-		}		
+		}
 		$TBL_ANSWER = Database::get_course_table('quiz_answer');
 		$TBL_ANSWER = Database::get_course_table('quiz_answer');
 
 
 		$questionId=$this->questionId;
 		$questionId=$this->questionId;
 		//$answerType=$this->selectType();
 		//$answerType=$this->selectType();
-		
+
 		$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type " .
 		$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type " .
 				"FROM $TBL_ANSWER " .
 				"FROM $TBL_ANSWER " .
 				"WHERE question_id='$questionId' " .
 				"WHERE question_id='$questionId' " .
 				"ORDER BY $field $order";
 				"ORDER BY $field $order";
-	
+
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 
 
 		$i=1;
 		$i=1;
@@ -217,7 +217,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	{
 	{
 		return $this->answer[$id];
 		return $this->answer[$id];
 	}
 	}
-	
+
 	/**
 	/**
 	 * Returns a list of answers
 	 * Returns a list of answers
 	 * @author Yannick Warnier <ywarnier@beeznest.org>
 	 * @author Yannick Warnier <ywarnier@beeznest.org>
@@ -256,7 +256,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 	}
 	 	}
 	 	return $list;
 	 	return $list;
 	 }
 	 }
-	 
+
 	 /**
 	 /**
 	  * Returns the question type
 	  * Returns the question type
 	  * @author	Yannick Warnier <ywarnier@beeznest.org>
 	  * @author	Yannick Warnier <ywarnier@beeznest.org>
@@ -273,7 +273,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 	$row = Database::fetch_array($res);
 	 	$row = Database::fetch_array($res);
 	 	return $row['type'];
 	 	return $row['type'];
 	 }
 	 }
-	 
+
 
 
 	/**
 	/**
 	 * tells if answer is correct or not
 	 * tells if answer is correct or not
@@ -364,7 +364,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 		$this->new_nbrAnswers++;
 		$this->new_nbrAnswers++;
 
 
 		$id=$this->new_nbrAnswers;
 		$id=$this->new_nbrAnswers;
-		
+
 		$this->new_answer[$id]=$answer;
 		$this->new_answer[$id]=$answer;
 		$this->new_correct[$id]=$correct;
 		$this->new_correct[$id]=$correct;
 		$this->new_comment[$id]=$comment;
 		$this->new_comment[$id]=$comment;
@@ -373,7 +373,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 		$this->new_hotspot_coordinates[$id]=$new_hotspot_coordinates;
 		$this->new_hotspot_coordinates[$id]=$new_hotspot_coordinates;
 		$this->new_hotspot_type[$id]=$new_hotspot_type;
 		$this->new_hotspot_type[$id]=$new_hotspot_type;
 	}
 	}
-	
+
 	/**
 	/**
 	 * updates an answer
 	 * updates an answer
 	 *
 	 *
@@ -386,9 +386,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	function updateAnswers($answer,$comment,$weighting,$position)
 	function updateAnswers($answer,$comment,$weighting,$position)
 	{
 	{
 		global $TBL_REPONSES;
 		global $TBL_REPONSES;
-		
+
 		$questionId=$this->questionId;
 		$questionId=$this->questionId;
-		
+
 		$sql = "UPDATE `$TBL_REPONSES` SET " .
 		$sql = "UPDATE `$TBL_REPONSES` SET " .
 				"`answer` = '$answer', " .
 				"`answer` = '$answer', " .
 				"`comment` = '$comment', " .
 				"`comment` = '$comment', " .
@@ -396,7 +396,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 				"`position` = '$position' " .
 				"`position` = '$position' " .
 				"WHERE `id` =$position " .
 				"WHERE `id` =$position " .
 				"AND `question_id` =$questionId";
 				"AND `question_id` =$questionId";
-		
+
 		api_sql_query($sql,__FILE__,__LINE__);
 		api_sql_query($sql,__FILE__,__LINE__);
 	}
 	}
 
 
@@ -419,7 +419,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 		$sql="INSERT INTO `$TBL_REPONSES`" .
 		$sql="INSERT INTO `$TBL_REPONSES`" .
 				"(id,question_id,answer,correct,comment," .
 				"(id,question_id,answer,correct,comment," .
 				"ponderation,position,hotspot_coordinates,hotspot_type) VALUES";
 				"ponderation,position,hotspot_coordinates,hotspot_type) VALUES";
-		
+
 		for($i=1;$i <= $this->new_nbrAnswers;$i++)
 		for($i=1;$i <= $this->new_nbrAnswers;$i++)
 		{
 		{
 			$answer=addslashes($this->new_answer[$i]);
 			$answer=addslashes($this->new_answer[$i]);
@@ -433,9 +433,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 			$sql.="('$i','$questionId','$answer','$correct','$comment',
 			$sql.="('$i','$questionId','$answer','$correct','$comment',
 					'$weighting','$position','$hotspot_coordinates','$hotspot_type'),";
 					'$weighting','$position','$hotspot_coordinates','$hotspot_type'),";
 		}
 		}
-		
+
 		$sql = substr($sql,0,-1);
 		$sql = substr($sql,0,-1);
-		
+
 		api_sql_query($sql,__FILE__,__LINE__);
 		api_sql_query($sql,__FILE__,__LINE__);
 
 
 		// moves $new_* arrays
 		// moves $new_* arrays

+ 53 - 53
main/exercice/answer_admin.inc.php

@@ -1,4 +1,4 @@
-<?php // $Id: answer_admin.inc.php 10594 2007-01-05 13:54:24Z elixir_inter $
+<?php // $Id: answer_admin.inc.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -79,7 +79,7 @@ if($modifyIn)
         $objAnswer->duplicate($questionId);
         $objAnswer->duplicate($questionId);
 
 
         // construction of the duplicated Answers
         // construction of the duplicated Answers
-        
+
         $objAnswer=new Answer($questionId);
         $objAnswer=new Answer($questionId);
     }
     }
 
 
@@ -99,13 +99,13 @@ if($modifyIn)
         $weighting=unserialize($weighting);
         $weighting=unserialize($weighting);
     }
     }
     //free answer
     //free answer
-    elseif($answerType == FREE_ANSWER ) 
+    elseif($answerType == FREE_ANSWER )
     {
     {
         $reponse=unserialize($reponse);
         $reponse=unserialize($reponse);
         $comment=unserialize($comment);
         $comment=unserialize($comment);
         $free_comment=$comment;
         $free_comment=$comment;
         $weighting=unserialize($weighting);
         $weighting=unserialize($weighting);
-    	
+
 	}
 	}
 	elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
 	elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
     {
     {
@@ -115,8 +115,8 @@ if($modifyIn)
         $weighting=unserialize($weighting);
         $weighting=unserialize($weighting);
         $hotspot_coordinates=unserialize($hotspot_coordinates);
         $hotspot_coordinates=unserialize($hotspot_coordinates);
         $hotspot_type=unserialize($hotspot_type);
         $hotspot_type=unserialize($hotspot_type);
-        
-    	
+
+
     }
     }
     //fill in blanks
     //fill in blanks
   else
   else
@@ -196,7 +196,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
                   //  $mainurl="question_pool.php";
 					?>
 					?>
 					<script>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					</script>
 					<?php
 					<?php
 			}
 			}
@@ -277,7 +277,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
                   //  $mainurl="question_pool.php";
 					?>
 					?>
 					<script>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					</script>
 					<?php
 					<?php
 
 
@@ -370,7 +370,7 @@ if($submitAnswers || $buttonBack)
         if ( empty ( $weighting ) ) {
         if ( empty ( $weighting ) ) {
             $weighting = $_POST['weighting'];
             $weighting = $_POST['weighting'];
 			$weightingtemp = $_POST['weighting'];
 			$weightingtemp = $_POST['weighting'];
-        
+
 		}
 		}
 
 
         if(!$buttonBack)
         if(!$buttonBack)
@@ -386,7 +386,7 @@ if($submitAnswers || $buttonBack)
                 }
                 }
                 else
                 else
                 {
                 {
-                    
+
                     $objAnswer->createAnswer('',0,$free_comment,$weighting,'');
                     $objAnswer->createAnswer('',0,$free_comment,$weighting,'');
                     $objAnswer->save();
                     $objAnswer->save();
 					// sets the total weighting of the question
 					// sets the total weighting of the question
@@ -402,7 +402,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
                   //  $mainurl="question_pool.php";
 					?>
 					?>
 					<script>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					</script>
 					<?php
 					<?php
                 }
                 }
@@ -489,7 +489,7 @@ if($submitAnswers || $buttonBack)
                     //$mainurl="question_pool.php";
                     //$mainurl="question_pool.php";
 					?>
 					?>
 					<script>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					</script>
 					<?php
 					<?php
                 }
                 }
@@ -540,28 +540,28 @@ if($submitAnswers || $buttonBack)
 
 
                 break;
                 break;
             }
             }
-            
+
             if($weighting[$i] <= 0)
             if($weighting[$i] <= 0)
             {
             {
             	$msgErr=get_lang('HotspotWeightingError');
             	$msgErr=get_lang('HotspotWeightingError');
-            	
+
             	// clears answers already recorded into the Answer object
             	// clears answers already recorded into the Answer object
                 $objAnswer->cancel();
                 $objAnswer->cancel();
 
 
-                break;	
+                break;
             }
             }
             if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
             if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
             {
             {
             	$msgErr=get_lang('HotspotNotDrawn');
             	$msgErr=get_lang('HotspotNotDrawn');
-            	
+
             	// clears answers already recorded into the Answer object
             	// clears answers already recorded into the Answer object
                 $objAnswer->cancel();
                 $objAnswer->cancel();
 
 
-                break;	
+                break;
             }
             }
-            
+
         }  // end for()
         }  // end for()
-        
+
 
 
         if(empty($msgErr))
         if(empty($msgErr))
         {
         {
@@ -574,7 +574,7 @@ if($submitAnswers || $buttonBack)
             	for($i=1;$i <= $nbrAnswers;$i++)
             	for($i=1;$i <= $nbrAnswers;$i++)
 		        {
 		        {
 		            if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
 		            if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
-		
+
 		            $reponse[$i]=trim($reponse[$i]);
 		            $reponse[$i]=trim($reponse[$i]);
 		            $comment[$i]=addslashes(trim($comment[$i]));
 		            $comment[$i]=addslashes(trim($comment[$i]));
 		            $weighting[$i]=intval($weighting[$i]);
 		            $weighting[$i]=intval($weighting[$i]);
@@ -582,13 +582,13 @@ if($submitAnswers || $buttonBack)
 					{
 					{
 						$questionWeighting+=$weighting[$i];
 						$questionWeighting+=$weighting[$i];
 					}
 					}
-					
+
 					// creates answer
 					// creates answer
 					$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
 					$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
 		        }  // end for()
 		        }  // end for()
 				// saves the answers into the data base
 				// saves the answers into the data base
 				$objAnswer->save();
 				$objAnswer->save();
-                
+
                 // sets the total weighting of the question
                 // sets the total weighting of the question
                 $objQuestion->updateWeighting($questionWeighting);
                 $objQuestion->updateWeighting($questionWeighting);
                 $objQuestion->save($exerciseId);
                 $objQuestion->save($exerciseId);
@@ -606,13 +606,13 @@ if($submitAnswers || $buttonBack)
 if($modifyAnswers)
 if($modifyAnswers)
 {
 {
 
 
-	
+
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
-    
+
     // construction of the Answer object
     // construction of the Answer object
     $objAnswer=new Answer($questionId);
     $objAnswer=new Answer($questionId);
-    
-    
+
+
     api_session_register('objAnswer');
     api_session_register('objAnswer');
 
 
     if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
     if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
@@ -712,7 +712,7 @@ if($modifyAnswers)
                 // but as we have passed into the submitAnswers loop, this should be in the
                 // but as we have passed into the submitAnswers loop, this should be in the
                 // objAnswer object.
                 // objAnswer object.
                 $free_comment = $objAnswer->selectComment(1);
                 $free_comment = $objAnswer->selectComment(1);
-				$weighting=$objAnswer->selectWeighting(1); //added 
+				$weighting=$objAnswer->selectWeighting(1); //added
             }
             }
             elseif(!$modifyIn)
             elseif(!$modifyIn)
             {
             {
@@ -810,12 +810,12 @@ if($modifyAnswers)
     elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
     elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
     {
     {
 		if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
 		if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
-		
-		$TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer';
-        
+
+		$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
+
 		if(!$nbrAnswers)
 		if(!$nbrAnswers)
         {
         {
-        	
+
             $nbrAnswers=$objAnswer->selectNbrAnswers();
             $nbrAnswers=$objAnswer->selectNbrAnswers();
 
 
             $reponse=Array();
             $reponse=Array();
@@ -833,10 +833,10 @@ if($modifyAnswers)
                 $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
                 $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
                 $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
                 $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
             }
             }
-            
-            
+
+
         }
         }
-        
+
         $_SESSION['tmp_answers'] = array();
         $_SESSION['tmp_answers'] = array();
         $_SESSION['tmp_answers']['answer'] = $reponse;
         $_SESSION['tmp_answers']['answer'] = $reponse;
         $_SESSION['tmp_answers']['comment'] = $comment;
         $_SESSION['tmp_answers']['comment'] = $comment;
@@ -848,9 +848,9 @@ if($modifyAnswers)
         {
         {
         	// At least 1 answer
         	// At least 1 answer
         	if ($nbrAnswers > 1) {
         	if ($nbrAnswers > 1) {
-				
+
 	            $nbrAnswers--;
 	            $nbrAnswers--;
-	            
+
 	            // Remove the last answer
 	            // Remove the last answer
 				$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 				$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 				$tmp = array_pop($_SESSION['tmp_answers']['comment']);
 				$tmp = array_pop($_SESSION['tmp_answers']['comment']);
@@ -869,7 +869,7 @@ if($modifyAnswers)
         	if ($nbrAnswers < 12)
         	if ($nbrAnswers < 12)
         	{
         	{
 	            $nbrAnswers++;
 	            $nbrAnswers++;
-	            
+
 	            // Add a new answer
 	            // Add a new answer
 	            $_SESSION['tmp_answers']['answer'][]='';
 	            $_SESSION['tmp_answers']['answer'][]='';
 				$_SESSION['tmp_answers']['comment'][]='';
 				$_SESSION['tmp_answers']['comment'][]='';
@@ -888,7 +888,7 @@ if($modifyAnswers)
     if(!$usedInSeveralExercises)
     if(!$usedInSeveralExercises)
     {
     {
         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
-    
+
         if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
         if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
         {
         {
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
@@ -905,7 +905,7 @@ if($modifyAnswers)
 <h3>
 <h3>
   <?php echo $questionName; ?>
   <?php echo $questionName; ?>
 </h3>
 </h3>
-<?php 
+<?php
 		/*if ($exerciseId==0){
 		/*if ($exerciseId==0){
 	?>
 	?>
 		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
 		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
@@ -914,9 +914,9 @@ if($modifyAnswers)
 		{
 		{
 		?>
 		?>
 		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?exerciseId=<?php  echo $exerciseId; ?>">
 		<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?exerciseId=<?php  echo $exerciseId; ?>">
-		<?php 
+		<?php
 		}*/
 		}*/
-	
+
 
 
 ?>
 ?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
@@ -1054,7 +1054,7 @@ if($modifyAnswers)
 
 
 <?php
 <?php
                 }
                 }
-    
+
                 if(!empty($msgErr))
                 if(!empty($msgErr))
                 {
                 {
 ?>
 ?>
@@ -1168,7 +1168,7 @@ if($modifyAnswers)
 			<?php
 			<?php
 			echo $desc = mysql_result($res,0,'description');
 			echo $desc = mysql_result($res,0,'description');
 			 ?>
 			 ?>
-			
+
 			<form name="formulaire" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php echo $modifyAnswers; ?>">
 			<form name="formulaire" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php echo $modifyAnswers; ?>">
 			<input type="hidden" name="formSent" value="1">
 			<input type="hidden" name="formSent" value="1">
 			<input type="hidden" name="setWeighting" value="1">
 			<input type="hidden" name="setWeighting" value="1">
@@ -1186,7 +1186,7 @@ if($modifyAnswers)
                 }
                 }
 
 
                 if(!empty($msgErr))
                 if(!empty($msgErr))
-                { 
+                {
 			?>
 			?>
 				<tr>
 				<tr>
 				<td colspan="2">
 				<td colspan="2">
@@ -1198,9 +1198,9 @@ if($modifyAnswers)
 				</tr>
 				</tr>
 			<?php
 			<?php
                 }
                 }
- 			if(!$submitAnswers && empty($free_comment)) 
+ 			if(!$submitAnswers && empty($free_comment))
 				echo '';
 				echo '';
-			else 
+			else
 				echo htmlentities($free_comment); ?>
 				echo htmlentities($free_comment); ?>
    				<tr><td width="22%"><?php echo get_lang('QuestionWeighting'); ?></td>
    				<tr><td width="22%"><?php echo get_lang('QuestionWeighting'); ?></td>
 				<td width="78%"><input type="text" size="4" name="weighting" value="<?php if(!$submitAnswers && !isset($weighting)) echo '0'; else echo $weighting; ?>"></td>
 				<td width="78%"><input type="text" size="4" name="weighting" value="<?php if(!$submitAnswers && !isset($weighting)) echo '0'; else echo $weighting; ?>"></td>
@@ -1381,11 +1381,11 @@ if($modifyAnswers)
 	<tr>
 	<tr>
 		<td width="550" valign="top">
 		<td width="550" valign="top">
 			<script type="text/javascript">
 			<script type="text/javascript">
-				<!-- 
+				<!--
 				// Version check based upon the values entered above in "Globals"
 				// Version check based upon the values entered above in "Globals"
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
-				
-				
+
+
 				// Check to see if the version meets the requirements for playback
 				// Check to see if the version meets the requirements for playback
 				if (hasReqestedVersion) {  // if we've detected an acceptable version
 				if (hasReqestedVersion) {  // if we've detected an acceptable version
 				    var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="550" height="377">'
 				    var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="550" height="377">'
@@ -1418,12 +1418,12 @@ if($modifyAnswers)
 					  <td style="border-bottom: 1px solid #4271b5"><?php echo get_lang('Comment'); ?></td>
 					  <td style="border-bottom: 1px solid #4271b5"><?php echo get_lang('Comment'); ?></td>
 					  <td style="width: 60px; border-bottom: 1px solid #4271b5"><?php echo get_lang('QuestionWeighting'); ?>*</td>
 					  <td style="width: 60px; border-bottom: 1px solid #4271b5"><?php echo get_lang('QuestionWeighting'); ?>*</td>
 					</tr>
 					</tr>
-					
+
 					<?php
 					<?php
 								for($i=1;$i <= $nbrAnswers;$i++)
 								for($i=1;$i <= $nbrAnswers;$i++)
 								{
 								{
 					?>
 					?>
-					
+
 					<tr>
 					<tr>
 					  <td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div></td>
 					  <td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div></td>
 					  <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="12" /></td>
 					  <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="12" /></td>
@@ -1432,11 +1432,11 @@ if($modifyAnswers)
 					  <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
 					  <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
 					  <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					  <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					</tr>
 					</tr>
-					
+
 					<?php
 					<?php
 					  			}
 					  			}
 					?>
 					?>
-					
+
 					<tr>
 					<tr>
 					  <td colspan="5">
 					  <td colspan="5">
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />

+ 169 - 163
main/exercice/exercice.php

@@ -1,29 +1,29 @@
 <?php
 <?php
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
-*	EXERCISE LIST  
+==============================================================================
+*	EXERCISE LIST
 *
 *
 *	This script shows the list of exercises for administrators and students.
 *	This script shows the list of exercises for administrators and students.
 *
 *
@@ -32,10 +32,10 @@
 *	@author Wolfgang Schneider, code/html cleanup
 *	@author Wolfgang Schneider, code/html cleanup
 *	@package dokeos.exercise
 *	@package dokeos.exercise
 * 	@todo use database library
 * 	@todo use database library
-============================================================================== 
+==============================================================================
 */
 */
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 require_once('../inc/global.inc.php');
 require_once('../inc/global.inc.php');
@@ -71,7 +71,7 @@ $TBL_EXERCICES			= Database::get_course_table(TABLE_QUIZ_TEST);
 $TBL_QUESTIONS			= Database::get_course_table(TABLE_QUIZ_QUESTION);
 $TBL_QUESTIONS			= Database::get_course_table(TABLE_QUIZ_QUESTION);
 $TBL_TRACK_EXERCICES   	= $_configuration['statistics_database']."`.`track_e_exercices";
 $TBL_TRACK_EXERCICES   	= $_configuration['statistics_database']."`.`track_e_exercices";
 $TBL_TRACK_HOTPOTATOES  = $_configuration['statistics_database']."`.`track_e_hotpotatoes";
 $TBL_TRACK_HOTPOTATOES  = $_configuration['statistics_database']."`.`track_e_hotpotatoes";
-$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt"; 
+$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt";
 
 
 // document path
 // document path
 $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
 $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
@@ -145,28 +145,34 @@ a.invisible:hover
 -->
 -->
 </style>';
 </style>';
 
 
-if($show!='result'){
+if($show!='result')
+{
 	$nameTools=get_lang('Exercices');
 	$nameTools=get_lang('Exercices');
 }
 }
-else {
+else
+{
 	if($is_allowedToEdit)
 	if($is_allowedToEdit)
 	{
 	{
-	$nameTools="Student Score";
-	$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
+		$nameTools=get_lang('StudentScore');
+		$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
 	}
 	}
 	else
 	else
 	{
 	{
-	$nameTools="Your result";
-	$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('Exercices'));
+		$nameTools=get_lang('YourScore');
+		$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('Exercices'));
 	}
 	}
 }
 }
 
 
 
 
-if ($origin != 'learnpath') { //so we are not in learnpath tool
+if ($origin != 'learnpath')
+{
+	//so we are not in learnpath tool
 	Display::display_header($nameTools,"Exercise");
 	Display::display_header($nameTools,"Exercise");
-	
-} else {
-	?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css"/> 
+
+}
+else
+{
+	?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css"/>
 
 
 <?php
 <?php
 }
 }
@@ -207,7 +213,7 @@ HotPotGCt($documentPath,1,$_user['user_id']);
 
 
 if($is_allowedToEdit)
 if($is_allowedToEdit)
 {
 {
-	
+
 	if(!empty($choice))
 	if(!empty($choice))
 	{
 	{
 		// construction of Exercise
 		// construction of Exercise
@@ -243,27 +249,27 @@ if($is_allowedToEdit)
 
 
 	//$sql="SELECT id,title,type,active FROM $TBL_EXERCICES ORDER BY title LIMIT $from,".($limitExPage+1);
 	//$sql="SELECT id,title,type,active FROM $TBL_EXERCICES ORDER BY title LIMIT $from,".($limitExPage+1);
 	//$result=api_sql_query($sql,__FILE__,__LINE__);
 	//$result=api_sql_query($sql,__FILE__,__LINE__);
-	
+
 
 
 	if(!empty($hpchoice))
 	if(!empty($hpchoice))
 	{
 	{
 		switch($hpchoice)
 		switch($hpchoice)
 		{
 		{
 				case 'delete':	// deletes an exercise
 				case 'delete':	// deletes an exercise
-							$imgparams = array();	
-							$imgcount = 0;							
+							$imgparams = array();
+							$imgcount = 0;
 							GetImgParams($file,$documentPath,$imgparams,$imgcount);
 							GetImgParams($file,$documentPath,$imgparams,$imgcount);
 							$fld = GetFolderName($file);
 							$fld = GetFolderName($file);
 							for($i=0;$i < $imgcount;$i++)
 							for($i=0;$i < $imgcount;$i++)
-							{						
-									my_delete($documentPath.$uploadPath."/".$fld."/".$imgparams[$i]);									
+							{
+									my_delete($documentPath.$uploadPath."/".$fld."/".$imgparams[$i]);
 									update_db_info("delete", $uploadPath."/".$fld."/".$imgparams[$i]);
 									update_db_info("delete", $uploadPath."/".$fld."/".$imgparams[$i]);
-							}	
-							
+							}
+
 							if ( my_delete($documentPath.$file))
 							if ( my_delete($documentPath.$file))
 							{
 							{
 								update_db_info("delete", $file);
 								update_db_info("delete", $file);
-							}											
+							}
 							my_delete($documentPath.$uploadPath."/".$fld."/");
 							my_delete($documentPath.$uploadPath."/".$fld."/");
 							break;
 							break;
 				case 'enable':  // enables an exercise
 				case 'enable':  // enables an exercise
@@ -307,16 +313,16 @@ if($show == 'test'){
 
 
 	//error_log('Show == test',0);
 	//error_log('Show == test',0);
 	$nbrExercises=mysql_num_rows($result);
 	$nbrExercises=mysql_num_rows($result);
-	
+
 	echo "<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">",
 	echo "<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">",
 		"<tr>";
 		"<tr>";
-	
-	if (($is_allowedToEdit) and ($origin != 'learnpath')) 	
+
+	if (($is_allowedToEdit) and ($origin != 'learnpath'))
 	{
 	{
 		//error_log('is_allowedToEdit and origin<> learnpath',0);
 		//error_log('is_allowedToEdit and origin<> learnpath',0);
 		echo "<td width=\"50%\" nowrap=\"nowrap\">",
 		echo "<td width=\"50%\" nowrap=\"nowrap\">",
 			"<img src=\"../img/quiz.gif\" alt=\"new test\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"exercise_admin.php\">".get_lang("NewEx")."</a>",
 			"<img src=\"../img/quiz.gif\" alt=\"new test\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"exercise_admin.php\">".get_lang("NewEx")."</a>",
-			
+
 			//"<img src=\"../img/quiz_na.gif\" alt=\"new test\" valign=\"ABSMIDDLE\"><a href=\"question_pool.php\">".get_lang("QuestionPool")."</a> | ",
 			//"<img src=\"../img/quiz_na.gif\" alt=\"new test\" valign=\"ABSMIDDLE\"><a href=\"question_pool.php\">".get_lang("QuestionPool")."</a> | ",
 			//" | <img src=\"../img/jqz.jpg\" alt=\"HotPotatoes\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"hotpotatoes.php\">".get_lang("ImportHotPotatoesQuiz")."</a>",
 			//" | <img src=\"../img/jqz.jpg\" alt=\"HotPotatoes\" valign=\"ABSMIDDLE\">&nbsp;<a href=\"hotpotatoes.php\">".get_lang("ImportHotPotatoesQuiz")."</a>",
 			"</td>",
 			"</td>",
@@ -327,23 +333,23 @@ if($show == 'test'){
 		//error_log('!is_allowedToEdit or origin == learnpath ('.$origin.')',0);
 		//error_log('!is_allowedToEdit or origin == learnpath ('.$origin.')',0);
 		echo "<td align=\"right\">";
 		echo "<td align=\"right\">";
 	}
 	}
-	
+
 	//get HotPotatoes files (active and inactive)
 	//get HotPotatoes files (active and inactive)
-	$res = api_sql_query ("SELECT * 
+	$res = api_sql_query ("SELECT *
 					FROM $TBL_DOCUMENT
 					FROM $TBL_DOCUMENT
-					WHERE 
+					WHERE
 					path LIKE '".$uploadPath."/%/%'",__FILE__,__LINE__);
 					path LIKE '".$uploadPath."/%/%'",__FILE__,__LINE__);
-	$nbrTests = Database::num_rows($res);	
-	$res = api_sql_query ("SELECT * 
-					FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip 
-					WHERE  d.id = ip.ref 
-					AND ip.tool = '".TOOL_DOCUMENT."' 
-					AND d.path LIKE '".$uploadPath."/%/%' 
+	$nbrTests = Database::num_rows($res);
+	$res = api_sql_query ("SELECT *
+					FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
+					WHERE  d.id = ip.ref
+					AND ip.tool = '".TOOL_DOCUMENT."'
+					AND d.path LIKE '".$uploadPath."/%/%'
 					AND ip.visibility='1'", __FILE__,__LINE__);
 					AND ip.visibility='1'", __FILE__,__LINE__);
-	$nbrActiveTests = Database::num_rows($res);	  
+	$nbrActiveTests = Database::num_rows($res);
 	//error_log('nbrActiveTests = '.$nbrActiveTests,0);
 	//error_log('nbrActiveTests = '.$nbrActiveTests,0);
-	
-	
+
+
 	if($is_allowedToEdit)
 	if($is_allowedToEdit)
 	{//if user is allowed to edit, also show hidden HP tests
 	{//if user is allowed to edit, also show hidden HP tests
 		$nbrHpTests = $nbrTests;
 		$nbrHpTests = $nbrTests;
@@ -352,8 +358,8 @@ if($show == 'test'){
 		$nbrHpTests = $nbrActiveTests;
 		$nbrHpTests = $nbrActiveTests;
 	}
 	}
 	$nbrNextTests = $nbrHpTests-(($page*$limitExPage));
 	$nbrNextTests = $nbrHpTests-(($page*$limitExPage));
-	
-	
+
+
 	//show pages navigation link for previous page
 	//show pages navigation link for previous page
 	if($page)
 	if($page)
 	{
 	{
@@ -363,33 +369,33 @@ if($show == 'test'){
 	{
 	{
 		echo "&lt;&lt; ",get_lang("PreviousPage")." | ";
 		echo "&lt;&lt; ",get_lang("PreviousPage")." | ";
 	}
 	}
-	
+
 	//show pages navigation link for previous page
 	//show pages navigation link for previous page
 	if($nbrExercises+$nbrNextTests > $limitExPage)
 	if($nbrExercises+$nbrNextTests > $limitExPage)
 	{
 	{
 		echo "<a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&page=".($page+1)."\">&gt;&gt; ",get_lang("NextPage")."</a>";
 		echo "<a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&page=".($page+1)."\">&gt;&gt; ",get_lang("NextPage")."</a>";
-	
+
 	}
 	}
 	elseif($page)
 	elseif($page)
 	{
 	{
 		echo get_lang("NextPage") . " &gt;&gt;";
 		echo get_lang("NextPage") . " &gt;&gt;";
 	}
 	}
-	
+
 	echo "</td>",
 	echo "</td>",
 			"</tr>",
 			"</tr>",
 			"</table>";
 			"</table>";
-	
-?> 
+
+?>
 <table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
 <table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
   <?php
   <?php
-	if (($is_allowedToEdit) and ($origin != 'learnpath')) 
+	if (($is_allowedToEdit) and ($origin != 'learnpath'))
 	{
 	{
 	?>
 	?>
   <tr bgcolor="#e6e6e6">
   <tr bgcolor="#e6e6e6">
     <td align="center" colspan="2"><?php echo get_lang("ExerciseName");?></td>
     <td align="center" colspan="2"><?php echo get_lang("ExerciseName");?></td>
      <td align="center"><?php echo get_lang("Description");?></td>
      <td align="center"><?php echo get_lang("Description");?></td>
 	 <td align="center"><?php echo get_lang("Modify");?></td>
 	 <td align="center"><?php echo get_lang("Modify");?></td>
-   
+
   </tr>
   </tr>
   <?php
   <?php
 	}
 	}
@@ -399,10 +405,10 @@ if($show == 'test'){
     <td align="center"><?php echo get_lang("ExerciseName");?></td>
     <td align="center"><?php echo get_lang("ExerciseName");?></td>
      <td align="center"><?php echo get_lang("Description");?></td>
      <td align="center"><?php echo get_lang("Description");?></td>
 	 <td align="center"><?php echo get_lang("State");?></td>
 	 <td align="center"><?php echo get_lang("State");?></td>
-   
+
   </tr>
   </tr>
 	<?php }
 	<?php }
-	
+
 	// show message if no HP test to show
 	// show message if no HP test to show
 	if(!($nbrExercises+$nbrHpTests) )
 	if(!($nbrExercises+$nbrHpTests) )
 	{
 	{
@@ -412,19 +418,19 @@ if($show == 'test'){
   </tr>
   </tr>
   <?php
   <?php
 	}
 	}
-	
+
 	$i=1;
 	$i=1;
-	
+
 	// while list exercises
 	// while list exercises
-	
+
 	if ($origin != 'learnpath') {
 	if ($origin != 'learnpath') {
-	
+
 		while($row=mysql_fetch_array($result))
 		while($row=mysql_fetch_array($result))
 		{
 		{
 
 
 			//error_log($row[0],0);
 			//error_log($row[0],0);
 			echo "<tr>\n";
 			echo "<tr>\n";
-			
+
 			// prof only
 			// prof only
 			if($is_allowedToEdit)
 			if($is_allowedToEdit)
 			{
 			{
@@ -440,31 +446,31 @@ if($show == 'test'){
       </td>
       </td>
     </tr>
     </tr>
   </table></td>
   </table></td>
- <td width="8%" align="center"> <?php 
+ <td width="8%" align="center"> <?php
  $exid = $row['id'];
  $exid = $row['id'];
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlresult =mysql_query($sqlquery);
  $sqlresult =mysql_query($sqlquery);
  $rowi = mysql_result($sqlresult,0);
  $rowi = mysql_result($sqlresult,0);
  echo $rowi.' Questions'; ?> </td>
  echo $rowi.' Questions'; ?> </td>
-       <td width="12%" align="center"><a href="admin.php?exerciseId=<?php echo $row[id]; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Build')); ?>" alt="<?php echo htmlentities(get_lang('Build')); ?>" /></a> 
-    <a href="exercice.php?choice=delete&exerciseId=<?php echo $row[id]; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('areYouSure'))); echo $row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete')); ?>" /></a> 
+       <td width="12%" align="center"><a href="admin.php?exerciseId=<?php echo $row[id]; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Build')); ?>" alt="<?php echo htmlentities(get_lang('Build')); ?>" /></a>
+    <a href="exercice.php?choice=delete&exerciseId=<?php echo $row[id]; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('areYouSure'))); echo $row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete')); ?>" /></a>
     <?php
     <?php
 				// if active
 				// if active
 				if($row['active'])
 				if($row['active'])
 				{
 				{
 					?>
 					?>
-      <a href="exercice.php?choice=disable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" alt="<?php echo htmlentities(get_lang('Deactivate')); ?>" /></a> 
+      <a href="exercice.php?choice=disable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" alt="<?php echo htmlentities(get_lang('Deactivate')); ?>" /></a>
     <?php
     <?php
 				}
 				}
 				// else if not active
 				// else if not active
 				else
 				else
 				{
 				{
 					?>
 					?>
-      <a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate')); ?>" /></a> 
+      <a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate')); ?>" /></a>
     <?php
     <?php
 				}
 				}
 				echo "</td></tr>\n";
 				echo "</td></tr>\n";
-                
+
 			}
 			}
 			// student only
 			// student only
 			else
 			else
@@ -476,17 +482,17 @@ if($show == 'test'){
             <td width="1">&nbsp;</td>
             <td width="1">&nbsp;</td>
             <?php $row['title']=api_parse_tex($row['title']);?>
             <?php $row['title']=api_parse_tex($row['title']);?>
             <td><a href="exercice_submit.php?<?php echo api_get_cidreq()."&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id"; ?>&exerciseId=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a></td>
             <td><a href="exercice_submit.php?<?php echo api_get_cidreq()."&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id"; ?>&exerciseId=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a></td>
-			
+
 			</tr>
 			</tr>
     </table></td>
     </table></td>
-	 <td align='center'> <?php 
+	 <td align='center'> <?php
  $exid = $row['id'];
  $exid = $row['id'];
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlresult =mysql_query($sqlquery);
  $sqlresult =mysql_query($sqlquery);
  $rowi = mysql_result($sqlresult,0);
  $rowi = mysql_result($sqlresult,0);
  echo $rowi.' Question(s)'; ?> </td>
  echo $rowi.' Question(s)'; ?> </td>
-	
-	<td align='center'><?php 
+
+	<td align='center'><?php
 		$eid = $row['id'];
 		$eid = $row['id'];
 	$uid= $_SESSION[_user][user_id];
 	$uid= $_SESSION[_user][user_id];
 	$qry = "select * from `".$TBL_TRACK_EXERCICES."` where exe_exo_id = $eid and exe_user_id = $uid";
 	$qry = "select * from `".$TBL_TRACK_EXERCICES."` where exe_exo_id = $eid and exe_user_id = $uid";
@@ -495,7 +501,7 @@ if($show == 'test'){
 	$row = mysql_fetch_array($qryres);
 	$row = mysql_fetch_array($qryres);
 	$percentage = ($row['exe_result']/$row['exe_weighting'])*100;
 	$percentage = ($row['exe_result']/$row['exe_weighting'])*100;
 	if ($num>0)
 	if ($num>0)
-	{	
+	{
 		echo get_lang('Attempted').' ('.get_lang('Score').':';
 		echo get_lang('Attempted').' ('.get_lang('Score').':';
 		printf("%1.2f\n",$percentage);
 		printf("%1.2f\n",$percentage);
 		echo " %)";
 		echo " %)";
@@ -511,56 +517,56 @@ if($show == 'test'){
   </tr>
   </tr>
   <?php
   <?php
 			}
 			}
-		
+
 			// skips the last exercise, that is only used to know if we have or not to create a link "Next page"
 			// skips the last exercise, that is only used to know if we have or not to create a link "Next page"
 			if($i == $limitExPage)
 			if($i == $limitExPage)
 			{
 			{
 				break;
 				break;
 			}
 			}
-		
+
 			$i++;
 			$i++;
 			echo "<tr><td colspan = '5'><hr></td></tr>";
 			echo "<tr><td colspan = '5'><hr></td></tr>";
 		}	// end while()
 		}	// end while()
-		
+
 		$ind = $i;
 		$ind = $i;
 
 
-		
+
 		if (($from+$limitExPage-1)>$nbrexerc)
 		if (($from+$limitExPage-1)>$nbrexerc)
-		{	
+		{
 			if($from>$nbrexerc)
 			if($from>$nbrexerc)
 			{
 			{
 				$from = $from - $nbrexerc;
 				$from = $from - $nbrexerc;
 			  $to = $limitExPage;
 			  $to = $limitExPage;
-			}	
+			}
 			else
 			else
-			{ 
+			{
 				$to = $limitExPage-($nbrexerc-$from);
 				$to = $limitExPage-($nbrexerc-$from);
 				$from = 0;
 				$from = 0;
-			}	
-		}	
+			}
+		}
 		if($is_allowedToEdit)
 		if($is_allowedToEdit)
 		{
 		{
-			$sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility 
+			$sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
 				FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
 				FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
-							WHERE   d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND 
-							 (d.path LIKE '%htm%' OR d.path LIKE '%html%')			
+							WHERE   d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND
+							 (d.path LIKE '%htm%' OR d.path LIKE '%html%')
 							AND   d.path  LIKE '".$uploadPath."/%/%' LIMIT $from,$to"; // only .htm or .html files listed
 							AND   d.path  LIKE '".$uploadPath."/%/%' LIMIT $from,$to"; // only .htm or .html files listed
 			$result = api_sql_query ($sql,__FILE__,__LINE__);
 			$result = api_sql_query ($sql,__FILE__,__LINE__);
 			//error_log($sql,0);
 			//error_log($sql,0);
 		}
 		}
-		else	
+		else
 		{
 		{
-			$sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility 
-				FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip 
-								WHERE d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND 
-								 (d.path LIKE '%htm%' OR d.path LIKE '%html%')   
+			$sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
+				FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
+								WHERE d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND
+								 (d.path LIKE '%htm%' OR d.path LIKE '%html%')
 								AND   d.path  LIKE '".$uploadPath."/%/%' AND ip.visibility='1' LIMIT $from,$to";
 								AND   d.path  LIKE '".$uploadPath."/%/%' AND ip.visibility='1' LIMIT $from,$to";
 			$result = api_sql_query($sql, __FILE__, __LINE__); // only .htm or .html files listed
 			$result = api_sql_query($sql, __FILE__, __LINE__); // only .htm or .html files listed
 			//error_log($sql,0);
 			//error_log($sql,0);
-		}	
+		}
 		//error_log(mysql_num_rows($result),0);
 		//error_log(mysql_num_rows($result),0);
 		while($row = Database::fetch_array($result, 'ASSOC'))
 		while($row = Database::fetch_array($result, 'ASSOC'))
-		{	
+		{
 			//error_log('hop',0);
 			//error_log('hop',0);
 			$attribute['path'      ][] = $row['path'      ];
 			$attribute['path'      ][] = $row['path'      ];
 			$attribute['visibility'][] = $row['visibility'];
 			$attribute['visibility'][] = $row['visibility'];
@@ -577,11 +583,11 @@ if($show == 'test'){
 				else
 				else
 				{ $active=0;}
 				{ $active=0;}
 				echo "<tr>\n";
 				echo "<tr>\n";
-				
-				$title = GetQuizName($path,$documentPath);		
+
+				$title = GetQuizName($path,$documentPath);
 				if ($title =='')
 				if ($title =='')
 				{
 				{
-					$title = GetFileName($path);		
+					$title = GetFileName($path);
 				}
 				}
 				// prof only
 				// prof only
 				if($is_allowedToEdit)
 				if($is_allowedToEdit)
@@ -598,7 +604,7 @@ if($show == 'test'){
   <td>
   <td>
  </td>
  </td>
   <td></td>
   <td></td>
-      <td width="12%" align="center"><a href="adminhp.php?hotpotatoesName=<?php echo $path; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo htmlentities(get_lang('Modify')); ?>" /></a> 
+      <td width="12%" align="center"><a href="adminhp.php?hotpotatoesName=<?php echo $path; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo htmlentities(get_lang('Modify')); ?>" /></a>
   <a href="<?php echo $exercicePath; ?>?hpchoice=delete&file=<?php echo $path; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('areYouSure')).$title."?"); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete')); ?>" /></a>
   <a href="<?php echo $exercicePath; ?>?hpchoice=delete&file=<?php echo $path; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('areYouSure')).$title."?"); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete')); ?>" /></a>
     <?php
     <?php
 					// if active
 					// if active
@@ -623,20 +629,20 @@ if($show == 'test'){
 				else
 				else
 				{
 				{
 					if ($active==1)
 					if ($active==1)
-					{	
+					{
 						$nbrActiveTests = $nbrActiveTests + 1;
 						$nbrActiveTests = $nbrActiveTests + 1;
 						?>
 						?>
     <td width="40%"><table border="0" cellpadding="0" cellspacing="0" width="100%">
     <td width="40%"><table border="0" cellpadding="0" cellspacing="0" width="100%">
-     
+
         <td width="20" align="right"><?php echo ($ind+($page*$limitExPage)).'.'; ?><!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>
         <td width="20" align="right"><?php echo ($ind+($page*$limitExPage)).'.'; ?><!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>
        <td width="1">&nbsp;</td>
        <td width="1">&nbsp;</td>
         <td><a href="showinframes.php?<?php echo api_get_cidreq()."&file=".$path."&cid=".$_course['official_code']."&uid=".$_user['user_id'].'"'; if(!$active) echo 'class="invisible"'; ?>"><?php echo $title;?></a></td>
         <td><a href="showinframes.php?<?php echo api_get_cidreq()."&file=".$path."&cid=".$_course['official_code']."&uid=".$_user['user_id'].'"'; if(!$active) echo 'class="invisible"'; ?>"><?php echo $title;?></a></td>
-      
+
      </tr>
      </tr>
     </table></td>
     </table></td>
   </tr>
   </tr>
   <?php
   <?php
-					}	
+					}
 				}
 				}
 				?>
 				?>
   <?php
   <?php
@@ -648,7 +654,7 @@ if($show == 'test'){
 				{
 				{
 					$ind++;
 					$ind++;
 				}
 				}
-				else 
+				else
 				{
 				{
 					if ($active==1)
 					if ($active==1)
 					{
 					{
@@ -657,8 +663,8 @@ if($show == 'test'){
 				}echo "<tr><td colspan = '5'><hr></td></tr>";
 				}echo "<tr><td colspan = '5'><hr></td></tr>";
 			}
 			}
 		}
 		}
-		
-		
+
+
 	} //end if ($origin != 'learnpath') {
 	} //end if ($origin != 'learnpath') {
 	?>
 	?>
 </table>
 </table>
@@ -678,8 +684,8 @@ if($_configuration['tracking_enabled'])
 {
 {
 	?>
 	?>
 <br>
 <br>
-<br> 
- <h3><?php 
+<br>
+ <h3><?php
  //add link to breadcrumb
  //add link to breadcrumb
  //$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('StudentScore'));
  //$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('StudentScore'));
 
 
@@ -691,14 +697,14 @@ if($_configuration['tracking_enabled'])
 		{
 		{
 		if ($_REQUEST['comments']=='update')
 		if ($_REQUEST['comments']=='update')
 				{
 				{
-					
+
 					$id  = $_GET['exeid'];
 					$id  = $_GET['exeid'];
 					$emailid = $_GET['emailid'];
 					$emailid = $_GET['emailid'];
 					$test  = $_GET['test'];
 					$test  = $_GET['test'];
 					$from = $_SESSION[_user]['mail'];
 					$from = $_SESSION[_user]['mail'];
 					$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
 					$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
 					$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
 					$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
-					
+
 					foreach ($_POST as $key=>$v)
 					foreach ($_POST as $key=>$v)
 						{
 						{
 						$keyexp = explode('_',$key);
 						$keyexp = explode('_',$key);
@@ -707,43 +713,43 @@ if($_configuration['tracking_enabled'])
 							$sql = "select question from $TBL_QUESTIONS where id = '$keyexp[1]'";
 							$sql = "select question from $TBL_QUESTIONS where id = '$keyexp[1]'";
 							$result =api_sql_query($sql, __FILE__, __LINE__);
 							$result =api_sql_query($sql, __FILE__, __LINE__);
 							$ques_name = mysql_result($result,0,"question");
 							$ques_name = mysql_result($result,0,"question");
-							
+
 							$query = "update `$TABLETRACK_ATTEMPT` set marks = '$v' where question_id = $keyexp[1] and exe_id=$id";
 							$query = "update `$TABLETRACK_ATTEMPT` set marks = '$v' where question_id = $keyexp[1] and exe_id=$id";
 							api_sql_query($query, __FILE__, __LINE__);
 							api_sql_query($query, __FILE__, __LINE__);
-							
-							$qry = 'SELECT sum(marks) as tot 
+
+							$qry = 'SELECT sum(marks) as tot
 									FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
 									FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
 									GROUP BY question_id';
 									GROUP BY question_id';
-							
+
 							$res = api_sql_query($qry,__FILE__,__LINE__);
 							$res = api_sql_query($qry,__FILE__,__LINE__);
 							$tot = mysql_result($res,0,'tot');
 							$tot = mysql_result($res,0,'tot');
-							
+
 							$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
 							$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
 							api_sql_query($totquery, __FILE__, __LINE__);
 							api_sql_query($totquery, __FILE__, __LINE__);
-							
+
 							}
 							}
 						else
 						else
 						  {
 						  {
 						  $query = "update `$TABLETRACK_ATTEMPT` set teacher_comment = '$v' where question_id = $keyexp[1] and exe_id = $id ";
 						  $query = "update `$TABLETRACK_ATTEMPT` set teacher_comment = '$v' where question_id = $keyexp[1] and exe_id = $id ";
 						   api_sql_query($query, __FILE__, __LINE__);
 						   api_sql_query($query, __FILE__, __LINE__);
 							}
 							}
-						
-						
+
+
 						}
 						}
-						
-						$qry = 'SELECT DISTINCT question_id, marks 
+
+						$qry = 'SELECT DISTINCT question_id, marks
 								FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
 								FROM `'.$TABLETRACK_ATTEMPT.'` where exe_id = '.intval($id).'
 								GROUP BY question_id';
 								GROUP BY question_id';
-						
+
 						$res = api_sql_query($qry,__FILE__,__LINE__);
 						$res = api_sql_query($qry,__FILE__,__LINE__);
 						$tot = 0;
 						$tot = 0;
 						while($row = mysql_fetch_assoc($res))
 						while($row = mysql_fetch_assoc($res))
 						{
 						{
 							$tot += $row ['marks'];
 							$tot += $row ['marks'];
 						}
 						}
-						
+
 						$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
 						$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
-						
+
 						api_sql_query($totquery, __FILE__, __LINE__);
 						api_sql_query($totquery, __FILE__, __LINE__);
 				$subject = "Examsheet viewed/corrected/commented by teacher";
 				$subject = "Examsheet viewed/corrected/commented by teacher";
 				$message = "<html>
 				$message = "<html>
@@ -751,9 +757,9 @@ if($_configuration['tracking_enabled'])
 <style type='text/css'>
 <style type='text/css'>
 <!--
 <!--
 .body{
 .body{
-font-family: Verdana, Arial, Helvetica, sans-serif; 
-font-weight: Normal; 
-color: #000000; 
+font-family: Verdana, Arial, Helvetica, sans-serif;
+font-weight: Normal;
+color: #000000;
 }
 }
 .style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
 .style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
 .style10 {
 .style10 {
@@ -773,12 +779,12 @@ color: #000000;
     <tr>
     <tr>
       <td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Question</span></td>
       <td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Question</span></td>
       <td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#ques_name#</span></td>
       <td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#ques_name#</span></td>
-  
+
     </tr>
     </tr>
     <tr>
     <tr>
       <td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Test</span></td>
       <td width='229' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Test</span></td>
        <td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#test#</span></td>
        <td width='469' valign='top' bgcolor='#F3F3F3'><span class='style16'>#test#</span></td>
-  
+
     </tr>
     </tr>
   </table>
   </table>
   <p>Click the link below to access   your account and view your commented Examsheet. <A href='#url#'>#url#</A><BR>
   <p>Click the link below to access   your account and view your commented Examsheet. <A href='#url#'>#url#</A><BR>
@@ -800,9 +806,9 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 				$headers .= 'From: '.$from_name.' <'.$from.'>' . "\r\n";
 				$headers .= 'From: '.$from_name.' <'.$from.'>' . "\r\n";
 				$headers="From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=iso-8859-15";
 				$headers="From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=iso-8859-15";
 			//mail($emailid, $subject, $mess,$headers);
 			//mail($emailid, $subject, $mess,$headers);
-			
-								
-						
+
+
+
 				}
 				}
 				}
 				}
 		?>
 		?>
@@ -815,27 +821,27 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 		  <td width="30%"><?php echo get_lang("Date"); ?></td>
 		  <td width="30%"><?php echo get_lang("Date"); ?></td>
 		  <td width="15%"><?php echo get_lang("Result"); ?></td>
 		  <td width="15%"><?php echo get_lang("Result"); ?></td>
 		  <td width="15%"><?php echo $is_allowedToEdit?"Correct Test":"View Test"; ?></td>
 		  <td width="15%"><?php echo $is_allowedToEdit?"Correct Test":"View Test"; ?></td>
-		  
-		 
-		 </tr> 
-		
+
+
+		 </tr>
+
 		<?php
 		<?php
 		if($is_allowedToEdit)
 		if($is_allowedToEdit)
 		{
 		{
 			//get all results (ourself and the others) as an admin should see them
 			//get all results (ourself and the others) as an admin should see them
 			//AND exe_user_id <> $_user['user_id']  clause has been removed
 			//AND exe_user_id <> $_user['user_id']  clause has been removed
-			$sql="SELECT CONCAT(`lastname`,' ',`firstname`),`ce`.`title`, `te`.`exe_result` , 
+			$sql="SELECT CONCAT(`lastname`,' ',`firstname`),`ce`.`title`, `te`.`exe_result` ,
 						`te`.`exe_weighting`, UNIX_TIMESTAMP(`te`.`exe_date`),`te`.`exe_Id`,email
 						`te`.`exe_weighting`, UNIX_TIMESTAMP(`te`.`exe_date`),`te`.`exe_Id`,email
 				  FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te, $TBL_USER AS user
 				  FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te, $TBL_USER AS user
 				  WHERE `te`.`exe_exo_id` = `ce`.`id` AND `user_id`=`te`.`exe_user_id` AND `te`.`exe_cours_id`='$_cid'
 				  WHERE `te`.`exe_exo_id` = `ce`.`id` AND `user_id`=`te`.`exe_user_id` AND `te`.`exe_cours_id`='$_cid'
 				  ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC";
 				  ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC";
-			
-			$hpsql="SELECT CONCAT(tu.lastname,' ',tu.firstname), tth.exe_name, 
+
+			$hpsql="SELECT CONCAT(tu.lastname,' ',tu.firstname), tth.exe_name,
 						tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date)
 						tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date)
 					FROM `$TBL_TRACK_HOTPOTATOES` tth, $TBL_USER tu
 					FROM `$TBL_TRACK_HOTPOTATOES` tth, $TBL_USER tu
 					WHERE  tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".$_cid."'
 					WHERE  tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".$_cid."'
 					ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
 					ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
-					  
+
 		}
 		}
 		else
 		else
 		{ // get only this user's results
 		{ // get only this user's results
@@ -843,20 +849,20 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 				  FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te
 				  FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te
 				  WHERE `te`.`exe_exo_id` = `ce`.`id` AND `te`.`exe_user_id`='".$_user['user_id']."' AND `te`.`exe_cours_id`='$_cid'
 				  WHERE `te`.`exe_exo_id` = `ce`.`id` AND `te`.`exe_user_id`='".$_user['user_id']."' AND `te`.`exe_cours_id`='$_cid'
 				  ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC";
 				  ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC";
-		
+
 			$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
 			$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
 					FROM `$TBL_TRACK_HOTPOTATOES`
 					FROM `$TBL_TRACK_HOTPOTATOES`
-					WHERE exe_user_id = '".$_user['user_id']."' AND exe_cours_id = '".$_cid."'      
+					WHERE exe_user_id = '".$_user['user_id']."' AND exe_cours_id = '".$_cid."'
 					ORDER BY exe_cours_id ASC, exe_date ASC";
 					ORDER BY exe_cours_id ASC, exe_date ASC";
-		
+
 		}
 		}
-		
+
 		$results=getManyResultsXCol($sql,7);
 		$results=getManyResultsXCol($sql,7);
 		$hpresults=getManyResultsXCol($hpsql,5);
 		$hpresults=getManyResultsXCol($hpsql,5);
-		
+
 		$NoTestRes = 0;
 		$NoTestRes = 0;
 		$NoHPTestRes = 0;
 		$NoHPTestRes = 0;
-		
+
 		if(is_array($results))
 		if(is_array($results))
 		{
 		{
 			for($i = 0; $i < sizeof($results); $i++)
 			for($i = 0; $i < sizeof($results); $i++)
@@ -873,36 +879,36 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 		 <td class="content" align="center"><?php echo $is_allowedToEdit?"<a href='exercise_show.php?user=$user&test=$test&dt=$dt&res=$res&id=$id&email=$mailid'>Edit</a>":"<a href='exercise_show.php?test=$test&dt=$dt&res=$res&id=$id'>Show</a>"?></td>
 		 <td class="content" align="center"><?php echo $is_allowedToEdit?"<a href='exercise_show.php?user=$user&test=$test&dt=$dt&res=$res&id=$id&email=$mailid'>Edit</a>":"<a href='exercise_show.php?test=$test&dt=$dt&res=$res&id=$id'>Show</a>"?></td>
 
 
 		 </tr>
 		 </tr>
-		
+
 		<?php
 		<?php
-			
+
 			}
 			}
 		}
 		}
 		else
 		else
 		{
 		{
-				$NoTestRes = 1;	
+				$NoTestRes = 1;
 		}
 		}
-		
+
 		// The Result of Tests
 		// The Result of Tests
 		if(is_array($hpresults))
 		if(is_array($hpresults))
 		{
 		{
-		
+
 			for($i = 0; $i < sizeof($hpresults); $i++)
 			for($i = 0; $i < sizeof($hpresults); $i++)
 			{
 			{
-				$title = GetQuizName($hpresults[$i][1],$documentPath);			
+				$title = GetQuizName($hpresults[$i][1],$documentPath);
 				if ($title =='')
 				if ($title =='')
 				{
 				{
-					$title = GetFileName($hpresults[$i][1]);		
-				}		
+					$title = GetFileName($hpresults[$i][1]);
+				}
 		?>
 		?>
 		<tr>
 		<tr>
 		<?php if($is_allowedToEdit): ?>
 		<?php if($is_allowedToEdit): ?>
 			<td class="content"><?php echo $hpresults[$i][0]; ?></td><?php endif; ?>
 			<td class="content"><?php echo $hpresults[$i][0]; ?></td><?php endif; ?>
-		  <td class="content"><?php echo $title; ?></td>  
+		  <td class="content"><?php echo $title; ?></td>
 		  <td class="content" align="center"><?php echo strftime($dateTimeFormatLong,$hpresults[$i][4]); ?></td>
 		  <td class="content" align="center"><?php echo strftime($dateTimeFormatLong,$hpresults[$i][4]); ?></td>
 		  <td class="content" align="center"><?php echo $hpresults[$i][2]; ?> / <?php echo $hpresults[$i][3]; ?></td>
 		  <td class="content" align="center"><?php echo $hpresults[$i][2]; ?> / <?php echo $hpresults[$i][3]; ?></td>
 		</tr>
 		</tr>
-		
+
 		<?php
 		<?php
 			}
 			}
 		}
 		}
@@ -910,24 +916,24 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 		{
 		{
 			$NoHPTestRes = 1;
 			$NoHPTestRes = 1;
 		}
 		}
-		
-		
-		
+
+
+
 		if ($NoTestRes==1 && $NoHPTestRes==1)
 		if ($NoTestRes==1 && $NoHPTestRes==1)
 		{
 		{
 		?>
 		?>
-		
+
 		 <tr>
 		 <tr>
 		  <td colspan="3"><?php echo get_lang("NoResult"); ?></td>
 		  <td colspan="3"><?php echo get_lang("NoResult"); ?></td>
 		 </tr>
 		 </tr>
-		
+
 		<?php
 		<?php
 		}
 		}
-		
+
 		?>
 		?>
-		
+
 		</table>
 		</table>
-		
+
 		<?php
 		<?php
 	}else{
 	}else{
 
 
@@ -940,8 +946,8 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 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();
 } else {
 } else {
-	?> 
-	<link rel="stylesheet" type="text/css" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" /> 
+	?>
+	<link rel="stylesheet" type="text/css" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" />
 	<?php
 	<?php
 }
 }
 ?>
 ?>

+ 25 - 25
main/exercice/exercice_submit.php

@@ -1,4 +1,4 @@
-<?php // $Id: exercice_submit.php 10594 2007-01-05 13:54:24Z elixir_inter $
+<?php // $Id: exercice_submit.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -62,7 +62,7 @@ define('FREE_ANSWER', 5);
 define('HOT_SPOT', 			6);
 define('HOT_SPOT', 			6);
 define('HOT_SPOT_ORDER', 	7);
 define('HOT_SPOT_ORDER', 	7);
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 include_once('../inc/global.inc.php');
 include_once('../inc/global.inc.php');
@@ -74,8 +74,8 @@ $is_allowedToEdit=$is_courseAdmin;
 
 
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 // general parameters passed via POST/GET
 // general parameters passed via POST/GET
 
 
@@ -160,7 +160,7 @@ if($formSent)
             // $exerciseResult receives the content of the form.
             // $exerciseResult receives the content of the form.
             // Each choice of the student is stored into the array $choice
             // Each choice of the student is stored into the array $choice
             $exerciseResult=$choice;
             $exerciseResult=$choice;
-            
+
             if (isset($_POST['hotspot']))
             if (isset($_POST['hotspot']))
             {
             {
             	$exerciseResultCoordinates = $_POST['hotspot'];
             	$exerciseResultCoordinates = $_POST['hotspot'];
@@ -176,7 +176,7 @@ if($formSent)
             {
             {
                 // stores the user answer into the array
                 // stores the user answer into the array
                 $exerciseResult[$key]=$choice[$key];
                 $exerciseResult[$key]=$choice[$key];
-                
+
                 if (isset($_POST['hotspot']))
                 if (isset($_POST['hotspot']))
                 {
                 {
                 	$exerciseResultCoordinates[$key] = $_POST['hotspot'][$key];
                 	$exerciseResultCoordinates[$key] = $_POST['hotspot'][$key];
@@ -222,7 +222,7 @@ if(!isset($_SESSION['objExercise']))
 
 
 }
 }
 
 
-if(!isset($objExcercise) && isset($_SESSION['objExercise'])){	
+if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
 	$objExercise = $_SESSION['objExercise'];
 	$objExercise = $_SESSION['objExercise'];
 }
 }
 if(!is_object($objExercise))
 if(!is_object($objExercise))
@@ -246,7 +246,7 @@ if(!isset($_SESSION['questionList']))
     api_session_register('questionList');
     api_session_register('questionList');
     if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
     if($debug>0){echo str_repeat('&nbsp;',0).'$_SESSION[questionList] was unset - set now - end'."<br />\n";}
 }
 }
-if(!isset($objExcercise) && isset($_SESSION['objExercise'])){	
+if(!isset($objExcercise) && isset($_SESSION['objExercise'])){
 	$questionList = $_SESSION['questionList'];
 	$questionList = $_SESSION['questionList'];
 }
 }
 
 
@@ -273,7 +273,7 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')
 if ($origin != 'learnpath') { //so we are not in learnpath tool
 if ($origin != 'learnpath') { //so we are not in learnpath tool
 
 
 $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
 $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
-					<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>					   
+					<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
 					<script language=\"JavaScript\" type=\"text/javascript\">
 					<script language=\"JavaScript\" type=\"text/javascript\">
 					<!--
 					<!--
 					// -----------------------------------------------------------------------------
 					// -----------------------------------------------------------------------------
@@ -295,7 +295,7 @@ $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/Java
 					  on error resume next
 					  on error resume next
 					  Dim swControl, swVersion
 					  Dim swControl, swVersion
 					  swVersion = 0
 					  swVersion = 0
-					  
+
 					  set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
 					  set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
 					  if (IsObject(swControl)) then
 					  if (IsObject(swControl)) then
 					    swVersion = swControl.GetVariable(\"\$version\")
 					    swVersion = swControl.GetVariable(\"\$version\")
@@ -304,7 +304,7 @@ $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/Java
 					End Function
 					End Function
 					// -->
 					// -->
 					</script>
 					</script>
-					
+
 					<script language=\"JavaScript1.1\" type=\"text/javascript\">
 					<script language=\"JavaScript1.1\" type=\"text/javascript\">
 					<!-- // Detect Client Browser type
 					<!-- // Detect Client Browser type
 					var isIE  = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
 					var isIE  = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
@@ -341,46 +341,46 @@ $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/Java
 						else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
 						else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
 						// Can't detect in all other cases
 						// Can't detect in all other cases
 						else {
 						else {
-							
+
 							flashVer = -1;
 							flashVer = -1;
 						}
 						}
 						return flashVer;
 						return flashVer;
-					} 
+					}
 					// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
 					// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
-					function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
+					function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
 					{
 					{
 					 	reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
 					 	reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
-					   	// loop backwards through the versions until we find the newest version	
-						for (i=25;i>0;i--) {	
+					   	// loop backwards through the versions until we find the newest version
+						for (i=25;i>0;i--) {
 							if (isIE && isWin && !isOpera) {
 							if (isIE && isWin && !isOpera) {
 								versionStr = VBGetSwfVer(i);
 								versionStr = VBGetSwfVer(i);
 							} else {
 							} else {
 								versionStr = JSGetSwfVer(i);
 								versionStr = JSGetSwfVer(i);
 							}
 							}
-							if (versionStr == -1 ) { 
+							if (versionStr == -1 ) {
 								return false;
 								return false;
 							} else if (versionStr != 0) {
 							} else if (versionStr != 0) {
 								if(isIE && isWin && !isOpera) {
 								if(isIE && isWin && !isOpera) {
 									tempArray         = versionStr.split(\" \");
 									tempArray         = versionStr.split(\" \");
 									tempString        = tempArray[1];
 									tempString        = tempArray[1];
-									versionArray      = tempString .split(\",\");				
+									versionArray      = tempString .split(\",\");
 								} else {
 								} else {
 									versionArray      = versionStr.split(\".\");
 									versionArray      = versionStr.split(\".\");
 								}
 								}
 								versionMajor      = versionArray[0];
 								versionMajor      = versionArray[0];
 								versionMinor      = versionArray[1];
 								versionMinor      = versionArray[1];
 								versionRevision   = versionArray[2];
 								versionRevision   = versionArray[2];
-								
+
 								versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 								versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 								versionNum        = parseFloat(versionString);
 								versionNum        = parseFloat(versionString);
 					        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 					        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 								if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 								if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 									return true;
 									return true;
 								} else {
 								} else {
-									return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
+									return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
 								}
 								}
 							}
 							}
-						}	
+						}
 					}
 					}
 					// -->
 					// -->
 					</script>";
 					</script>";
@@ -392,15 +392,15 @@ else
 	{
 	{
 		$charset = 'ISO-8859-15';
 		$charset = 'ISO-8859-15';
 	}
 	}
-	header('Content-Type: text/html; charset='. $charset);	
-	
+	header('Content-Type: text/html; charset='. $charset);
+
 	@$document_language = Database::get_language_isocode($language_interface);
 	@$document_language = Database::get_language_isocode($language_interface);
 	if(empty($document_language))
 	if(empty($document_language))
 	{
 	{
 	  //if there was no valid iso-code, use the english one
 	  //if there was no valid iso-code, use the english one
 	  $document_language = 'en';
 	  $document_language = 'en';
 	}
 	}
-	
+
 	/*
 	/*
 	 * HTML HEADER
 	 * HTML HEADER
 	 */
 	 */
@@ -443,7 +443,7 @@ foreach($questionList as $questionId)
 {
 {
 	$i++;
 	$i++;
 	$objQuestionTmp = Question :: read($questionId);
 	$objQuestionTmp = Question :: read($questionId);
-	
+
 	// for sequential exercises
 	// for sequential exercises
 	if($exerciseType == 2)
 	if($exerciseType == 2)
 	{
 	{

+ 32 - 35
main/exercice/exercise.class.php

@@ -1,38 +1,38 @@
-<?php // $Id: exercise.class.php 10691 2007-01-12 12:16:28Z elixir_inter $
+<?php // $Id: exercise.class.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 
 
 if(!class_exists('Exercise')):
 if(!class_exists('Exercise')):
- 
+
 /**
 /**
-============================================================================== 
+==============================================================================
 	CLASS EXERCISE
 	CLASS EXERCISE
 *
 *
 *	This class allows to instantiate an object of type Exercise
 *	This class allows to instantiate an object of type Exercise
 *
 *
 *	@author Olivier Brouckaert
 *	@author Olivier Brouckaert
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 */
 class Exercise
 class Exercise
 {
 {
@@ -73,14 +73,11 @@ class Exercise
 	function read($id)
 	function read($id)
 	{
 	{
 		global $_course;
 		global $_course;
-		#$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
-		#$TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-		#$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-		#$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
-    $TBL_EXERCICE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
-    $TBL_EXERCICES          = Database::get_course_table(TABLE_QUIZ_TEST);
-    $TBL_QUESTIONS          = Database::get_course_table(TABLE_QUIZ_QUESTION);
-    #$TBL_REPONSES           = Database::get_course_table(TABLE_QUIZ_ANSWER);
+
+	    $TBL_EXERCICE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
+    	$TBL_EXERCICES          = Database::get_course_table(TABLE_QUIZ_TEST);
+	    $TBL_QUESTIONS          = Database::get_course_table(TABLE_QUIZ_QUESTION);
+    	#$TBL_REPONSES           = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 		$sql="SELECT title,description,sound,type,random,active FROM $TBL_EXERCICES WHERE id='$id'";
 		$sql="SELECT title,description,sound,type,random,active FROM $TBL_EXERCICES WHERE id='$id'";
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 		$result=api_sql_query($sql,__FILE__,__LINE__);
@@ -607,17 +604,17 @@ class Exercise
 		$sql="DELETE FROM $TBL_EXERCICES WHERE id='$id'";
 		$sql="DELETE FROM $TBL_EXERCICES WHERE id='$id'";
 		api_sql_query($sql,__FILE__,__LINE__);
 		api_sql_query($sql,__FILE__,__LINE__);
 	}
 	}
-	
+
 	/**
 	/**
 	 * Creates the form to create / edit an exercise
 	 * Creates the form to create / edit an exercise
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 */
 	 */
-	function createForm ($form) 
+	function createForm ($form)
 	{
 	{
-		
+
 		// title
 		// title
 		$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName').' : ');
 		$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName').' : ');
-		
+
 		// fck editor
 		// fck editor
 		global $fck_attribute;
 		global $fck_attribute;
 		$fck_attribute = array();
 		$fck_attribute = array();
@@ -625,19 +622,19 @@ class Exercise
 		$fck_attribute['Width'] = '100%';
 		$fck_attribute['Width'] = '100%';
 		$fck_attribute['ToolbarSet'] = 'NewTest';
 		$fck_attribute['ToolbarSet'] = 'NewTest';
 		$form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription').' : ');
 		$form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription').' : ');
-		
+
 		// type
 		// type
 		$radios = array();
 		$radios = array();
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
 		$form -> addGroup($radios, null, get_lang('ExerciseType').' : ', '<br />');
 		$form -> addGroup($radios, null, get_lang('ExerciseType').' : ', '<br />');
-		
+
 		// submit
 		// submit
 		$form -> addElement('submit', 'submitExercise', get_lang('Ok'));
 		$form -> addElement('submit', 'submitExercise', get_lang('Ok'));
-		
+
 		// rules
 		// rules
 		$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
 		$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
-		
+
 		// defaults
 		// defaults
 		$defaults = array();
 		$defaults = array();
 		if($this -> id > 0)
 		if($this -> id > 0)
@@ -647,25 +644,25 @@ class Exercise
 			$defaults['exerciseDescription'] = $this -> selectDescription();
 			$defaults['exerciseDescription'] = $this -> selectDescription();
 		}
 		}
 		$defaults['exerciseType'] = '1';
 		$defaults['exerciseType'] = '1';
-		
+
 		$form -> setDefaults($defaults);
 		$form -> setDefaults($defaults);
-		
-		
+
+
 	}
 	}
-	
-	
+
+
 	/**
 	/**
 	 * function which process the creation of exercises
 	 * function which process the creation of exercises
 	 * @param FormValidator $form the formvalidator instance
 	 * @param FormValidator $form the formvalidator instance
 	 */
 	 */
-	function processCreation($form) 
+	function processCreation($form)
 	{
 	{
-		
+
 		$this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
 		$this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
 		$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
 		$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
 		$this -> updateType($form -> getSubmitValue('exerciseType'));
 		$this -> updateType($form -> getSubmitValue('exerciseType'));
 		$this -> save();
 		$this -> save();
-		
+
 	}
 	}
 }
 }
 
 

+ 77 - 77
main/exercice/exercise_result.php

@@ -1,29 +1,29 @@
-<?php // $Id: exercise_result.php 10750 2007-01-17 08:43:53Z pcool $
+<?php // $Id: exercise_result.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
-*	EXERCISE RESULT  
+==============================================================================
+*	EXERCISE RESULT
 *
 *
 *	This script gets informations from the script "exercise_submit.php",
 *	This script gets informations from the script "exercise_submit.php",
 *	through the session, and calculates the score of the student for
 *	through the session, and calculates the score of the student for
@@ -36,7 +36,7 @@
 *	@package dokeos.exercise
 *	@package dokeos.exercise
 *	@todo	split more code up in functions, move functions to library?
 *	@todo	split more code up in functions, move functions to library?
 * 	@todo 	use database library
 * 	@todo 	use database library
-============================================================================== 
+==============================================================================
 */
 */
 
 
 /*
 /*
@@ -58,7 +58,7 @@ define('HOT_SPOT', 6);
 define('HOT_SPOT_ORDER', 	7);
 define('HOT_SPOT_ORDER', 	7);
 
 
 global $_cid;
 global $_cid;
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 include('../inc/global.inc.php');
 include('../inc/global.inc.php');
@@ -69,14 +69,14 @@ include(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
 // Database table definitions
 // Database table definitions
 $TBL_EXERCICE_QUESTION 	= $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION 	= $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         	= $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         	= $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         	= $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          	= $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         	= Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          	= Database::get_course_table(TABLE_QUIZ_ANSWER);
 $TABLETRACK_EXERCICES 	= $_configuration['statistics_database']."`.`track_e_exercices";
 $TABLETRACK_EXERCICES 	= $_configuration['statistics_database']."`.`track_e_exercices";
-$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt"; 
+$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt";
 $main_user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
 $main_user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_ans 				= Database :: get_course_table(TABLE_QUIZ_ANSWER);
 $table_ans 				= Database :: get_course_table(TABLE_QUIZ_ANSWER);
-					
+
 //temp values to move to AWACS
 //temp values to move to AWACS
 $dsp_percent = false; //false to display total score as absolute values
 $dsp_percent = false; //false to display total score as absolute values
 //debug param. 0: no display - 1: debug display
 //debug param. 0: no display - 1: debug display
@@ -106,7 +106,7 @@ if ( empty ( $choice ) ) {
 }
 }
 if ( empty ( $questionNum ) ) {
 if ( empty ( $questionNum ) ) {
    $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
    $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
+}
 if ( empty ( $nbrQuestions ) ) {
 if ( empty ( $nbrQuestions ) ) {
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
 }
@@ -152,20 +152,20 @@ if ($origin != 'learnpath')
 }
 }
 else
 else
 {
 {
-	
+
 	if(empty($charset))
 	if(empty($charset))
 	{
 	{
 		$charset = 'ISO-8859-15';
 		$charset = 'ISO-8859-15';
 	}
 	}
-	header('Content-Type: text/html; charset='. $charset);	
-	
+	header('Content-Type: text/html; charset='. $charset);
+
 	@$document_language = Database::get_language_isocode($language_interface);
 	@$document_language = Database::get_language_isocode($language_interface);
 	if(empty($document_language))
 	if(empty($document_language))
 	{
 	{
 	  //if there was no valid iso-code, use the english one
 	  //if there was no valid iso-code, use the english one
 	  $document_language = 'en';
 	  $document_language = 'en';
 	}
 	}
-	
+
 	/*
 	/*
 	 * HTML HEADER
 	 * HTML HEADER
 	 */
 	 */
@@ -193,7 +193,7 @@ else
 
 
 function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect)
 function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect)
 {
 {
-	?>	
+	?>
 	<tr>
 	<tr>
 	<td width="5%" align="center">
 	<td width="5%" align="center">
 		<img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
 		<img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
@@ -219,27 +219,27 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
 
 
 function display_fill_in_blanks_answer($answer)
 function display_fill_in_blanks_answer($answer)
 {
 {
-	?>					
+	?>
 		<tr>
 		<tr>
 		<td>
 		<td>
 			<?php echo nl2br($answer); ?>
 			<?php echo nl2br($answer); ?>
 		</td>
 		</td>
-		</tr>					
+		</tr>
 	<?php
 	<?php
 }
 }
 
 
 function display_free_answer($answer)
 function display_free_answer($answer)
 {
 {
-	?>					
+	?>
 		<tr>
 		<tr>
 		<td width="55%">
 		<td width="55%">
 			<?php echo nl2br(stripslashes($answer)); ?>
 			<?php echo nl2br(stripslashes($answer)); ?>
 		</td>
 		</td>
    <td width="45%">
    <td width="45%">
     <?php echo get_lang('notCorrectedYet');?>
     <?php echo get_lang('notCorrectedYet');?>
-	
+
    </td>
    </td>
-		</tr>					
+		</tr>
 	<?php
 	<?php
 }
 }
 
 
@@ -260,7 +260,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 									"#ED2024",
 									"#ED2024",
 									"#45C7F0",
 									"#45C7F0",
 									"#F7BDE2");
 									"#F7BDE2");
-	?>		
+	?>
 		<tr>
 		<tr>
 				<td width="25%" valign="top">
 				<td width="25%" valign="top">
 					<div style="float:left; padding-left:5px;">
 					<div style="float:left; padding-left:5px;">
@@ -278,15 +278,15 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 		</tr>
 		</tr>
 	<?php
 	<?php
 }
 }
-					
+
 /*
 /*
 ==============================================================================
 ==============================================================================
 		MAIN CODE
 		MAIN CODE
 ==============================================================================
 ==============================================================================
 */
 */
 $exerciseTitle=api_parse_tex($exerciseTitle);
 $exerciseTitle=api_parse_tex($exerciseTitle);
-	
-?>	
+
+?>
 	<h3><?php echo $exerciseTitle ?>: <?php echo get_lang("Result"); ?></h3>
 	<h3><?php echo $exerciseTitle ?>: <?php echo get_lang("Result"); ?></h3>
 	<form method="get" action="exercice.php">
 	<form method="get" action="exercice.php">
 	<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
 	<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
@@ -296,20 +296,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 <?php
 <?php
 	$i=$totalScore=$totalWeighting=0;
 	$i=$totalScore=$totalWeighting=0;
 	if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
 	if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
- 
+
 
 
 	// added by Priya Saini
 	// added by Priya Saini
 	$sql = "select max(exe_Id) as id from `".$TABLETRACK_EXERCICES."`";
 	$sql = "select max(exe_Id) as id from `".$TABLETRACK_EXERCICES."`";
 	$res = api_sql_query($sql, __FILE__, __LINE__);
 	$res = api_sql_query($sql, __FILE__, __LINE__);
 	$exeId =mysql_result($res,0,"id");
 	$exeId =mysql_result($res,0,"id");
 	$exeId=$exeId+1;
 	$exeId=$exeId+1;
-	
+
 	foreach($questionList as $questionId)
 	foreach($questionList as $questionId)
 	{
 	{
 		// gets the student choice for this question
 		// gets the student choice for this question
 		$choice=$exerciseResult[$questionId];
 		$choice=$exerciseResult[$questionId];
 		// creates a temporary Question object
 		// creates a temporary Question object
-		
+
 		$objQuestionTmp = Question :: read($questionId);
 		$objQuestionTmp = Question :: read($questionId);
 
 
 		$questionName=$objQuestionTmp->selectTitle();
 		$questionName=$objQuestionTmp->selectTitle();
@@ -371,7 +371,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		}
 		elseif($answerType == FILL_IN_BLANKS)
 		elseif($answerType == FILL_IN_BLANKS)
 		{
 		{
-			?>			
+			?>
 				<tr>
 				<tr>
 				<td>
 				<td>
 					<i><?php echo get_lang("Answer"); ?></i>
 					<i><?php echo get_lang("Answer"); ?></i>
@@ -381,7 +381,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		}
 		elseif($answerType == FREE_ANSWER)
 		elseif($answerType == FREE_ANSWER)
 		{
 		{
-			?>			
+			?>
 				<tr>
 				<tr>
 				<td width="55%">
 				<td width="55%">
 					<i><?php echo get_lang("Answer"); ?></i>
 					<i><?php echo get_lang("Answer"); ?></i>
@@ -394,7 +394,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		}
 		elseif($answerType == HOT_SPOT)
 		elseif($answerType == HOT_SPOT)
 		{
 		{
-			?>			
+			?>
 				<tr>
 				<tr>
 					<td width="40%">
 					<td width="40%">
 						<i><?php echo get_lang('Hotspot'); ?></i><br /><br />
 						<i><?php echo get_lang('Hotspot'); ?></i><br /><br />
@@ -449,7 +449,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 			switch($answerType)
 			switch($answerType)
 			{
 			{
 				// for unique answer
 				// for unique answer
-				case UNIQUE_ANSWER :	
+				case UNIQUE_ANSWER :
 										$studentChoice=($choice == $answerId)?1:0;
 										$studentChoice=($choice == $answerId)?1:0;
 
 
 										if($studentChoice)
 										if($studentChoice)
@@ -457,12 +457,12 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 										  	$questionScore+=$answerWeighting;
 										  	$questionScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 										}
 										}
-										
+
 
 
 										break;
 										break;
 				// for multiple answers
 				// for multiple answers
-				case MULTIPLE_ANSWER :	
-										
+				case MULTIPLE_ANSWER :
+
 										$studentChoice=$choice[$answerId];
 										$studentChoice=$choice[$answerId];
 
 
 										if($studentChoice)
 										if($studentChoice)
@@ -470,20 +470,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 											$questionScore+=$answerWeighting;
 											$questionScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 										}
 										}
-										
+
 										break;
 										break;
 				// for fill in the blanks
 				// for fill in the blanks
-				case FILL_IN_BLANKS :	// splits text and weightings that are joined with the character '::'									
-										
+				case FILL_IN_BLANKS :	// splits text and weightings that are joined with the character '::'
+
 										list($answer,$answerWeighting)=explode('::',$answer);
 										list($answer,$answerWeighting)=explode('::',$answer);
 
 
 										// splits weightings that are joined with a comma
 										// splits weightings that are joined with a comma
 										$answerWeighting=explode(',',$answerWeighting);
 										$answerWeighting=explode(',',$answerWeighting);
 
 
 										// we save the answer because it will be modified
 										// we save the answer because it will be modified
-										
+
 										$temp=$answer;
 										$temp=$answer;
-								
+
 										// TeX parsing
 										// TeX parsing
 										// 1. find everything between the [tex] and [/tex] tags
 										// 1. find everything between the [tex] and [/tex] tags
 										 $startlocations=strpos($temp,'[tex]');
 										 $startlocations=strpos($temp,'[tex]');
@@ -491,7 +491,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 
 										if($startlocations !== false && $endlocations !== false)
 										if($startlocations !== false && $endlocations !== false)
 										{
 										{
-											
+
 											$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
 											$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
 											// 2. replace this by {texcode}
 											// 2. replace this by {texcode}
 											$temp=str_replace($texstring,'{texcode}',$temp);
 											$temp=str_replace($texstring,'{texcode}',$temp);
@@ -499,13 +499,13 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 
 										$answer='';
 										$answer='';
 
 
-				
+
 										$j=0;
 										$j=0;
 
 
 										// the loop will stop at the end of the text
 										// the loop will stop at the end of the text
 										while(1)
 										while(1)
-										{ 
-												
+										{
+
 											// quits the loop if there are no more blanks
 											// quits the loop if there are no more blanks
 											if(($pos = strpos($temp,'[')) === false)
 											if(($pos = strpos($temp,'[')) === false)
 											{
 											{
@@ -524,14 +524,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 											// quits the loop if there are no more blanks
 											// quits the loop if there are no more blanks
 											if(($pos = strpos($temp,']')) === false)
 											if(($pos = strpos($temp,']')) === false)
 											{
 											{
-												
+
 												// adds the end of the text
 												// adds the end of the text
 												$answer.=$temp;
 												$answer.=$temp;
 												break;
 												break;
 											}
 											}
 
 
 											$choice[$j]=trim($choice[$j]);
 											$choice[$j]=trim($choice[$j]);
-						
+
 											// if the word entered by the student IS the same as the one defined by the professor
 											// if the word entered by the student IS the same as the one defined by the professor
 											if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j])))
 											if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j])))
 											{
 											{
@@ -566,7 +566,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 
 										break;
 										break;
 				// for free answer
 				// for free answer
-				case FREE_ANSWER :	   
+				case FREE_ANSWER :
 										$studentChoice=$choice;
 										$studentChoice=$choice;
 
 
 										if($studentChoice)
 										if($studentChoice)
@@ -574,11 +574,11 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 										  	$questionScore=0;
 										  	$questionScore=0;
 											$totalScore+=0;
 											$totalScore+=0;
 										}
 										}
-										
+
 
 
 										break;
 										break;
 				// for matching
 				// for matching
-				case MATCHING :			
+				case MATCHING :
 										if($answerCorrect)
 										if($answerCorrect)
 										{
 										{
 											if($answerCorrect == $choice[$answerId])
 											if($answerCorrect == $choice[$answerId])
@@ -641,7 +641,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				elseif($answerType == FREE_ANSWER)
 				elseif($answerType == FREE_ANSWER)
 				{
 				{
 					// to store the details of open questions in an array to be used in mail
 					// to store the details of open questions in an array to be used in mail
-					
+
 					$arrques[] = $questionName;
 					$arrques[] = $questionName;
 					$arrans[]  = $choice;
 					$arrans[]  = $choice;
 					$firstName =   $_SESSION['_user']['firstName'];
 					$firstName =   $_SESSION['_user']['firstName'];
@@ -666,7 +666,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				}
 				}
 				else
 				else
 				{
 				{
-					?>					
+					?>
 						<tr>
 						<tr>
 						<td width="50%">
 						<td width="50%">
 							<?php
 							<?php
@@ -679,18 +679,18 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 							$matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							$matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							echo $matching[$answerCorrect]; ?></b></font>
 							echo $matching[$answerCorrect]; ?></b></font>
 						</td>
 						</td>
-						</tr>		
+						</tr>
 					<?php
 					<?php
 				}
 				}
 			}
 			}
 		} // end for that loops over all answers of the current question
 		} // end for that loops over all answers of the current question
-		
+
 		if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
 		if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
 			{
 			{
 				// We made an extra table for the answers
 				// We made an extra table for the answers
 				echo "</table></td></tr>";
 				echo "</table></td></tr>";
 			}
 			}
-		?>	
+		?>
 			<tr>
 			<tr>
 			<td colspan="<?php echo $colspan; ?>" align="right">
 			<td colspan="<?php echo $colspan; ?>" align="right">
 				<b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b>
 				<b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b>
@@ -716,7 +716,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				for ($i=0;$i<sizeof($reply);$i++)
 				for ($i=0;$i<sizeof($reply);$i++)
 				{
 				{
 					$ans = $reply[$i];
 					$ans = $reply[$i];
-					exercise_attempt($questionScore,$ans,$quesId,$exeId);			
+					exercise_attempt($questionScore,$ans,$quesId,$exeId);
 				}
 				}
 			}
 			}
 			elseif ($answerType==4)
 			elseif ($answerType==4)
@@ -724,16 +724,16 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				$j=3;
 				$j=3;
 				for ($i=0;$i<sizeof($choice);$i++,$j++)
 				for ($i=0;$i<sizeof($choice);$i++,$j++)
 				{
 				{
-					
+
 					$val = $choice[$j];
 					$val = $choice[$j];
 					if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
 					if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
 						$val = $arr1[1][0];
 						$val = $arr1[1][0];
-					$sql = "select position from $table_ans where question_id=$questionId and answer='$val'";	
+					$sql = "select position from $table_ans where question_id=$questionId and answer='$val'";
 					$res = api_sql_query($sql, __FILE__, __LINE__);
 					$res = api_sql_query($sql, __FILE__, __LINE__);
 					$answer = mysql_result($res,0,"position");
 					$answer = mysql_result($res,0,"position");
-					
+
 					exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
 					exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
-						
+
 				}
 				}
 			}
 			}
 			elseif ($answerType==5)
 			elseif ($answerType==5)
@@ -781,14 +781,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		</td>
 		</td>
 		</tr>
 		</tr>
 		</table>
 		</table>
-		
+
 		</form>
 		</form>
-		
+
 		<br />
 		<br />
 	<?php
 	<?php
 /*
 /*
 ==============================================================================
 ==============================================================================
-		Tracking of results 
+		Tracking of results
 ==============================================================================
 ==============================================================================
 */
 */
 
 
@@ -796,7 +796,7 @@ if($_configuration['tracking_enabled'])
 {
 {
 	//include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
 	//include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
 	event_exercice($objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
 	event_exercice($objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
-	
+
 }
 }
 
 
 if ($origin != 'learnpath')
 if ($origin != 'learnpath')
@@ -822,15 +822,15 @@ if (!empty($arrques))
 	$msg = "<html><head>
 	$msg = "<html><head>
 	 <link rel='stylesheet' href='http://www.dokeos.com/styles.css' type='text/css'>
 	 <link rel='stylesheet' href='http://www.dokeos.com/styles.css' type='text/css'>
   <meta content='text/html; charset=ISO-8859-1' http-equiv='content-type'>";
   <meta content='text/html; charset=ISO-8859-1' http-equiv='content-type'>";
-  
+
 
 
 /*<style type='text/css'>
 /*<style type='text/css'>
 
 
 <!--
 <!--
 .body{
 .body{
-font-family: Verdana, Arial, Helvetica, sans-serif; 
-font-weight: Normal; 
-color: #000000; 
+font-family: Verdana, Arial, Helvetica, sans-serif;
+font-weight: Normal;
+color: #000000;
 }
 }
 .style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
 .style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }
 .style10 {
 .style10 {
@@ -881,7 +881,7 @@ color: #000000;
     <td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Answer </span></td>
     <td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Answer </span></td>
     <td valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
     <td valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
   	</tr>";
   	</tr>";
-					
+
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
@@ -890,7 +890,7 @@ color: #000000;
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg= str_replace("#course#",$courseName,$msg1);
 	$msg= str_replace("#course#",$courseName,$msg1);
-			
+
 	}
 	}
 	$msg.="</table><br>*/
 	$msg.="</table><br>*/
 	//
 	//
@@ -932,7 +932,7 @@ color: #000000;
     <td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Answer </span></td>
     <td width='220' valign='top' bgcolor='E5EDF8'>&nbsp;&nbsp;<span class='style10'>Answer </span></td>
     <td valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
     <td valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
   	</tr>";
   	</tr>";
-					
+
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
@@ -941,7 +941,7 @@ color: #000000;
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg= str_replace("#course#",$courseName,$msg1);
 	$msg= str_replace("#course#",$courseName,$msg1);
-			
+
 	}
 	}
 	$msg.="</table><br>
 	$msg.="</table><br>
  	<span class='style16'>Click the following links tp check the answer and give feedbacks,<br>
  	<span class='style16'>Click the following links tp check the answer and give feedbacks,<br>

+ 102 - 102
main/exercice/exercise_show.php

@@ -4,7 +4,7 @@
  * @todo use the Database:: functions
  * @todo use the Database:: functions
  * @todo small letters for table variables
  * @todo small letters for table variables
  */
  */
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 // including the global dokeos file
 // including the global dokeos file
@@ -34,21 +34,21 @@ api_protect_course_script();
 // Database table definitions
 // Database table definitions
 $TBL_EXERCICE_QUESTION 	= $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION 	= $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         	= $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         	= $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         	= $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          	= $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         	= Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          	= Database::get_course_table(TABLE_QUIZ_ANSWER);
 $main_user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
 $main_user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
-$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt"; 
+$TABLETRACK_ATTEMPT 	= $_configuration['statistics_database']."`.`track_e_attempt";
 $TABLETRACK_EXERCICES 	= $_configuration['statistics_database']."`.`track_e_exercices";
 $TABLETRACK_EXERCICES 	= $_configuration['statistics_database']."`.`track_e_exercices";
 
 
-$dsp_percent = false; 
+$dsp_percent = false;
 $debug=0;
 $debug=0;
 if($debug>0)
 if($debug>0)
 {
 {
 	echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
 	echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
 }
 }
 // general parameters passed via POST/GET
 // general parameters passed via POST/GET
-if ( empty ( $origin ) ) 
+if ( empty ( $origin ) )
 {
 {
     $origin = $_REQUEST['origin'];
     $origin = $_REQUEST['origin'];
 }
 }
@@ -72,7 +72,7 @@ if ( empty ( $choice ) ) {
 }
 }
 if ( empty ( $questionNum ) ) {
 if ( empty ( $questionNum ) ) {
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
+}
 if ( empty ( $nbrQuestions ) ) {
 if ( empty ( $nbrQuestions ) ) {
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
 }
@@ -82,7 +82,7 @@ if ( empty ( $questionList ) ) {
 if ( empty ( $objExercise ) ) {
 if ( empty ( $objExercise ) ) {
     $objExercise = $_SESSION['objExercise'];
     $objExercise = $_SESSION['objExercise'];
 }
 }
-$is_allowedToEdit=$is_courseAdmin;	
+$is_allowedToEdit=$is_courseAdmin;
 $nameTools=get_lang('Exercice');
 $nameTools=get_lang('Exercice');
 
 
 $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
 $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
@@ -122,33 +122,33 @@ function getFCK(vals,marksid){
   var f=document.getElementById('myform');
   var f=document.getElementById('myform');
 
 
   var m_id = marksid.split(',');
   var m_id = marksid.split(',');
-  for(var i=0;i<m_id.length;i++){ 
+  for(var i=0;i<m_id.length;i++){
   var oHidn = document.createElement("input");
   var oHidn = document.createElement("input");
 			oHidn.type = "hidden";
 			oHidn.type = "hidden";
 			var selname = oHidn.name = "marks_"+m_id[i];
 			var selname = oHidn.name = "marks_"+m_id[i];
-			var selid = document.forms['marksform_'+m_id[i]].marks.selectedIndex;			
+			var selid = document.forms['marksform_'+m_id[i]].marks.selectedIndex;
 			oHidn.value = document.forms['marksform_'+m_id[i]].marks.options[selid].text;
 			oHidn.value = document.forms['marksform_'+m_id[i]].marks.options[selid].text;
 			f.appendChild(oHidn);
 			f.appendChild(oHidn);
-	}  
+	}
 
 
 	var ids = vals.split(',');
 	var ids = vals.split(',');
-	for(var k=0;k<ids.length;k++){  
+	for(var k=0;k<ids.length;k++){
 			var oHidden = document.createElement("input");
 			var oHidden = document.createElement("input");
 			oHidden.type = "hidden";
 			oHidden.type = "hidden";
 			oHidden.name = "comments_"+ids[k];
 			oHidden.name = "comments_"+ids[k];
 			oEditor = FCKeditorAPI.GetInstance(oHidden.name) ;
 			oEditor = FCKeditorAPI.GetInstance(oHidden.name) ;
 			oHidden.value = oEditor.GetXHTML(true);
 			oHidden.value = oEditor.GetXHTML(true);
-			f.appendChild(oHidden);  
+			f.appendChild(oHidden);
 	}
 	}
 //f.submit();
 //f.submit();
 }
 }
 </script>
 </script>
 <?php
 <?php
-		
+
 //functions
 //functions
 function get_comments($id,$question_id)
 function get_comments($id,$question_id)
 	{
 	{
-	global $TABLETRACK_ATTEMPT;				
+	global $TABLETRACK_ATTEMPT;
 	$sql = "select teacher_comment from `".$TABLETRACK_ATTEMPT."` where exe_id=$id and question_id = '$question_id' order by question_id";
 	$sql = "select teacher_comment from `".$TABLETRACK_ATTEMPT."` where exe_id=$id and question_id = '$question_id' order by question_id";
 	$sqlres = api_sql_query($sql, __FILE__, __LINE__);
 	$sqlres = api_sql_query($sql, __FILE__, __LINE__);
 	$comm = mysql_result($sqlres,0,"teacher_comment");
 	$comm = mysql_result($sqlres,0,"teacher_comment");
@@ -180,42 +180,42 @@ function display_unique_or_multiple_answer($answerType, $studentChoice, $answer,
 }
 }
 function display_fill_in_blanks_answer($answer,$id,$questionId)
 function display_fill_in_blanks_answer($answer,$id,$questionId)
 {
 {
-	
-	?>					
+
+	?>
 		<tr>
 		<tr>
 		<td>
 		<td>
 			<?php echo nl2br($answer); ?>
 			<?php echo nl2br($answer); ?>
-		</td><?php 
+		</td><?php
 		if(!$is_allowedToEdit) {?>
 		if(!$is_allowedToEdit) {?>
 		<td>
 		<td>
-		<?php 
+		<?php
 		$comm = get_comments($id,$questionId);
 		$comm = get_comments($id,$questionId);
 		//echo $comm;
 		//echo $comm;
 		?>
 		?>
 		</td>
 		</td>
-		</tr>					
+		</tr>
 	<?php }
 	<?php }
 }
 }
 
 
 function display_free_answer($answer,$id,$questionId)
 function display_free_answer($answer,$id,$questionId)
 {
 {
-	?>					
+	?>
 		<tr>
 		<tr>
 		<td>
 		<td>
 			<?php echo nl2br(stripslashes($answer)); ?>
 			<?php echo nl2br(stripslashes($answer)); ?>
 		</td> <?php if(!$is_allowedToEdit) {?>
 		</td> <?php if(!$is_allowedToEdit) {?>
    <td>
    <td>
-    <?php 
-	
+    <?php
+
 	$comm = get_comments($id,$questionId);
 	$comm = get_comments($id,$questionId);
 	/*if ($comm!='')
 	/*if ($comm!='')
 	echo $comm;
 	echo $comm;
 	else
 	else
 	echo  get_lang('notCorrectedYet');
 	echo  get_lang('notCorrectedYet');
 	*/?>
 	*/?>
-	
-   </td> <?php }?>		
-		</tr>			
+
+   </td> <?php }?>
+		</tr>
 	<?php
 	<?php
 }
 }
 
 
@@ -236,12 +236,12 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 									"#ED2024",
 									"#ED2024",
 									"#45C7F0",
 									"#45C7F0",
 									"#F7BDE2");
 									"#F7BDE2");
-	?>		
+	?>
 		<tr>
 		<tr>
 				<td width="50%" valign="top">
 				<td width="50%" valign="top">
 					<div style="width:100%;">
 					<div style="width:100%;">
 						<div style="height:11px; width:11px; background-color:<?php echo $hotspot_colors[$answerId]; ?>; float:left; margin:3px;"></div>
 						<div style="height:11px; width:11px; background-color:<?php echo $hotspot_colors[$answerId]; ?>; float:left; margin:3px;"></div>
-						<div><?php echo $answer ?></div>						
+						<div><?php echo $answer ?></div>
 					</div>
 					</div>
 				</td>
 				</td>
 				<td width="25%" valign="top"><?php echo $answerId; ?></td>
 				<td width="25%" valign="top"><?php echo $answerId; ?></td>
@@ -266,12 +266,12 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 	<?php $exerciseTitle=api_parse_tex($test);
 	<?php $exerciseTitle=api_parse_tex($test);
 $query = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id='$id' group by question_id";
 $query = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id='$id' group by question_id";
 $result =api_sql_query($query, __FILE__, __LINE__);
 $result =api_sql_query($query, __FILE__, __LINE__);
-?>	
+?>
 	<h3><?php echo $test ?>: <?php echo get_lang("Result"); ?></h3>
 	<h3><?php echo $test ?>: <?php echo get_lang("Result"); ?></h3>
-	
+
 	 </td>
 	 </td>
   </tr>
   </tr>
-  <?php 
+  <?php
 
 
 
 
 	$i=$totalScore=$totalWeighting=0;
 	$i=$totalScore=$totalWeighting=0;
@@ -296,11 +296,11 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				$questionWeighting=$objQuestionTmp->selectWeighting();
 				$questionWeighting=$objQuestionTmp->selectWeighting();
 				$answerType=$objQuestionTmp->selectType();
 				$answerType=$objQuestionTmp->selectType();
 				$quesId =$objQuestionTmp->selectId(); //added by priya saini
 				$quesId =$objQuestionTmp->selectId(); //added by priya saini
-				
+
 				// destruction of the Question object
 				// destruction of the Question object
 					unset($objQuestionTmp);
 					unset($objQuestionTmp);
 
 
-				
+
 
 
 				if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
 				if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
 				{
 				{
@@ -342,7 +342,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			// construction of the Answer object
 			// construction of the Answer object
 				$objAnswerTmp=new Answer($questionId);
 				$objAnswerTmp=new Answer($questionId);
 				$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 				$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
-				$questionScore=0; 
+				$questionScore=0;
 				for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
 				for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
 					{
 					{
 						$answer=$objAnswerTmp->selectAnswer($answerId);
 						$answer=$objAnswerTmp->selectAnswer($answerId);
@@ -362,10 +362,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 							$questionScore+=$answerWeighting;
 							$questionScore+=$answerWeighting;
 							$totalScore+=$answerWeighting;
 							$totalScore+=$answerWeighting;
 							}
 							}
-					
+
 				?>
 				?>
 			<tr>
 			<tr>
-			<td> <?php 
+			<td> <?php
 			if($answerId==1)
 			if($answerId==1)
 					display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
 					display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
 			else
 			else
@@ -373,7 +373,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				?>
 				?>
 			</td>
 			</td>
 			</tr>
 			</tr>
-			<?php 
+			<?php
 		$i++;
 		$i++;
 		 }?>
 		 }?>
 			</table>
 			</table>
@@ -392,7 +392,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<tr>
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
 			</tr>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
 			$questionScore=0;
@@ -422,7 +422,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			</tr><?php
 			</tr><?php
 		$i++;
 		$i++;
 
 
-		
+
 		}?>
 		}?>
 			</table>
 			</table>
 	<?php  }
 	<?php  }
@@ -438,7 +438,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<tr>
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
 			</tr>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
 			$questionScore=0;
@@ -467,7 +467,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				// the loop will stop at the end of the text
 				// the loop will stop at the end of the text
 				$i=0;
 				$i=0;
 				while(1)
 				while(1)
-					{ 
+					{
 					// quits the loop if there are no more blanks
 					// quits the loop if there are no more blanks
 					if(($pos = strpos($temp,'[')) === false)
 					if(($pos = strpos($temp,'[')) === false)
 						{
 						{
@@ -505,10 +505,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 ?>
 ?>
 			<tr>
 			<tr>
 			<td> <?php display_fill_in_blanks_answer($answer,$id,$questionId); ?> </td>
 			<td> <?php display_fill_in_blanks_answer($answer,$id,$questionId); ?> </td>
-			</tr><?php 
+			</tr><?php
 		$i++;
 		$i++;
 
 
-	
+
 		}?>
 		}?>
 			</table>
 			</table>
 	<?php  }
 	<?php  }
@@ -525,14 +525,14 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
 			</tr>
 			</tr>
 
 
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
-			$questionScore=0;
-			$query = "select answer, marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
-			$resq=api_sql_query($query);
-			$choice = mysql_result($resq,0,"answer");
-			$questionScore = mysql_result($resq,0,"marks");
+			$questionScore=0;
+			$query = "select answer, marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
+			$resq=api_sql_query($query);
+			$choice = mysql_result($resq,0,"answer");
+			$questionScore = mysql_result($resq,0,"marks");
 			?>
 			?>
 			<tr>
 			<tr>
 			<td valign="top"><?php display_free_answer($choice, $id, $questionId);?> </td>
 			<td valign="top"><?php display_free_answer($choice, $id, $questionId);?> </td>
@@ -548,12 +548,12 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<tr>
 			<td><i><?php echo get_lang("ElementList"); ?></i> </td>
 			<td><i><?php echo get_lang("ElementList"); ?></i> </td>
 			<td><i><?php echo get_lang("CorrespondsTo"); ?></i></td>
 			<td><i><?php echo get_lang("CorrespondsTo"); ?></i></td>
-			
+
 			</tr>
 			</tr>
 			<tr>
 			<tr>
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
 			</tr>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
 			$questionScore=0;
@@ -571,7 +571,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 					$answ = $row['answer'];
 					$answ = $row['answer'];
 					$choice[$ind] = $answ;
 					$choice[$ind] = $answ;
 					}
 					}
-					
+
 				 if($answerCorrect)
 				 if($answerCorrect)
 				{
 				{
 					if($answerCorrect == $choice[$answerId])
 					if($answerCorrect == $choice[$answerId])
@@ -595,19 +595,19 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				}
 				}
 				 ?>
 				 ?>
 			<tr>
 			<tr>
-			
-			
+
+
 							  <?php
 							  <?php
 								$answer=api_parse_tex($answer);
 								$answer=api_parse_tex($answer);
 								//echo $answer; ?>
 								//echo $answer; ?>
-						     
-							  <?php 
+
+							  <?php
 						$query = "select position from `".$TABLETRACK_ATTEMPT."` where question_id = $questionId and exe_id=$id";
 						$query = "select position from `".$TABLETRACK_ATTEMPT."` where question_id = $questionId and exe_id=$id";
 						$resapp = api_sql_query($query, __FILE__, __LINE__);
 						$resapp = api_sql_query($query, __FILE__, __LINE__);
 						while($row = mysql_fetch_array($resapp))
 						while($row = mysql_fetch_array($resapp))
 							{
 							{
 							 $tp = $row['position'];
 							 $tp = $row['position'];
-						     }											
+						     }
 						foreach($choice as $key => $v)
 						foreach($choice as $key => $v)
 							{
 							{
 							if($key==$answerId)
 							if($key==$answerId)
@@ -615,28 +615,28 @@ $result =api_sql_query($query, __FILE__, __LINE__);
                                  echo "<td>".$answer."</td>";
                                  echo "<td>".$answer."</td>";
 								 echo "<td>";
 								 echo "<td>";
 								 echo $v.'/';
 								 echo $v.'/';
-								
-								}								
+
+								}
 							}
 							}
-									
+
 							?>  <font color="green"><b>
 							?>  <font color="green"><b>
 							<?php
 							<?php
 							 $matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							 $matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							 echo $matching[$answerCorrect]; ?></b></font>
 							 echo $matching[$answerCorrect]; ?></b></font>
 			</td>
 			</td>
-			
-			</tr><?php 
+
+			</tr><?php
 		$i++;
 		$i++;
 
 
-		
+
 		}?>
 		}?>
 			</table>
 			</table>
 	<?php }
 	<?php }
 	else if($answerType == HOTSPOT){
 	else if($answerType == HOTSPOT){
-		
-		
+
+
 		?>
 		?>
-		
+
 		<table width="355" border="0" cellspacing="0" cellpadding="0">
 		<table width="355" border="0" cellspacing="0" cellpadding="0">
 			<tr>
 			<tr>
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
@@ -648,7 +648,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<td>&nbsp;</td>
 			<td>&nbsp;</td>
 			</tr>
 			</tr>
 
 
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
 			$questionScore=0;
@@ -665,14 +665,14 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				$answerComment=$objAnswerTmp->selectComment($answerId);
 				$answerComment=$objAnswerTmp->selectComment($answerId);
 				$answerCorrect=$objAnswerTmp->isCorrect($answerId);
 				$answerCorrect=$objAnswerTmp->isCorrect($answerId);
 				$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
 				$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
-				
+
 				$query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 				$query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 				$resq=api_sql_query($query);
 				$resq=api_sql_query($query);
 				$choice = mysql_result($resq,0,"answer");
 				$choice = mysql_result($resq,0,"answer");
-				
+
 				display_hotspot_answer($answerId,$answer,$choice,$answerComment);
 				display_hotspot_answer($answerId,$answer,$choice,$answerComment);
-				
-				$i++;	
+
+				$i++;
 		 	}
 		 	}
 		 	$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 		 	$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 			$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
 			$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
@@ -680,21 +680,21 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			$totalScore+=$questionScore;
 			$totalScore+=$questionScore;
 		 	?>
 		 	?>
 			</table></td></tr></table>
 			</table></td></tr></table>
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-	<?php	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	<?php
 	}
 	}
 	?>
 	?>
 
 
@@ -702,7 +702,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 		 </td>
 		 </td>
 		<td width="346" valign = "top"><i>
 		<td width="346" valign = "top"><i>
 		<?php echo get_lang("Comment"); ?></i>
 		<?php echo get_lang("Comment"); ?></i>
-			 <?php if($is_allowedToEdit) 
+			 <?php if($is_allowedToEdit)
 					 		{
 					 		{
 							//if (isset($_REQUEST['showdiv']) && $questionId==$_REQUEST['ques_id'])
 							//if (isset($_REQUEST['showdiv']) && $questionId==$_REQUEST['ques_id'])
 								//{
 								//{
@@ -721,7 +721,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 								$fck_attribute['Height'] = '150';
 								$fck_attribute['Height'] = '150';
 								$fck_attribute['ToolbarSet'] = 'Comment';
 								$fck_attribute['ToolbarSet'] = 'Comment';
 								$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
 								$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
-								$$questionId = new FormValidator('frmcomments'.$questionId,'post','');													
+								$$questionId = new FormValidator('frmcomments'.$questionId,'post','');
 								$renderer =& $$questionId->defaultRenderer();
 								$renderer =& $$questionId->defaultRenderer();
 								$renderer->setFormTemplate(
 								$renderer->setFormTemplate(
 	'<form{attributes}><div align="left">{content}</div></form>');
 	'<form{attributes}><div align="left">{content}</div></form>');
@@ -735,22 +735,22 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 								//$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
 								//$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
 								$$questionId->setDefaults(${user.$questionId});
 								$$questionId->setDefaults(${user.$questionId});
 								$$questionId->display();
 								$$questionId->display();
-								?>	
+								?>
 								</div>
 								</div>
 							<?php
 							<?php
-							
-							
+
+
 								}
 								}
 							else
 							else
 								{
 								{
-							
+
 							$comnt = get_comments($id,$questionId);
 							$comnt = get_comments($id,$questionId);
 							echo "<br> <br>".$comnt;
 							echo "<br> <br>".$comnt;
 								}
 								}
-					?>  
+					?>
 
 
 		 </td>
 		 </td>
-	</tr>	
+	</tr>
   <tr>
   <tr>
   <td></td>
   <td></td>
   <td align= "left" >
   <td align= "left" >
@@ -764,9 +764,9 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 								?>
 								?>
 							 <div id="<?php echo $marksname; ?>" style="visibility:hidden">
 							 <div id="<?php echo $marksname; ?>" style="visibility:hidden">
 							 <form name="marksform_<?php echo $questionId; ?>" method="post" action="">
 							 <form name="marksform_<?php echo $questionId; ?>" method="post" action="">
-														 
-								  
-								  <?php 
+
+
+								  <?php
 								  $arrmarks[] = $questionId;
 								  $arrmarks[] = $questionId;
 								 echo "Assign Marks ";
 								 echo "Assign Marks ";
 								  echo "<select name='marks' id='marks'>";
 								  echo "<select name='marks' id='marks'>";
@@ -777,10 +777,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 											?></option>
 											?></option>
     									<?php } ?>
     									<?php } ?>
 								  </select>
 								  </select>
-								  </form></div><?php 
+								  </form></div><?php
 								 }
 								 }
 						}?>
 						}?>
-				
+
   </td><tr><td></td><td align="right"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b></td>
   </td><tr><td></td><td align="right"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b></td>
   </tr>
   </tr>
 	<?php  unset($objAnswerTmp);
 	<?php  unset($objAnswerTmp);
@@ -788,7 +788,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 $totalWeighting+=$questionWeighting;
 $totalWeighting+=$questionWeighting;
 		}
 		}
 ?>
 ?>
-<tr><td></td><td align=right><b><?php 
+<tr><td></td><td align=right><b><?php
 			$query = "update `".$TABLETRACK_EXERCICES."` set exe_result = $totalScore where exe_id = '$id'";
 			$query = "update `".$TABLETRACK_EXERCICES."` set exe_result = $totalScore where exe_id = '$id'";
 			api_sql_query($query,__FILE__,__LINE__);
 			api_sql_query($query,__FILE__,__LINE__);
 			echo get_lang('YourTotalScore')." ";
 			echo get_lang('YourTotalScore')." ";
@@ -810,9 +810,9 @@ $totalWeighting+=$questionWeighting;
 			if($is_allowedToEdit)
 			if($is_allowedToEdit)
 			{
 			{
 		?>
 		?>
-			
+
 			 <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid=<?php echo $id; ?>&test=<?php echo $test; ?>&emailid=<?php echo $emailId;?>" method="post">
 			 <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid=<?php echo $id; ?>&test=<?php echo $test; ?>&emailid=<?php echo $emailId;?>" method="post">
-			 <input type="submit" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"/> 
+			 <input type="submit" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"/>
 			 </form>
 			 </form>
 		<?php } ?>
 		<?php } ?>
 		</td>
 		</td>

+ 33 - 33
main/exercice/hotspot_actionscript.as.php

@@ -1,118 +1,118 @@
 <?php
 <?php
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
+==============================================================================
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *
 *
 *	@author Toon Keppens
 *	@author Toon Keppens
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 */
 
 
 	include('exercise.class.php');
 	include('exercise.class.php');
 	include('question.class.php');
 	include('question.class.php');
 	include('answer.class.php');
 	include('answer.class.php');
-	
+
 	include('../inc/global.inc.php');
 	include('../inc/global.inc.php');
-	
+
 	// set vars
 	// set vars
 	$questionId    = $_GET['modifyAnswers'];
 	$questionId    = $_GET['modifyAnswers'];
 	$objQuestion = Question::read($questionId);
 	$objQuestion = Question::read($questionId);
-	
-	$TBL_ANSWERS   = $_course['dbNameGlu'].'quiz_answer';
+
+	$TBL_ANSWERS   = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	
+
 	$picturePath   = $documentPath.'/images';
 	$picturePath   = $documentPath.'/images';
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureWidth  = $pictureSize[0];
 	$pictureWidth  = $pictureSize[0];
 	$pictureHeight = $pictureSize[1];
 	$pictureHeight = $pictureSize[1];
-	
+
 	$courseLang = $_course['language'];
 	$courseLang = $_course['language'];
 	$courseCode = $_course['sysCode'];
 	$courseCode = $_course['sysCode'];
 	$coursePath = $_course['path'];
 	$coursePath = $_course['path'];
-	
+
 	// Query db for answers
 	// Query db for answers
 	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	$result = api_sql_query($sql,__FILE__,__LINE__);
 	$result = api_sql_query($sql,__FILE__,__LINE__);
-	
+
 	// Init
 	// Init
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$i = 0;
 	$i = 0;
 	$nmbrTries = 0;
 	$nmbrTries = 0;
-	
+
 	while ($hotspot = mysql_fetch_assoc($result))
 	while ($hotspot = mysql_fetch_assoc($result))
 	{
 	{
     	$output .= "&hotspot_".$hotspot['id']."=true";
     	$output .= "&hotspot_".$hotspot['id']."=true";
 		$output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
 		$output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
-		
+
 		// Square or rectancle
 		// Square or rectancle
 		if ($hotspot['hotspot_type'] == 'square' )
 		if ($hotspot['hotspot_type'] == 'square' )
 		{
 		{
 			$output .= "&hotspot_".$hotspot['id']."_type=square";
 			$output .= "&hotspot_".$hotspot['id']."_type=square";
 		}
 		}
-		
+
 		// Circle or ovale
 		// Circle or ovale
 		if ($hotspot['hotspot_type'] == 'circle')
 		if ($hotspot['hotspot_type'] == 'circle')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=circle";
 			$output .= "&hotspot_".$hotspot['id']."_type=circle";
 		}
 		}
-		
+
 		// Polygon
 		// Polygon
 		if ($hotspot['hotspot_type'] == 'poly')
 		if ($hotspot['hotspot_type'] == 'poly')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=poly";
 			$output .= "&hotspot_".$hotspot['id']."_type=poly";
 		}
 		}
-		
+
 		// This is a good answer, count + 1 for nmbr of clicks
 		// This is a good answer, count + 1 for nmbr of clicks
 		if ($hotspot['hotspot_type'] > 0)
 		if ($hotspot['hotspot_type'] > 0)
 		{
 		{
 			$nmbrTries++;
 			$nmbrTries++;
 		}
 		}
-		
+
 		$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
 		$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
-		
+
 		$i++;
 		$i++;
-		
+
 	}
 	}
-	
-	// Generate empty 
+
+	// Generate empty
 	$i++;
 	$i++;
 	for ($i; $i <= 12; $i++)
 	for ($i; $i <= 12; $i++)
 	{
 	{
 		$output .= "&hotspot_".$i."=false";
 		$output .= "&hotspot_".$i."=false";
 	}
 	}
-	
+
 	// Output
 	// Output
 	echo $output."&nmbrTries=".$nmbrTries."&done=done";
 	echo $output."&nmbrTries=".$nmbrTries."&done=done";
-	
+
 	/*echo '<pre>';
 	/*echo '<pre>';
-	
+
 	var_dump($explode);
 	var_dump($explode);
-	
+
 	echo '</pre>';*/
 	echo '</pre>';*/
 
 
 ?>
 ?>

+ 30 - 30
main/exercice/hotspot_actionscript_admin.as.php

@@ -1,112 +1,112 @@
 <?php
 <?php
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
+==============================================================================
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *
 *
 *	@author Toon Keppens
 *	@author Toon Keppens
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 */
 
 
 	include('exercise.class.php');
 	include('exercise.class.php');
 	include('question.class.php');
 	include('question.class.php');
 	include('answer.class.php');
 	include('answer.class.php');
-	
+
 	include('../inc/global.inc.php');
 	include('../inc/global.inc.php');
-	
+
 	// set vars
 	// set vars
 	$questionId    = $_GET['modifyAnswers'];
 	$questionId    = $_GET['modifyAnswers'];
 	$objQuestion = Question::read($questionId);
 	$objQuestion = Question::read($questionId);
-	
-	$TBL_ANSWERS   = $_course['dbNameGlu'].'quiz_answer';
+
+	$TBL_ANSWERS   = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	
+
 	$picturePath   = $documentPath.'/images';
 	$picturePath   = $documentPath.'/images';
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureWidth  = $pictureSize[0];
 	$pictureWidth  = $pictureSize[0];
 	$pictureHeight = $pictureSize[1];
 	$pictureHeight = $pictureSize[1];
-	
+
 	$courseLang = $_course['language'];
 	$courseLang = $_course['language'];
 	$courseCode = $_course['sysCode'];
 	$courseCode = $_course['sysCode'];
 	$coursePath = $_course['path'];
 	$coursePath = $_course['path'];
-	
+
 	// Query db for answers
 	// Query db for answers
 	//$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	//$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	//$result = api_sql_query($sql,__FILE__,__LINE__);
 	//$result = api_sql_query($sql,__FILE__,__LINE__);
-	
+
 	// Init
 	// Init
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$i = 0;
 	$i = 0;
 	$nmbrTries = 0;
 	$nmbrTries = 0;
-	
-	
+
+
 	$answers=$_SESSION['tmp_answers'];
 	$answers=$_SESSION['tmp_answers'];
 	$nbrAnswers = count($answers['answer']);
 	$nbrAnswers = count($answers['answer']);
-	
+
     for($i=1;$i <= $nbrAnswers;$i++)
     for($i=1;$i <= $nbrAnswers;$i++)
     {
     {
     	$output .= "&hotspot_".$i."=true";
     	$output .= "&hotspot_".$i."=true";
 		$output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
 		$output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
-		
+
 		// Square or rectancle
 		// Square or rectancle
 		if ($answers['hotspot_type'][$i] == 'square' )
 		if ($answers['hotspot_type'][$i] == 'square' )
 		{
 		{
 			$output .= "&hotspot_".$i."_type=square";
 			$output .= "&hotspot_".$i."_type=square";
 		}
 		}
-		
+
 		// Circle or ovale
 		// Circle or ovale
 		if ($answers['hotspot_type'][$i] == 'circle')
 		if ($answers['hotspot_type'][$i] == 'circle')
-		{	
+		{
 			$output .= "&hotspot_".$i."_type=circle";
 			$output .= "&hotspot_".$i."_type=circle";
 		}
 		}
-		
+
 		// Polygon
 		// Polygon
 		if ($answers['hotspot_type'][$i] == 'poly')
 		if ($answers['hotspot_type'][$i] == 'poly')
-		{	
+		{
 			$output .= "&hotspot_".$i."_type=poly";
 			$output .= "&hotspot_".$i."_type=poly";
 		}
 		}
-		
+
 		// This is a good answer, count + 1 for nmbr of clicks
 		// This is a good answer, count + 1 for nmbr of clicks
 		if ($answers['weighting'][$i] > 0)
 		if ($answers['weighting'][$i] > 0)
 		{
 		{
 			$nmbrTries++;
 			$nmbrTries++;
 		}
 		}
-		
+
 		$output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
 		$output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
     }
     }
-	
-	// Generate empty 
+
+	// Generate empty
 	$i++;
 	$i++;
 	for ($i; $i <= 12; $i++)
 	for ($i; $i <= 12; $i++)
 	{
 	{
 		$output .= "&hotspot_".$i."=false";
 		$output .= "&hotspot_".$i."=false";
 	}
 	}
-	
+
 	// Output
 	// Output
 	echo $output."&nmbrTries=".$nmbrTries."&done=done";
 	echo $output."&nmbrTries=".$nmbrTries."&done=done";
 
 

+ 39 - 39
main/exercice/hotspot_admin.inc.php

@@ -83,7 +83,7 @@ if($modifyIn)
         $objAnswer->duplicate($questionId);
         $objAnswer->duplicate($questionId);
 
 
         // construction of the duplicated Answers
         // construction of the duplicated Answers
-        
+
         $objAnswer=new Answer($questionId);
         $objAnswer=new Answer($questionId);
     }
     }
 
 
@@ -94,7 +94,7 @@ if($modifyIn)
     $weighting=unserialize($weighting);
     $weighting=unserialize($weighting);
     $hotspot_coordinates=unserialize($hotspot_coordinates);
     $hotspot_coordinates=unserialize($hotspot_coordinates);
     $hotspot_type=unserialize($hotspot_type);
     $hotspot_type=unserialize($hotspot_type);
-        
+
 
 
     unset($buttonBack);
     unset($buttonBack);
 }
 }
@@ -103,7 +103,7 @@ if($modifyIn)
 if($submitAnswers || $buttonBack)
 if($submitAnswers || $buttonBack)
 {
 {
     if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
     if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
-    
+
     $questionWeighting=$nbrGoodAnswers=0;
     $questionWeighting=$nbrGoodAnswers=0;
 
 
     for($i=1;$i <= $nbrAnswers;$i++)
     for($i=1;$i <= $nbrAnswers;$i++)
@@ -124,32 +124,32 @@ if($submitAnswers || $buttonBack)
 
 
             break;
             break;
         }
         }
-        
+
         if($weighting[$i] <= 0)
         if($weighting[$i] <= 0)
         {
         {
         	$msgErr=get_lang('HotspotWeightingError');
         	$msgErr=get_lang('HotspotWeightingError');
-        	
+
         	// clears answers already recorded into the Answer object
         	// clears answers already recorded into the Answer object
             $objAnswer->cancel();
             $objAnswer->cancel();
 
 
-            break;	
+            break;
         }
         }
         if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
         if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
         {
         {
         	$msgErr=get_lang('HotspotNotDrawn');
         	$msgErr=get_lang('HotspotNotDrawn');
-        	
+
         	// clears answers already recorded into the Answer object
         	// clears answers already recorded into the Answer object
             $objAnswer->cancel();
             $objAnswer->cancel();
 
 
-            break;	
+            break;
         }
         }
-        
+
     }  // end for()
     }  // end for()
-   
+
 
 
     if(empty($msgErr))
     if(empty($msgErr))
     {
     {
-        
+
     	for($i=1;$i <= $nbrAnswers;$i++)
     	for($i=1;$i <= $nbrAnswers;$i++)
         {
         {
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
@@ -161,13 +161,13 @@ if($submitAnswers || $buttonBack)
 			{
 			{
 				$questionWeighting+=$weighting[$i];
 				$questionWeighting+=$weighting[$i];
 			}
 			}
-			
+
 			// creates answer
 			// creates answer
 			$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
 			$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
         }  // end for()
         }  // end for()
 		// saves the answers into the data base
 		// saves the answers into the data base
 		$objAnswer->save();
 		$objAnswer->save();
-        
+
         // sets the total weighting of the question
         // sets the total weighting of the question
         $objQuestion->updateWeighting($questionWeighting);
         $objQuestion->updateWeighting($questionWeighting);
         $objQuestion->save($exerciseId);
         $objQuestion->save($exerciseId);
@@ -175,9 +175,9 @@ if($submitAnswers || $buttonBack)
         $editQuestion=$questionId;
         $editQuestion=$questionId;
 
 
         unset($modifyAnswers);
         unset($modifyAnswers);
-        
+
         echo '<script type="text/javascript">window.location.href="admin.php"</script>';
         echo '<script type="text/javascript">window.location.href="admin.php"</script>';
-        
+
     }
     }
     if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
     if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
 
 
@@ -186,21 +186,21 @@ if($submitAnswers || $buttonBack)
 if($modifyAnswers)
 if($modifyAnswers)
 {
 {
 
 
-	
+
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
-    
+
     // construction of the Answer object
     // construction of the Answer object
     $objAnswer=new Answer($objQuestion -> id);
     $objAnswer=new Answer($objQuestion -> id);
-   
+
     api_session_register('objAnswer');
     api_session_register('objAnswer');
 
 
 	if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
 	if($debug>0){echo str_repeat('&nbsp;',2).'$answerType is HOT_SPOT'."<br />\n";}
-	
-	$TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer';
-    
+
+	$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
+
 	if(!$nbrAnswers)
 	if(!$nbrAnswers)
     {
     {
-    	
+
         $nbrAnswers=$objAnswer->selectNbrAnswers();
         $nbrAnswers=$objAnswer->selectNbrAnswers();
 
 
         $reponse=Array();
         $reponse=Array();
@@ -218,10 +218,10 @@ if($modifyAnswers)
             $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
             $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
             $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
             $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
         }
         }
-        
-        
+
+
     }
     }
-   
+
     $_SESSION['tmp_answers'] = array();
     $_SESSION['tmp_answers'] = array();
     $_SESSION['tmp_answers']['answer'] = $reponse;
     $_SESSION['tmp_answers']['answer'] = $reponse;
     $_SESSION['tmp_answers']['comment'] = $comment;
     $_SESSION['tmp_answers']['comment'] = $comment;
@@ -233,9 +233,9 @@ if($modifyAnswers)
     {
     {
     	// At least 1 answer
     	// At least 1 answer
     	if ($nbrAnswers > 1) {
     	if ($nbrAnswers > 1) {
-			
+
             $nbrAnswers--;
             $nbrAnswers--;
-            
+
             // Remove the last answer
             // Remove the last answer
 			$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 			$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 			$tmp = array_pop($_SESSION['tmp_answers']['comment']);
 			$tmp = array_pop($_SESSION['tmp_answers']['comment']);
@@ -254,7 +254,7 @@ if($modifyAnswers)
     	if ($nbrAnswers < 12)
     	if ($nbrAnswers < 12)
     	{
     	{
             $nbrAnswers++;
             $nbrAnswers++;
-            
+
             // Add a new answer
             // Add a new answer
             $_SESSION['tmp_answers']['answer'][]='';
             $_SESSION['tmp_answers']['answer'][]='';
 			$_SESSION['tmp_answers']['comment'][]='';
 			$_SESSION['tmp_answers']['comment'][]='';
@@ -266,13 +266,13 @@ if($modifyAnswers)
     	{
     	{
     		$msgErr=get_lang('MaxHotspot');
     		$msgErr=get_lang('MaxHotspot');
     	}
     	}
-        
+
 
 
     }
     }
 
 
         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
-    
-       
+
+
         if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
         if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
         $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix)
         $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix)
         						"#4271B5",
         						"#4271B5",
@@ -306,11 +306,11 @@ if($modifyAnswers)
 	<tr>
 	<tr>
 		<td width="550" valign="top">
 		<td width="550" valign="top">
 			<script type="text/javascript">
 			<script type="text/javascript">
-				<!-- 
+				<!--
 				// Version check based upon the values entered above in "Globals"
 				// Version check based upon the values entered above in "Globals"
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
-				
-				
+
+
 				// Check to see if the version meets the requirements for playback
 				// Check to see if the version meets the requirements for playback
 				if (hasReqestedVersion) {  // if we've detected an acceptable version
 				if (hasReqestedVersion) {  // if we've detected an acceptable version
 				    var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="550" height="377">'
 				    var oeTags = '<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_admin.swf?modifyAnswers=<?php echo $modifyAnswers ?>" width="550" height="377">'
@@ -343,12 +343,12 @@ if($modifyAnswers)
 					  <td style="border-bottom: 1px solid #4271b5"><?php echo get_lang('Comment'); ?></td>
 					  <td style="border-bottom: 1px solid #4271b5"><?php echo get_lang('Comment'); ?></td>
 					  <td style="width: 60px; border-bottom: 1px solid #4271b5"><?php echo get_lang('QuestionWeighting'); ?>*</td>
 					  <td style="width: 60px; border-bottom: 1px solid #4271b5"><?php echo get_lang('QuestionWeighting'); ?>*</td>
 					</tr>
 					</tr>
-					
+
 					<?php
 					<?php
 								for($i=1;$i <= $nbrAnswers;$i++)
 								for($i=1;$i <= $nbrAnswers;$i++)
 								{
 								{
 					?>
 					?>
-					
+
 					<tr>
 					<tr>
 					  <td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div></td>
 					  <td valign="top"><div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div></td>
 					  <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="12" /></td>
 					  <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo htmlentities($reponse[$i]); ?>" size="12" /></td>
@@ -357,11 +357,11 @@ if($modifyAnswers)
 					  <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
 					  <input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
 					  <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					  <input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					</tr>
 					</tr>
-					
+
 					<?php
 					<?php
 					  			}
 					  			}
 					?>
 					?>
-					
+
 					<tr>
 					<tr>
 					  <td colspan="5">
 					  <td colspan="5">
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />
@@ -387,7 +387,7 @@ if($modifyAnswers)
 
 
 
 
 <?php
 <?php
-    
+
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers was set - end'."<br />\n";}
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers was set - end'."<br />\n";}
 }
 }
 ?>
 ?>

+ 38 - 38
main/exercice/hotspot_answers.as.php

@@ -1,100 +1,100 @@
 <?php
 <?php
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
+==============================================================================
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *
 *
 *	@author Toon Keppens
 *	@author Toon Keppens
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 */
 
 
 
 
 	include('exercise.class.php');
 	include('exercise.class.php');
 	include('question.class.php');
 	include('question.class.php');
 	include('answer.class.php');
 	include('answer.class.php');
-	
+
 	include('../inc/global.inc.php');
 	include('../inc/global.inc.php');
 	//include('../inc/lib/database.inc.lib');
 	//include('../inc/lib/database.inc.lib');
-	
+
 	// set vars
 	// set vars
 	$userId        = $_user['user_id'];
 	$userId        = $_user['user_id'];
 	$questionId    = $_GET['modifyAnswers'];
 	$questionId    = $_GET['modifyAnswers'];
-	
+
 	$objQuestion = Question :: read($questionId);
 	$objQuestion = Question :: read($questionId);
-	
-	$TBL_ANSWERS   = $_course['dbNameGlu'].'quiz_answer';
+
+	$TBL_ANSWERS   = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	
+
 	$picturePath   = $documentPath.'/images';
 	$picturePath   = $documentPath.'/images';
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureWidth  = $pictureSize[0];
 	$pictureWidth  = $pictureSize[0];
 	$pictureHeight = $pictureSize[1];
 	$pictureHeight = $pictureSize[1];
-	
+
 	$courseLang = $_course['language'];
 	$courseLang = $_course['language'];
 	$courseCode = $_course['sysCode'];
 	$courseCode = $_course['sysCode'];
 	$coursePath = $_course['path'];
 	$coursePath = $_course['path'];
-	
+
 	// Query db for answers
 	// Query db for answers
 	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
 	$result = api_sql_query($sql,__FILE__,__LINE__);
 	$result = api_sql_query($sql,__FILE__,__LINE__);
-	
+
 	// Init
 	// Init
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$i = 0;
 	$i = 0;
-	
+
 	while ($hotspot = mysql_fetch_array($result)) {
 	while ($hotspot = mysql_fetch_array($result)) {
-		
+
 		$output .= "&hotspot_".$hotspot['id']."=true";
 		$output .= "&hotspot_".$hotspot['id']."=true";
-		
+
 		// Square or rectancle
 		// Square or rectancle
 		if ($hotspot['hotspot_type'] == 'square' )
 		if ($hotspot['hotspot_type'] == 'square' )
 		{
 		{
 			$output .= "&hotspot_".$hotspot['id']."_type=square";
 			$output .= "&hotspot_".$hotspot['id']."_type=square";
 		}
 		}
-		
+
 		// Circle or ovale
 		// Circle or ovale
 		if ($hotspot['hotspot_type'] == 'circle')
 		if ($hotspot['hotspot_type'] == 'circle')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=circle";
 			$output .= "&hotspot_".$hotspot['id']."_type=circle";
 		}
 		}
-		
+
 		// Polygon
 		// Polygon
 		if ($hotspot['hotspot_type'] == 'poly')
 		if ($hotspot['hotspot_type'] == 'poly')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=poly";
 			$output .= "&hotspot_".$hotspot['id']."_type=poly";
 		}
 		}
-		
+
 		$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
 		$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
-		
+
 		$i++;
 		$i++;
 	}
 	}
-	
-	// Generate empty 
+
+	// Generate empty
 	$i++;
 	$i++;
 	for ($i; $i <= 12; $i++)
 	for ($i; $i <= 12; $i++)
 	{
 	{
@@ -103,27 +103,27 @@
 
 
 	// set vars
 	// set vars
 	$questionId    = $_GET['modifyAnswers'];
 	$questionId    = $_GET['modifyAnswers'];
-	
+
 	$courseCode = $_course['sysCode'];
 	$courseCode = $_course['sysCode'];
-	
+
 	// Get clicks
 	// Get clicks
 	foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
 	foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
 	{
 	{
 		$output2 .= $coordinate."|";
 		$output2 .= $coordinate."|";
 	}
 	}
-	
+
 	//var_dump($_SESSION['exerciseResultCoordinates']);
 	//var_dump($_SESSION['exerciseResultCoordinates']);
 	// Output
 	// Output
 	$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
 	$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
-	
+
 	$explode = explode('&', $output);
 	$explode = explode('&', $output);
-	
+
 	/*echo '<pre>';
 	/*echo '<pre>';
-	
+
 	var_dump($explode);
 	var_dump($explode);
-	
+
 	echo '</pre>';*/
 	echo '</pre>';*/
-	
+
 	echo $output;
 	echo $output;
-	
+
 ?>
 ?>

+ 23 - 23
main/exercice/mark_free_answer.php

@@ -1,35 +1,35 @@
 <?php // $Id: mark_free_answer.php,v 1.1.2.1 2005/08/30 01:47:37 yannoo Exp $
 <?php // $Id: mark_free_answer.php,v 1.1.2.1 2005/08/30 01:47:37 yannoo Exp $
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2005 Yannick Warnier <yannick.warnier@dokeos.com>
 	Copyright (c) 2005 Yannick Warnier <yannick.warnier@dokeos.com>
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
-*	FREE ANSWER MARKING SCRIPT  
+==============================================================================
+*	FREE ANSWER MARKING SCRIPT
 *
 *
 *	This script allows a course tutor to mark a student's free answer.
 *	This script allows a course tutor to mark a student's free answer.
 *	@author Yannick Warnier <yannick.warnier@dokeos.com>
 *	@author Yannick Warnier <yannick.warnier@dokeos.com>
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-* 
+*
 * 	@todo use the Database:: functions
 * 	@todo use the Database:: functions
 * 	@todo respect coding guidelines
 * 	@todo respect coding guidelines
-============================================================================== 
+==============================================================================
 */
 */
 
 
 /*
 /*
@@ -37,10 +37,10 @@
 		INIT SECTION
 		INIT SECTION
 ==============================================================================
 ==============================================================================
 */
 */
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 include('../inc/global.inc.php');
 include('../inc/global.inc.php');
 
 
 // including additional libraries
 // including additional libraries
@@ -62,8 +62,8 @@ define('FREE_ANSWER', 5);
 /** @todo use the Database:: functions */
 /** @todo use the Database:: functions */
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 //debug param. 0: no display - 1: debug display
 //debug param. 0: no display - 1: debug display
 $debug=0;
 $debug=0;
@@ -111,23 +111,23 @@ $obj_question = Question :: read($my_qst);
 
 
 $nameTools=get_lang('Exercice');
 $nameTools=get_lang('Exercice');
 
 
-$interbreadcrump[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
+$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
 
 
 $my_msg = 'No change.';
 $my_msg = 'No change.';
 
 
 if($action == 'mark'){
 if($action == 'mark'){
 	if (!empty($_POST['score']) AND $_POST['score'] < $obj_question->selectWeighting() AND $_POST['score'] >= 0){
 	if (!empty($_POST['score']) AND $_POST['score'] < $obj_question->selectWeighting() AND $_POST['score'] >= 0){
-		
+
 		//mark the user mark into the database using something similar to the following function:
 		//mark the user mark into the database using something similar to the following function:
 		global $_configuration;
 		global $_configuration;
-		
+
 		if($_configuration['tracking_enabled'])
 		if($_configuration['tracking_enabled'])
 		{
 		{
 			$exercise_table = Database::get_statistic_table('track_e_exercices');
 			$exercise_table = Database::get_statistic_table('track_e_exercices');
 			#$tbl_learnpath_user = Database::get_course_table('learnpath_user');
 			#$tbl_learnpath_user = Database::get_course_table('learnpath_user');
 			#global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id;
 			#global $origin, $tbl_learnpath_user, $learnpath_id, $learnpath_item_id;
-			$sql = "SELECT * FROM $exercise_table 
-				WHERE exe_user_id = '$my_usr' AND exe_cours_id = '$my_cid' AND exe_exo_id = '$my_exe' 
+			$sql = "SELECT * FROM $exercise_table
+				WHERE exe_user_id = '$my_usr' AND exe_cours_id = '$my_cid' AND exe_exo_id = '$my_exe'
 				ORDER BY exe_date DESC";
 				ORDER BY exe_date DESC";
 			#echo $sql;
 			#echo $sql;
 			$res = api_sql_query($sql,__FILE__,__LINE__);
 			$res = api_sql_query($sql,__FILE__,__LINE__);
@@ -136,7 +136,7 @@ if($action == 'mark'){
 				//@todo Check that just summing past score and the new free answer mark doesn't come up
 				//@todo Check that just summing past score and the new free answer mark doesn't come up
 				// with a score higher than the possible score for that exercise
 				// with a score higher than the possible score for that exercise
 				$my_score = $row['exe_result'] + $_POST['score'];
 				$my_score = $row['exe_result'] + $_POST['score'];
-				$sql = "UPDATE $exercise_table SET exe_result = '$my_score' 
+				$sql = "UPDATE $exercise_table SET exe_result = '$my_score'
 					WHERE exe_id = '".$row['exe_id']."'";
 					WHERE exe_id = '".$row['exe_id']."'";
 				#echo $sql;
 				#echo $sql;
 				$res = api_sql_query($sql,__FILE__,__LINE__);
 				$res = api_sql_query($sql,__FILE__,__LINE__);
@@ -153,7 +153,7 @@ if($action == 'mark'){
 						   `exe_weighting`,
 						   `exe_weighting`,
 						   `exe_date`
 						   `exe_date`
 						  )
 						  )
-				
+
 						  VALUES
 						  VALUES
 						  (
 						  (
 						  ".$my_usr.",
 						  ".$my_usr.",
@@ -196,7 +196,7 @@ if($action == 'mark'){
 	echo $my_msg.'<br />
 	echo $my_msg.'<br />
 		<a href="exercice.php?cidReq='.$cidReq.'">'.get_lang('Back').'</a>';
 		<a href="exercice.php?cidReq='.$cidReq.'">'.get_lang('Back').'</a>';
 }else{
 }else{
-	
+
 
 
 	echo '<h2>'.$obj_question->question .':</h2>
 	echo '<h2>'.$obj_question->question .':</h2>
 		'.$obj_question->selectTitle().'<br /><br />
 		'.$obj_question->selectTitle().'<br /><br />

+ 62 - 62
main/exercice/question.class.php

@@ -1,33 +1,33 @@
-<?php // $Id: question.class.php 10748 2007-01-17 08:22:39Z elixir_inter $
+<?php // $Id: question.class.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 */
 /**
 /**
-============================================================================== 
+==============================================================================
 *	File containing the Question class.
 *	File containing the Question class.
 *
 *
 *	@author Olivier Brouckaert
 *	@author Olivier Brouckaert
 *	@package dokeos.exercise
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 */
 
 
 if(!class_exists('Question')):
 if(!class_exists('Question')):
@@ -45,7 +45,7 @@ define(HOT_SPOT_ORDER, 	7);
 
 
 /**
 /**
 	CLASS QUESTION
 	CLASS QUESTION
- *	
+ *
  *	This class allows to instantiate an object of type Question
  *	This class allows to instantiate an object of type Question
  *
  *
  *	@author Olivier Brouckaert, original author
  *	@author Olivier Brouckaert, original author
@@ -60,11 +60,11 @@ abstract class Question
 	var $weighting;
 	var $weighting;
 	var $position;
 	var $position;
 	var $type;
 	var $type;
-	
+
 	var $picture;
 	var $picture;
 
 
 	var $exerciseList;  // array with the list of exercises which this question is in
 	var $exerciseList;  // array with the list of exercises which this question is in
-	
+
 	static $typePicture = 'new_question.png';
 	static $typePicture = 'new_question.png';
 	static $explanationLangVar = '';
 	static $explanationLangVar = '';
 	static $questionTypes = array(
 	static $questionTypes = array(
@@ -75,7 +75,7 @@ abstract class Question
 							FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
 							FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
 							HOT_SPOT => array('hotspot.class.php' , 'HotSpot')
 							HOT_SPOT => array('hotspot.class.php' , 'HotSpot')
 							);
 							);
-	
+
 	/**
 	/**
 	 * constructor of the class
 	 * constructor of the class
 	 *
 	 *
@@ -104,14 +104,14 @@ abstract class Question
 	static function read($id)
 	static function read($id)
 	{
 	{
 		global $_course;
 		global $_course;
-		
+
 		$TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 		$TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-		$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
+		$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
 		$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 		$TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 		$sql="SELECT question,description,ponderation,position,type,picture FROM `$TBL_QUESTIONS` WHERE id='$id'";
 		$sql="SELECT question,description,ponderation,position,type,picture FROM `$TBL_QUESTIONS` WHERE id='$id'";
-		
+
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 		$result=api_sql_query($sql,__FILE__,__LINE__);
-		
+
 		// if the question has been found
 		// if the question has been found
 		if($object=mysql_fetch_object($result))
 		if($object=mysql_fetch_object($result))
 		{
 		{
@@ -335,7 +335,7 @@ abstract class Question
 
 
 		return false;
 		return false;
 	}
 	}
-	
+
 	/**
 	/**
 	 * Resizes a picture || Warning!: can only be called after uploadPicture, or if picture is already available in object.
 	 * Resizes a picture || Warning!: can only be called after uploadPicture, or if picture is already available in object.
 	 *
 	 *
@@ -347,22 +347,22 @@ abstract class Question
 	function resizePicture($Dimension, $Max)
 	function resizePicture($Dimension, $Max)
 	{
 	{
 		global $picturePath;
 		global $picturePath;
-		
+
 		// if the question has an ID
 		// if the question has an ID
 		if($this->id)
 		if($this->id)
 		{
 		{
 	  		// Get dimensions from current image.
 	  		// Get dimensions from current image.
 	  		$current_img = imagecreatefromjpeg($picturePath.'/'.$this->picture);
 	  		$current_img = imagecreatefromjpeg($picturePath.'/'.$this->picture);
-			
+
 	  		$current_image_size = getimagesize($picturePath.'/'.$this->picture);
 	  		$current_image_size = getimagesize($picturePath.'/'.$this->picture);
 	  		$current_height = imagesy($current_img);
 	  		$current_height = imagesy($current_img);
 			$current_width = imagesx($current_img);
 			$current_width = imagesx($current_img);
-			
+
 			if($current_image_size[0] < $Max && $current_image_size[1] <$Max)
 			if($current_image_size[0] < $Max && $current_image_size[1] <$Max)
 				return true;
 				return true;
 			elseif($current_height == "")
 			elseif($current_height == "")
 				return false;
 				return false;
-			
+
 			// Resize according to height.
 			// Resize according to height.
 			if ($Dimension == "height")
 			if ($Dimension == "height")
 			{
 			{
@@ -370,7 +370,7 @@ abstract class Question
 				$new_height = $Max;
 				$new_height = $Max;
 				$new_width = ceil($current_width / $resize_scale);
 				$new_width = ceil($current_width / $resize_scale);
 			}
 			}
-			
+
 			// Resize according to width
 			// Resize according to width
 			if ($Dimension == "width")
 			if ($Dimension == "width")
 			{
 			{
@@ -378,7 +378,7 @@ abstract class Question
 				$new_width = $Max;
 				$new_width = $Max;
 				$new_height = ceil($current_height / $resize_scale);
 				$new_height = ceil($current_height / $resize_scale);
 			}
 			}
-			
+
 			// Resize according to height or width, both should not be larger than $Max after resizing.
 			// Resize according to height or width, both should not be larger than $Max after resizing.
 			if ($Dimension == "any")
 			if ($Dimension == "any")
 			{
 			{
@@ -395,22 +395,22 @@ abstract class Question
 					$new_height = ceil($current_height / $resize_scale);
 					$new_height = ceil($current_height / $resize_scale);
 				}
 				}
 			}
 			}
-			
+
 			// Create new image
 			// Create new image
 		    $new_img = imagecreatetruecolor($new_width, $new_height);
 		    $new_img = imagecreatetruecolor($new_width, $new_height);
 			$bgColor = imagecolorallocate($new_img, 255,255,255);
 			$bgColor = imagecolorallocate($new_img, 255,255,255);
 			imagefill($new_img , 0,0 , $bgColor);
 			imagefill($new_img , 0,0 , $bgColor);
-			
+
 			// Resize image
 			// Resize image
 			imagecopyresized($new_img, $current_img, 0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
 			imagecopyresized($new_img, $current_img, 0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
-			
+
 			// Write image to file
 			// Write image to file
 		    $result = imagejpeg($new_img, $picturePath.'/'.$this->picture, 100);
 		    $result = imagejpeg($new_img, $picturePath.'/'.$this->picture, 100);
-		    
+
 		    // Delete temperory images, clear memory
 		    // Delete temperory images, clear memory
 			imagedestroy($current_img);
 			imagedestroy($current_img);
 			imagedestroy($new_img);
 			imagedestroy($new_img);
-			
+
 			if ($result)
 			if ($result)
 			{
 			{
 				return true;
 				return true;
@@ -421,7 +421,7 @@ abstract class Question
 			}
 			}
 		}
 		}
 
 
-		
+
 	}
 	}
 
 
 	/**
 	/**
@@ -559,13 +559,13 @@ abstract class Question
 		{
 		{
 			$sql="INSERT INTO `$TBL_QUESTIONS`(question,description,ponderation,position,type,picture) VALUES('$question','$description','$weighting','$position','$type','$picture')";
 			$sql="INSERT INTO `$TBL_QUESTIONS`(question,description,ponderation,position,type,picture) VALUES('$question','$description','$weighting','$position','$type','$picture')";
 			api_sql_query($sql,__FILE__,__LINE__);
 			api_sql_query($sql,__FILE__,__LINE__);
-			
+
 			$this->id=mysql_insert_id();
 			$this->id=mysql_insert_id();
-			
+
 			// If hotspot, create first answer
 			// If hotspot, create first answer
 			if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) {
 			if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) {
-				$TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer';
-				
+				$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
+
 				$sql="INSERT INTO `$TBL_ANSWERS` (`id` , `question_id` , `answer` , `correct` , `comment` , `ponderation` , `position` , `hotspot_coordinates` , `hotspot_type` ) VALUES ('1', '$this->id', '', NULL , '', NULL , '1', '0;0|0|0', 'square')";
 				$sql="INSERT INTO `$TBL_ANSWERS` (`id` , `question_id` , `answer` , `correct` , `comment` , `ponderation` , `position` , `hotspot_coordinates` , `hotspot_type` ) VALUES ('1', '$this->id', '', NULL , '', NULL , '1', '0;0|0|0', 'square')";
 				api_sql_query($sql,__FILE__,__LINE__);
 				api_sql_query($sql,__FILE__,__LINE__);
 			}
 			}
@@ -597,7 +597,7 @@ abstract class Question
 			$this->exerciseList[]=$exerciseId;
 			$this->exerciseList[]=$exerciseId;
 
 
 			$sql="INSERT INTO `$TBL_EXERCICE_QUESTION`(question_id,exercice_id) VALUES('$id','$exerciseId')";
 			$sql="INSERT INTO `$TBL_EXERCICE_QUESTION`(question_id,exercice_id) VALUES('$id','$exerciseId')";
-			
+
 			api_sql_query($sql,__FILE__,__LINE__);
 			api_sql_query($sql,__FILE__,__LINE__);
 		}
 		}
 	}
 	}
@@ -699,19 +699,19 @@ abstract class Question
 
 
 		return $id;
 		return $id;
 	}
 	}
-	
+
 	/**
 	/**
 	 * Returns an instance of the class corresponding to the type
 	 * Returns an instance of the class corresponding to the type
 	 * @param integer $type the type of the question
 	 * @param integer $type the type of the question
 	 * @return an instance of a Question subclass (or of Questionc class by default)
 	 * @return an instance of a Question subclass (or of Questionc class by default)
 	 */
 	 */
 	static function getInstance ($type) {
 	static function getInstance ($type) {
-		
+
 		list($file_name,$class_name) = self::$questionTypes[$type];
 		list($file_name,$class_name) = self::$questionTypes[$type];
 
 
 		include_once ($file_name);
 		include_once ($file_name);
-		
-		
+
+
 		if(class_exists($class_name))
 		if(class_exists($class_name))
 		{
 		{
 			return new $class_name();
 			return new $class_name();
@@ -721,25 +721,25 @@ abstract class Question
 			echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
 			echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
 			return null;
 			return null;
 		}
 		}
-		
+
 	}
 	}
-	
+
 	/**
 	/**
 	 * Creates the form to create / edit a question
 	 * Creates the form to create / edit a question
 	 * A subclass can redifine this function to add fields...
 	 * A subclass can redifine this function to add fields...
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 */
 	 */
 	function createForm (&$form) {
 	function createForm (&$form) {
-		
+
 		// question name
 		// question name
 		$form->addElement('text','questionName',get_lang('Question'),'size="60"');
 		$form->addElement('text','questionName',get_lang('Question'),'size="60"');
 		$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
 		$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
-		
+
 		// question type
 		// question type
 		$answerType= intval($_REQUEST['answerType']);
 		$answerType= intval($_REQUEST['answerType']);
 		$form->addElement('hidden','answerType',$_REQUEST['answerType']);
 		$form->addElement('hidden','answerType',$_REQUEST['answerType']);
-		
-		
+
+
 		// html editor
 		// html editor
 		global $fck_attribute;
 		global $fck_attribute;
 		$fck_attribute = array();
 		$fck_attribute = array();
@@ -749,50 +749,50 @@ abstract class Question
 		$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
 		$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
 		$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
 		$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
 		if(!api_is_allowed_to_edit()) $fck_attribute['Config']['UserStatus'] = 'student';
 		if(!api_is_allowed_to_edit()) $fck_attribute['Config']['UserStatus'] = 'student';
-		
+
 		$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false);
 		$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false);
-		
+
 		// hidden values
 		// hidden values
-		$form->addElement('hidden','myid',$_REQUEST['myid']);	
-		
-		
+		$form->addElement('hidden','myid',$_REQUEST['myid']);
+
+
 		// default values
 		// default values
 		$defaults = array();
 		$defaults = array();
 		$defaults['questionName'] = $this -> question;
 		$defaults['questionName'] = $this -> question;
 		$defaults['questionDescription'] = $this -> description;
 		$defaults['questionDescription'] = $this -> description;
 		$form -> setDefaults($defaults);
 		$form -> setDefaults($defaults);
 	}
 	}
-	
+
 	/**
 	/**
 	 * function which process the creation of questions
 	 * function which process the creation of questions
 	 * @param FormValidator $form the formvalidator instance
 	 * @param FormValidator $form the formvalidator instance
 	 * @param Exercise $objExercise the Exercise instance
 	 * @param Exercise $objExercise the Exercise instance
 	 */
 	 */
 	function processCreation ($form, $objExercise) {
 	function processCreation ($form, $objExercise) {
-		   
+
 		$this -> updateTitle($form->getSubmitValue('questionName'));
 		$this -> updateTitle($form->getSubmitValue('questionName'));
 	    $this -> updateDescription($form->getSubmitValue('questionDescription'));
 	    $this -> updateDescription($form->getSubmitValue('questionDescription'));
 	    $this -> save($objExercise -> id);
 	    $this -> save($objExercise -> id);
-	    
+
 	    // modify the exercise
 	    // modify the exercise
 	    $objExercise->addToList($this -> id);
 	    $objExercise->addToList($this -> id);
 	    $objExercise->save();
 	    $objExercise->save();
-	    
+
 	}
 	}
-	
+
 	/**
 	/**
 	 * abstract function which creates the form to create / edit the answers of the question
 	 * abstract function which creates the form to create / edit the answers of the question
 	 * @param the formvalidator instance
 	 * @param the formvalidator instance
 	 */
 	 */
 	abstract function createAnswersForm ($form);
 	abstract function createAnswersForm ($form);
-	
+
 	/**
 	/**
 	 * abstract function which process the creation of answers
 	 * abstract function which process the creation of answers
-	 * @param the formvalidator instance 
+	 * @param the formvalidator instance
 	 */
 	 */
 	abstract function processAnswersCreation ($form);
 	abstract function processAnswersCreation ($form);
-	
-	
+
+
 	/**
 	/**
 	 * Displays the menu of question types
 	 * Displays the menu of question types
 	 */
 	 */
@@ -814,7 +814,7 @@ abstract class Question
 			include_once($a_type[0]);
 			include_once($a_type[0]);
 			eval('$img = '.$a_type[1].'::$typePicture;');
 			eval('$img = '.$a_type[1].'::$typePicture;');
 			eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
 			eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
-			
+
 			echo '
 			echo '
 			<div id="answer_type_'.$i.'" style="display: inline">
 			<div id="answer_type_'.$i.'" style="display: inline">
 				<a href="admin.php?newQuestion=yes&answerType='.$i.'" onmouseover="explain(\''.$explanation.'\')"><img src="'.api_get_path(WEB_IMG_PATH).'/'.$img.'" /></a>
 				<a href="admin.php?newQuestion=yes&answerType='.$i.'" onmouseover="explain(\''.$explanation.'\')"><img src="'.api_get_path(WEB_IMG_PATH).'/'.$img.'" /></a>
@@ -822,7 +822,7 @@ abstract class Question
 		}
 		}
 		echo '
 		echo '
 		<div id="answer_type_explanation" class="accordion_content" style="display:block">'.get_lang('ChooseQuestionType').'</div></div>';
 		<div id="answer_type_explanation" class="accordion_content" style="display:block">'.get_lang('ChooseQuestionType').'</div></div>';
-		
+
 	}
 	}
 }
 }
 
 

+ 4 - 4
main/exercice/question_pool.php

@@ -1,4 +1,4 @@
-<?php // $Id: question_pool.php 10748 2007-01-17 08:22:39Z elixir_inter $
+<?php // $Id: question_pool.php 10774 2007-01-17 21:24:24Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -39,7 +39,7 @@ include('exercise.class.php');
 include('question.class.php');
 include('question.class.php');
 include('answer.class.php');
 include('answer.class.php');
 
 
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 $language_file='exercice';
 
 
 include('../inc/global.inc.php');
 include('../inc/global.inc.php');
@@ -49,8 +49,8 @@ $is_allowedToEdit=$is_courseAdmin;
 
 
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
 $TBL_EXERCICES         = $_course['dbNameGlu'].'quiz';
-$TBL_QUESTIONS         = $_course['dbNameGlu'].'quiz_question';
-$TBL_REPONSES          = $_course['dbNameGlu'].'quiz_answer';
+$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 
 if ( empty ( $delete ) ) {
 if ( empty ( $delete ) ) {
     $delete = $_GET['delete'];
     $delete = $_GET['delete'];