Browse Source

Multiple answer \"combination\" result fixes

Julio Montoya 15 years ago
parent
commit
102bd23269
2 changed files with 38 additions and 10 deletions
  1. 29 4
      main/exercice/exercice_submit.php
  2. 9 6
      main/exercice/exercise_show.php

+ 29 - 4
main/exercice/exercice_submit.php

@@ -386,7 +386,7 @@ if ($formSent) {
 						if ($answerType == FREE_ANSWER) {
 							$nbrAnswers = 1;
 						}
-
+						$real_answers = array();
 						for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
 							$answer = $objAnswerTmp->selectAnswer($answerId);
 							$answerComment = $objAnswerTmp->selectComment($answerId);
@@ -411,11 +411,36 @@ if ($formSent) {
 									}																		
 									break;
 								case MULTIPLE_ANSWER_COMBINATION:
-									$studentChoice=$choice[$numAnswer];													
-									if ($studentChoice) {
+									$studentChoice=$choice[$numAnswer];									
+																			
+									if ($answerCorrect == 1) {
+										if ($studentChoice) {
+											$real_answers[$answerId] = true;
+										} else {
+											$real_answers[$answerId] = false;
+										}
+									} else {
+										if ($studentChoice) {
+											$real_answers[$answerId] = false;
+										} else {
+											$real_answers[$answerId] = true;
+										}
+									}
+										
+									$final_answer = true;
+								 	foreach($real_answers as $my_answer) {
+								 		if (!$my_answer) {
+								 			$final_answer = false;
+								 		}		 		
+								 	}
+								 			 	
+								 	if ($final_answer) {
+								 		//getting only the first score where we save the weight of all the question 
+								 		$answerWeighting=$objAnswerTmp->selectWeighting(1);
 										$questionScore+=$answerWeighting;
 										$totalScore+=$answerWeighting;
-									}																		
+									}																	
+																									
 									break;
 									// for fill in the blanks
 								case FILL_IN_BLANKS :

+ 9 - 6
main/exercice/exercise_show.php

@@ -712,20 +712,20 @@ if ($show_results) {
 				echo '</td></tr>';
 				$i++;
 		 	}
-		 	
+		 			 	
 		 	$final_answer = true;
 		 	foreach($real_answers as $my_answer) {
 		 		if (!$my_answer) {
 		 			$final_answer = false;
 		 		}		 		
-		 	}		 	
+		 	}
+		 			 	
 		 	if ($final_answer) {
 		 		//getting only the first score where we save the weight of all the question 
 		 		$answerWeighting=$objAnswerTmp->selectWeighting(1);
 				$questionScore+=$answerWeighting;
 				$totalScore+=$answerWeighting;
-			}			
-		 	
+			}
 		 	
 		 	echo '</table>';
 		} elseif ($answerType == UNIQUE_ANSWER) {
@@ -1167,12 +1167,15 @@ if ($show_results) {
 		</tr>
 		</table>
 
-		<div id="question_score">
+		
 		<?php
 		$my_total_score  = float_format($questionScore,1);
 		$my_total_weight = float_format($questionWeighting,1);
-		echo get_lang('Score')." : $my_total_score/$my_total_weight";
+		
+		echo '<div id="question_score">';
+		echo get_lang('Score')." : $my_total_score/$my_total_weight";		
 		echo '</div>';
+	
 		unset($objAnswerTmp);
 		$i++;
 		$totalWeighting+=$questionWeighting;