Explorar el Código

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

Patrick Cool hace 18 años
padre
commit
f284a3250b

+ 45 - 35
main/exercice/addlimits.php

@@ -1,6 +1,6 @@
 <?php
 /**
- * @todo use database library 
+ * @todo use database library
  */
 /*
 -----------------------------------------------------------
@@ -35,7 +35,7 @@ define('FREE_ANSWER', 5);
 	Language
 -----------------------------------------------------------
 */
-// name of the language file that needs to be included 
+// name of the language file that needs to be included
 $language_file='exercice';
 
 /*
@@ -49,58 +49,71 @@ api_protect_course_script();
 
 /*
 -----------------------------------------------------------
-	Table definitions 
+	Table definitions
 	@todo: use the Database :: get_course_table functions
 -----------------------------------------------------------
 */
 $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_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_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";
 
-$dsp_percent = false; 
+$dsp_percent = false;
 $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
-if ( empty ( $origin ) ) {
+if ( empty ( $origin ) )
+{
     $origin = $_REQUEST['origin'];
 }
-if ( empty ( $learnpath_id ) ) {
+if ( empty ( $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']);
 }
-if ( empty ( $formSent ) ) {
+if ( empty ( $formSent ) )
+{
     $formSent= $_REQUEST['formSent'];
 }
-if ( empty ( $exerciseResult ) ) {
+if ( empty ( $exerciseResult ) )
+{
     $exerciseResult = $_SESSION['exerciseResult'];
 }
-if ( empty ( $questionId ) ) {
+if ( empty ( $questionId ) )
+{
     $questionId = $_REQUEST['questionId'];
 }
 if ( empty ( $choice ) ) {
     $choice = $_REQUEST['choice'];
 }
-if ( empty ( $questionNum ) ) {
+if ( empty ( $questionNum ) )
+{
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
-if ( empty ( $nbrQuestions ) ) {
+}
+if ( empty ( $nbrQuestions ) )
+{
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
-if ( empty ( $questionList ) ) {
+if ( empty ( $questionList ) )
+{
     $questionList = $_SESSION['questionList'];
 }
-if ( empty ( $objExercise ) ) {
+if ( empty ( $objExercise ) )
+{
     $objExercise = $_SESSION['objExercise'];
 }
 $exercise_id = $_GET['exercise_id'];
-$is_allowedToEdit=$is_courseAdmin;	
+$is_allowedToEdit=$is_courseAdmin;
 
 
 $nameTools=get_lang('Exercice');
@@ -117,7 +130,7 @@ Display::display_header($nameTools,"Exercise");
 include('../inc/global.inc.php');
 if (isset($_POST['ok']))
 {
-	$message = "Test limits added";
+	$message = get_lang('TestLimitsAdded');
 	Display::display_normal_message($message);
 }
 ?>
@@ -127,26 +140,23 @@ if (isset($_POST['ok']))
   <script type="text/javascript">
   function selectlimited()
   {
-  document.getElementById('limited').checked="checked";
+  	document.getElementById('limited').checked="checked";
   }
    function selectattempts()
   {
-  document.getElementById('attemptlimited').checked="checked";
+  	document.getElementById('attemptlimited').checked="checked";
   }
   </script>
-  <h3>
-  <?php 
-  echo "AddLimits"; ?>
-</h3>
+  <h3><?php  echo get_lang('AddLimits'); ?></h3>
 <br>
 <form action="addlimits.php" name="frmlimit" method="post">
 <h4>
 Time :
 </h4>
 <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>
-<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();" >
   <option selected="selected">1</option>
   <option>2</option>
@@ -165,13 +175,13 @@ Time :
   <option>40</option>
   <option>50</option>
   <option>60</option>
-</select> minute(s).
+</select><?php echo get_lang('Minutes'); ?>.
 <h4>
-Attempts :
+<?php echo get_lang('Attempts'); ?>:
 </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>
-<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();">
   <option selected="selected">1</option>
   <option>2</option>
@@ -183,10 +193,10 @@ Attempts :
   <option>8</option>
   <option>9</option>
   <option>10</option>
-  </select> time(s).
+  </select><?php echo get_lang('Times'); ?>.
 
 <br> <br>
-<input type="submit" name="ok" value="Ok">
+<input type="submit" name="ok" value="<?php echo get_lang('Ok'); ?>">
 </form>
 <?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
@@ -75,7 +75,7 @@ include('question.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';
 
 include("../inc/global.inc.php");
@@ -109,28 +109,36 @@ if($_SERVER['REQUEST_METHOD'] == 'POST')
 }
 
 // get vars from GET
-if ( empty ( $exerciseId ) ) {
+if ( empty ( $exerciseId ) )
+{
     $exerciseId = mysql_real_escape_string($_GET['exerciseId']);
 }
-if ( empty ( $newQuestion ) ) {
+if ( empty ( $newQuestion ) )
+{
     $newQuestion = $_GET['newQuestion'];
 }
-if ( empty ( $modifyAnswers ) ) {
+if ( empty ( $modifyAnswers ) )
+{
     $modifyAnswers = $_GET['modifyAnswers'];
 }
-if ( empty ( $editQuestion ) ) {
+if ( empty ( $editQuestion ) )
+{
     $editQuestion = $_GET['editQuestion'];
 }
-if ( empty ( $modifyQuestion ) ) {
+if ( empty ( $modifyQuestion ) )
+{
     $modifyQuestion = $_GET['modifyQuestion'];
 }
-if ( empty ( $deleteQuestion ) ) {
+if ( empty ( $deleteQuestion ) )
+{
     $deleteQuestion = $_GET['deleteQuestion'];
 }
-if ( empty ( $questionId ) ) {
+if ( empty ( $questionId ) )
+{
     $questionId = $_SESSION['questionId'];
 }
-if ( empty ( $modifyExercise ) ) {
+if ( empty ( $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
 $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_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 $TBL_DOCUMENT          = $_course['dbNameGlu']."document";
 
 if(!$is_allowedToEdit)
@@ -179,8 +187,7 @@ if(!is_object($objExercise))
 	// creation of a new exercise if wrong or not specified exercise ID
 	if($exerciseId)
 	{
-	
-    $objExercise->read($exerciseId);
+	    $objExercise->read($exerciseId);
 	}
 
 	// saves the object into the session
@@ -282,12 +289,12 @@ else
 	$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
 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
@@ -326,7 +333,7 @@ Function VBGetSwfVer(i)
   on error resume next
   Dim swControl, swVersion
   swVersion = 0
-  
+
   set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
   if (IsObject(swControl)) then
     swVersion = swControl.GetVariable(\"\$version\")
@@ -372,46 +379,46 @@ function JSGetSwfVer(i){
 	else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
 	// Can't detect in all other cases
 	else {
-		
+
 		flashVer = -1;
 	}
 	return flashVer;
-} 
+}
 // 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);
-   	// 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) {
 			versionStr = VBGetSwfVer(i);
 		} else {
 			versionStr = JSGetSwfVer(i);
 		}
-		if (versionStr == -1 ) { 
+		if (versionStr == -1 ) {
 			return false;
 		} else if (versionStr != 0) {
 			if(isIE && isWin && !isOpera) {
 				tempArray         = versionStr.split(\" \");
 				tempString        = tempArray[1];
-				versionArray      = tempString .split(\",\");				
+				versionArray      = tempString .split(\",\");
 			} else {
 				versionArray      = versionStr.split(\".\");
 			}
 			versionMajor      = versionArray[0];
 			versionMinor      = versionArray[1];
 			versionRevision   = versionArray[2];
-			
+
 			versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 			versionNum        = parseFloat(versionString);
         	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 				return true;
 			} else {
-				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
+				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
 			}
 		}
-	}	
+	}
 }
 // -->
 </script>";
@@ -428,7 +435,7 @@ if($newQuestion || $editQuestion)
 {
 	// statement management
 	$type = $_REQUEST['answerType'];
-	?><input type="hidden" name="Type" value="<?php echo $type; ?>" /> 
+	?><input type="hidden" name="Type" value="<?php echo $type; ?>" />
 	<?php
 	include('question_admin.inc.php');
 }
@@ -440,7 +447,7 @@ if(!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspota
 {
 	// question list management
 	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
@@ -34,7 +34,7 @@ include('answer.class.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';
 
 include('../inc/global.inc.php');
@@ -44,7 +44,7 @@ if(isset($_REQUEST["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(FILL_IN_BLANKS,	3);
 define(MATCHING,		4);
-define(FREE_ANSWER,     5); 
+define(FREE_ANSWER,     5);
 
 // allows script inclusions
 define(ALLOWED_TO_INCLUDE,1);
@@ -94,6 +94,7 @@ $nameTools = get_lang('adminHP');
 
 Display::display_header($nameTools,"Exercise");
 
+/** @todo probably wrong !!!! */
 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
 if(isset($newName))
 {
-		if($newName!="")		
+		if($newName!="")
 		{
 			//alter database record for that test
 			SetComment($hotpotatoesName,$newName);
 			echo "<script language='Javascript' type='text/javascript'> window.location='exercice.php'; </script>";
-		}		
+		}
 }
 
 echo "<form action=\"{$_SERVER['PHP_SELF']}\" method='post' name='form1'>";
@@ -125,7 +126,7 @@ if($lstrComment=="")
 if($lstrComment=="")
 	$lstrComment = GetFileName($hotpotatoesName,$documentPath);
 
-echo $lstrComment;	
+echo $lstrComment;
 echo "\" size=40>&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='';\">";

+ 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
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 
 if(!class_exists('Answer')):
@@ -112,13 +112,13 @@ class Answer
 	function read()
 	{
 		global $_course;
-		$TBL_ANSWER = Database::get_course_table('quiz_answer');
+		$TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 		$questionId=$this->questionId;
 		//$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__);
 
 		$i=1;
@@ -147,24 +147,24 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 */
 	function readOrderedBy($field,$order=ASC)
 	{
-		global $_course;		
+		global $_course;
 		$field = mysql_real_escape_string($field);
 		if(empty($field)){
 			$field = 'position';
 		}
 		if($order != 'ASC' and $order!='DESC'){
 			$order = 'ASC';
-		}		
+		}
 		$TBL_ANSWER = Database::get_course_table('quiz_answer');
 
 		$questionId=$this->questionId;
 		//$answerType=$this->selectType();
-		
+
 		$sql="SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type " .
 				"FROM $TBL_ANSWER " .
 				"WHERE question_id='$questionId' " .
 				"ORDER BY $field $order";
-	
+
 		$result=api_sql_query($sql,__FILE__,__LINE__);
 
 		$i=1;
@@ -217,7 +217,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	{
 		return $this->answer[$id];
 	}
-	
+
 	/**
 	 * Returns a list of answers
 	 * @author Yannick Warnier <ywarnier@beeznest.org>
@@ -256,7 +256,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 	}
 	 	return $list;
 	 }
-	 
+
 	 /**
 	  * Returns the question type
 	  * @author	Yannick Warnier <ywarnier@beeznest.org>
@@ -273,7 +273,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	 	$row = Database::fetch_array($res);
 	 	return $row['type'];
 	 }
-	 
+
 
 	/**
 	 * tells if answer is correct or not
@@ -364,7 +364,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 		$this->new_nbrAnswers++;
 
 		$id=$this->new_nbrAnswers;
-		
+
 		$this->new_answer[$id]=$answer;
 		$this->new_correct[$id]=$correct;
 		$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_type[$id]=$new_hotspot_type;
 	}
-	
+
 	/**
 	 * updates an answer
 	 *
@@ -386,9 +386,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 	function updateAnswers($answer,$comment,$weighting,$position)
 	{
 		global $TBL_REPONSES;
-		
+
 		$questionId=$this->questionId;
-		
+
 		$sql = "UPDATE `$TBL_REPONSES` SET " .
 				"`answer` = '$answer', " .
 				"`comment` = '$comment', " .
@@ -396,7 +396,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 				"`position` = '$position' " .
 				"WHERE `id` =$position " .
 				"AND `question_id` =$questionId";
-		
+
 		api_sql_query($sql,__FILE__,__LINE__);
 	}
 
@@ -419,7 +419,7 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 		$sql="INSERT INTO `$TBL_REPONSES`" .
 				"(id,question_id,answer,correct,comment," .
 				"ponderation,position,hotspot_coordinates,hotspot_type) VALUES";
-		
+
 		for($i=1;$i <= $this->new_nbrAnswers;$i++)
 		{
 			$answer=addslashes($this->new_answer[$i]);
@@ -433,9 +433,9 @@ $this->hotspot_coordinates[$i]=$object->hotspot_coordinates;
 			$sql.="('$i','$questionId','$answer','$correct','$comment',
 					'$weighting','$position','$hotspot_coordinates','$hotspot_type'),";
 		}
-		
+
 		$sql = substr($sql,0,-1);
-		
+
 		api_sql_query($sql,__FILE__,__LINE__);
 
 		// 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
@@ -79,7 +79,7 @@ if($modifyIn)
         $objAnswer->duplicate($questionId);
 
         // construction of the duplicated Answers
-        
+
         $objAnswer=new Answer($questionId);
     }
 
@@ -99,13 +99,13 @@ if($modifyIn)
         $weighting=unserialize($weighting);
     }
     //free answer
-    elseif($answerType == FREE_ANSWER ) 
+    elseif($answerType == FREE_ANSWER )
     {
         $reponse=unserialize($reponse);
         $comment=unserialize($comment);
         $free_comment=$comment;
         $weighting=unserialize($weighting);
-    	
+
 	}
 	elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
     {
@@ -115,8 +115,8 @@ if($modifyIn)
         $weighting=unserialize($weighting);
         $hotspot_coordinates=unserialize($hotspot_coordinates);
         $hotspot_type=unserialize($hotspot_type);
-        
-    	
+
+
     }
     //fill in blanks
   else
@@ -196,7 +196,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
 					?>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					<?php
 			}
@@ -277,7 +277,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
 					?>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					<?php
 
@@ -370,7 +370,7 @@ if($submitAnswers || $buttonBack)
         if ( empty ( $weighting ) ) {
             $weighting = $_POST['weighting'];
 			$weightingtemp = $_POST['weighting'];
-        
+
 		}
 
         if(!$buttonBack)
@@ -386,7 +386,7 @@ if($submitAnswers || $buttonBack)
                 }
                 else
                 {
-                    
+
                     $objAnswer->createAnswer('',0,$free_comment,$weighting,'');
                     $objAnswer->save();
 					// sets the total weighting of the question
@@ -402,7 +402,7 @@ if($submitAnswers || $buttonBack)
                   //  $mainurl="question_pool.php";
 					?>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					<?php
                 }
@@ -489,7 +489,7 @@ if($submitAnswers || $buttonBack)
                     //$mainurl="question_pool.php";
 					?>
 					<script>
-					window.location.href='<?php echo $mainurl;?>';	
+					window.location.href='<?php echo $mainurl;?>';
 					</script>
 					<?php
                 }
@@ -540,28 +540,28 @@ if($submitAnswers || $buttonBack)
 
                 break;
             }
-            
+
             if($weighting[$i] <= 0)
             {
             	$msgErr=get_lang('HotspotWeightingError');
-            	
+
             	// clears answers already recorded into the Answer object
                 $objAnswer->cancel();
 
-                break;	
+                break;
             }
             if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
             {
             	$msgErr=get_lang('HotspotNotDrawn');
-            	
+
             	// clears answers already recorded into the Answer object
                 $objAnswer->cancel();
 
-                break;	
+                break;
             }
-            
+
         }  // end for()
-        
+
 
         if(empty($msgErr))
         {
@@ -574,7 +574,7 @@ if($submitAnswers || $buttonBack)
             	for($i=1;$i <= $nbrAnswers;$i++)
 		        {
 		            if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
-		
+
 		            $reponse[$i]=trim($reponse[$i]);
 		            $comment[$i]=addslashes(trim($comment[$i]));
 		            $weighting[$i]=intval($weighting[$i]);
@@ -582,13 +582,13 @@ if($submitAnswers || $buttonBack)
 					{
 						$questionWeighting+=$weighting[$i];
 					}
-					
+
 					// creates answer
 					$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
 		        }  // end for()
 				// saves the answers into the data base
 				$objAnswer->save();
-                
+
                 // sets the total weighting of the question
                 $objQuestion->updateWeighting($questionWeighting);
                 $objQuestion->save($exerciseId);
@@ -606,13 +606,13 @@ if($submitAnswers || $buttonBack)
 if($modifyAnswers)
 {
 
-	
+
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
-    
+
     // construction of the Answer object
     $objAnswer=new Answer($questionId);
-    
-    
+
+
     api_session_register('objAnswer');
 
     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
                 // objAnswer object.
                 $free_comment = $objAnswer->selectComment(1);
-				$weighting=$objAnswer->selectWeighting(1); //added 
+				$weighting=$objAnswer->selectWeighting(1); //added
             }
             elseif(!$modifyIn)
             {
@@ -810,12 +810,12 @@ if($modifyAnswers)
     elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
     {
 		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)
         {
-        	
+
             $nbrAnswers=$objAnswer->selectNbrAnswers();
 
             $reponse=Array();
@@ -833,10 +833,10 @@ if($modifyAnswers)
                 $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
                 $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
             }
-            
-            
+
+
         }
-        
+
         $_SESSION['tmp_answers'] = array();
         $_SESSION['tmp_answers']['answer'] = $reponse;
         $_SESSION['tmp_answers']['comment'] = $comment;
@@ -848,9 +848,9 @@ if($modifyAnswers)
         {
         	// At least 1 answer
         	if ($nbrAnswers > 1) {
-				
+
 	            $nbrAnswers--;
-	            
+
 	            // Remove the last answer
 				$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 				$tmp = array_pop($_SESSION['tmp_answers']['comment']);
@@ -869,7 +869,7 @@ if($modifyAnswers)
         	if ($nbrAnswers < 12)
         	{
 	            $nbrAnswers++;
-	            
+
 	            // Add a new answer
 	            $_SESSION['tmp_answers']['answer'][]='';
 				$_SESSION['tmp_answers']['comment'][]='';
@@ -888,7 +888,7 @@ if($modifyAnswers)
     if(!$usedInSeveralExercises)
     {
         if($debug>0){echo str_repeat('&nbsp;',2).'$usedInSeveralExercises is untrue'."<br />\n";}
-    
+
         if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
         {
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is UNIQUE_ANSWER or MULTIPLE_ANSWER'."<br />\n";}
@@ -905,7 +905,7 @@ if($modifyAnswers)
 <h3>
   <?php echo $questionName; ?>
 </h3>
-<?php 
+<?php
 		/*if ($exerciseId==0){
 	?>
 		<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; ?>">
-		<?php 
+		<?php
 		}*/
-	
+
 
 ?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php  echo $modifyAnswers; ?>">
@@ -1054,7 +1054,7 @@ if($modifyAnswers)
 
 <?php
                 }
-    
+
                 if(!empty($msgErr))
                 {
 ?>
@@ -1168,7 +1168,7 @@ if($modifyAnswers)
 			<?php
 			echo $desc = mysql_result($res,0,'description');
 			 ?>
-			
+
 			<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="setWeighting" value="1">
@@ -1186,7 +1186,7 @@ if($modifyAnswers)
                 }
 
                 if(!empty($msgErr))
-                { 
+                {
 			?>
 				<tr>
 				<td colspan="2">
@@ -1198,9 +1198,9 @@ if($modifyAnswers)
 				</tr>
 			<?php
                 }
- 			if(!$submitAnswers && empty($free_comment)) 
+ 			if(!$submitAnswers && empty($free_comment))
 				echo '';
-			else 
+			else
 				echo htmlentities($free_comment); ?>
    				<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>
@@ -1381,11 +1381,11 @@ if($modifyAnswers)
 	<tr>
 		<td width="550" valign="top">
 			<script type="text/javascript">
-				<!-- 
+				<!--
 				// Version check based upon the values entered above in "Globals"
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
-				
-				
+
+
 				// Check to see if the version meets the requirements for playback
 				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">'
@@ -1418,12 +1418,12 @@ if($modifyAnswers)
 					  <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>
 					</tr>
-					
+
 					<?php
 								for($i=1;$i <= $nbrAnswers;$i++)
 								{
 					?>
-					
+
 					<tr>
 					  <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>
@@ -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_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					</tr>
-					
+
 					<?php
 					  			}
 					?>
-					
+
 					<tr>
 					  <td colspan="5">
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />

+ 169 - 163
main/exercice/exercice.php

@@ -1,29 +1,29 @@
 <?php
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	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.
 *
@@ -32,10 +32,10 @@
 *	@author Wolfgang Schneider, code/html cleanup
 *	@package dokeos.exercise
 * 	@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';
 
 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_TRACK_EXERCICES   	= $_configuration['statistics_database']."`.`track_e_exercices";
 $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
 $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
@@ -145,28 +145,34 @@ a.invisible:hover
 -->
 </style>';
 
-if($show!='result'){
+if($show!='result')
+{
 	$nameTools=get_lang('Exercices');
 }
-else {
+else
+{
 	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
 	{
-	$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");
-	
-} 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
 }
@@ -207,7 +213,7 @@ HotPotGCt($documentPath,1,$_user['user_id']);
 
 if($is_allowedToEdit)
 {
-	
+
 	if(!empty($choice))
 	{
 		// 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);
 	//$result=api_sql_query($sql,__FILE__,__LINE__);
-	
+
 
 	if(!empty($hpchoice))
 	{
 		switch($hpchoice)
 		{
 				case 'delete':	// deletes an exercise
-							$imgparams = array();	
-							$imgcount = 0;							
+							$imgparams = array();
+							$imgcount = 0;
 							GetImgParams($file,$documentPath,$imgparams,$imgcount);
 							$fld = GetFolderName($file);
 							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]);
-							}	
-							
+							}
+
 							if ( my_delete($documentPath.$file))
 							{
 								update_db_info("delete", $file);
-							}											
+							}
 							my_delete($documentPath.$uploadPath."/".$fld."/");
 							break;
 				case 'enable':  // enables an exercise
@@ -307,16 +313,16 @@ if($show == 'test'){
 
 	//error_log('Show == test',0);
 	$nbrExercises=mysql_num_rows($result);
-	
+
 	echo "<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">",
 		"<tr>";
-	
-	if (($is_allowedToEdit) and ($origin != 'learnpath')) 	
+
+	if (($is_allowedToEdit) and ($origin != 'learnpath'))
 	{
 		//error_log('is_allowedToEdit and origin<> learnpath',0);
 		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_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>",
 			"</td>",
@@ -327,23 +333,23 @@ if($show == 'test'){
 		//error_log('!is_allowedToEdit or origin == learnpath ('.$origin.')',0);
 		echo "<td align=\"right\">";
 	}
-	
+
 	//get HotPotatoes files (active and inactive)
-	$res = api_sql_query ("SELECT * 
+	$res = api_sql_query ("SELECT *
 					FROM $TBL_DOCUMENT
-					WHERE 
+					WHERE
 					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__);
-	$nbrActiveTests = Database::num_rows($res);	  
+	$nbrActiveTests = Database::num_rows($res);
 	//error_log('nbrActiveTests = '.$nbrActiveTests,0);
-	
-	
+
+
 	if($is_allowedToEdit)
 	{//if user is allowed to edit, also show hidden HP tests
 		$nbrHpTests = $nbrTests;
@@ -352,8 +358,8 @@ if($show == 'test'){
 		$nbrHpTests = $nbrActiveTests;
 	}
 	$nbrNextTests = $nbrHpTests-(($page*$limitExPage));
-	
-	
+
+
 	//show pages navigation link for previous page
 	if($page)
 	{
@@ -363,33 +369,33 @@ if($show == 'test'){
 	{
 		echo "&lt;&lt; ",get_lang("PreviousPage")." | ";
 	}
-	
+
 	//show pages navigation link for previous page
 	if($nbrExercises+$nbrNextTests > $limitExPage)
 	{
 		echo "<a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq()."&page=".($page+1)."\">&gt;&gt; ",get_lang("NextPage")."</a>";
-	
+
 	}
 	elseif($page)
 	{
 		echo get_lang("NextPage") . " &gt;&gt;";
 	}
-	
+
 	echo "</td>",
 			"</tr>",
 			"</table>";
-	
-?> 
+
+?>
 <table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
   <?php
-	if (($is_allowedToEdit) and ($origin != 'learnpath')) 
+	if (($is_allowedToEdit) and ($origin != 'learnpath'))
 	{
 	?>
   <tr bgcolor="#e6e6e6">
     <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("Modify");?></td>
-   
+
   </tr>
   <?php
 	}
@@ -399,10 +405,10 @@ if($show == 'test'){
     <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("State");?></td>
-   
+
   </tr>
 	<?php }
-	
+
 	// show message if no HP test to show
 	if(!($nbrExercises+$nbrHpTests) )
 	{
@@ -412,19 +418,19 @@ if($show == 'test'){
   </tr>
   <?php
 	}
-	
+
 	$i=1;
-	
+
 	// while list exercises
-	
+
 	if ($origin != 'learnpath') {
-	
+
 		while($row=mysql_fetch_array($result))
 		{
 
 			//error_log($row[0],0);
 			echo "<tr>\n";
-			
+
 			// prof only
 			if($is_allowedToEdit)
 			{
@@ -440,31 +446,31 @@ if($show == 'test'){
       </td>
     </tr>
   </table></td>
- <td width="8%" align="center"> <?php 
+ <td width="8%" align="center"> <?php
  $exid = $row['id'];
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlresult =mysql_query($sqlquery);
  $rowi = mysql_result($sqlresult,0);
  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
 				// if 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
 				}
 				// else if not active
 				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
 				}
 				echo "</td></tr>\n";
-                
+
 			}
 			// student only
 			else
@@ -476,17 +482,17 @@ if($show == 'test'){
             <td width="1">&nbsp;</td>
             <?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>
-			
+
 			</tr>
     </table></td>
-	 <td align='center'> <?php 
+	 <td align='center'> <?php
  $exid = $row['id'];
  $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE `exercice_id` = '$exid'";
  $sqlresult =mysql_query($sqlquery);
  $rowi = mysql_result($sqlresult,0);
  echo $rowi.' Question(s)'; ?> </td>
-	
-	<td align='center'><?php 
+
+	<td align='center'><?php
 		$eid = $row['id'];
 	$uid= $_SESSION[_user][user_id];
 	$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);
 	$percentage = ($row['exe_result']/$row['exe_weighting'])*100;
 	if ($num>0)
-	{	
+	{
 		echo get_lang('Attempted').' ('.get_lang('Score').':';
 		printf("%1.2f\n",$percentage);
 		echo " %)";
@@ -511,56 +517,56 @@ if($show == 'test'){
   </tr>
   <?php
 			}
-		
+
 			// skips the last exercise, that is only used to know if we have or not to create a link "Next page"
 			if($i == $limitExPage)
 			{
 				break;
 			}
-		
+
 			$i++;
 			echo "<tr><td colspan = '5'><hr></td></tr>";
 		}	// end while()
-		
+
 		$ind = $i;
 
-		
+
 		if (($from+$limitExPage-1)>$nbrexerc)
-		{	
+		{
 			if($from>$nbrexerc)
 			{
 				$from = $from - $nbrexerc;
 			  $to = $limitExPage;
-			}	
+			}
 			else
-			{ 
+			{
 				$to = $limitExPage-($nbrexerc-$from);
 				$from = 0;
-			}	
-		}	
+			}
+		}
 		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
-							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
 			$result = api_sql_query ($sql,__FILE__,__LINE__);
 			//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";
 			$result = api_sql_query($sql, __FILE__, __LINE__); // only .htm or .html files listed
 			//error_log($sql,0);
-		}	
+		}
 		//error_log(mysql_num_rows($result),0);
 		while($row = Database::fetch_array($result, 'ASSOC'))
-		{	
+		{
 			//error_log('hop',0);
 			$attribute['path'      ][] = $row['path'      ];
 			$attribute['visibility'][] = $row['visibility'];
@@ -577,11 +583,11 @@ if($show == 'test'){
 				else
 				{ $active=0;}
 				echo "<tr>\n";
-				
-				$title = GetQuizName($path,$documentPath);		
+
+				$title = GetQuizName($path,$documentPath);
 				if ($title =='')
 				{
-					$title = GetFileName($path);		
+					$title = GetFileName($path);
 				}
 				// prof only
 				if($is_allowedToEdit)
@@ -598,7 +604,7 @@ if($show == 'test'){
   <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>
     <?php
 					// if active
@@ -623,20 +629,20 @@ if($show == 'test'){
 				else
 				{
 					if ($active==1)
-					{	
+					{
 						$nbrActiveTests = $nbrActiveTests + 1;
 						?>
     <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="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>
-      
+
      </tr>
     </table></td>
   </tr>
   <?php
-					}	
+					}
 				}
 				?>
   <?php
@@ -648,7 +654,7 @@ if($show == 'test'){
 				{
 					$ind++;
 				}
-				else 
+				else
 				{
 					if ($active==1)
 					{
@@ -657,8 +663,8 @@ if($show == 'test'){
 				}echo "<tr><td colspan = '5'><hr></td></tr>";
 			}
 		}
-		
-		
+
+
 	} //end if ($origin != 'learnpath') {
 	?>
 </table>
@@ -678,8 +684,8 @@ if($_configuration['tracking_enabled'])
 {
 	?>
 <br>
-<br> 
- <h3><?php 
+<br>
+ <h3><?php
  //add link to breadcrumb
  //$interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('StudentScore'));
 
@@ -691,14 +697,14 @@ if($_configuration['tracking_enabled'])
 		{
 		if ($_REQUEST['comments']=='update')
 				{
-					
+
 					$id  = $_GET['exeid'];
 					$emailid = $_GET['emailid'];
 					$test  = $_GET['test'];
 					$from = $_SESSION[_user]['mail'];
 					$from_name = $_SESSION[_user]['firstName']." ".$_SESSION[_user]['lastName'];
 					$url = $_SESSION['checkDokeosURL'].'claroline/exercice/exercice.php?'.api_get_cidreq().'&show=result';
-					
+
 					foreach ($_POST as $key=>$v)
 						{
 						$keyexp = explode('_',$key);
@@ -707,43 +713,43 @@ if($_configuration['tracking_enabled'])
 							$sql = "select question from $TBL_QUESTIONS where id = '$keyexp[1]'";
 							$result =api_sql_query($sql, __FILE__, __LINE__);
 							$ques_name = mysql_result($result,0,"question");
-							
+
 							$query = "update `$TABLETRACK_ATTEMPT` set marks = '$v' where question_id = $keyexp[1] and exe_id=$id";
 							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).'
 									GROUP BY question_id';
-							
+
 							$res = api_sql_query($qry,__FILE__,__LINE__);
 							$tot = mysql_result($res,0,'tot');
-							
+
 							$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
 							api_sql_query($totquery, __FILE__, __LINE__);
-							
+
 							}
 						else
 						  {
 						  $query = "update `$TABLETRACK_ATTEMPT` set teacher_comment = '$v' where question_id = $keyexp[1] and exe_id = $id ";
 						   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).'
 								GROUP BY question_id';
-						
+
 						$res = api_sql_query($qry,__FILE__,__LINE__);
 						$tot = 0;
 						while($row = mysql_fetch_assoc($res))
 						{
 							$tot += $row ['marks'];
 						}
-						
+
 						$totquery = "update `$TBL_TRACK_EXERCICES` set exe_result = $tot where exe_Id=$id";
-						
+
 						api_sql_query($totquery, __FILE__, __LINE__);
 				$subject = "Examsheet viewed/corrected/commented by teacher";
 				$message = "<html>
@@ -751,9 +757,9 @@ if($_configuration['tracking_enabled'])
 <style type='text/css'>
 <!--
 .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; }
 .style10 {
@@ -773,12 +779,12 @@ color: #000000;
     <tr>
       <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>
-  
+
     </tr>
     <tr>
       <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>
-  
+
     </tr>
   </table>
   <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\r\nReply-to: $to\r\nContent-type: text/html; charset=iso-8859-15";
 			//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="15%"><?php echo get_lang("Result"); ?></td>
 		  <td width="15%"><?php echo $is_allowedToEdit?"Correct Test":"View Test"; ?></td>
-		  
-		 
-		 </tr> 
-		
+
+
+		 </tr>
+
 		<?php
 		if($is_allowedToEdit)
 		{
 			//get all results (ourself and the others) as an admin should see them
 			//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
 				  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'
 				  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)
 					FROM `$TBL_TRACK_HOTPOTATOES` tth, $TBL_USER tu
 					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";
-					  
+
 		}
 		else
 		{ // 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
 				  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";
-		
+
 			$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
 					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";
-		
+
 		}
-		
+
 		$results=getManyResultsXCol($sql,7);
 		$hpresults=getManyResultsXCol($hpsql,5);
-		
+
 		$NoTestRes = 0;
 		$NoHPTestRes = 0;
-		
+
 		if(is_array($results))
 		{
 			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>
 
 		 </tr>
-		
+
 		<?php
-			
+
 			}
 		}
 		else
 		{
-				$NoTestRes = 1;	
+				$NoTestRes = 1;
 		}
-		
+
 		// The Result of Tests
 		if(is_array($hpresults))
 		{
-		
+
 			for($i = 0; $i < sizeof($hpresults); $i++)
 			{
-				$title = GetQuizName($hpresults[$i][1],$documentPath);			
+				$title = GetQuizName($hpresults[$i][1],$documentPath);
 				if ($title =='')
 				{
-					$title = GetFileName($hpresults[$i][1]);		
-				}		
+					$title = GetFileName($hpresults[$i][1]);
+				}
 		?>
 		<tr>
 		<?php if($is_allowedToEdit): ?>
 			<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 $hpresults[$i][2]; ?> / <?php echo $hpresults[$i][3]; ?></td>
 		</tr>
-		
+
 		<?php
 			}
 		}
@@ -910,24 +916,24 @@ $message = "<p>You attempt for the test #test# has been viewed/commented/correct
 		{
 			$NoHPTestRes = 1;
 		}
-		
-		
-		
+
+
+
 		if ($NoTestRes==1 && $NoHPTestRes==1)
 		{
 		?>
-		
+
 		 <tr>
 		  <td colspan="3"><?php echo get_lang("NoResult"); ?></td>
 		 </tr>
-		
+
 		<?php
 		}
-		
+
 		?>
-		
+
 		</table>
-		
+
 		<?php
 	}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
 	Display::display_footer();
 } 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
 }
 ?>

+ 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
@@ -62,7 +62,7 @@ define('FREE_ANSWER', 5);
 define('HOT_SPOT', 			6);
 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';
 
 include_once('../inc/global.inc.php');
@@ -74,8 +74,8 @@ $is_allowedToEdit=$is_courseAdmin;
 
 $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_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 // general parameters passed via POST/GET
 
@@ -160,7 +160,7 @@ if($formSent)
             // $exerciseResult receives the content of the form.
             // Each choice of the student is stored into the array $choice
             $exerciseResult=$choice;
-            
+
             if (isset($_POST['hotspot']))
             {
             	$exerciseResultCoordinates = $_POST['hotspot'];
@@ -176,7 +176,7 @@ if($formSent)
             {
                 // stores the user answer into the array
                 $exerciseResult[$key]=$choice[$key];
-                
+
                 if (isset($_POST['hotspot']))
                 {
                 	$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'];
 }
 if(!is_object($objExercise))
@@ -246,7 +246,7 @@ if(!isset($_SESSION['questionList']))
     api_session_register('questionList');
     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'];
 }
 
@@ -273,7 +273,7 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')
 if ($origin != 'learnpath') { //so we are not in learnpath tool
 
 $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\">
 					<!--
 					// -----------------------------------------------------------------------------
@@ -295,7 +295,7 @@ $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/Java
 					  on error resume next
 					  Dim swControl, swVersion
 					  swVersion = 0
-					  
+
 					  set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
 					  if (IsObject(swControl)) then
 					    swVersion = swControl.GetVariable(\"\$version\")
@@ -304,7 +304,7 @@ $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/Java
 					End Function
 					// -->
 					</script>
-					
+
 					<script language=\"JavaScript1.1\" type=\"text/javascript\">
 					<!-- // Detect Client Browser type
 					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;
 						// Can't detect in all other cases
 						else {
-							
+
 							flashVer = -1;
 						}
 						return flashVer;
-					} 
+					}
 					// 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);
-					   	// 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) {
 								versionStr = VBGetSwfVer(i);
 							} else {
 								versionStr = JSGetSwfVer(i);
 							}
-							if (versionStr == -1 ) { 
+							if (versionStr == -1 ) {
 								return false;
 							} else if (versionStr != 0) {
 								if(isIE && isWin && !isOpera) {
 									tempArray         = versionStr.split(\" \");
 									tempString        = tempArray[1];
-									versionArray      = tempString .split(\",\");				
+									versionArray      = tempString .split(\",\");
 								} else {
 									versionArray      = versionStr.split(\".\");
 								}
 								versionMajor      = versionArray[0];
 								versionMinor      = versionArray[1];
 								versionRevision   = versionArray[2];
-								
+
 								versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
 								versionNum        = parseFloat(versionString);
 					        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 								if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 									return true;
 								} else {
-									return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
+									return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
 								}
 							}
-						}	
+						}
 					}
 					// -->
 					</script>";
@@ -392,15 +392,15 @@ else
 	{
 		$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);
 	if(empty($document_language))
 	{
 	  //if there was no valid iso-code, use the english one
 	  $document_language = 'en';
 	}
-	
+
 	/*
 	 * HTML HEADER
 	 */
@@ -443,7 +443,7 @@ foreach($questionList as $questionId)
 {
 	$i++;
 	$objQuestionTmp = Question :: read($questionId);
-	
+
 	// for sequential exercises
 	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
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 
 if(!class_exists('Exercise')):
- 
+
 /**
-============================================================================== 
+==============================================================================
 	CLASS EXERCISE
 *
 *	This class allows to instantiate an object of type Exercise
 *
 *	@author Olivier Brouckaert
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 class Exercise
 {
@@ -73,14 +73,11 @@ class Exercise
 	function read($id)
 	{
 		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'";
 		$result=api_sql_query($sql,__FILE__,__LINE__);
@@ -607,17 +604,17 @@ class Exercise
 		$sql="DELETE FROM $TBL_EXERCICES WHERE id='$id'";
 		api_sql_query($sql,__FILE__,__LINE__);
 	}
-	
+
 	/**
 	 * Creates the form to create / edit an exercise
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 */
-	function createForm ($form) 
+	function createForm ($form)
 	{
-		
+
 		// title
 		$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName').' : ');
-		
+
 		// fck editor
 		global $fck_attribute;
 		$fck_attribute = array();
@@ -625,19 +622,19 @@ class Exercise
 		$fck_attribute['Width'] = '100%';
 		$fck_attribute['ToolbarSet'] = 'NewTest';
 		$form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription').' : ');
-		
+
 		// type
 		$radios = array();
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SimpleExercise'),'1');
 		$radios[] = FormValidator :: createElement ('radio', 'exerciseType', null, get_lang('SequentialExercise'),'2');
 		$form -> addGroup($radios, null, get_lang('ExerciseType').' : ', '<br />');
-		
+
 		// submit
 		$form -> addElement('submit', 'submitExercise', get_lang('Ok'));
-		
+
 		// rules
 		$form -> addRule ('exerciseTitle', get_lang('GiveExerciseName'), 'required');
-		
+
 		// defaults
 		$defaults = array();
 		if($this -> id > 0)
@@ -647,25 +644,25 @@ class Exercise
 			$defaults['exerciseDescription'] = $this -> selectDescription();
 		}
 		$defaults['exerciseType'] = '1';
-		
+
 		$form -> setDefaults($defaults);
-		
-		
+
+
 	}
-	
-	
+
+
 	/**
 	 * function which process the creation of exercises
 	 * @param FormValidator $form the formvalidator instance
 	 */
-	function processCreation($form) 
+	function processCreation($form)
 	{
-		
+
 		$this -> updateTitle($form -> getSubmitValue('exerciseTitle'));
 		$this -> updateDescription($form -> getSubmitValue('exerciseDescription'));
 		$this -> updateType($form -> getSubmitValue('exerciseType'));
 		$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
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	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",
 *	through the session, and calculates the score of the student for
@@ -36,7 +36,7 @@
 *	@package dokeos.exercise
 *	@todo	split more code up in functions, move functions to library?
 * 	@todo 	use database library
-============================================================================== 
+==============================================================================
 */
 
 /*
@@ -58,7 +58,7 @@ define('HOT_SPOT', 6);
 define('HOT_SPOT_ORDER', 	7);
 
 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';
 
 include('../inc/global.inc.php');
@@ -69,14 +69,14 @@ include(api_get_path(LIBRARY_PATH).'mail.lib.inc.php');
 // Database table definitions
 $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_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_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_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $table_ans 				= Database :: get_course_table(TABLE_QUIZ_ANSWER);
-					
+
 //temp values to move to AWACS
 $dsp_percent = false; //false to display total score as absolute values
 //debug param. 0: no display - 1: debug display
@@ -106,7 +106,7 @@ if ( empty ( $choice ) ) {
 }
 if ( empty ( $questionNum ) ) {
    $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
+}
 if ( empty ( $nbrQuestions ) ) {
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
@@ -152,20 +152,20 @@ if ($origin != 'learnpath')
 }
 else
 {
-	
+
 	if(empty($charset))
 	{
 		$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);
 	if(empty($document_language))
 	{
 	  //if there was no valid iso-code, use the english one
 	  $document_language = 'en';
 	}
-	
+
 	/*
 	 * HTML HEADER
 	 */
@@ -193,7 +193,7 @@ else
 
 function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect)
 {
-	?>	
+	?>
 	<tr>
 	<td width="5%" align="center">
 		<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)
 {
-	?>					
+	?>
 		<tr>
 		<td>
 			<?php echo nl2br($answer); ?>
 		</td>
-		</tr>					
+		</tr>
 	<?php
 }
 
 function display_free_answer($answer)
 {
-	?>					
+	?>
 		<tr>
 		<td width="55%">
 			<?php echo nl2br(stripslashes($answer)); ?>
 		</td>
    <td width="45%">
     <?php echo get_lang('notCorrectedYet');?>
-	
+
    </td>
-		</tr>					
+		</tr>
 	<?php
 }
 
@@ -260,7 +260,7 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 									"#ED2024",
 									"#45C7F0",
 									"#F7BDE2");
-	?>		
+	?>
 		<tr>
 				<td width="25%" valign="top">
 					<div style="float:left; padding-left:5px;">
@@ -278,15 +278,15 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 		</tr>
 	<?php
 }
-					
+
 /*
 ==============================================================================
 		MAIN CODE
 ==============================================================================
 */
 $exerciseTitle=api_parse_tex($exerciseTitle);
-	
-?>	
+
+?>
 	<h3><?php echo $exerciseTitle ?>: <?php echo get_lang("Result"); ?></h3>
 	<form method="get" action="exercice.php">
 	<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
@@ -296,20 +296,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 <?php
 	$i=$totalScore=$totalWeighting=0;
 	if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
- 
+
 
 	// added by Priya Saini
 	$sql = "select max(exe_Id) as id from `".$TABLETRACK_EXERCICES."`";
 	$res = api_sql_query($sql, __FILE__, __LINE__);
 	$exeId =mysql_result($res,0,"id");
 	$exeId=$exeId+1;
-	
+
 	foreach($questionList as $questionId)
 	{
 		// gets the student choice for this question
 		$choice=$exerciseResult[$questionId];
 		// creates a temporary Question object
-		
+
 		$objQuestionTmp = Question :: read($questionId);
 
 		$questionName=$objQuestionTmp->selectTitle();
@@ -371,7 +371,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		elseif($answerType == FILL_IN_BLANKS)
 		{
-			?>			
+			?>
 				<tr>
 				<td>
 					<i><?php echo get_lang("Answer"); ?></i>
@@ -381,7 +381,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		elseif($answerType == FREE_ANSWER)
 		{
-			?>			
+			?>
 				<tr>
 				<td width="55%">
 					<i><?php echo get_lang("Answer"); ?></i>
@@ -394,7 +394,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		}
 		elseif($answerType == HOT_SPOT)
 		{
-			?>			
+			?>
 				<tr>
 					<td width="40%">
 						<i><?php echo get_lang('Hotspot'); ?></i><br /><br />
@@ -449,7 +449,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 			switch($answerType)
 			{
 				// for unique answer
-				case UNIQUE_ANSWER :	
+				case UNIQUE_ANSWER :
 										$studentChoice=($choice == $answerId)?1:0;
 
 										if($studentChoice)
@@ -457,12 +457,12 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 										  	$questionScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 										}
-										
+
 
 										break;
 				// for multiple answers
-				case MULTIPLE_ANSWER :	
-										
+				case MULTIPLE_ANSWER :
+
 										$studentChoice=$choice[$answerId];
 
 										if($studentChoice)
@@ -470,20 +470,20 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 											$questionScore+=$answerWeighting;
 											$totalScore+=$answerWeighting;
 										}
-										
+
 										break;
 				// 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);
 
 										// splits weightings that are joined with a comma
 										$answerWeighting=explode(',',$answerWeighting);
 
 										// we save the answer because it will be modified
-										
+
 										$temp=$answer;
-								
+
 										// TeX parsing
 										// 1. find everything between the [tex] and [/tex] tags
 										 $startlocations=strpos($temp,'[tex]');
@@ -491,7 +491,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 										if($startlocations !== false && $endlocations !== false)
 										{
-											
+
 											$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
 											// 2. replace this by {texcode}
 											$temp=str_replace($texstring,'{texcode}',$temp);
@@ -499,13 +499,13 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 										$answer='';
 
-				
+
 										$j=0;
 
 										// the loop will stop at the end of the text
 										while(1)
-										{ 
-												
+										{
+
 											// quits the loop if there are no more blanks
 											if(($pos = strpos($temp,'[')) === false)
 											{
@@ -524,14 +524,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 											// quits the loop if there are no more blanks
 											if(($pos = strpos($temp,']')) === false)
 											{
-												
+
 												// adds the end of the text
 												$answer.=$temp;
 												break;
 											}
 
 											$choice[$j]=trim($choice[$j]);
-						
+
 											// 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])))
 											{
@@ -566,7 +566,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 
 										break;
 				// for free answer
-				case FREE_ANSWER :	   
+				case FREE_ANSWER :
 										$studentChoice=$choice;
 
 										if($studentChoice)
@@ -574,11 +574,11 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 										  	$questionScore=0;
 											$totalScore+=0;
 										}
-										
+
 
 										break;
 				// for matching
-				case MATCHING :			
+				case MATCHING :
 										if($answerCorrect)
 										{
 											if($answerCorrect == $choice[$answerId])
@@ -641,7 +641,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				elseif($answerType == FREE_ANSWER)
 				{
 					// to store the details of open questions in an array to be used in mail
-					
+
 					$arrques[] = $questionName;
 					$arrans[]  = $choice;
 					$firstName =   $_SESSION['_user']['firstName'];
@@ -666,7 +666,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				}
 				else
 				{
-					?>					
+					?>
 						<tr>
 						<td width="50%">
 							<?php
@@ -679,18 +679,18 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 							$matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							echo $matching[$answerCorrect]; ?></b></font>
 						</td>
-						</tr>		
+						</tr>
 					<?php
 				}
 			}
 		} // end for that loops over all answers of the current question
-		
+
 		if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
 			{
 				// We made an extra table for the answers
 				echo "</table></td></tr>";
 			}
-		?>	
+		?>
 			<tr>
 			<td colspan="<?php echo $colspan; ?>" align="right">
 				<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++)
 				{
 					$ans = $reply[$i];
-					exercise_attempt($questionScore,$ans,$quesId,$exeId);			
+					exercise_attempt($questionScore,$ans,$quesId,$exeId);
 				}
 			}
 			elseif ($answerType==4)
@@ -724,16 +724,16 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				$j=3;
 				for ($i=0;$i<sizeof($choice);$i++,$j++)
 				{
-					
+
 					$val = $choice[$j];
 					if (preg_match_all ('#<font color="red"><s>([0-9a-z ]*)</s></font>#', $val, $arr1))
 						$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__);
 					$answer = mysql_result($res,0,"position");
-					
+
 					exercise_attempt($questionScore,$answer,$quesId,$exeId,$j);
-						
+
 				}
 			}
 			elseif ($answerType==5)
@@ -781,14 +781,14 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		</td>
 		</tr>
 		</table>
-		
+
 		</form>
-		
+
 		<br />
 	<?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');
 	event_exercice($objExercise->selectId(),$totalScore,$totalWeighting,$answer,$question_id);
-	
+
 }
 
 if ($origin != 'learnpath')
@@ -822,15 +822,15 @@ if (!empty($arrques))
 	$msg = "<html><head>
 	 <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'>";
-  
+
 
 /*<style type='text/css'>
 
 <!--
 .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; }
 .style10 {
@@ -881,7 +881,7 @@ color: #000000;
     <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>
   	</tr>";
-					
+
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
@@ -890,7 +890,7 @@ color: #000000;
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg= str_replace("#course#",$courseName,$msg1);
-			
+
 	}
 	$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 valign='top' bgcolor='F3F3F3'><span class='style16'> #answer#</span></td>
   	</tr>";
-					
+
 	$msg1= str_replace("#exercise#",$exerciseTitle,$msg);
 	$msg= str_replace("#firstName#",$firstName,$msg1);
 	$msg1= str_replace("#lastName#",$lastName,$msg);
@@ -941,7 +941,7 @@ color: #000000;
 	$msg= str_replace("#answer#",$arrans[$i],$msg1);
 	$msg1= str_replace("#i#",$i,$msg);
 	$msg= str_replace("#course#",$courseName,$msg1);
-			
+
 	}
 	$msg.="</table><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 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';
 
 // including the global dokeos file
@@ -34,21 +34,21 @@ api_protect_course_script();
 // Database table definitions
 $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_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_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";
 
-$dsp_percent = false; 
+$dsp_percent = false;
 $debug=0;
 if($debug>0)
 {
 	echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
 }
 // general parameters passed via POST/GET
-if ( empty ( $origin ) ) 
+if ( empty ( $origin ) )
 {
     $origin = $_REQUEST['origin'];
 }
@@ -72,7 +72,7 @@ if ( empty ( $choice ) ) {
 }
 if ( empty ( $questionNum ) ) {
     $questionNum    = mysql_real_escape_string($_REQUEST['questionNum']);
-} 
+}
 if ( empty ( $nbrQuestions ) ) {
     $nbrQuestions   = mysql_real_escape_string($_REQUEST['nbrQuestions']);
 }
@@ -82,7 +82,7 @@ if ( empty ( $questionList ) ) {
 if ( empty ( $objExercise ) ) {
     $objExercise = $_SESSION['objExercise'];
 }
-$is_allowedToEdit=$is_courseAdmin;	
+$is_allowedToEdit=$is_courseAdmin;
 $nameTools=get_lang('Exercice');
 
 $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
@@ -122,33 +122,33 @@ function getFCK(vals,marksid){
   var f=document.getElementById('myform');
 
   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");
 			oHidn.type = "hidden";
 			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;
 			f.appendChild(oHidn);
-	}  
+	}
 
 	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");
 			oHidden.type = "hidden";
 			oHidden.name = "comments_"+ids[k];
 			oEditor = FCKeditorAPI.GetInstance(oHidden.name) ;
 			oHidden.value = oEditor.GetXHTML(true);
-			f.appendChild(oHidden);  
+			f.appendChild(oHidden);
 	}
 //f.submit();
 }
 </script>
 <?php
-		
+
 //functions
 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";
 	$sqlres = api_sql_query($sql, __FILE__, __LINE__);
 	$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)
 {
-	
-	?>					
+
+	?>
 		<tr>
 		<td>
 			<?php echo nl2br($answer); ?>
-		</td><?php 
+		</td><?php
 		if(!$is_allowedToEdit) {?>
 		<td>
-		<?php 
+		<?php
 		$comm = get_comments($id,$questionId);
 		//echo $comm;
 		?>
 		</td>
-		</tr>					
+		</tr>
 	<?php }
 }
 
 function display_free_answer($answer,$id,$questionId)
 {
-	?>					
+	?>
 		<tr>
 		<td>
 			<?php echo nl2br(stripslashes($answer)); ?>
 		</td> <?php if(!$is_allowedToEdit) {?>
    <td>
-    <?php 
-	
+    <?php
+
 	$comm = get_comments($id,$questionId);
 	/*if ($comm!='')
 	echo $comm;
 	else
 	echo  get_lang('notCorrectedYet');
 	*/?>
-	
-   </td> <?php }?>		
-		</tr>			
+
+   </td> <?php }?>
+		</tr>
 	<?php
 }
 
@@ -236,12 +236,12 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 									"#ED2024",
 									"#45C7F0",
 									"#F7BDE2");
-	?>		
+	?>
 		<tr>
 				<td width="50%" valign="top">
 					<div style="width:100%;">
 						<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>
 				</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);
 $query = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id='$id' group by question_id";
 $result =api_sql_query($query, __FILE__, __LINE__);
-?>	
+?>
 	<h3><?php echo $test ?>: <?php echo get_lang("Result"); ?></h3>
-	
+
 	 </td>
   </tr>
-  <?php 
+  <?php
 
 
 	$i=$totalScore=$totalWeighting=0;
@@ -296,11 +296,11 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				$questionWeighting=$objQuestionTmp->selectWeighting();
 				$answerType=$objQuestionTmp->selectType();
 				$quesId =$objQuestionTmp->selectId(); //added by priya saini
-				
+
 				// destruction of the Question object
 					unset($objQuestionTmp);
 
-				
+
 
 				if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
 				{
@@ -342,7 +342,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			// construction of the Answer object
 				$objAnswerTmp=new Answer($questionId);
 				$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
-				$questionScore=0; 
+				$questionScore=0;
 				for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
 					{
 						$answer=$objAnswerTmp->selectAnswer($answerId);
@@ -362,10 +362,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 							$questionScore+=$answerWeighting;
 							$totalScore+=$answerWeighting;
 							}
-					
+
 				?>
 			<tr>
-			<td> <?php 
+			<td> <?php
 			if($answerId==1)
 					display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
 			else
@@ -373,7 +373,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				?>
 			</td>
 			</tr>
-			<?php 
+			<?php
 		$i++;
 		 }?>
 			</table>
@@ -392,7 +392,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<td>&nbsp;</td>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
@@ -422,7 +422,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			</tr><?php
 		$i++;
 
-		
+
 		}?>
 			</table>
 	<?php  }
@@ -438,7 +438,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<td>&nbsp;</td>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
@@ -467,7 +467,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				// the loop will stop at the end of the text
 				$i=0;
 				while(1)
-					{ 
+					{
 					// quits the loop if there are no more blanks
 					if(($pos = strpos($temp,'[')) === false)
 						{
@@ -505,10 +505,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 ?>
 			<tr>
 			<td> <?php display_fill_in_blanks_answer($answer,$id,$questionId); ?> </td>
-			</tr><?php 
+			</tr><?php
 		$i++;
 
-	
+
 		}?>
 			</table>
 	<?php  }
@@ -525,14 +525,14 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<td>&nbsp;</td>
 			</tr>
 
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$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>
 			<td valign="top"><?php display_free_answer($choice, $id, $questionId);?> </td>
@@ -548,12 +548,12 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<tr>
 			<td><i><?php echo get_lang("ElementList"); ?></i> </td>
 			<td><i><?php echo get_lang("CorrespondsTo"); ?></i></td>
-			
+
 			</tr>
 			<tr>
 			<td>&nbsp;</td>
 			</tr>
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
@@ -571,7 +571,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 					$answ = $row['answer'];
 					$choice[$ind] = $answ;
 					}
-					
+
 				 if($answerCorrect)
 				{
 					if($answerCorrect == $choice[$answerId])
@@ -595,19 +595,19 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				}
 				 ?>
 			<tr>
-			
-			
+
+
 							  <?php
 								$answer=api_parse_tex($answer);
 								//echo $answer; ?>
-						     
-							  <?php 
+
+							  <?php
 						$query = "select position from `".$TABLETRACK_ATTEMPT."` where question_id = $questionId and exe_id=$id";
 						$resapp = api_sql_query($query, __FILE__, __LINE__);
 						while($row = mysql_fetch_array($resapp))
 							{
 							 $tp = $row['position'];
-						     }											
+						     }
 						foreach($choice as $key => $v)
 							{
 							if($key==$answerId)
@@ -615,28 +615,28 @@ $result =api_sql_query($query, __FILE__, __LINE__);
                                  echo "<td>".$answer."</td>";
 								 echo "<td>";
 								 echo $v.'/';
-								
-								}								
+
+								}
 							}
-									
+
 							?>  <font color="green"><b>
 							<?php
 							 $matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
 							 echo $matching[$answerCorrect]; ?></b></font>
 			</td>
-			
-			</tr><?php 
+
+			</tr><?php
 		$i++;
 
-		
+
 		}?>
 			</table>
 	<?php }
 	else if($answerType == HOTSPOT){
-		
-		
+
+
 		?>
-		
+
 		<table width="355" border="0" cellspacing="0" cellpadding="0">
 			<tr>
 			<td>&nbsp;</td>
@@ -648,7 +648,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			<td>&nbsp;</td>
 			</tr>
 
-			<?php 
+			<?php
 			$objAnswerTmp=new Answer($questionId);
 			$nbrAnswers=$objAnswerTmp->selectNbrAnswers();
 			$questionScore=0;
@@ -665,14 +665,14 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 				$answerComment=$objAnswerTmp->selectComment($answerId);
 				$answerCorrect=$objAnswerTmp->isCorrect($answerId);
 				$answerWeighting=$objAnswerTmp->selectWeighting($answerId);
-				
+
 				$query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 				$resq=api_sql_query($query);
 				$choice = mysql_result($resq,0,"answer");
-				
+
 				display_hotspot_answer($answerId,$answer,$choice,$answerComment);
-				
-				$i++;	
+
+				$i++;
 		 	}
 		 	$queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
 			$resfree = api_sql_query($queryfree, __FILE__, __LINE__);
@@ -680,21 +680,21 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 			$totalScore+=$questionScore;
 		 	?>
 			</table></td></tr></table>
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-	<?php	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	<?php
 	}
 	?>
 
@@ -702,7 +702,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 		 </td>
 		<td width="346" valign = "top"><i>
 		<?php echo get_lang("Comment"); ?></i>
-			 <?php if($is_allowedToEdit) 
+			 <?php if($is_allowedToEdit)
 					 		{
 							//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['ToolbarSet'] = 'Comment';
 								$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
-								$$questionId = new FormValidator('frmcomments'.$questionId,'post','');													
+								$$questionId = new FormValidator('frmcomments'.$questionId,'post','');
 								$renderer =& $$questionId->defaultRenderer();
 								$renderer->setFormTemplate(
 	'<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->setDefaults(${user.$questionId});
 								$$questionId->display();
-								?>	
+								?>
 								</div>
 							<?php
-							
-							
+
+
 								}
 							else
 								{
-							
+
 							$comnt = get_comments($id,$questionId);
 							echo "<br> <br>".$comnt;
 								}
-					?>  
+					?>
 
 		 </td>
-	</tr>	
+	</tr>
   <tr>
   <td></td>
   <td align= "left" >
@@ -764,9 +764,9 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 								?>
 							 <div id="<?php echo $marksname; ?>" style="visibility:hidden">
 							 <form name="marksform_<?php echo $questionId; ?>" method="post" action="">
-														 
-								  
-								  <?php 
+
+
+								  <?php
 								  $arrmarks[] = $questionId;
 								 echo "Assign Marks ";
 								  echo "<select name='marks' id='marks'>";
@@ -777,10 +777,10 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 											?></option>
     									<?php } ?>
 								  </select>
-								  </form></div><?php 
+								  </form></div><?php
 								 }
 						}?>
-				
+
   </td><tr><td></td><td align="right"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b></td>
   </tr>
 	<?php  unset($objAnswerTmp);
@@ -788,7 +788,7 @@ $result =api_sql_query($query, __FILE__, __LINE__);
 $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'";
 			api_sql_query($query,__FILE__,__LINE__);
 			echo get_lang('YourTotalScore')." ";
@@ -810,9 +810,9 @@ $totalWeighting+=$questionWeighting;
 			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">
-			 <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>
 		<?php } ?>
 		</td>

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

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

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

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

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

@@ -83,7 +83,7 @@ if($modifyIn)
         $objAnswer->duplicate($questionId);
 
         // construction of the duplicated Answers
-        
+
         $objAnswer=new Answer($questionId);
     }
 
@@ -94,7 +94,7 @@ if($modifyIn)
     $weighting=unserialize($weighting);
     $hotspot_coordinates=unserialize($hotspot_coordinates);
     $hotspot_type=unserialize($hotspot_type);
-        
+
 
     unset($buttonBack);
 }
@@ -103,7 +103,7 @@ if($modifyIn)
 if($submitAnswers || $buttonBack)
 {
     if($debug>0){echo '$submitAnswers or $buttonBack was set'."<br />\n";}
-    
+
     $questionWeighting=$nbrGoodAnswers=0;
 
     for($i=1;$i <= $nbrAnswers;$i++)
@@ -124,32 +124,32 @@ if($submitAnswers || $buttonBack)
 
             break;
         }
-        
+
         if($weighting[$i] <= 0)
         {
         	$msgErr=get_lang('HotspotWeightingError');
-        	
+
         	// clears answers already recorded into the Answer object
             $objAnswer->cancel();
 
-            break;	
+            break;
         }
         if($hotspot_coordinates[$i] == '0;0|0|0' || empty($hotspot_coordinates[$i]))
         {
         	$msgErr=get_lang('HotspotNotDrawn');
-        	
+
         	// clears answers already recorded into the Answer object
             $objAnswer->cancel();
 
-            break;	
+            break;
         }
-        
+
     }  // end for()
-   
+
 
     if(empty($msgErr))
     {
-        
+
     	for($i=1;$i <= $nbrAnswers;$i++)
         {
             if($debug>0){echo str_repeat('&nbsp;',4).'$answerType is HOT_SPOT'."<br />\n";}
@@ -161,13 +161,13 @@ if($submitAnswers || $buttonBack)
 			{
 				$questionWeighting+=$weighting[$i];
 			}
-			
+
 			// creates answer
 			$objAnswer->createAnswer($reponse[$i], '',$comment[$i],$weighting[$i],$i,$hotspot_coordinates[$i],$hotspot_type[$i]);
         }  // end for()
 		// saves the answers into the data base
 		$objAnswer->save();
-        
+
         // sets the total weighting of the question
         $objQuestion->updateWeighting($questionWeighting);
         $objQuestion->save($exerciseId);
@@ -175,9 +175,9 @@ if($submitAnswers || $buttonBack)
         $editQuestion=$questionId;
 
         unset($modifyAnswers);
-        
+
         echo '<script type="text/javascript">window.location.href="admin.php"</script>';
-        
+
     }
     if($debug>0){echo '$modifyIn was set - end'."<br />\n";}
 
@@ -186,21 +186,21 @@ if($submitAnswers || $buttonBack)
 if($modifyAnswers)
 {
 
-	
+
     if($debug>0){echo str_repeat('&nbsp;',0).'$modifyAnswers is set'."<br />\n";}
-    
+
     // construction of the Answer object
     $objAnswer=new Answer($objQuestion -> id);
-   
+
     api_session_register('objAnswer');
 
 	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)
     {
-    	
+
         $nbrAnswers=$objAnswer->selectNbrAnswers();
 
         $reponse=Array();
@@ -218,10 +218,10 @@ if($modifyAnswers)
             $hotspot_coordinates[$i]=$objAnswer->selectHotspotCoordinates($i);
             $hotspot_type[$i]=$objAnswer->selectHotspotType($i);
         }
-        
-        
+
+
     }
-   
+
     $_SESSION['tmp_answers'] = array();
     $_SESSION['tmp_answers']['answer'] = $reponse;
     $_SESSION['tmp_answers']['comment'] = $comment;
@@ -233,9 +233,9 @@ if($modifyAnswers)
     {
     	// At least 1 answer
     	if ($nbrAnswers > 1) {
-			
+
             $nbrAnswers--;
-            
+
             // Remove the last answer
 			$tmp = array_pop($_SESSION['tmp_answers']['answer']);
 			$tmp = array_pop($_SESSION['tmp_answers']['comment']);
@@ -254,7 +254,7 @@ if($modifyAnswers)
     	if ($nbrAnswers < 12)
     	{
             $nbrAnswers++;
-            
+
             // Add a new answer
             $_SESSION['tmp_answers']['answer'][]='';
 			$_SESSION['tmp_answers']['comment'][]='';
@@ -266,13 +266,13 @@ if($modifyAnswers)
     	{
     		$msgErr=get_lang('MaxHotspot');
     	}
-        
+
 
     }
 
         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";}
         $hotspot_colors = array("", // $i starts from 1 on next loop (ugly fix)
         						"#4271B5",
@@ -306,11 +306,11 @@ if($modifyAnswers)
 	<tr>
 		<td width="550" valign="top">
 			<script type="text/javascript">
-				<!-- 
+				<!--
 				// Version check based upon the values entered above in "Globals"
 				var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
-				
-				
+
+
 				// Check to see if the version meets the requirements for playback
 				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">'
@@ -343,12 +343,12 @@ if($modifyAnswers)
 					  <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>
 					</tr>
-					
+
 					<?php
 								for($i=1;$i <= $nbrAnswers;$i++)
 								{
 					?>
-					
+
 					<tr>
 					  <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>
@@ -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_type[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_type[$i]) ? 'square' : $hotspot_type[$i]); ?>" /></td>
 					</tr>
-					
+
 					<?php
 					  			}
 					?>
-					
+
 					<tr>
 					  <td colspan="5">
 						<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" />
@@ -387,7 +387,7 @@ if($modifyAnswers)
 
 
 <?php
-    
+
     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
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 *	This file generates the ActionScript variables code used by the HotSpot .swf
 *
 *	@author Toon Keppens
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 
 
 	include('exercise.class.php');
 	include('question.class.php');
 	include('answer.class.php');
-	
+
 	include('../inc/global.inc.php');
 	//include('../inc/lib/database.inc.lib');
-	
+
 	// set vars
 	$userId        = $_user['user_id'];
 	$questionId    = $_GET['modifyAnswers'];
-	
+
 	$objQuestion = Question :: read($questionId);
-	
-	$TBL_ANSWERS   = $_course['dbNameGlu'].'quiz_answer';
+
+	$TBL_ANSWERS   = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 	$dbNameGlu     = $_course['dbNameGlu'];
 	$documentPath  = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
-	
+
 	$picturePath   = $documentPath.'/images';
 	$pictureName   = $objQuestion->selectPicture();
 	$pictureSize   = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
 	$pictureWidth  = $pictureSize[0];
 	$pictureHeight = $pictureSize[1];
-	
+
 	$courseLang = $_course['language'];
 	$courseCode = $_course['sysCode'];
 	$coursePath = $_course['path'];
-	
+
 	// Query db for answers
 	$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__);
-	
+
 	// Init
 	$output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$coursePath";
 	$i = 0;
-	
+
 	while ($hotspot = mysql_fetch_array($result)) {
-		
+
 		$output .= "&hotspot_".$hotspot['id']."=true";
-		
+
 		// Square or rectancle
 		if ($hotspot['hotspot_type'] == 'square' )
 		{
 			$output .= "&hotspot_".$hotspot['id']."_type=square";
 		}
-		
+
 		// Circle or ovale
 		if ($hotspot['hotspot_type'] == 'circle')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=circle";
 		}
-		
+
 		// Polygon
 		if ($hotspot['hotspot_type'] == 'poly')
-		{	
+		{
 			$output .= "&hotspot_".$hotspot['id']."_type=poly";
 		}
-		
+
 		$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
-		
+
 		$i++;
 	}
-	
-	// Generate empty 
+
+	// Generate empty
 	$i++;
 	for ($i; $i <= 12; $i++)
 	{
@@ -103,27 +103,27 @@
 
 	// set vars
 	$questionId    = $_GET['modifyAnswers'];
-	
+
 	$courseCode = $_course['sysCode'];
-	
+
 	// Get clicks
 	foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
 	{
 		$output2 .= $coordinate."|";
 	}
-	
+
 	//var_dump($_SESSION['exerciseResultCoordinates']);
 	// Output
 	$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
-	
+
 	$explode = explode('&', $output);
-	
+
 	/*echo '<pre>';
-	
+
 	var_dump($explode);
-	
+
 	echo '</pre>';*/
-	
+
 	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 $
 /*
-============================================================================== 
+==============================================================================
 	Dokeos - elearning and course management software
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2005 Yannick Warnier <yannick.warnier@dokeos.com>
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	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.
 *	@author Yannick Warnier <yannick.warnier@dokeos.com>
 *	@package dokeos.exercise
-* 
+*
 * 	@todo use the Database:: functions
 * 	@todo respect coding guidelines
-============================================================================== 
+==============================================================================
 */
 
 /*
@@ -37,10 +37,10 @@
 		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';
 
-// 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');
 
 // including additional libraries
@@ -62,8 +62,8 @@ define('FREE_ANSWER', 5);
 /** @todo use the Database:: functions */
 $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_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=0;
@@ -111,23 +111,23 @@ $obj_question = Question :: read($my_qst);
 
 $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.';
 
 if($action == 'mark'){
 	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:
 		global $_configuration;
-		
+
 		if($_configuration['tracking_enabled'])
 		{
 			$exercise_table = Database::get_statistic_table('track_e_exercices');
 			#$tbl_learnpath_user = Database::get_course_table('learnpath_user');
 			#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";
 			#echo $sql;
 			$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
 				// with a score higher than the possible score for that exercise
 				$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']."'";
 				#echo $sql;
 				$res = api_sql_query($sql,__FILE__,__LINE__);
@@ -153,7 +153,7 @@ if($action == 'mark'){
 						   `exe_weighting`,
 						   `exe_date`
 						  )
-				
+
 						  VALUES
 						  (
 						  ".$my_usr.",
@@ -196,7 +196,7 @@ if($action == 'mark'){
 	echo $my_msg.'<br />
 		<a href="exercice.php?cidReq='.$cidReq.'">'.get_lang('Back').'</a>';
 }else{
-	
+
 
 	echo '<h2>'.$obj_question->question .':</h2>
 		'.$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
-	
+
 	Copyright (c) 2004 Dokeos S.A.
 	Copyright (c) 2003 Ghent University (UGent)
 	Copyright (c) 2001 Universite catholique de Louvain (UCL)
 	Copyright (c) Olivier Brouckaert
-	
+
 	For a full list of contributors, see "credits.txt".
 	The full license can be read in "license.txt".
-	
+
 	This program is free software; you can redistribute it and/or
 	modify it under the terms of the GNU General Public License
 	as published by the Free Software Foundation; either version 2
 	of the License, or (at your option) any later version.
-	
+
 	See the GNU General Public License for more details.
-	
+
 	Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
-============================================================================== 
+==============================================================================
 */
 /**
-============================================================================== 
+==============================================================================
 *	File containing the Question class.
 *
 *	@author Olivier Brouckaert
 *	@package dokeos.exercise
-============================================================================== 
+==============================================================================
 */
 
 if(!class_exists('Question')):
@@ -45,7 +45,7 @@ define(HOT_SPOT_ORDER, 	7);
 
 /**
 	CLASS QUESTION
- *	
+ *
  *	This class allows to instantiate an object of type Question
  *
  *	@author Olivier Brouckaert, original author
@@ -60,11 +60,11 @@ abstract class Question
 	var $weighting;
 	var $position;
 	var $type;
-	
+
 	var $picture;
 
 	var $exerciseList;  // array with the list of exercises which this question is in
-	
+
 	static $typePicture = 'new_question.png';
 	static $explanationLangVar = '';
 	static $questionTypes = array(
@@ -75,7 +75,7 @@ abstract class Question
 							FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
 							HOT_SPOT => array('hotspot.class.php' , 'HotSpot')
 							);
-	
+
 	/**
 	 * constructor of the class
 	 *
@@ -104,14 +104,14 @@ abstract class Question
 	static function read($id)
 	{
 		global $_course;
-		
+
 		$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';
 		$sql="SELECT question,description,ponderation,position,type,picture FROM `$TBL_QUESTIONS` WHERE id='$id'";
-		
+
 		$result=api_sql_query($sql,__FILE__,__LINE__);
-		
+
 		// if the question has been found
 		if($object=mysql_fetch_object($result))
 		{
@@ -335,7 +335,7 @@ abstract class Question
 
 		return false;
 	}
-	
+
 	/**
 	 * 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)
 	{
 		global $picturePath;
-		
+
 		// if the question has an ID
 		if($this->id)
 		{
 	  		// Get dimensions from current image.
 	  		$current_img = imagecreatefromjpeg($picturePath.'/'.$this->picture);
-			
+
 	  		$current_image_size = getimagesize($picturePath.'/'.$this->picture);
 	  		$current_height = imagesy($current_img);
 			$current_width = imagesx($current_img);
-			
+
 			if($current_image_size[0] < $Max && $current_image_size[1] <$Max)
 				return true;
 			elseif($current_height == "")
 				return false;
-			
+
 			// Resize according to height.
 			if ($Dimension == "height")
 			{
@@ -370,7 +370,7 @@ abstract class Question
 				$new_height = $Max;
 				$new_width = ceil($current_width / $resize_scale);
 			}
-			
+
 			// Resize according to width
 			if ($Dimension == "width")
 			{
@@ -378,7 +378,7 @@ abstract class Question
 				$new_width = $Max;
 				$new_height = ceil($current_height / $resize_scale);
 			}
-			
+
 			// Resize according to height or width, both should not be larger than $Max after resizing.
 			if ($Dimension == "any")
 			{
@@ -395,22 +395,22 @@ abstract class Question
 					$new_height = ceil($current_height / $resize_scale);
 				}
 			}
-			
+
 			// Create new image
 		    $new_img = imagecreatetruecolor($new_width, $new_height);
 			$bgColor = imagecolorallocate($new_img, 255,255,255);
 			imagefill($new_img , 0,0 , $bgColor);
-			
+
 			// Resize image
 			imagecopyresized($new_img, $current_img, 0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
-			
+
 			// Write image to file
 		    $result = imagejpeg($new_img, $picturePath.'/'.$this->picture, 100);
-		    
+
 		    // Delete temperory images, clear memory
 			imagedestroy($current_img);
 			imagedestroy($new_img);
-			
+
 			if ($result)
 			{
 				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')";
 			api_sql_query($sql,__FILE__,__LINE__);
-			
+
 			$this->id=mysql_insert_id();
-			
+
 			// If hotspot, create first answer
 			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')";
 				api_sql_query($sql,__FILE__,__LINE__);
 			}
@@ -597,7 +597,7 @@ abstract class Question
 			$this->exerciseList[]=$exerciseId;
 
 			$sql="INSERT INTO `$TBL_EXERCICE_QUESTION`(question_id,exercice_id) VALUES('$id','$exerciseId')";
-			
+
 			api_sql_query($sql,__FILE__,__LINE__);
 		}
 	}
@@ -699,19 +699,19 @@ abstract class Question
 
 		return $id;
 	}
-	
+
 	/**
 	 * Returns an instance of the class corresponding to the type
 	 * @param integer $type the type of the question
 	 * @return an instance of a Question subclass (or of Questionc class by default)
 	 */
 	static function getInstance ($type) {
-		
+
 		list($file_name,$class_name) = self::$questionTypes[$type];
 
 		include_once ($file_name);
-		
-		
+
+
 		if(class_exists($class_name))
 		{
 			return new $class_name();
@@ -721,25 +721,25 @@ abstract class Question
 			echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
 			return null;
 		}
-		
+
 	}
-	
+
 	/**
 	 * Creates the form to create / edit a question
 	 * A subclass can redifine this function to add fields...
 	 * @param FormValidator $form the formvalidator instance (by reference)
 	 */
 	function createForm (&$form) {
-		
+
 		// question name
 		$form->addElement('text','questionName',get_lang('Question'),'size="60"');
 		$form->addRule('questionName', get_lang('GiveQuestion'), 'required');
-		
+
 		// question type
 		$answerType= intval($_REQUEST['answerType']);
 		$form->addElement('hidden','answerType',$_REQUEST['answerType']);
-		
-		
+
+
 		// html editor
 		global $fck_attribute;
 		$fck_attribute = array();
@@ -749,50 +749,50 @@ abstract class Question
 		$fck_attribute['Config']['IMUploadPath'] = 'upload/test/';
 		$fck_attribute['Config']['FlashUploadPath'] = 'upload/test/';
 		if(!api_is_allowed_to_edit()) $fck_attribute['Config']['UserStatus'] = 'student';
-		
+
 		$form->add_html_editor('questionDescription', get_lang('QuestionDescription'), false);
-		
+
 		// hidden values
-		$form->addElement('hidden','myid',$_REQUEST['myid']);	
-		
-		
+		$form->addElement('hidden','myid',$_REQUEST['myid']);
+
+
 		// default values
 		$defaults = array();
 		$defaults['questionName'] = $this -> question;
 		$defaults['questionDescription'] = $this -> description;
 		$form -> setDefaults($defaults);
 	}
-	
+
 	/**
 	 * function which process the creation of questions
 	 * @param FormValidator $form the formvalidator instance
 	 * @param Exercise $objExercise the Exercise instance
 	 */
 	function processCreation ($form, $objExercise) {
-		   
+
 		$this -> updateTitle($form->getSubmitValue('questionName'));
 	    $this -> updateDescription($form->getSubmitValue('questionDescription'));
 	    $this -> save($objExercise -> id);
-	    
+
 	    // modify the exercise
 	    $objExercise->addToList($this -> id);
 	    $objExercise->save();
-	    
+
 	}
-	
+
 	/**
 	 * abstract function which creates the form to create / edit the answers of the question
 	 * @param the formvalidator instance
 	 */
 	abstract function createAnswersForm ($form);
-	
+
 	/**
 	 * abstract function which process the creation of answers
-	 * @param the formvalidator instance 
+	 * @param the formvalidator instance
 	 */
 	abstract function processAnswersCreation ($form);
-	
-	
+
+
 	/**
 	 * Displays the menu of question types
 	 */
@@ -814,7 +814,7 @@ abstract class Question
 			include_once($a_type[0]);
 			eval('$img = '.$a_type[1].'::$typePicture;');
 			eval('$explanation = get_lang('.$a_type[1].'::$explanationLangVar);');
-			
+
 			echo '
 			<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>
@@ -822,7 +822,7 @@ abstract class Question
 		}
 		echo '
 		<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
@@ -39,7 +39,7 @@ include('exercise.class.php');
 include('question.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';
 
 include('../inc/global.inc.php');
@@ -49,8 +49,8 @@ $is_allowedToEdit=$is_courseAdmin;
 
 $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_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION);
+$TBL_REPONSES          = Database::get_course_table(TABLE_QUIZ_ANSWER);
 
 if ( empty ( $delete ) ) {
     $delete = $_GET['delete'];