Browse Source

Fix problem with matching questions - see BT#914

Yannick Warnier 15 years ago
parent
commit
ab2cbd2fb2
2 changed files with 207 additions and 183 deletions
  1. 2 0
      documentation/changelog.html
  2. 205 183
      main/exercice/exercise.lib.php

+ 2 - 0
documentation/changelog.html

@@ -74,6 +74,8 @@
   <li>Fixed minor bug in online mail editor in order to show the sender's name and e-mail</li>
   <li>Fixed minor bug in online mail editor in order to show the sender's name and e-mail</li>
   <li>Fixed bug that prevented importing SCORM resource from course archives (Bug #872)</li>
   <li>Fixed bug that prevented importing SCORM resource from course archives (Bug #872)</li>
   <li>Fixed bug that prevented proper tests importing from course zip-archives created on systems prior to Chamilo 1.8.6.2 (Bug #879)</li>
   <li>Fixed bug that prevented proper tests importing from course zip-archives created on systems prior to Chamilo 1.8.6.2 (Bug #879)</li>
+  <li>Fixed graphical bug preventing the use of matching-type exercises (thanks to USIL team - BT#914)</li>
+  <li>Added hidden debugging feature that marks all right answers (for matching, multiple and single choice questions) (private BT#914)</li>
 </ul>
 </ul>
 <h3>CSS changes</h3>
 <h3>CSS changes</h3>
 <ul>
 <ul>

+ 205 - 183
main/exercice/exercise.lib.php

@@ -19,15 +19,16 @@ require_once '../inc/lib/fckeditor/fckeditor.php';
  * @param int current item from the list of questions
  * @param int current item from the list of questions
  * @param int number of total questions
  * @param int number of total questions
  * */
  * */
-function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_item, $total_item)
-{
+function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_item, $total_item) {
+	//change false to true in the following line to enable answer hinting
+	$debug_mark_answer = api_is_allowed_to_edit() && false;
 	if (!ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) {
 	if (!ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) {
 		//echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript"></script>';
 		//echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript"></script>';
 		//echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.corners.min.js" type="text/javascript"></script>';
 		//echo '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.corners.min.js" type="text/javascript"></script>';
 	}
 	}
 	
 	
 	// reads question informations
 	// reads question informations
-	if(!$objQuestionTmp = Question::read($questionId)) {
+	if (!$objQuestionTmp = Question::read($questionId)) {
 		// question not found
 		// question not found
 		return false;
 		return false;
 	}
 	}
@@ -37,7 +38,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 
 
 	if ($answerType != HOT_SPOT) {
 	if ($answerType != HOT_SPOT) {
 		// Question is not of type hotspot
 		// Question is not of type hotspot
-		if(!$onlyAnswers) {
+		if (!$onlyAnswers) {
 			$questionName=$objQuestionTmp->selectTitle();
 			$questionName=$objQuestionTmp->selectTitle();
 			$questionDescription=$objQuestionTmp->selectDescription();
 			$questionDescription=$objQuestionTmp->selectDescription();
 
 
@@ -61,57 +62,61 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 			$s.=$questionDescription;
 			$s.=$questionDescription;
 			$s.="</td></tr></table>";
 			$s.="</td></tr></table>";
 
 
-			if(!empty($pictureName))
-			{
+			if (!empty($pictureName)) {
 				$s.="
 				$s.="
 				<tr>
 				<tr>
 				  <td align='center' colspan='2'><img src='../document/download.php?doc_url=%2Fimages%2F'".$pictureName."' border='0'></td>
 				  <td align='center' colspan='2'><img src='../document/download.php?doc_url=%2Fimages%2F'".$pictureName."' border='0'></td>
 				</tr>";
 				</tr>";
 			}
 			}
-
 		}
 		}
 		$s.= '</table>';
 		$s.= '</table>';
 		if (!ereg("MSIE",$_SERVER["HTTP_USER_AGENT"])) {
 		if (!ereg("MSIE",$_SERVER["HTTP_USER_AGENT"])) {
-			$s.="<div class=\"rounded exercise_questions\" style=\"width: 720px; padding: 3px; background-color:#ccc;\">";
+			$s .= '<div class="rounded exercise_questions" style="width: 720px; padding: 3px;">';
 		} else {
 		} else {
 			$option_ie="margin-left:10px";
 			$option_ie="margin-left:10px";
 		}
 		}
-		$s.="<table width=\"720\" class='exercise_options' style=\"width: 720px;$option_ie background-color:#fff;\">";
-		// construction of the Answer object
+		$s .= '<table width="720" class="exercise_options" style="width: 720px;$option_ie background-color:#fff;\">';
+		// construction of the Answer object (also gets all answers details)
 		$objAnswerTmp=new Answer($questionId);
 		$objAnswerTmp=new Answer($questionId);
-
 		$nbrAnswers=$objAnswerTmp->selectNbrAnswers(); 
 		$nbrAnswers=$objAnswerTmp->selectNbrAnswers(); 
 
 
-		// only used for the answer type "Matching"
-		if($answerType == MATCHING)
-		{
-			$x = 1;
-			$letter = 'A';
-			$cpt2=1;
-			$Select=array();
-			$answer_matching = $cpt1 = array();		
-
-			for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
+		// For "matching" type here, we need something a little bit special
+		// because the match between the suggestions and the answers cannot be
+		// done easily (suggestions and answers are in the same table), so we
+		// have to go through answers first (elems with "correct" value to 0).
+        $select_items = array();
+        //This will contain the number of answers on the left side. We call them
+        // suggestions here, for the sake of comprehensions, while the ones
+        // on the right side are called answers
+        $num_suggestions = 0;
+        
+		if ($answerType == MATCHING) {
+			$x = 1; //iterate through answers
+			$letter = 'A'; //mark letters for each answer
+			$answer_matching = $cpt1 = array();
+			$answer_suggestions = $nbrAnswers;
+
+			for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
 				$answerCorrect = $objAnswerTmp->isCorrect($answerId);
 				$answerCorrect = $objAnswerTmp->isCorrect($answerId);
 				$numAnswer = $objAnswerTmp->selectAutoId($answerId);
 				$numAnswer = $objAnswerTmp->selectAutoId($answerId);
 				$answer=$objAnswerTmp->selectAnswer($answerId);
 				$answer=$objAnswerTmp->selectAnswer($answerId);
-				if(!$answerCorrect) {
+				if ($answerCorrect==0) {
 					// options (A, B, C, ...) that will be put into the list-box
 					// options (A, B, C, ...) that will be put into the list-box
+					// have the "correct" field set to 0 because they are answer
 					$cpt1[$x] = $letter;
 					$cpt1[$x] = $letter;
 					$answer_matching[$x]=$objAnswerTmp->selectAnswerByAutoId($numAnswer);
 					$answer_matching[$x]=$objAnswerTmp->selectAnswerByAutoId($numAnswer);
-					$x++;
-					$letter++;						
+					$x++; $letter++;
 				}
 				}
 			}
 			}
-			
-			foreach($answer_matching as $value) {				
-				$Select[$value['id']]['Lettre'] =  $cpt1[$value['id']];
-				$Select[$value['id']]['Reponse'] = $value['answer'];
+			$i = 1;
+			foreach ($answer_matching as $id => $value) {
+                $select_items[$i]['id'] =  $value['id'];
+				$select_items[$i]['letter'] =  $cpt1[$id];
+				$select_items[$i]['answer'] = $value['answer'];
+				$i ++;
 			}
 			}
-					
-		}
-		elseif($answerType == FREE_ANSWER)
-		{
+			$num_suggestions = ($nbrAnswers - $x) + 1;
+		} elseif ($answerType == FREE_ANSWER) {
 	        #$comment = $objAnswerTmp->selectComment(1);
 	        #$comment = $objAnswerTmp->selectComment(1);
 	        //
 	        //
 
 
@@ -122,35 +127,38 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 			$oFCKeditor->Height = '200';
 			$oFCKeditor->Height = '200';
 			$oFCKeditor->Value	= '' ;
 			$oFCKeditor->Value	= '' ;
 
 
-			$s .= "<tr><td colspan='2'>".$oFCKeditor->CreateHtml()."</td></tr>";
+			$s .= '<tr><td colspan="3">'.$oFCKeditor->CreateHtml()."</td></tr>";
 			//$s.="<tr><td colspan='2'><textarea cols='80' rows='10' name='choice[".$questionId."]'>$answer</textarea></td></tr>";
 			//$s.="<tr><td colspan='2'><textarea cols='80' rows='10' name='choice[".$questionId."]'>$answer</textarea></td></tr>";
 
 
 		}
 		}
 
 
-		for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
-			$answer=$objAnswerTmp->selectAnswer($answerId);
-			$answerCorrect=$objAnswerTmp->isCorrect($answerId);
-			$numAnswer=$objAnswerTmp->selectAutoId($answerId);
-			if($answerType == FILL_IN_BLANKS) {
+		// Now navigate through the possible answers, using the max number of
+		// answers for the question as a limiter
+        $lines_count=1; // a counter for matching-type answers
+        for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
+			$answer          = $objAnswerTmp->selectAnswer($answerId);
+			$answerCorrect   = $objAnswerTmp->isCorrect($answerId);
+			$numAnswer       = $objAnswerTmp->selectAutoId($answerId);
+			if ($answerType == FILL_IN_BLANKS) {
 				// splits text and weightings that are joined with the character '::'
 				// splits text and weightings that are joined with the character '::'
-				list($answer)=explode('::',$answer);
+				list($answer) = explode('::',$answer);
 
 
 				// because [] is parsed here we follow this procedure:
 				// because [] is parsed here we follow this procedure:
 				// 1. find everything between the [tex] and [/tex] tags
 				// 1. find everything between the [tex] and [/tex] tags
-				$startlocations=api_strpos($answer,'[tex]');
-				$endlocations=api_strpos($answer,'[/tex]');
+				$startlocations = api_strpos($answer,'[tex]');
+				$endlocations = api_strpos($answer,'[/tex]');
 
 
-				if($startlocations !== false && $endlocations !== false) {
-					$texstring=api_substr($answer,$startlocations,$endlocations-$startlocations+6);
+				if ($startlocations !== false && $endlocations !== false) {
+					$texstring = api_substr($answer,$startlocations,$endlocations-$startlocations+6);
 				// 2. replace this by {texcode}
 				// 2. replace this by {texcode}
-					$answer=str_replace($texstring,'{texcode}',$answer);
+					$answer = str_replace($texstring,'{texcode}',$answer);
 				}
 				}
 
 
 				// 3. do the normal matching parsing
 				// 3. do the normal matching parsing
 				// replaces [blank] by an input field
 				// replaces [blank] by an input field
 
 
 				//getting the matches
 				//getting the matches
-				$answer=api_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
 				// Change input size
 				/*
 				/*
@@ -199,104 +207,126 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 
 
 			}
 			}
 			// unique answer
 			// unique answer
-			if($answerType == UNIQUE_ANSWER) {
-				$s.="<input type='hidden' name='choice2[".$questionId."]' value='0'>
+			if ($answerType == UNIQUE_ANSWER) {
+                // set $debug_mark_answer to true at function start to
+                // show the correct answer with a suffix '-x'
+                $help = $selected = '';
+                if ($debug_mark_answer==true) {
+                   if ($answerCorrect) {
+                     $help = 'x-';
+                     $selected = 'checked="checked"';
+                   }
+                }
+				$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0">
 				<tr>
 				<tr>
-				 <td>
-				 	<div class='u-m-answer'>
-					<p style='float:left; padding-right:4px;'>
-					<span><input class='checkbox' type='radio' name='choice[".$questionId."]' value='".$numAnswer."'></p></span>";
-                    $answer=api_parse_tex($answer);
-                    $s.=Security::remove_XSS($answer, STUDENT);                    
-                    $s.="</div></td></tr>";
-
-			} elseif($answerType == MULTIPLE_ANSWER) {
+				 <td colspan="3">
+				 	<div class="u-m-answer">
+					<p style="float:left; padding-right:4px;">
+					<span><input class="checkbox" type="radio" name="choice['.$questionId.']" value="'.$numAnswer.'" '.$selected.'></p></span>';
+                    $answer = api_parse_tex($answer);
+                    $s .= Security::remove_XSS($answer, STUDENT);                    
+                    $s .= '</div></td></tr>';
+
+			} elseif ($answerType == MULTIPLE_ANSWER) {
 			// multiple answers
 			// multiple answers
-				$s.="<input type='hidden' name='choice2[".$questionId."]' value='0'>
+                // set $debug_mark_answer to true at function start to
+                // show the correct answer with a suffix '-x'
+				$help = $selected = '';
+                if ($debug_mark_answer==true) {
+                   if ($answerCorrect) {
+                     $help = 'x-';
+                     $selected = 'checked="checked"';
+                   }
+                }
+				$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0">
 				<tr>
 				<tr>
-				  <td>
-					 <div class='u-m-answer'>
-					 <p style='float:left; padding-right:4px;'>
-					 <span><input class='checkbox' type='checkbox' name='choice[".$questionId."][".$numAnswer."]' value='1'></p></span>";
+				  <td colspan="3">
+					 <div class="u-m-answer">
+					 <p style="float:left; padding-right:4px;">
+					 <span><input class="checkbox" type="checkbox" name="choice['.$questionId.']['.$numAnswer.']" value="1" '.$selected.'></p></span>';
 				$answer = api_parse_tex($answer);
 				$answer = api_parse_tex($answer);
-				$s.=Security::remove_XSS($answer, STUDENT);
-				$s.="</div></td></tr>";			
+				$s .= Security::remove_XSS($answer, STUDENT);
+				$s .= '</div></td></tr>';			
 				
 				
-			} elseif($answerType == MULTIPLE_ANSWER_COMBINATION) {
+			} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
 			// multiple answers
 			// multiple answers
-				$s.="<input type='hidden' name='choice2[".$questionId."]' value='0'>
+                // set $debug_mark_answer to true at function start to
+                // show the correct answer with a suffix '-x'
+                $help = $selected = '';
+                if ($debug_mark_answer==true) {
+                   if ($answerCorrect) {
+                     $help = 'x-';
+                     $selected = 'checked="checked"';
+                   }
+                }
+				$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0">
 				<tr>
 				<tr>
-				  <td>
-					 <div class='u-m-answer'>
-					 <p style='float:left; padding-right:4px;'>
-					 <span><input class='checkbox' type='checkbox' name='choice[".$questionId."][".$numAnswer."]' value='1'></p></span>";
+				  <td colspan="3">
+					 <div class="u-m-answer">
+					 <p style="float:left; padding-right:4px;">
+					 <span><input class="checkbox" type="checkbox" name="choice['.$questionId.']['.$numAnswer.']" value="1" '.$selected.'></p></span>';
 				$answer = api_parse_tex($answer);
 				$answer = api_parse_tex($answer);
-				$s.=Security::remove_XSS($answer, STUDENT);
-				$s.="</div></td></tr>";
-			}
-			// fill in blanks
-			elseif($answerType == FILL_IN_BLANKS) {
-				$s.="<tr><td colspan='2'>$answer</td></tr>";
-			}
-			// free answer
-
-			// matching // TODO: replace $answerId by $numAnswer
-			else {				
-				if ($answerCorrect) {
-					$s.="
-					<tr>
-					  <td colspan='2'>
-						<div style='width:100%;' >";	
-					$answer=api_parse_tex($answer);
+				$s .= Security::remove_XSS($answer, STUDENT);
+				$s .= '</div></td></tr>';
+			} elseif ($answerType == FILL_IN_BLANKS) {
+                // fill in blanks
+				$s .= '<tr><td colspan="3">'.$answer.'</td></tr>';
+			} else {
+                //  matching type, showing suggestions and answers 
+                // TODO: replace $answerId by $numAnswer
+                if ($answerCorrect != 0) {
+                	// only show elements to be answered (not the contents of
+                	// the select boxes, who are corrrect = 0)
+                	$s .= '<tr><td width="45%">';	
+					$parsed_answer = api_parse_tex($answer);
 					//left part questions
 					//left part questions
-					$s.='	<span style=\' float:left; width:5%;\'><b>'.$cpt2.'</b>.&nbsp;</span>
-							<span style=\' float:left; width:95%;\'>'.$answer.'</span>';
-							
-					$s.="<td width='20%' valign='top' align='center'>&nbsp;&nbsp;<select name='choice[".$questionId."][".$numAnswer."]'>
-							<option value='0'>--</option>";
-
+					$s .= '<span style="float:left; width:5%;"><b>'.$lines_count.'</b>.&nbsp;</span>
+						 <span style="float:left; width:95%;">'.$parsed_answer.'</span></td>';
+					//middle part (matches selects)
+				    $s .= '<td width="10%" valign="top" align="center">&nbsp;&nbsp;
+				            <select name="choice['.$questionId.']['.$numAnswer.']">
+							  <option value="0">--</option>';
 		            // fills the list-box
 		            // fills the list-box
-		            foreach($Select as $key=>$val) {
-						$s.="<option value='".$key."'>".$val['Lettre']."</option>";
+		            foreach ($select_items as $key=>$val) {
+		            	// set $debug_mark_answer to true at function start to
+		            	// show the correct answer with a suffix '-x'
+		            	$help = $selected = '';
+		            	if ($debug_mark_answer==true) {
+		            		if ($val['id'] == $answerCorrect) {
+		            			$help = '-x';
+		            			$selected = 'selected="selected"';
+		            		}
+		            	}
+						$s.='<option value="'.$val['id'].'" '.$selected.'>'.$val['letter'].$help.'</option>';
 					}  // end foreach()
 					}  // end foreach()
 
 
-					$s.="</select>&nbsp;&nbsp;</td>";
-					
+					$s .= '</select>&nbsp;&nbsp;</td>';
+					//print_r($select_items);
 					//right part (answers)
 					//right part (answers)
-					$s.="<td ><div style='width:100%;'>";	 
-					if(isset($Select[$cpt2]))
-						$s.='<span style=\'float:left; width:5%;\'><b>'.$Select[$cpt2]['Lettre'].'.</b></span>
-							 <span style=\' float:left; width:95%;\'>'.$Select[$cpt2]['Reponse'].'</span>';
-					else
+					$s.='<td width="45%">';
+					if (isset($select_items[$lines_count])) {
+						$s.='<span style="float:left; width:5%;"><b>'.$select_items[$lines_count]['letter'].'.</b></span>'.
+							 '<span style="float:left; width:95%;">'.$select_items[$lines_count]['answer'].'</span>';
+					} else {
 						$s.='&nbsp;';
 						$s.='&nbsp;';
-					$s.="
-						</div></td>";
-						 
-					$s.="			
-						</div>
-					  </td>
-					</tr>";
-
-					$cpt2++;
-
-					// if the left side of the "matching" has been completely shown
-					if($answerId == $nbrAnswers)
-					{
+					}
+					$s .= '</td>';
+					$s .= '</tr>';
+
+					$lines_count++;
+
+					//if the left side of the "matching" has been completely 
+					// shown but the right side still has values to show...
+					if (($lines_count -1) == $num_suggestions) {
 						// if it remains answers to shown at the right side
 						// if it remains answers to shown at the right side
-						while(isset($Select[$cpt2])) {
-							$s.="<tr>
-							  <td colspan='2'>
-								<table border='0' cellpadding='0' cellspacing='0' width='100%'>
-								<tr>
-								  <td width='60%' colspan='2'>&nbsp;</td>
-								  <td width='40%' valign='top'>";
-							$s.='<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse'];
+						while (isset($select_items[$lines_count])) {
+							$s .= '<tr>
+								  <td colspan="2">&nbsp;</td>
+								  <td valign="top">';
+							$s.='<b>'.$select_items[$lines_count]['letter'].'.</b> '.$select_items[$lines_count]['answer'];
 							$s.="</td>
 							$s.="</td>
-								</tr>
-								</table>
-							  </td>
 							</tr>";
 							</tr>";
-							$cpt2++;
+							$lines_count++;
 						}	// end while()
 						}	// end while()
 					}  // end if()
 					}  // end if()
 				}
 				}
@@ -313,12 +343,9 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 		// destruction of the Question object
 		// destruction of the Question object
 		unset($objQuestionTmp);
 		unset($objQuestionTmp);
 
 
-		if ($origin != 'export')
-		{
+		if ($origin != 'export') {
 			echo $s;
 			echo $s;
-		}
-		else
-		{
+		} else {
 			return($s);
 			return($s);
 		}
 		}
 	} elseif ($answerType == HOT_SPOT) {
 	} elseif ($answerType == HOT_SPOT) {
@@ -333,7 +360,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 		
 		
 		// get answers of hotpost
 		// get answers of hotpost
 		$answers_hotspot = array();
 		$answers_hotspot = array();
-		for($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
+		for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) {
 			$answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
 			$answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
 			$answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);						
 			$answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);						
 		}
 		}
@@ -348,7 +375,7 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 		}		
 		}		
 		$answer_list .= '</dl></div>';
 		$answer_list .= '</dl></div>';
 
 
-		if(!$onlyAnswers) {
+		if (!$onlyAnswers) {
 			echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
 			echo '<div id="question_title" class="sectiontitle">'.get_lang('Question').' '.$current_item.' : '.$questionName.'</div>';
 			//@todo I need to the get the feedback type
 			//@todo I need to the get the feedback type
 			//if($answerType == 2)
 			//if($answerType == 2)
@@ -364,11 +391,10 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 		$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
 		$canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
 		//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
 		//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
 		//echo $tes;
 		//echo $tes;
-		$s .= "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
-						<script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
-						<script language=\"JavaScript\" type=\"text/javascript\">
+		$s .= '<script language="JavaScript" type="text/javascript" src="../plugin/hotspot/JavaScriptFlashGateway.js"></script>
+						<script src="../plugin/hotspot/hotspot.js" type="text/javascript" language="JavaScript"></script>
+						<script language="JavaScript" type="text/javascript">
 						<!--
 						<!--
-						// -----------------------------------------------------------------------------
 						// Globals
 						// Globals
 						// Major version of Flash required
 						// Major version of Flash required
 						var requiredMajorVersion = 7;
 						var requiredMajorVersion = 7;
@@ -378,17 +404,16 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 						var requiredRevision = 0;
 						var requiredRevision = 0;
 						// the version of javascript supported
 						// the version of javascript supported
 						var jsVersion = 1.0;
 						var jsVersion = 1.0;
-						// -----------------------------------------------------------------------------
 						// -->
 						// -->
 						</script>
 						</script>
-						<script language=\"VBScript\" type=\"text/vbscript\">
+						<script language="VBScript" type="text/vbscript">
 						<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
 						<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
 						Function VBGetSwfVer(i)
 						Function VBGetSwfVer(i)
 						  on error resume next
 						  on error resume next
 						  Dim swControl, swVersion
 						  Dim swControl, swVersion
 						  swVersion = 0
 						  swVersion = 0
 
 
-						  set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
+						  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
 						  if (IsObject(swControl)) then
 						  if (IsObject(swControl)) then
 						    swVersion = swControl.GetVariable(\"\$version\")
 						    swVersion = swControl.GetVariable(\"\$version\")
 						  end if
 						  end if
@@ -397,41 +422,41 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 						// -->
 						// -->
 						</script>
 						</script>
 
 
-						<script language=\"JavaScript1.1\" type=\"text/javascript\">
+						<script language="JavaScript1.1" type="text/javascript">
 						<!-- // Detect Client Browser type
 						<!-- // Detect Client Browser type
-						var isIE  = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
-						var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
-						var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
+						var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
+						var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
+						var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
 						jsVersion = 1.1;
 						jsVersion = 1.1;
 						// JavaScript helper required to detect Flash Player PlugIn version information
 						// JavaScript helper required to detect Flash Player PlugIn version information
-						function JSGetSwfVer(i){
+						function JSGetSwfVer(i) {
 							// NS/Opera version >= 3 check for Flash plugin in plugin array
 							// NS/Opera version >= 3 check for Flash plugin in plugin array
 							if (navigator.plugins != null && navigator.plugins.length > 0) {
 							if (navigator.plugins != null && navigator.plugins.length > 0) {
-								if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
-									var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
-						      		var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
-									descArray = flashDescription.split(\" \");
-									tempArrayMajor = descArray[2].split(\".\");
+								if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
+									var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
+						      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
+									descArray = flashDescription.split(" ");
+									tempArrayMajor = descArray[2].split(".");
 									versionMajor = tempArrayMajor[0];
 									versionMajor = tempArrayMajor[0];
 									versionMinor = tempArrayMajor[1];
 									versionMinor = tempArrayMajor[1];
-									if ( descArray[3] != \"\" ) {
-										tempArrayMinor = descArray[3].split(\"r\");
+									if ( descArray[3] != "" ) {
+										tempArrayMinor = descArray[3].split("r");
 									} else {
 									} else {
-										tempArrayMinor = descArray[4].split(\"r\");
+										tempArrayMinor = descArray[4].split("r");
 									}
 									}
 						      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
 						      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
-						            flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
+						            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
 						      	} else {
 						      	} else {
 									flashVer = -1;
 									flashVer = -1;
 								}
 								}
 							}
 							}
 							// MSN/WebTV 2.6 supports Flash 4
 							// MSN/WebTV 2.6 supports Flash 4
-							else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
+							else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
 							// WebTV 2.5 supports Flash 3
 							// WebTV 2.5 supports Flash 3
-							else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
+							else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
 							// older WebTV supports Flash 2
 							// older WebTV supports Flash 2
-							else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
-							// Can't detect in all other cases
+							else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
+							// Can\'t detect in all other cases
 							else
 							else
 							{
 							{
 								flashVer = -1;
 								flashVer = -1;
@@ -440,9 +465,8 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 						}
 						}
 						// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
 						// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
 
 
-						function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
-						{
-						 	reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
+						function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
+						 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
 						   	// loop backwards through the versions until we find the newest version
 						   	// loop backwards through the versions until we find the newest version
 							for (i=25;i>0;i--) {
 							for (i=25;i>0;i--) {
 								if (isIE && isWin && !isOpera) {
 								if (isIE && isWin && !isOpera) {
@@ -454,17 +478,17 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 									return false;
 									return false;
 								} else if (versionStr != 0) {
 								} else if (versionStr != 0) {
 									if(isIE && isWin && !isOpera) {
 									if(isIE && isWin && !isOpera) {
-										tempArray         = versionStr.split(\" \");
+										tempArray         = versionStr.split(" ");
 										tempString        = tempArray[1];
 										tempString        = tempArray[1];
-										versionArray      = tempString .split(\",\");
+										versionArray      = tempString .split(",");
 									} else {
 									} else {
-										versionArray      = versionStr.split(\".\");
+										versionArray      = versionStr.split(".");
 									}
 									}
 									versionMajor      = versionArray[0];
 									versionMajor      = versionArray[0];
 									versionMinor      = versionArray[1];
 									versionMinor      = versionArray[1];
 									versionRevision   = versionArray[2];
 									versionRevision   = versionArray[2];
 
 
-									versionString     = versionMajor + \".\" + versionRevision;   // 7.0r24 == 7.24
+									versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
 									versionNum        = parseFloat(versionString);
 									versionNum        = parseFloat(versionString);
 						        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 						        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
 									if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
 									if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
@@ -476,36 +500,34 @@ function showQuestion($questionId, $onlyAnswers=false, $origin=false,$current_it
 							}
 							}
 						}
 						}
 						// -->
 						// -->
-						</script>";
-		$s .= '<tr><td valign="top" colspan="2" width="520"><table><tr><td width="520">'."
-					<script language=\"JavaScript\" type=\"text/javascript\">
+						</script>';
+		$s .= '<tr><td valign="top" colspan="2" width="520"><table><tr><td width="520">
+					<script language="JavaScript" type="text/javascript">
 						<!--
 						<!--
-						// Version check based upon the values entered above in \"Globals\"
+						// Version check based upon the values entered above in "Globals"
 						var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
 						var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
 
 
 
 
 						// Check to see if the version meets the requirements for playback
 						// Check to see if the version meets the requirements for playback
-						if (hasReqestedVersion) {  // if we've detected an acceptable version
-						    var oeTags = '<object type=\"application/x-shockwave-flash\" data=\"../plugin/hotspot/hotspot_user.swf?modifyAnswers=".$questionId."&amp;canClick:".$canClick."\" width=\"560\" height=\"436\">'
-										+ '<param name=\"movie\" value=\"../plugin/hotspot/hotspot_user.swf?modifyAnswers=".$questionId."&amp;canClick:".$canClick."\" \/>'
-										+ '<\/object>';
+						if (hasReqestedVersion) {  // if we\'ve detected an acceptable version
+						    var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_user.swf?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" width="560" height="436">\'
+										+ \'<param name="movie" value="../plugin/hotspot/hotspot_user.swf?modifyAnswers='.$questionId.'&amp;canClick:'.$canClick.'" />\'
+										+ \'<\/object>\';
 						    document.write(oeTags);   // embed the Flash Content SWF when all tests are passed
 						    document.write(oeTags);   // embed the Flash Content SWF when all tests are passed
-						} else {  // flash is too old or we can't detect the plugin
-							var alternateContent = 'Error<br \/>'
-								+ 'Hotspots requires Macromedia Flash 7.<br \/>'
-								+ '<a href=http://www.macromedia.com/go/getflash/>Get Flash<\/a>';
+						} else {  // flash is too old or we can\'t detect the plugin
+							var alternateContent = "Error<br \/>"
+								+ "Hotspots requires Macromedia Flash 7.<br \/>"
+								+ "<a href=\"http://www.macromedia.com/go/getflash/\">Get Flash<\/a>";
 							document.write(alternateContent);  // insert non-flash content
 							document.write(alternateContent);  // insert non-flash content
 						}
 						}
 						// -->
 						// -->
 					</script>
 					</script>
 					</td>
 					</td>
-					<td valign='top' align='left'>$answer_list</td></tr>
+					<td valign="top" align="left">'.$answer_list.'</td></tr>
 					</table>
 					</table>
-		</td></tr>";
+		</td></tr>';
 		echo $s;
 		echo $s;
 	}
 	}
-	echo "</table><br />";
-
+	echo '</table><br />';
 	return $nbrAnswers;
 	return $nbrAnswers;
-}
-?>
+}