Browse Source

[svn r20451] FS#306 - The Tests tool: Improvements for better encoding management.

Ivan Tcholakov 16 years ago
parent
commit
031a083de8

+ 3 - 3
main/exercice/GC.php

@@ -22,7 +22,7 @@
 *	Code library for HotPotatoes integration.
 *	@package dokeos.exercise
 * 	@author Istvan Mandak
-* 	@version $Id: GC.php 10789 2007-01-18 19:18:27Z pcool $
+* 	@version $Id: GC.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 
@@ -74,11 +74,11 @@
 						}
 					 else
 					  {
-					  	echo $folder."/".$val."<BR>";
+					  	echo $folder."/".$val."<br />";
 					  }
 				 }
 			}
 		}
 
 
-?>
+?>

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

@@ -23,7 +23,7 @@
 *	5 arrays are created to receive the attributes of each answer belonging to a specified question
 * 	@package dokeos.exercise
 * 	@author Olivier Brouckaert
-* 	@version $Id: answer.class.php 20308 2009-05-05 00:42:54Z cvargas1 $
+* 	@version $Id: answer.class.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 
@@ -446,7 +446,7 @@ class Answer
 			$sql.="('$i','$questionId','$answer','$correct','$comment',
 					'$weighting','$position','$hotspot_coordinates','$hotspot_type','$destination'),";
 		}		
-		$sql = substr($sql,0,-1);	
+		$sql = api_substr($sql,0,-1);
 		api_sql_query($sql,__FILE__,__LINE__);
 
 		// moves $new_* arrays
@@ -496,7 +496,7 @@ class Answer
 						"'$weighting','$position','$hotspot_coordinates','$hotspot_type','$destination'),";
 			}
 
-			$sql=substr($sql,0,-1);
+			$sql=api_substr($sql,0,-1);
 			api_sql_query($sql,__FILE__,__LINE__);
 		}
 	}

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

@@ -22,7 +22,7 @@
 *	This script allows to manage answers. It is included from the script admin.php
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert
-* 	@version $Id: answer_admin.inc.php 19466 2009-03-31 20:18:12Z cvargas1 $
+* 	@version $Id: answer_admin.inc.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 
@@ -260,7 +260,7 @@ if($submitAnswers || $buttonBack)
                         $reponse.=$val.',';
                     }
 
-                    $reponse=substr($reponse,0,-1);
+                    $reponse=api_substr($reponse,0,-1);
 
                     $objAnswer->createAnswer($reponse,0,'',0,'');
                     $objAnswer->save();
@@ -290,7 +290,7 @@ if($submitAnswers || $buttonBack)
             {
                 $msgErr=get_lang('GiveText');
             }
-            elseif(!ereg('\[.+\]',$reponse))
+            elseif(!api_ereg('\[.+\]',$reponse))
             {
                 $msgErr=get_lang('DefineBlanks');
             }
@@ -308,12 +308,12 @@ if($submitAnswers || $buttonBack)
                 $temp=$reponse;
 
                 // 1. find everything between the [tex] and [/tex] tags
-                $startlocations=strpos($temp,'[tex]');
-                $endlocations=strpos($temp,'[/tex]');
+                $startlocations=api_strpos($temp,'[tex]');
+                $endlocations=api_strpos($temp,'[/tex]');
 
                 if($startlocations !== false && $endlocations !== false)
                 {
-                    $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
+                    $texstring=api_substr($temp,$startlocations,$endlocations-$startlocations+6);
 
                     // 2. replace this by {texcode}
                     $temp=str_replace($texstring,"{texcode}",$temp);
@@ -328,25 +328,25 @@ if($submitAnswers || $buttonBack)
                 while(1)
                 {
                     // quits the loop if there are no more blanks
-                    if(($pos = strpos($temp,'[')) === false)
+                    if(($pos = api_strpos($temp,'[')) === false)
                     {
                         break;
                     }
 
                     // removes characters till '['
-                    $temp=substr($temp,$pos+1);
+                    $temp=api_substr($temp,$pos+1);
 
                     // quits the loop if there are no more blanks
-                    if(($pos = strpos($temp,']')) === false)
+                    if(($pos = api_strpos($temp,']')) === false)
                     {
                         break;
                     }
 
                     // stores the found blank into the array
-                    $blanks[$i++]=substr($temp,0,$pos);
+                    $blanks[$i++]=api_substr($temp,0,$pos);
 
                     // removes the character ']'
-                    $temp=substr($temp,$pos+1);
+                    $temp=api_substr($temp,$pos+1);
                 }
             }
         }
@@ -990,8 +990,8 @@ if($modifyAnswers)
 				}
 ?>
 
-  <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="reponse[<?php echo $i; ?>]"><?php echo htmlentities($reponse[$i],ENT_QUOTES,$charset); ?></textarea></td>
-  <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="comment[<?php echo $i; ?>]"><?php echo htmlentities($comment[$i],ENT_QUOTES,$charset); ?></textarea></td>
+  <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="reponse[<?php echo $i; ?>]"><?php echo api_htmlentities($reponse[$i],ENT_QUOTES,$charset); ?></textarea></td>
+  <td align="left"><textarea wrap="virtual" rows="7" cols="25" name="comment[<?php echo $i; ?>]"><?php echo api_htmlentities($comment[$i],ENT_QUOTES,$charset); ?></textarea></td>
 
     <td valign="top"><input type="text" name="weighting[<?php echo $i; ?>]" size="5" value="<?php echo isset($weighting[$i])?$weighting[$i]:0; ?>"></td>
 </tr>
@@ -1005,7 +1005,7 @@ if($modifyAnswers)
 	<input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>">
 	&nbsp;&nbsp;<input type="submit" name="lessAnswers" value="<?php echo get_lang('LessAnswers'); ?>">
 	&nbsp;&nbsp;<input type="submit" name="moreAnswers" value="<?php echo get_lang('MoreAnswers'); ?>">
-	<!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;"> //-->
+	<!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;"> //-->
   </td>
 </tr>
 </table>
@@ -1033,7 +1033,7 @@ if($modifyAnswers)
             {
 ?>
 
-<input type="hidden" name="weighting" value="<?php echo $submitAnswers?htmlentities($weighting,ENT_QUOTES,$charset):htmlentities(serialize($weighting),ENT_QUOTES,$charset); ?>">
+<input type="hidden" name="weighting" value="<?php echo $submitAnswers?api_htmlentities($weighting,ENT_QUOTES,$charset):api_htmlentities(serialize($weighting),ENT_QUOTES,$charset); ?>">
 
 <table border="0" cellpadding="5" width="500">
 
@@ -1071,11 +1071,11 @@ if($modifyAnswers)
   <td><?php echo get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'); ?> :</td>
 </tr>
 <tr>
-  <td><textarea wrap="virtual" name="reponse" cols="65" rows="6"><?php if(!$submitAnswers && empty($reponse)) echo get_lang('DefaultTextInBlanks'); else echo htmlentities($reponse,ENT_QUOTES,$charset); ?></textarea></td>
+  <td><textarea wrap="virtual" name="reponse" cols="65" rows="6"><?php if(!$submitAnswers && empty($reponse)) echo get_lang('DefaultTextInBlanks'); else echo api_htmlentities($reponse,ENT_QUOTES,$charset); ?></textarea></td>
 </tr>
 <tr>
   <td colspan="5">
-	<!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;">
+	<!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;">
 	&nbsp;&nbsp; //--> <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>">
   </td>
 </tr>
@@ -1086,8 +1086,8 @@ if($modifyAnswers)
  else
 {
 ?>
-<input type="hidden" name="blanks" value="<?php echo htmlentities(serialize($blanks),ENT_QUOTES,$charset); ?>">
-<input type="hidden" name="reponse" value="<?php echo htmlentities($reponse,ENT_QUOTES,$charset); ?>">
+<input type="hidden" name="blanks" value="<?php echo api_htmlentities(serialize($blanks),ENT_QUOTES,$charset); ?>">
+<input type="hidden" name="reponse" value="<?php echo api_htmlentities($reponse,ENT_QUOTES,$charset); ?>">
 <table border="0" cellpadding="5" width="500">
 <?php
                 if(!empty($msgErr))
@@ -1136,7 +1136,7 @@ if($modifyAnswers)
   <td colspan="2">
 	<input type="submit" name="buttonBack" value="&lt; <?php echo get_lang('Back'); ?>">
 	&nbsp;&nbsp;<input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>">
-	<!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;"> //-->
+	<!-- &nbsp;&nbsp;<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;"> //-->
   </td>
 </tr>
 </table>
@@ -1195,7 +1195,7 @@ if($modifyAnswers)
  			if(!$submitAnswers && empty($free_comment))
 				echo '';
 			else
-				echo htmlentities($free_comment,ENT_QUOTES,$charset); ?>
+				echo api_htmlentities($free_comment,ENT_QUOTES,$charset); ?>
    				<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>
 				</tr>
@@ -1274,7 +1274,7 @@ if($modifyAnswers)
 
 <tr>
   <td><?php echo $j; ?></td>
-  <td><input type="text" name="match[<?php echo $i; ?>]" size="58" value="<?php if(!$formSent && !isset($match[$i])) echo ${"langDefaultMakeCorrespond$j"}; else echo htmlentities($match[$i],ENT_QUOTES,$charset); ?>"></td>
+  <td><input type="text" name="match[<?php echo $i; ?>]" size="58" value="<?php if(!$formSent && !isset($match[$i])) echo ${"langDefaultMakeCorrespond$j"}; else echo api_htmlentities($match[$i],ENT_QUOTES,$charset); ?>"></td>
   <td align="center"><select name="sel[<?php echo $i; ?>]">
 
 <?php
@@ -1313,7 +1313,7 @@ if($modifyAnswers)
 
 <tr>
   <td><?php echo $val; ?></td>
-  <td colspan="3"><input type="text" name="option[<?php echo $key; ?>]" size="80" value="<?php if(!$formSent && !isset($option[$key])) echo get_lang("DefaultMatchingOpt$val"); else echo htmlentities($option[$key],ENT_QUOTES,$charset); ?>"></td>
+  <td colspan="3"><input type="text" name="option[<?php echo $key; ?>]" size="80" value="<?php if(!$formSent && !isset($option[$key])) echo get_lang("DefaultMatchingOpt$val"); else echo api_htmlentities($option[$key],ENT_QUOTES,$charset); ?>"></td>
 </tr>
 
 <?php
@@ -1331,7 +1331,7 @@ if($modifyAnswers)
 </tr>
 <tr>
   <td colspan="4">
-	<!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;">
+	<!-- <input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;">
 	&nbsp;&nbsp; //--> <input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>">
   </td>
 </tr>
@@ -1420,8 +1420,8 @@ if($modifyAnswers)
 
 					<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],ENT_QUOTES,$charset); ?>" size="12" /></td>
-					  <td align="left"><textarea wrap="virtual" rows="3" cols="10" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo htmlentities($comment[$i],ENT_QUOTES,$charset); ?></textarea></td>
+					  <td valign="top" align="left"><input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo api_htmlentities($reponse[$i],ENT_QUOTES,$charset); ?>" size="12" /></td>
+					  <td align="left"><textarea wrap="virtual" rows="3" cols="10" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo api_htmlentities($comment[$i],ENT_QUOTES,$charset); ?></textarea></td>
 					  <td valign="top"><input type="text" name="weighting[<?php echo $i; ?>]" size="1" value="<?php echo (isset($weighting[$i]) ? $weighting[$i] : 1); ?>" />
 					  <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>
@@ -1437,7 +1437,7 @@ if($modifyAnswers)
 						<input type="submit" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" />
 						<hr noshade="noshade" size="1" style="color: #4271b5" />
 						<input type="submit" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" />
-						<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;" />
+						<input type="submit" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)); ?>')) return false;" />
 					  </td>
 					</tr>
 				</table>

+ 17 - 17
main/exercice/exercice.php

@@ -1,5 +1,5 @@
 <?php
-// $Id: exercice.php 20418 2009-05-08 19:33:09Z juliomontoya $
+// $Id: exercice.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 
 /*
 ==============================================================================
@@ -912,21 +912,21 @@ if ($show == 'test') {
 				$rs_random = api_sql_query($sql_random_query, __FILE__, __LINE__);
 				$row_random = Database :: fetch_array($rs_random);
 				if ($row_random['random'] > 0) {
-					echo $row_random['random'] . ' ' . strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question'))) . '</td>';
+					echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question'))) . '</td>';
 				} else {
-					echo $rowi . ' ' . strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question'))) . '</td>';
+					echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question'))) . '</td>';
 				}
 
 				//echo '<td><a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a></td>';
 ?>
 		    <td>
-		    <a href="admin.php?exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>	      
+		    <a href="admin.php?exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>	      
 			<?php
 
 				if ($row['results_disabled']) {
-					//echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
+					//echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.api_htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
 				} else {
-					//echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
+					//echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.api_htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
 				}
 ?>
 			<!--<a href="exercise_admin.php?modifyExercise=yes&exerciseId=--><?php
@@ -948,13 +948,13 @@ if ($show == 'test') {
 				//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'),ENT_QUOTES,$charset); ?>" /></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 api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
 	    		<?php
 
 				} else {
 					// else if not active
 ?>
-	      		<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'),ENT_QUOTES,$charset); ?>" /></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 api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
 	    		<?php
 
 				}
@@ -980,10 +980,10 @@ if ($show == 'test') {
 				$rs_random = api_sql_query($sql_random_query, __FILE__, __LINE__);
 				$row_random = Database :: fetch_array($rs_random);
 				if ($row_random['random'] > 0) {
-					echo $row_random['random'] . ' ' . strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
+					echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
 				} else {
 					//show results student
-					echo $rowi . ' ' . strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
+					echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
 				}
 ?> </td>
   <td align="center"><?php
@@ -1085,21 +1085,21 @@ if ($show == 'test') {
 	   <td><?php echo ($ind+($page*$limitExPage)).'.'; ?></td>
        <td><a href="showinframes.php?file=<?php echo $path?>&cid=<?php echo $_course['official_code'];?>&uid=<?php echo $_user['user_id'];?>" <?php if(!$active) echo 'class="invisible"'; ?>><?php echo $title?></a></td>    
   <td></td>
-      <td><a href="adminhp.php?hotpotatoesName=<?php echo $path; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" /></a>
-       <img src="../img/wizard_gray_small.gif" border="0" title="<?php echo htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" />
-  <a href="<?php echo $exercicePath; ?>?hpchoice=delete&amp;file=<?php echo $path; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('AreYouSure'),ENT_QUOTES,$charset).$title."?"); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
+      <td><a href="adminhp.php?hotpotatoesName=<?php echo $path; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" /></a>
+       <img src="../img/wizard_gray_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" />
+  <a href="<?php echo $exercicePath; ?>?hpchoice=delete&amp;file=<?php echo $path; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSure'),ENT_QUOTES,$charset).$title."?"); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
     <?php
 
 					// if active
 					if ($active) {
 						$nbrActiveTests = $nbrActiveTests +1;
 ?>
-      <a href="<?php echo $exercicePath; ?>?hpchoice=disable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/visible.gif" border="0" alt="<?php echo htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
+      <a href="<?php echo $exercicePath; ?>?hpchoice=disable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/visible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
     <?php
 
 					} else { // else if not active
 ?>
-    <a href="<?php echo $exercicePath; ?>?hpchoice=enable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/invisible.gif" border="0" alt="<?php echo htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
+    <a href="<?php echo $exercicePath; ?>?hpchoice=enable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/invisible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
     <?php
 
 					}
@@ -1117,7 +1117,7 @@ if ($show == 'test') {
         <td><?php echo ($ind+($page*$limitExPage)).'.'; ?><!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>
        <td>&nbsp;</td>
         <td><a href="showinframes.php?<?php echo api_get_cidreq()."&amp;file=".$path."&amp;cid=".$_course['official_code']."&amp;uid=".$_user['user_id'].'"'; if(!$active) echo 'class="invisible"'; ?>"><?php echo $title;?></a></td>
-		<td>&nbsp;</td><td>&nbsp;</td>float_format
+		<td>&nbsp;</td><td>&nbsp;</td>
   </tr>
   <?php
 
@@ -1389,4 +1389,4 @@ if ($origin != 'learnpath') { //so we are not in learnpath tool
 	<link rel="stylesheet" type="text/css" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" />
 	<?php
 }
-?>
+?>

+ 6 - 6
main/exercice/exercise.lib.php

@@ -1,4 +1,4 @@
-<?php // $Id: exercise.lib.php 20411 2009-05-08 15:57:21Z juliomontoya $
+<?php // $Id: exercise.lib.php 20451 2009-05-10 12:02:22Z ivantcholakov $
  
 /*
 ==============================================================================
@@ -29,7 +29,7 @@
 * 	shows a question and its answers
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert <oli.brouckaert@skynet.be>
-* 	@version $Id: exercise.lib.php 20411 2009-05-08 15:57:21Z juliomontoya $
+* 	@version $Id: exercise.lib.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 /**
@@ -144,11 +144,11 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 		
 				// because [] is parsed here we follow this procedure:
 				// 1. find everything between the [tex] and [/tex] tags
-				$startlocations=strpos($answer,'[tex]');
-				$endlocations=strpos($answer,'[/tex]');
+				$startlocations=api_strpos($answer,'[tex]');
+				$endlocations=api_strpos($answer,'[/tex]');
 
 				if($startlocations !== false && $endlocations !== false) {
-					$texstring=substr($answer,$startlocations,$endlocations-$startlocations+6);
+					$texstring=api_substr($answer,$startlocations,$endlocations-$startlocations+6);
 				// 2. replace this by {texcode}
 					$answer=str_replace($texstring,'{texcode}',$answer);
 				}
@@ -157,7 +157,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 				// replaces [blank] by an input field			
 				
 				//getting the matches				
-				$answer=ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10">',($answer));
+				$answer=api_ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10">',($answer));
 				
 				// Change input size 
 				/*

+ 11 - 9
main/exercice/exercise_result.class.php

@@ -222,6 +222,7 @@ class ExerciseResult
 	 */
 	public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields)
 	{
+		global $charset;
 		$this->_getExercisesReporting($document_path,$user_id);
 		$filename = 'exercise_results_'.date('YmdGis').'.csv';
 		if(!empty($user_id))
@@ -242,7 +243,7 @@ class ExerciseResult
 			$num = count($extra_user_fields);
 			foreach($extra_user_fields as $field)
 			{
-				$data .= '"'.str_replace("\r\n",'  ',html_entity_decode(strip_tags($field[3]))).'";';
+				$data .= '"'.str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";';
 			}
 			$display_extra_user_fields = true;
 		}
@@ -256,7 +257,7 @@ class ExerciseResult
 		{
 			if(!empty($row['user']))
 			{
-				$data .= str_replace("\r\n",'  ',html_entity_decode(strip_tags($row['user']))).';';
+				$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['user']), ENT_QUOTES, $charset)).';';
 			}
 			if($export_user_fields)
 			{
@@ -264,10 +265,10 @@ class ExerciseResult
 				$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
 				foreach($user_fields_values as $value)
 				{
-					$data .= '"'.str_replace('"','""',html_entity_decode(strip_tags($value))).'";';
+					$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
 				}
 			}
-			$data .= str_replace("\r\n",'  ',html_entity_decode(strip_tags($row['title']))).';';
+			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
 			$data .= str_replace("\r\n",'  ',$row['time']).';';
 			$data .= str_replace("\r\n",'  ',$row['result']).';';
 			$data .= str_replace("\r\n",'  ',$row['max']).';';
@@ -303,6 +304,7 @@ class ExerciseResult
 	 */
 	public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields)
 	{
+		global $charset;
 		$this->_getExercisesReporting($document_path,$user_id);
 		$filename = 'exercise_results_'.date('YmdGis').'.xls';
 		if(!empty($user_id))
@@ -327,7 +329,7 @@ class ExerciseResult
 			//show the fields names for user fields
 			foreach($extra_user_fields as $field)
 			{
-				$worksheet->write($line,$column,html_entity_decode(strip_tags($field[3])));
+				$worksheet->write($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
 				$column++;
 			}
 		}
@@ -345,17 +347,17 @@ class ExerciseResult
 			$column = 0;
 			if(!empty($row['user']))
 			{
-				$worksheet->write($line,$column,html_entity_decode(strip_tags($row['user'])));
+				$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['user']), ENT_QUOTES, $charset));
 				$column++;
 			}
 			//show user fields data, if any, for this user
 			$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
 			foreach($user_fields_values as $value)
 			{
-				$worksheet->write($line,$column,html_entity_decode(strip_tags($value)));
+				$worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
 				$column++;
 			}
-			$worksheet->write($line,$column,html_entity_decode(strip_tags($row['title'])));
+			$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
 			$column++;
 			$worksheet->write($line,$column,$row['time']);
 			$column++;
@@ -371,4 +373,4 @@ class ExerciseResult
 }
 
 endif;
-?>
+?>

+ 13 - 13
main/exercice/exercise_result.php

@@ -29,7 +29,7 @@
 *	@author Olivier Brouckaert, main author
 *	@author Roan Embrechts, some refactoring
 * 	@author Julio Montoya Armas switchable fill in blank option added
-* 	@version $Id: exercise_result.php 20357 2009-05-06 03:54:49Z cvargas1 $
+* 	@version $Id: exercise_result.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 *
 *	@todo	split more code up in functions, move functions to library?
 */
@@ -651,12 +651,12 @@ foreach ($questionList as $questionId) {
 
 					// TeX parsing
 					// 1. find everything between the [tex] and [/tex] tags
-					$startlocations=strpos($temp,'[tex]');
-					$endlocations=strpos($temp,'[/tex]');
+					$startlocations=api_strpos($temp,'[tex]');
+					$endlocations=api_strpos($temp,'[/tex]');
 
 					if($startlocations !== false && $endlocations !== false)
 					{
-						$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
+						$texstring=api_substr($temp,$startlocations,$endlocations-$startlocations+6);
 						// 2. replace this by {texcode}
 						$temp=str_replace($texstring,'{texcode}',$temp);
 					}
@@ -672,7 +672,7 @@ foreach ($questionList as $questionId) {
 					while(1)
 					{
 						// quits the loop if there are no more blanks (detect '[')
-						if(($pos = strpos($temp,'[')) === false)
+						if(($pos = api_strpos($temp,'[')) === false)
 						{
 							// adds the end of the text
 							$answer=$temp;
@@ -684,23 +684,23 @@ foreach ($questionList as $questionId) {
 						}
 						// adds the piece of text that is before the blank 
                         //and ends with '[' into a general storage array
-                        $real_text[]=substr($temp,0,$pos+1);
-						$answer.=substr($temp,0,$pos+1);
+                        $real_text[]=api_substr($temp,0,$pos+1);
+						$answer.=api_substr($temp,0,$pos+1);
 						//take the string remaining (after the last "[" we found)
-						$temp=substr($temp,$pos+1);
+						$temp=api_substr($temp,$pos+1);
 						// quit the loop if there are no more blanks, and update $pos to the position of next ']'
-						if(($pos = strpos($temp,']')) === false)
+						if(($pos = api_strpos($temp,']')) === false)
 						{
 							// adds the end of the text
 							$answer.=$temp;
 							break;
 						}
 						$choice[$j]=trim($choice[$j]);
-						$user_tags[]=stripslashes(strtolower($choice[$j]));
+						$user_tags[]=stripslashes(api_strtolower($choice[$j]));
 						//put the contents of the [] answer tag into correct_tags[]
-                        $correct_tags[]=strtolower(substr($temp,0,$pos));
+                        $correct_tags[]=api_strtolower(api_substr($temp,0,$pos));
 						$j++;
-						$temp=substr($temp,$pos+1);
+						$temp=api_substr($temp,$pos+1);
                         //$answer .= ']';
 					}
 														
@@ -1166,4 +1166,4 @@ if(count($arrques)>0) {
 		}	
 	api_mail_html($student_name, $to, $subject, $mail_content, $from_name, $from, array('encoding'=>$mycharset,'charset'=>$mycharset));
 }
-?>
+?>

+ 18 - 18
main/exercice/exercise_show.php

@@ -4,7 +4,7 @@
 *
 *	@package dokeos.exercise
 * 	@author Julio Montoya Armas Added switchable fill in blank option added
-* 	@version $Id: exercise_show.php 20391 2009-05-07 17:02:18Z iflorespaz $
+* 	@version $Id: exercise_show.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 *
 * 	@todo remove the debug code and use the general debug library
 * 	@todo use the Database:: functions
@@ -641,10 +641,10 @@ if ($show_results) {
 		
 				// TeX parsing
 				// 1. find everything between the [tex] and [/tex] tags
-				$startlocations=strpos($temp,'[tex]');
-				$endlocations=strpos($temp,'[/tex]');
+				$startlocations=api_strpos($temp,'[tex]');
+				$endlocations=api_strpos($temp,'[/tex]');
 				if ($startlocations !== false && $endlocations !== false) {
-					$texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
+					$texstring=api_substr($temp,$startlocations,$endlocations-$startlocations+6);
 					// 2. replace this by {texcode}
 					$temp=str_replace($texstring,'{texcode}',$temp);
 				}
@@ -655,16 +655,16 @@ if ($show_results) {
 				if (!$switchable_answer_set) {
 					while (1) {
 						// quits the loop if there are no more blanks
-						if (($pos = strpos($temp,'[')) === false) {
+						if (($pos = api_strpos($temp,'[')) === false) {
 							// adds the end of the text
 							$answer.=$temp;				
 							// TeX parsing
 							$texstring = api_parse_tex($texstring);
 							break;
 						}
-					    $temp=substr($temp,$pos+1);
+					    $temp=api_substr($temp,$pos+1);
 						// quits the loop if there are no more blanks
-						if (($pos = strpos($temp,']')) === false) {
+						if (($pos = api_strpos($temp,']')) === false) {
 							break;
 						}
 						
@@ -676,7 +676,7 @@ if ($show_results) {
 						$choice = $arr[1];
 						$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]))) {
+						if (api_strtolower(api_substr($temp,0,$pos)) == stripslashes(api_strtolower($choice[$j]))) {
 							// gives the related weighting to the student
 							$questionScore+=$answerWeighting[$j];
 							// increments total score
@@ -684,7 +684,7 @@ if ($show_results) {
 						}
 						// else if the word entered by the student IS NOT the same as the one defined by the professor
 						$j++;
-						$temp=substr($temp,$pos+1);
+						$temp=api_substr($temp,$pos+1);
 						$i=$i+1;
 					}
 					$answer = $str;
@@ -692,7 +692,7 @@ if ($show_results) {
 					//multiple fill in blank	
 					while (1) {
 						// quits the loop if there are no more blanks
-						if (($pos = strpos($temp,'[')) === false) {
+						if (($pos = api_strpos($temp,'[')) === false) {
 							// adds the end of the text
 							$answer.=$temp;
 							// TeX parsing
@@ -701,12 +701,12 @@ if ($show_results) {
 							break;
 						}
 						// adds the piece of text that is before the blank and ended by [
-						$real_text[]=substr($temp,0,$pos+1);
-						$answer.=substr($temp,0,$pos+1);					
-						$temp=substr($temp,$pos+1);
+						$real_text[]=api_substr($temp,0,$pos+1);
+						$answer.=api_substr($temp,0,$pos+1);					
+						$temp=api_substr($temp,$pos+1);
 
 						// quits the loop if there are no more blanks
-						if (($pos = strpos($temp,']')) === false) {
+						if (($pos = api_strpos($temp,']')) === false) {
 							// adds the end of the text
 							//$answer.=$temp;
 							break;
@@ -719,11 +719,11 @@ if ($show_results) {
 						$choice = $arr[1];
 						
 						$choice[$j]=trim($choice[$j]);					
-						$user_tags[]=stripslashes(strtolower($choice[$j]));
-						$correct_tags[]=strtolower(substr($temp,0,$pos));	
+						$user_tags[]=stripslashes(api_strtolower($choice[$j]));
+						$correct_tags[]=api_strtolower(api_substr($temp,0,$pos));	
 						
 						$j++;
-						$temp=substr($temp,$pos+1);
+						$temp=api_substr($temp,$pos+1);
 						$i=$i+1;
 					}
 					$answer='';
@@ -1067,4 +1067,4 @@ api_session_unregister('questionList');
 unset ($questionList);
 
 api_session_unregister('exerciseResult');
-unset ($exerciseResult);
+unset ($exerciseResult);

+ 8 - 8
main/exercice/export/qti2/qti2_classes.php

@@ -174,8 +174,8 @@ class ImsAnswerFillInBlanks extends Answer
 	                {
 	                	$key = $answer['id'];
 	                	$answer = $answer['answer'];
-	                	$len = strlen($answer);
-	                    $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.strlen($answer).'"/>', $text);
+	                	$len = api_strlen($answer);
+	                    $text = str_replace('['.$answer.']','<textEntryInteraction responseIdentifier="fill_'.$key.'" expectedLength="'.api_strlen($answer).'"/>', $text);
 	                }
 				}
                 $out = $text;
@@ -394,7 +394,7 @@ class ImsAnswerHotspot extends Answer
 	        {
 	        	$key = $answer['id'];
 	        	$answerTxt = $answer['answer'];
-	        	$len = strlen($answerTxt);
+	        	$len = api_strlen($answerTxt);
 	        	//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
 	        	$coords = '';
 	        	$type = 'default';
@@ -414,10 +414,10 @@ class ImsAnswerHotspot extends Answer
 	        		case 'poly':
 	        			$type = 'poly';
 						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
-	        			break;
-	        		 case 'delineation' :
-	        			$type = 'delineation';
-						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
+	        			break;
+	        		 case 'delineation' :
+	        			$type = 'delineation';
+						$coords = str_replace(array(';','|'),array(',',','),$answer['hotspot_coord']);
 	        			break;
 	        	}
 	            $text .= '        <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
@@ -477,4 +477,4 @@ class ImsAnswerFree extends Answer
     	return '';
     }
 }
-?>
+?>

+ 10 - 10
main/exercice/export/scorm/scorm_classes.php

@@ -325,18 +325,18 @@ class ScormAnswerFillInBlanks extends Answer
 		$jstmpc = '';
 		$jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
 		$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
-		$startlocations=strpos($answer,'[');
-		$endlocations=strpos($answer,']');
+		$startlocations=api_strpos($answer,'[');
+		$endlocations=api_strpos($answer,']');
 		while($startlocations !== false && $endlocations !== false)
 		{
-			$texstring=substr($answer,$startlocations,($endlocations-$startlocations)+1);
-			$answer = substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1);
+			$texstring=api_substr($answer,$startlocations,($endlocations-$startlocations)+1);
+			$answer = api_substr_replace($answer,'<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />',$startlocations,($endlocations-$startlocations)+1);
 			$jstmp .= $i.',';
-			$jstmpc .= "'".htmlentities(substr($texstring,1,-1),ENT_QUOTES,$charset)."',";			
+			$jstmpc .= "'".api_htmlentities(api_substr($texstring,1,-1),ENT_QUOTES,$charset)."',";			
 	    	$jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weights[$i-1].";\n";
 			$i++;
-			$startlocations=strpos($answer,'[');
-			$endlocations=strpos($answer,']');
+			$startlocations=api_strpos($answer,'[');
+			$endlocations=api_strpos($answer,']');
 		}
 
 		$html .= 	'<tr>' . "\n" 
@@ -345,8 +345,8 @@ class ScormAnswerFillInBlanks extends Answer
 	    		.	'</td>' . "\n"
 	    		.	'</tr>' . "\n";
 		$html .= '</table></td></tr>' . "\n";
-		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n";
-    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n";
+		$js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n";
+    	$js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n";
     	$js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n";
     	$js .= $jstmpw;
         return array($js,$html);
@@ -719,4 +719,4 @@ class ScormAnswerHotspot extends Answer
         return array($js,$html);
     }
 }
-?>
+?>

+ 4 - 2
main/exercice/fill_blanks.class.php

@@ -182,9 +182,11 @@ class FillBlanks extends Question
 	 */
 	function processAnswersCreation($form) 
 	{
+		global $charset;
+
 		$answer = $form -> getSubmitValue('answer');
 		//Due the fckeditor transform the elements to their HTML value
-		$answer = html_entity_decode($answer);
+		$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
 
 		//remove the :: eventually written by the user
 		$answer = str_replace('::','',$answer);
@@ -204,7 +206,7 @@ class FillBlanks extends Question
 				$answer .= $form -> getSubmitValue('weighting['.$i.']').',';
 				$this -> weighting += $form -> getSubmitValue('weighting['.$i.']');
 			}
-			$answer = substr($answer,0,-1);
+			$answer = api_substr($answer,0,-1);
 		}
 		$is_multiple = $form -> getSubmitValue('multiple_answer');
 		$answer.='@'.$is_multiple;

+ 4 - 4
main/exercice/hotpotatoes.lib.php

@@ -22,7 +22,7 @@
 *	Code library for HotPotatoes integration.
 *	@package dokeos.exercise
 * 	@author Istvan Mandak
-* 	@version $Id: hotpotatoes.lib.php 20279 2009-05-04 15:55:58Z juliomontoya $
+* 	@version $Id: hotpotatoes.lib.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 
@@ -87,12 +87,12 @@ function GetQuizName($fname,$fpath)
 			$contents = fread($fp, filesize($fpath.$fname));
 			fclose($fp);
 	
-			$contents = strtolower($contents);
+			$contents = api_strtolower($contents);
 	
 			$pattern = array ( 1 => "title>", 2 => "/title>");
 	
-			$s_contents = substr($contents,0,strpos($contents,$pattern["2"])-1);
-			$e_contents = substr($s_contents,strpos($contents,$pattern["1"])+strlen($pattern["1"]),strlen($s_contents));
+			$s_contents = api_substr($contents,0,api_strpos($contents,$pattern["2"])-1);
+			$e_contents = api_substr($s_contents,api_strpos($contents,$pattern["1"])+api_strlen($pattern["1"]),api_strlen($s_contents));
 	
 			$title = $e_contents;
 		} else {

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

@@ -256,56 +256,56 @@ if($modifyAnswers)
 	if(!empty($msgErr))
 	{
 		Display::display_normal_message($msgErr); //main API
-	}
+	}
 	
-?>
-
+?>
+
 <form method="post" action="<?php echo api_get_self(); ?>?hotspotadmin=<?php echo $modifyAnswers; ?>" name="frm_exercise">
-<table border="0" cellpadding="0" cellspacing="2" width="100%">
-
-	<tr>
-		<td colspan="2" valign="bottom">
-			<button type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" ><?php echo get_lang('LessHotspots'); ?></button>
-			<button type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('langMoreHotspotsImage'); ?></button>
+<table border="0" cellpadding="0" cellspacing="2" width="100%">
+
+	<tr>
+		<td colspan="2" valign="bottom">
+			<button type="submit" class="minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" ><?php echo get_lang('LessHotspots'); ?></button>
+			<button type="submit" class="plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('langMoreHotspotsImage'); ?></button>
 			<button type="submit" class="cancel" name="cancelAnswers" value="<?php echo get_lang('Cancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('ConfirmYourChoice'))); ?>')) return false;" ><?php echo get_lang('Cancel'); ?></button>
-			<button type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" /><?php echo get_lang('AddQuestionToExercise'); ?></button>
-		</td>
+			<button type="submit" class="save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" /><?php echo get_lang('AddQuestionToExercise'); ?></button>
+		</td>
 	</tr>
-	<tr>
-		<td valign="top" style="border:1px solid #4271b5;border-top:none;border-bottom:none;border-right:none;" >			
-				<input type="hidden" name="formSent" value="1" />
-				<input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers; ?>" />
-				<table class="data_table">
-					<!--
-					<tr>
-					  <td colspan="5"><?php echo get_lang('AnswerHotspot'); ?> :</td>
-					</tr>
-					-->
-					<tr>
-					  <th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
-					  <th ><?php echo get_lang('HotspotDescription'); ?>*</th>
-					  <th ><?php echo get_lang('Comment'); ?></th>
-					  <th><?php echo get_lang('QuestionWeighting'); ?>*</th>
-					</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="45" /></td>
-					  <td align="left"><textarea wrap="virtual" rows="1" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo stripslashes(htmlentities($comment[$i])); ?></textarea></td>
-					  <td valign="top"><input type="text" name="weighting[<?php echo $i; ?>]" size="5" value="<?php echo (isset($weighting[$i]) ? float_format($weighting[$i],1) : 10); ?>" />
-					  <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
-					  			}
-					?>
-
-				</table>
-		</td>	
+	<tr>
+		<td valign="top" style="border:1px solid #4271b5;border-top:none;border-bottom:none;border-right:none;" >			
+				<input type="hidden" name="formSent" value="1" />
+				<input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers; ?>" />
+				<table class="data_table">
+					<!--
+					<tr>
+					  <td colspan="5"><?php echo get_lang('AnswerHotspot'); ?> :</td>
+					</tr>
+					-->
+					<tr>
+					  <th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
+					  <th ><?php echo get_lang('HotspotDescription'); ?>*</th>
+					  <th ><?php echo get_lang('Comment'); ?></th>
+					  <th><?php echo get_lang('QuestionWeighting'); ?>*</th>
+					</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 api_htmlentities($reponse[$i], ENT_QUOTES, api_get_system_encoding()); ?>" size="45" /></td>
+					  <td align="left"><textarea wrap="virtual" rows="1" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo stripslashes(api_htmlentities($comment[$i], ENT_QUOTES, api_get_system_encoding())); ?></textarea></td>
+					  <td valign="top"><input type="text" name="weighting[<?php echo $i; ?>]" size="5" value="<?php echo (isset($weighting[$i]) ? float_format($weighting[$i],1) : 10); ?>" />
+					  <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
+					  			}
+					?>
+
+				</table>
+		</td>	
 	</tr>
 	<tr>
 		<td colspan="2" valign="top" style="border:1px solid #ccc;border-top:none">

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

@@ -15,8 +15,8 @@ include('../inc/global.inc.php');
 
 // set vars
 $userId        = $_user['user_id'];
-$questionId    = $_GET['modifyAnswers'];
-$exe_id    = $_GET['exe_id'];
+$questionId    = $_GET['modifyAnswers'];
+$exe_id    = $_GET['exe_id'];
 $from_db = isset($_GET['from_db']) ? $_GET['from_db'] : 0;
 $objQuestion = Question :: read($questionId);
 $TBL_ANSWERS   = Database::get_course_table(TABLE_QUIZ_ANSWER);
@@ -33,7 +33,7 @@ $courseCode = $_course['sysCode'];
 $coursePath = $_course['path'];
 
 // Query db for answers
-$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
+$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
 $result = api_sql_query($sql,__FILE__,__LINE__);
 
 // Init
@@ -59,12 +59,12 @@ while ($hotspot = mysql_fetch_array($result))
 	if ($hotspot['hotspot_type'] == 'poly')
 	{
 		$output .= "&hotspot_".$hotspot['id']."_type=poly";
-	}
-	
-	// Delineation
-	if ($hotspot['hotspot_type'] == 'delineation')
-	{
-		$output .= "&hotspot_".$hotspot['id']."_type=delineation";
+	}
+	
+	// Delineation
+	if ($hotspot['hotspot_type'] == 'delineation')
+	{
+		$output .= "&hotspot_".$hotspot['id']."_type=delineation";
 	}
 
 	$output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
@@ -93,7 +93,7 @@ if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
 	$sql = 'SELECT hotspot_coordinate '.
 			' FROM '.$tbl_track_e_hotspot.
 			' WHERE hotspot_question_id = '.intval($questionId).
-			' AND hotspot_course_code = "'.Database::escape_string($course_code).'"'.
+			' AND hotspot_course_code = "'.Database::escape_string($course_code).'"'.
 			' AND hotspot_exe_id='.intval($exe_id);
 	$rs = @api_sql_query($sql); // don't output error because we are in Flash execution.
 	while($row = Database :: fetch_array($rs)) {
@@ -101,9 +101,9 @@ if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
 	}
 }
 
-$output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
+$output .= "&p_hotspot_answers=".api_substr($output2,0,-1)."&done=done";
 
 $explode = explode('&', $output);
 
 echo $output;
-?>
+?>

+ 2 - 2
main/exercice/hotspot_save.inc.php

@@ -42,9 +42,9 @@ if ($_GET['type'] == "poly" || $_GET['type'] == "delineation")
 		$hotspot_coordinates .= $coord.$delimiter;
 		$i++;
 	}
-	$hotspot_coordinates = substr($hotspot_coordinates,0,-2);
+	$hotspot_coordinates = api_substr($hotspot_coordinates,0,-2);
 }
 $sql = "UPDATE `$TBL_ANSWER` SET hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',hotspot_type = '".Database::escape_string($hotspot_type)."' WHERE id = '".Database::escape_string($answerId)."' AND question_id ='".Database::escape_string($questionId)."' LIMIT 1 ;";
 $result = api_sql_query($sql,__FILE__,__LINE__);
 echo "done=done";
-?>
+?>

+ 2 - 2
main/exercice/hotspot_savescore.inc.php

@@ -29,7 +29,7 @@ if ($_GET['answerId'] == "0") // click is NOT on a hotspot
 else // user clicked ON a hotspot
 {
 	$hit = 1;
-	$answerId = substr($_GET['answerId'],22,2);
+	$answerId = api_substr($_GET['answerId'],22,2);
 	// Save into session
 	$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
 }
@@ -56,4 +56,4 @@ $result = api_sql_query($sql,__FILE__,__LINE__);
 // Save insert id into session if users changes answer.
 $insert_id = mysql_insert_id();
 $_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
-?>
+?>

+ 5 - 5
main/exercice/question_pool.php

@@ -1,4 +1,4 @@
-<?php // $Id: question_pool.php 20089 2009-04-24 21:12:54Z cvargas1 $
+<?php // $Id: question_pool.php 20451 2009-05-10 12:02:22Z ivantcholakov $
  
 /*
 ==============================================================================
@@ -30,7 +30,7 @@
 * 	One question can be in several exercises
 *	@package dokeos.exercise
 * 	@author Olivier Brouckaert
-* 	@version $Id: question_pool.php 20089 2009-04-24 21:12:54Z cvargas1 $
+* 	@version $Id: question_pool.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 // name of the language file that needs to be included
@@ -371,8 +371,8 @@ if($is_allowedToEdit)
                 echo '<a href="admin.php?'.api_get_cidreq().'&amp;editQuestion=',$row['id'],'"><img src="../img/edit.gif" border="0" alt="',get_lang('Modify'),'"></a>',
                     '</td>',
                     '<td align="center">',
-                    '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
-                    //'<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
+                    '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
+                    //'<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
 			} else {
                 //echo $row['level'],'</td>',
 //					'<td><a href="',api_get_self(),'?',api_get_cidreq(),'&recup=',$row['id'],'&fromExercise=',$fromExercise,'"><img src="../img/view_more_stats.gif" border="0" alt="',get_lang('Reuse'),'"></a>';
@@ -404,4 +404,4 @@ if($is_allowedToEdit)
 	api_not_allowed(true);
 }
 
-?>
+?>

+ 2 - 2
main/exercice/testheaderpage.php

@@ -22,7 +22,7 @@
 *	Code library for HotPotatoes integration.
 *	@package dokeos.exercise
 * 	@author Istvan Mandak
-* 	@version $Id: testheaderpage.php 20279 2009-05-04 15:55:58Z juliomontoya $
+* 	@version $Id: testheaderpage.php 20451 2009-05-10 12:02:22Z ivantcholakov $
 */
 
 // name of the language file that needs to be included
@@ -52,4 +52,4 @@ include('../inc/global.inc.php');
 	$interbreadcrumb[]= array ("url"=>"./exercice.php", "name"=> get_lang('Exercices'));
 	Display::display_header($nameTools,"Exercise");
 	echo "<a name='TOP'></a>";
-?>
+?>