Browse Source

[svn r20288] Fixing colors answers in hotspot see FS#4041

Julio Montoya 16 years ago
parent
commit
f5e4c1e24e
2 changed files with 28 additions and 19 deletions
  1. 23 15
      main/exercice/exercise_result.php
  2. 5 4
      main/exercice/exercise_show.php

+ 23 - 15
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 20280 2009-05-04 16:10:06Z cfasanando $
+* 	@version $Id: exercise_result.php 20288 2009-05-04 17:48:40Z juliomontoya $
 *
 *	@todo	split more code up in functions, move functions to library?
 */
@@ -434,10 +434,18 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 				</td>
 				<td valign="top"><?php echo $answerId; ?></td>
 				<td valign="top">
-					<?php $studentChoice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $studentChoice; ?>
+					<?php $my_choice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $my_choice; ?>
 				</td>
-				<td valign="top">
-					<?php echo stripslashes($answerComment); ?>
+				<td valign="top">				
+					<?php
+					if ($studentChoice) {
+						echo '<span style="font-weight: bold; color: #008000;">';							
+					} else {
+						echo '<span style="font-weight: bold; color: #FF0000;">';												
+					}					
+					echo stripslashes($answerComment);
+					echo '</span>';				 
+					?>
 				</td>
 		</tr>
 	<?php
@@ -937,8 +945,7 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 			}
 		} // end for that loops over all answers of the current question
 
-		if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER)
-			{
+		if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
 				// We made an extra table for the answers
 				if($origin != 'learnpath') {
 				echo "</table></td></tr>";
@@ -962,10 +969,9 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 				<b>
 				<?php
 				if($questionScore==-1){ 
-					echo get_lang('Score')." : 0/$questionWeighting";
-				}
-				else{
-					echo get_lang('Score')." : $questionScore/$questionWeighting";
+					echo get_lang('Score').": 0 /".float_format($questionWeighting);
+				} else {					
+					echo get_lang('Score').": ".float_format($questionScore,1)."/".float_format($questionWeighting,1);
 				}
 				?></b><br /><br />
 			</td>
@@ -1035,13 +1041,15 @@ $exerciseTitle=api_parse_tex($exerciseTitle);
 		<table width="100%" border="0" cellpadding="3" cellspacing="2">
 		<tr>
 		<td>
-			<b><?php echo get_lang('YourTotalScore')." ";
-			if($dsp_percent == true){
+			<b>
+			<?php echo get_lang('YourTotalScore')." ";
+			if ($dsp_percent == true) {
 			  echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
-			}else{
-			  echo $totalScore."/".$totalWeighting;
+			} else {
+			  echo float_format($totalScore,1)."/".float_format($totalWeighting,1);
 			}
-                        ?></b>
+			?>
+			</b>
 		</td>
 		</tr>
 		<tr>

+ 5 - 4
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 20287 2009-05-04 17:14:06Z iflorespaz $
+* 	@version $Id: exercise_show.php 20288 2009-05-04 17:48:40Z juliomontoya $
 *
 * 	@todo remove the debug code and use the general debug library
 * 	@todo use the Database:: functions
@@ -339,16 +339,17 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
 		</td>
 		<td valign="top" align="left"><?php echo $answerId; ?></td>
 		<td valign="top" align="left">
-			<?php $studentChoice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $studentChoice; ?>
+			<?php 
+			$my_choice = ($studentChoice)?get_lang('Correct'):get_lang('Fault'); echo $my_choice; ?>
 		</td>
 		
 		<td valign="top" align="left" >
 			<?php
 			$answerComment=api_parse_tex($answerComment);
 			if($studentChoice) {
-				echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';			
+				echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';							
 			} else {
-				echo '<span style="font-weight: bold; color: #008000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';
+				echo '<span style="font-weight: bold; color: #FF0000;">'.nl2br(make_clickable(stripslashes($answerComment))).'</span>';				
 			} 
 			?>
 		</td>