Browse Source

Cleaning exercises + adding third option in the \"show score to learner\" exercise setting see #2539

Julio Montoya 14 years ago
parent
commit
009a93e921

+ 68 - 33
main/exercice/exercise.class.php

@@ -1678,6 +1678,8 @@ class Exercise {
 	 */
 	function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0) {        
 		global $_configuration, $feedback_type;   
+		
+		$html = '';
 		   
         $questionId   = intval($questionId);
 		$exeId        = intval($exeId);        
@@ -1787,10 +1789,8 @@ class Exercise {
                         } else {
                         	$questionScore  +=  $doubt_score;
                         }
-                   }
-                   //$questionWeighting+=$true_score;                   
-                   $totalScore       +=$true_score;
-                   //echo $studentChoice.' - '.$answerCorrect.' '.$questionScore.' - '.$questionWeighting.'<br />';                                           
+                   }                  
+                   $totalScore       +=$true_score;                                 
                    break;
                 case MULTIPLE_ANSWER :                   
                     if ($from_database) {
@@ -1829,8 +1829,7 @@ class Exercise {
                                              
                         $numAnswer=$objAnswerTmp->selectAutoId($answerId);
                         $studentChoice=$choice[$numAnswer];
-                        //echo $studentChoice.' - '.$answerCorrect.'<br /> ';
-                        
+                       
                         if ($answerCorrect == 1) {
                             if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class
                                 $real_answers[$answerId] = true;
@@ -2102,8 +2101,8 @@ class Exercise {
                     }
                     break;
                     // for matching
-                case MATCHING :                
-                    if ($from_database) {                                    
+                case MATCHING :   
+                    if ($from_database) {                                  
                         $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" AND correct=0';
                         $res_answer = Database::query($sql_answer);
                         // getting the real answer
@@ -2116,15 +2115,8 @@ class Exercise {
                                               WHERE question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto';
             
                         $res_answers = Database::query($sql_select_answer);
-                        if ($show_result) {
-                            echo '<table width="100%" height="71" border="0" cellspacing="3" cellpadding="3" >';
-                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
-                            echo '<tr>
-                                    <td><span style="font-style: italic;">'.get_lang('ElementList').'</span> </td>
-                                    <td><span style="font-style: italic;">'.get_lang('CorrespondsTo').'</span></td>
-                                  </tr>';
-                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
-                        }
+                        
+                   
                         $questionScore = 0;
             
                         while ($a_answers = Database::fetch_array($res_answers)) {        
@@ -2331,13 +2323,14 @@ class Exercise {
             }
         }        
        
-       if ($from == 'exercise_result') {
-            global $colspan;
+       if ($from == 'exercise_result') {            
             // if answer is hotspot. To the difference of exercise_show.php, we use the results from the session (from_db=0)
             // TODO Change this, because it is wrong to show the user some results that haven't been stored in the database yet
             if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
-                    // We made an extra table for the answers
-                    if($origin != 'learnpath') {                        
+                // We made an extra table for the answers
+                 if ($show_result) {
+                    if ($origin != 'learnpath') {
+                                          
                         echo '</table></td></tr>';
                         echo '<tr>
                             <td colspan="2">';
@@ -2346,28 +2339,26 @@ class Exercise {
                         echo '<param name="movie" value="'.api_get_path(WEB_PLUGIN_PATH).'plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id=&from_db=0" />
                                 </object>
                             </td>
-                        </tr>';                    
+                        </tr>';  
+                                          
                     }
-                }
+                 }
+            }
             if ($origin != 'learnpath') { 
-            ?>
-                <tr>
-                <td colspan="<?php echo $colspan; ?>" align="left">                    
-                    <?php                    
+                if ($show_result) {            
+                    echo '</table>'; 
                     if ($this->type == ALL_ON_ONE_PAGE) {
                         echo '<div id="question_score">';                        
                         if ($propagate_neg == 0 && $questionScore < 0) {
                 	        $questionScore = 0;
                 	    }                    	    
-                        echo get_lang('Score').": ".show_score($questionScore, $questionWeighting,false, false);
+                        echo get_lang('Score').": ".show_score($questionScore, $questionWeighting, false, false);
                         
                         echo '</div>';
                     }
-                    ?><br />
-                </td>
-                </tr>
-                </table>
-                <?php }
+                    echo '<br />';
+                }
+            }
         }        
         unset ($objAnswerTmp);
         $i++;
@@ -2588,6 +2579,50 @@ class Exercise {
             $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset));
         }
     }
+    
+    function show_exercise_result_header($user_data, $date = null) {
+        $description = '';
+        if (!empty($this->description)) {
+        	$description = '<tr>
+        		<td style="font-weight:bold" width="10%">
+        			&nbsp;'.get_lang("Description").' :
+        		</td>
+        		<td width="90%">			
+        		'.$this->description.'
+        		</td>
+        	</tr>';
+        }
+        $date_data = '';
+        if (!empty($date)) {
+        	$date_data = '<tr>
+        		<td style="font-weight:bold" width="10%">
+        			&nbsp;'.get_lang("Date").' :
+        		</td>
+        		<td width="90%">			
+        		'.$date.'
+        		</td>
+        	</tr>';
+        }
+        
+        
+        $html = '<table width="100%">
+        	<tr>
+        	<td colspan="2">
+        		<h2>'.Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result').'</h2>
+        	</td>	
+        	</tr>		
+        	<tr>
+        		<td style="font-weight:bold" width="90px">&nbsp;'.get_lang('User').' : </td>
+        		<td>
+        		'.$user_data.'
+                </td>
+            </tr>            
+            '.$date_data.'
+        	'.$description.'
+        </table>
+        <br />';
+        return $html;
+    }
 }
 endif;
 ?>

+ 77 - 163
main/exercice/exercise_result.php

@@ -135,10 +135,18 @@ if ($origin != 'learnpath') {
 <body dir="<?php echo api_get_text_direction(); ?>">
 <?php
 }
+//Hide results
+$show_results     = false;
+$show_only_score  = false;
 
-if ($objExercise->results_disabled) {
-	ob_start();
+if ($objExercise->results_disabled == 0) {
+    $show_results = true;	
 }
+
+if ($objExercise->results_disabled == 2) {
+    $show_only_score = true;
+}
+
 /* DISPLAY AND MAIN PROCESS */
 
 // I'm in a preview mode as course admin. Display the action menu.
@@ -153,31 +161,34 @@ $exerciseTitle=text_filter($objExercise->selectTitle());
 $feedback_type = $objExercise->feedbacktype;
 
 //show exercise title
-if($origin != 'learnpath') {?>
-	<h2><?php echo Display::return_icon('quiz_big.png', get_lang('Result')).' '; echo $exerciseTitle; ?> : <?php echo get_lang("Result"); ?></h2>
-	<?php echo $objExercise->selectDescription(); ?>
-<?php } ?>
-
+if($origin == 'learnpath') { ?>
 	<form method="get" action="exercice.php?<?php echo api_get_cidreq() ?>">
 	<input type="hidden" name="origin" value="<?php echo $origin; ?>" />
     <input type="hidden" name="learnpath_id" value="<?php echo $learnpath_id; ?>" />
     <input type="hidden" name="learnpath_item_id" value="<?php echo $learnpath_item_id; ?>" />
     <input type="hidden" name="learnpath_item_view_id" value="<?php echo $learnpath_item_view_id; ?>" />
-
 <?php
-
+}
 $i=$totalScore=$totalWeighting=0;
 if($debug>0){error_log ("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));}
 
-if ($_configuration['tracking_enabled']) {
-	// Create an empty exercise
-	if (api_is_allowed_to_session_edit() )
-		$exeId= create_event_exercice($objExercise->selectId());
+// Create an empty exercise
+if (api_is_allowed_to_session_edit()) {
+    $exeId= create_event_exercice($objExercise->selectId());
 }
 $counter=0;
 
+$user_info   = api_get_user_info(api_get_user_id());     
+if ($show_results || $show_only_score) {
+    echo $exercise_header = $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']));
+}
+
+	     
 // Loop over all question to show results for each of them, one by one
 foreach ($questionList as $questionId) {
+    // destruction of the Question object
+	unset($objQuestionTmp);
+	
 	$counter++;
 	// gets the student choice for this question
 	$choice                = $exerciseResult[$questionId];
@@ -189,134 +200,54 @@ foreach ($questionList as $questionId) {
 	$questionDescription   = $objQuestionTmp->selectDescription();
 	$questionWeighting     = $objQuestionTmp->selectWeighting();
 	$answerType            = $objQuestionTmp->selectType();
-	$quesId                = $objQuestionTmp->selectId(); //added by priya saini
-
-	// destruction of the Question object
-	unset($objQuestionTmp);
-
-	// decide how many columns we want to use to show the results of each type
-	if (in_array($answerType, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE,UNIQUE_ANSWER_NO_OPTION))) {
-		$colspan=4;
-	} elseif($answerType == MATCHING || $answerType == FREE_ANSWER) {
-		$colspan=2;
-	} elseif($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
-		$colspan=4;
-		$rowspan=$nbrAnswers+1;
-	} else {
-		$colspan=1;
-	}
-	// show titles
-	if ($origin != 'learnpath') {?>
-		<table width="100%" border="0" cellpadding="3" cellspacing="2">
-		<tr>
-		<td colspan="<?php echo $colspan; ?>">
-            <div id="question_title" class="sectiontitle">
-			<?php echo get_lang("Question").' '.($counter).' : '.$questionName; ?>
-            </div>
-		</td>
-		</tr>
-		<tr>
-		<td colspan="<?php echo $colspan; ?>">
-			<i><?php echo $questionDescription; ?></i>
-		</td>
-		</tr>
-		<?php
-		if (in_array($answerType, array(UNIQUE_ANSWER, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE,UNIQUE_ANSWER_NO_OPTION))) {
-			?>
-				<tr>
-				<td width="5%" valign="top" align="center" nowrap="nowrap">
-					<i><?php echo get_lang("Choice"); ?></i>
-				</td>
-				<td width="5%"  align="center" nowrap="nowrap">
-					<i><?php echo get_lang("ExpectedChoice"); ?></i>
-				</td>
-				<td width="45%" valign="top">
-					<i><?php echo get_lang("Answer"); ?></i>
-				</td>
-				<?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
-				<td width="45%" valign="top">
-					<i><?php echo get_lang("Comment"); ?></i>
-				</td>
-				<?php } else { ?>
-					<td>&nbsp;</td>
-				<?php } ?>
-				</tr>
-			<?php
-		} elseif ($answerType == FILL_IN_BLANKS) { ?>
-				<tr>
-				<td>
-					<i><?php echo get_lang("Answer"); ?></i>
-				</td>
-				</tr>
-			<?php
-		} elseif ($answerType == FREE_ANSWER) {
-			?>
-				<tr>
-				<td width="55%">
-					<i><?php echo get_lang("Answer"); ?></i>
-				</td>
-				<?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
-				<td width="45%" valign="top">
-					<i><?php echo get_lang("Comment"); ?></i>
-				</td>
-				<?php } else { ?>
-					<td>&nbsp;</td>
-				<?php } ?>
-				</tr>
-			<?php
-		} elseif ($answerType == HOT_SPOT) {
-			?>
-				<tr>
-					<td valign="top" colspan="2">
-						<table width="552" border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;">
-							<tr>
-								<td width="152" valign="top">
-									<i><?php echo get_lang("CorrectAnswer"); ?></i><br /><br />
-								</td>
-								<td width="100" valign="top">
-									<i><?php echo get_lang('HotspotHit'); ?></i><br /><br />
-								</td>
-								<?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
-								<td width="300" valign="top">
-									<i><?php echo get_lang("Comment"); ?></i><br /><br />
-								</td>
-								<?php } else { ?>
-									<td>&nbsp;</td>
-								<?php } ?>
-							</tr>
-			<?php
-		} else { //matching type
-			?>
-				<tr>
-				<td width="50%">
-					<i><?php echo get_lang("ElementList"); ?></i>
-				</td>
-				<td width="50%">
-					<i><?php echo get_lang("CorrespondsTo"); ?></i>
-				</td>
-				</tr>
-			<?php
-		}
+	$quesId                = $objQuestionTmp->selectId();
+	
+	if ($show_results) {
+    	// show titles
+    	if ($origin != 'learnpath') { 
+    		echo $objQuestionTmp->return_header($objExercise->feedbacktype);
+    		if ($answerType == HOT_SPOT) {		    
+    			?>
+    				<tr>
+    					<td valign="top" colspan="2">
+    						<table width="552" border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;">
+    							<tr>
+    								<td width="152" valign="top">
+    									<i><?php echo get_lang("CorrectAnswer"); ?></i><br /><br />
+    								</td>
+    								<td width="100" valign="top">
+    									<i><?php echo get_lang('HotspotHit'); ?></i><br /><br />
+    								</td>
+    								<?php if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
+    								<td width="300" valign="top">
+    									<i><?php echo get_lang("Comment"); ?></i><br /><br />
+    								</td>
+    								<?php } else { ?>
+    									<td>&nbsp;</td>
+    								<?php } ?>
+    							</tr>
+    			<?php
+    		}
+    	}
 	}
 
 	// We're inside *one* question. Go through each possible answer for this question
-	$result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, true, $objExercise->selectPropagateNeg());   	
+	$result = $objExercise->manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, $show_results, $objExercise->selectPropagateNeg());   	
     $totalScore        += $result['score'];    
-    $totalWeighting    += $result['weight'];
-    
+    $totalWeighting    += $result['weight'];    
 } // end huge foreach() block that loops over all questions
 
-if($origin != 'learnpath') {
-    echo '<div id="question_score">';
-    echo get_lang('YourTotalScore')." ";	
-    if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
-	    $totalScore = 0;
-    }     
-    echo show_score($totalScore, $totalWeighting, false);	
-    echo '</div>';
-	?>
-    <button type="submit" class="save"><?php echo get_lang('Finish');?></button>
-<?php 
+if ($origin != 'learnpath') {
+    if ($show_results || $show_only_score) {
+        echo '<div id="question_score">';
+        echo get_lang('YourTotalScore')." ";	
+        if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) {
+    	    $totalScore = 0;
+        }     
+        echo show_score($totalScore, $totalWeighting, false);	
+        echo '</div>';
+    }
+    /* <button type="submit" class="save"><?php echo get_lang('Finish');?></button> */
 }
 
 // Tracking of results
@@ -330,35 +261,18 @@ if (api_is_allowed_to_session_edit() ) {
 	update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting,api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration);
 }
 
-
-if ($objExercise->results_disabled) {
-	ob_end_clean();
-	if ($origin != 'learnpath') {
-		Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
-	} else {
-		Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><br />',false);
-
-		$lp_mode =  $_SESSION['lp_mode'];
-		$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype;
-		$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
-		echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
-		//record the results in the learning path, using the SCORM interface (API)
-		echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
-		echo '</body></html>';
-	}
+if ($origin != 'learnpath') {
+	Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><a href="exercice.php" />'.get_lang('Back').'</a>',false);
 } else {
-	//show score
-	if ($origin == 'learnpath') {
-		Display::display_normal_message(get_lang('ExerciseFinished'));
-		$lp_mode =  $_SESSION['lp_mode'];
-		$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype;
-		$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
-		echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
-
-		//record the results in the learning path, using the SCORM interface (API)
-		echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
-		echo '</body></html>';
-	}
+	Display :: display_normal_message(get_lang('ExerciseFinished').'<br /><br />',false);
+
+	$lp_mode =  $_SESSION['lp_mode'];
+	$url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype;
+	$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
+	echo '<script language="javascript" type="text/javascript">'.$href.'</script>'."\n";
+	//record the results in the learning path, using the SCORM interface (API)
+	echo '<script language="javascript" type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
+	echo '</body></html>';
 }
 
 if ($origin != 'learnpath') {

+ 152 - 274
main/exercice/exercise_show.php

@@ -201,11 +201,10 @@ function getFCK(vals,marksid) {
 //f.submit();
 }
 </script>
-<table width="100%" border="0" cellspacing="0" cellpadding="0">
-  <tr>
-    <td colspan="2">
 <?php
-$show_results = true;
+$show_results           = true;
+$show_only_total_score  = false;
+
 // Avoiding the "Score 0/0" message  when the exe_id is not set
 if (!empty($track_exercise_info)) {
 	$exerciseTitle			= text_filter($track_exercise_info['title']);
@@ -213,283 +212,149 @@ if (!empty($track_exercise_info)) {
 	// if the results_disabled of the Quiz is 1 when block the script
 	$result_disabled		= $track_exercise_info['results_disabled'];
 	
-	if (!(api_is_platform_admin() || api_is_course_admin()) ) {     
-		if ($result_disabled == 1) {
+	//if (!(api_is_platform_admin() || api_is_course_admin()) ) {    
+		if ($result_disabled == 1) {		    
 			//api_not_allowed();
 			$show_results = false;
 			//Display::display_warning_message(get_lang('CantViewResults'));
 			if ($origin != 'learnpath') {
+			    echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
+                      <tr>
+                        <td colspan="2">';
 				Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercice.php">'.(get_lang('BackToExercisesList')).'</a>', false);
 				echo '</td>
 				</tr>
 				</table>';
 			}
 		} elseif ($result_disabled == 2) {
-		    $show_results = false;		  
+		    $show_results = false;
+		    $show_only_total_score = true;			  
 			if ($origin != 'learnpath') {
-				Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercice.php">'.(get_lang('BackToExercisesList')).'</a>', false);
+			    echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
+                      <tr>
+                        <td colspan="2">';
+				Display::display_warning_message(get_lang('ThankYouForPassingTheTest'), false);
 				echo '</td>
 				</tr>
 				</table>';
 			}			  
 		}       
-	}
+	//}
 } else {
 	Display::display_warning_message(get_lang('CantViewResults'));
 	$show_results = false;
-	echo '</td>
-	</tr>
-	</table>';
 }
 
+//var_dump($show_results);
+
 if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
 	$show_results = false;
 }
+$html = '';
+if ($show_results || $show_only_total_score) {
+    $user_info   = api_get_user_info($student_id);
+    //Shows exercise header
+    echo $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']), api_convert_and_format_date($exercise_date));
+}
 
-if ($show_results) {
-	?>
-	<table width="100%">
-		<tr>
-		<td colspan="2">
-			<h2><?php echo  Display::return_icon('quiz_big.png', get_lang('Result')).' '.$exerciseTitle.' : '.get_lang('Result');?></h2>
-		</td>	
-		</tr>		
-		<tr>
-			<td style="font-weight:bold" width="90px"><?php echo '&nbsp;'.get_lang('User')?> : </td>
-			<td>
-            <?php			
-			$user_info   = api_get_user_info($student_id);
-			echo api_get_person_name($user_info['firstName'], $user_info['lastName']);            	
-			?>            
-            </td>
-        </tr>
-        <tr>         
-            <td style="font-weight:bold" width="90px"><?php echo '&nbsp;'.get_lang('Date')?> : </td>
-            <td>
-            <?php
-            echo api_convert_and_format_date($exercise_date);    
-            ?>            
-            </td>
-		</tr>
-		<?php if (!empty($exerciseDescription)) { ?>
-		<tr>
-			<td style="font-weight:bold" width="10%">
-				<?php echo '&nbsp;'.get_lang("Description").' :'; ?>
-			</td>
-			<td width="90%">			
-			<?php echo $exerciseDescription; ?>
-			</td>
-		</tr>
-		<?php } ?>
-	</table>
-	<br />
-	</table>
-  	<?php
+$i=$totalScore=$totalWeighting=0;
 
-    $i=$totalScore=$totalWeighting=0;
+if($debug>0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));}
 
-    if($debug>0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));}
-    
-    $arrques = array();
-    $arrans = array();
-
-	$user_restriction = $is_allowedToEdit ? '' :  "AND user_id=".intval($student_id)." ";
-	$query = "SELECT attempts.question_id, answer  from ".$TBL_TRACK_ATTEMPT." as attempts
-					INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
-					INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
-					INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
-			  WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
-			  GROUP BY quizz_rel_questions.question_order, attempts.question_id";
-				//GROUP BY questions.position, attempts.question_id";
-
-	$result =Database::query($query);	
-	$questionList = array();
-	$exerciseResult = array();
-	
-	while ($row = Database::fetch_array($result)) {
-		$questionList[] = $row['question_id'];
-		$exerciseResult[$row['question_id']] = $row['answer'];
-	}
-	
-	//Fixing #2073 Fixing order of questions
-	if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
-		$tempquestionList = explode(',',$track_exercise_info['data_tracking']);
-		if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
-			$questionList = $tempquestionList;			
-		}		
-	}
-	
-	// for each question
-	$counter=0;
+$arrques = array();
+$arrans  = array();
 
-    $total_weighting = 0;
-    foreach ($questionList as $questionId) {
-        $objQuestionTmp     = Question::read($questionId);
-        $total_weighting  +=$objQuestionTmp->selectWeighting();        
-    }
-            
-	foreach ($questionList as $questionId) {
-		$counter++;		
-		$choice=$exerciseResult[$questionId];
-		// creates a temporary Question object
-		$objQuestionTmp 	= Question::read($questionId);
-		$questionName		= $objQuestionTmp->selectTitle();
-		$questionDescription= $objQuestionTmp->selectDescription();
-		$questionWeighting	= $objQuestionTmp->selectWeighting();
-		$answerType			= $objQuestionTmp->selectType();
-		$quesId 			= $objQuestionTmp->selectId(); //added by priya saini
-        
+$user_restriction = $is_allowedToEdit ? '' :  "AND user_id=".intval($student_id)." ";
+$query = "SELECT attempts.question_id, answer  from ".$TBL_TRACK_ATTEMPT." as attempts
+				INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id
+				INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id
+				INNER JOIN ".$TBL_QUESTIONS." as questions ON questions.id=quizz_rel_questions.question_id
+		  WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
+		  GROUP BY quizz_rel_questions.question_order, attempts.question_id";
+			//GROUP BY questions.position, attempts.question_id";
 
-		// destruction of the Question object
-		unset($objQuestionTmp);
+$result =Database::query($query);	
+$questionList = array();
+$exerciseResult = array();
 
-		if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) {
-			$colspan=2;
-		}
-		if($answerType == MATCHING || $answerType == FREE_ANSWER) {
-			$colspan=2;
-		} else {
-			$colspan=2;
-		}
-        
-		echo '<div id="question_title" class="sectiontitle">';
-        echo get_lang("Question").' '.($counter).' : '.$questionName; 
-    	echo '</div>';
-    	echo '<div id="question_description">';
-        echo $questionDescription; 
-    	echo '</div>';
-	 	
-		if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
-			?>
-			<table width="100%" border="0" cellspacing="3" cellpadding="3">
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<tr>
-				<td><i><?php echo get_lang("Choice"); ?></i> </td>
-				<td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
-				<td><i><?php echo get_lang("Answer"); ?></i></td>
-				<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
-				<td><i><?php echo get_lang("Comment"); ?></i></td>
-				<?php } else { ?>
-				<td>&nbsp;</td>
-				<?php } ?>
-			</tr>
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<?php
-			// construction of the Answer object
-       
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());            
-            //var_dump($question_result);
-            $questionScore      = $question_result['score'];
-            $totalScore        += $question_result['score'];            
-            //$questionWeighting += $question_result['weight'];
-            
-		 	echo '</table>';
-		} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType ==  MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
-			$choice=array();
-			?>
-			<table width="100%" border="0" cellspacing="3" cellpadding="3">
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<tr>
-				<td><i><?php echo get_lang("Choice"); ?></i> </td>
-				<td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
-				<td><i><?php echo get_lang("Answer"); ?></i></td>
-				<td><i><?php echo get_lang("Comment"); ?></i></td>
-			</tr>
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<?php
-	            
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());                       
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];
+while ($row = Database::fetch_array($result)) {
+	$questionList[] = $row['question_id'];
+	$exerciseResult[$row['question_id']] = $row['answer'];
+}
 
-		 	echo '</table>';
-		} elseif ($answerType == UNIQUE_ANSWER || $answerType ==  UNIQUE_ANSWER_NO_OPTION) {
-			?>
-			<table width="100%" border="0" cellspacing="3" cellpadding="3">
-				<tr>
-				<td>&nbsp;</td>
-				</tr>
-				<tr>
-					<td><i><?php echo get_lang("Choice"); ?></i> </td>
-					<td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
-					<td><i><?php echo get_lang("Answer"); ?></i></td>
-					<?php if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
-					<td><i><?php echo get_lang("Comment"); ?></i></td>
-					<?php } else { ?>
-					<td>&nbsp;</td>
-					<?php } ?>
-				</tr>
-				<tr>
-				<td>&nbsp;</td>
-				</tr>
-			<?php	
-            
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];  
-			echo '</table>';
-
-		} elseif ($answerType == FILL_IN_BLANKS) {
-			?>
-			<table width="100%" border="0" cellspacing="3" cellpadding="3">
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<tr>
-			<td><i><?php echo get_lang("Answer"); ?></i> </td>
-			</tr>
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<?php
-                      
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];
-              
-			echo '</table>';
-		} elseif ($answerType == FREE_ANSWER) {
-            $answer = $str;
-			?>
-			<table width="100%" border="0" cellspacing="3" cellpadding="3">
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<tr>
-			<td><i><?php echo get_lang("Answer"); ?></i> </td>
-			</tr>
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
+//Fixing #2073 Fixing order of questions
+if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
+	$tempquestionList = explode(',',$track_exercise_info['data_tracking']);
+	if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
+		$questionList = $tempquestionList;			
+	}		
+}
 
-			<?php
-			
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());            
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];
-
-		} elseif ($answerType == MATCHING) {            
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());            
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];			
-			echo '</table>';
-		} elseif ($answerType == HOT_SPOT) {
-			
-			echo '<table width="500" border="0">
-            <tr>
+// for each question
+$counter=0;
+
+$total_weighting = 0;
+foreach ($questionList as $questionId) {
+    $objQuestionTmp     = Question::read($questionId);
+    $total_weighting  +=$objQuestionTmp->selectWeighting();        
+}
+        
+foreach ($questionList as $questionId) {
+	$counter++;		
+	$choice=$exerciseResult[$questionId];
+		// destruction of the Question object
+	unset($objQuestionTmp);
+	
+	// creates a temporary Question object
+	$objQuestionTmp 	= Question::read($questionId);
+	$questionName		= $objQuestionTmp->selectTitle();
+	$questionDescription= $objQuestionTmp->selectDescription();
+	$questionWeighting	= $objQuestionTmp->selectWeighting();
+	$answerType			= $objQuestionTmp->selectType();
+	$quesId 			= $objQuestionTmp->selectId();	
+	        	
+ 	if ($show_results) { 	    
+	    echo $objQuestionTmp->return_header($feedback_type);
+	}		
+	if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());            
+        $questionScore   = $question_result['score'];
+        $totalScore      += $question_result['score'];
+	} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType ==  MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
+		$choice=array();
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());                       
+        $questionScore   = $question_result['score'];
+        $totalScore     += $question_result['score'];	
+	} elseif ($answerType == UNIQUE_ANSWER || $answerType ==  UNIQUE_ANSWER_NO_OPTION) {	
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
+        $questionScore   = $question_result['score'];
+        $totalScore     += $question_result['score'];  
+		echo '</table>';
+	} elseif ($answerType == FILL_IN_BLANKS) {
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
+        $questionScore   = $question_result['score'];
+        $totalScore     += $question_result['score'];              
+
+	} elseif ($answerType == FREE_ANSWER) {
+        $answer = $str;     
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());            
+        $questionScore   = $question_result['score'];
+        $totalScore     += $question_result['score'];
+	} elseif ($answerType == MATCHING) {            
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());            
+        $questionScore   = $question_result['score'];
+        $totalScore     += $question_result['score'];		
+	} elseif ($answerType == HOT_SPOT) {	
+	    if ($show_results) {		
+		    echo '<table width="500" border="0"><tr>
                     <td valign="top" align="center" style="padding-left:0px;" >
-                        <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';			
-            $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, true, $objExercise->selectPropagateNeg());            
-            $questionScore  = $question_result['score'];
-            $totalScore    += $question_result['score'];
+                        <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
+		}		
+        $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());            
+        $questionScore  = $question_result['score'];
+        $totalScore    += $question_result['score'];
+        
+        if ($show_results) {                
 			echo '</table></td></tr>';            
 		 	echo '<tr>
 				<td colspan="2">'.
@@ -499,7 +364,16 @@ if ($show_results) {
 				</td>
 			</tr>
 			</table><br/>';
-		}
+        }
+	}
+	
+	if ($show_results) {
+	    if ($answerType != HOT_SPOT) {
+	        echo '</table>';
+	    }
+	}
+	
+	if ($show_results) {		    
 
 		echo '<table width="100%" border="0" cellspacing="3" cellpadding="0">';
 		
@@ -552,6 +426,7 @@ if ($show_results) {
 			}
 			echo '</td><td>';
 		}
+		
 		if ($is_allowedToEdit) {
 			if ($answerType == FREE_ANSWER) {
 				$marksname = "marksName".$questionId;
@@ -581,40 +456,43 @@ if ($show_results) {
 				 $questionScore=0;
 			}
 		}
-		?>
-		</td>
-		</tr>
-		</table>
-		<?php
-        
-		/*
-		Do not convert question results
-		$my_total_score  = convert_score($questionScore, $total_weighting);
-		$my_total_weight = convert_score($questionWeighting, $total_weighting);*/
 		
-		$my_total_score  = $questionScore;
-		$my_total_weight = $questionWeighting;       
-
-		echo '<div id="question_score">';
-	    if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
-	        $my_total_score = 0;
-	    }  
-	    
+    		echo '</td>
+		</tr>
+		</table>';		
+	}
+	
+    
+	/*
+	Do not convert question results
+	$my_total_score  = convert_score($questionScore, $total_weighting);
+	$my_total_weight = convert_score($questionWeighting, $total_weighting);*/
+	
+	$my_total_score  = $questionScore;
+	$my_total_weight = $questionWeighting;   
+	
+    if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
+        $my_total_score = 0;
+    }  
+    if ($show_results) {
+	    echo '<div id="question_score">';
 		//echo get_lang('Score')." : $my_total_score / $my_total_weight";
 		echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);    
 		
         //echo get_lang('Score')." : ".show_score($my_total_score, $total_weighting, false);
 		echo '</div>';
+    }
 
-		unset($objAnswerTmp);
-		$i++;
-		$totalWeighting+=$questionWeighting;
-        
-	} // end of large foreach on questions
-} //end of condition if $show_results
+	unset($objAnswerTmp);
+	$i++;
+
+	$totalWeighting+=$questionWeighting;
+    
+} // end of large foreach on questions
 
+//Total score
 if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
-	if ($show_results) {        
+	if ($show_results || $show_only_total_score ) {        
 		echo '<div id="question_score">'.get_lang('YourTotalScore').": ";
         $my_total_score_temp = $totalScore; 
 	    if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {

+ 16 - 1
main/exercice/fill_blanks.class.php

@@ -4,7 +4,7 @@
 
 /**
 *	File containing the FillBlanks class.
-*	@package dokeos.exercise
+*	@package chamilo.exercise
 * 	@author Eric Marguin
 * 	@author Julio Montoya Armas switchable fill in blank option added
 * 	@version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
@@ -200,6 +200,21 @@ class FillBlanks extends Question
         $objAnswer->createAnswer($answer,0,'',0,'');
         $objAnswer->save();
 	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+				<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+			<td><i><?php echo get_lang("Answer"); ?></i> </td>
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	  
+	}
 }
 
 endif;

+ 18 - 20
main/exercice/freeanswer.class.php

@@ -1,28 +1,10 @@
 <?php
-/*
-    DOKEOS - elearning and course management software
-
-    For a full list of contributors, see documentation/credits.html
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License
-    as published by the Free Software Foundation; either version 2
-    of the License, or (at your option) any later version.
-    See "documentation/licence.html" more details.
-
-    Contact:
-		Dokeos
-		Rue des Palais 44 Paleizenstraat
-		B-1030 Brussels - Belgium
-		Tel. +32 (2) 211 34 56
-*/
-
-
+/* For licensing terms, see /license.txt */
 /**
 *	File containing the FreeAnswer class.
 *	This class allows to instantiate an object of type FREE_ANSWER,
 *	extending the class question
-*	@package dokeos.exercise
+*	@package chamilo.exercise
 * 	@author Eric Marguin
 * 	@version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
 */
@@ -72,6 +54,22 @@ class FreeAnswer extends Question {
 		$this -> weighting = $form -> getSubmitValue('weighting');
 		$this->save();
 	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+			<td><i><?php echo get_lang("Answer"); ?></i> </td>
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';				
+        return $header;	  
+	}
+	
 }
 endif;
 ?>

+ 15 - 4
main/exercice/matching.class.php

@@ -236,8 +236,7 @@ class Matching extends Question {
 		}
 
 		// insert the answers
-		for($i=1 ; $i<=$nb_matches ; ++$i)
-		{
+		for($i=1 ; $i<=$nb_matches ; ++$i) {
 			$position++;
 			$answer = $form -> getSubmitValue('answer['.$i.']');
 			$matches = $form -> getSubmitValue('matches['.$i.']');
@@ -245,11 +244,23 @@ class Matching extends Question {
 			$this -> weighting += $weighting;
 			$objAnswer->createAnswer($answer,$matches,'',$weighting,$position);
 		}
-
 		$objAnswer->save();
 		$this->save();
-
 	}
+	
+		function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	         
+                            echo '<table width="100%" height="71" border="0" cellspacing="3" cellpadding="3" >';
+                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
+                            echo '<tr>
+                                    <td><span style="font-style: italic;">'.get_lang('ElementList').'</span> </td>
+                                    <td><span style="font-style: italic;">'.get_lang('CorrespondsTo').'</span></td>
+                                  </tr>';
+                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
+                    
+		}
+
 
 }
 

+ 29 - 13
main/exercice/multiple_answer.class.php

@@ -181,13 +181,10 @@ class MultipleAnswer extends Question {
 	function processAnswersCreation($form) {
 
 		$questionWeighting = $nbrGoodAnswers = 0;
+		$objAnswer  = new Answer($this->id);
+		$nb_answers = $form->getSubmitValue('nb_answers');
 
-		$objAnswer = new Answer($this->id);
-
-		$nb_answers = $form -> getSubmitValue('nb_answers');
-
-		for($i=1 ; $i <= $nb_answers ; $i++)
-        {
+		for($i=1 ; $i <= $nb_answers ; $i++) {
         	$answer = trim($form -> getSubmitValue('answer['.$i.']'));
             $comment = trim($form -> getSubmitValue('comment['.$i.']'));
             $weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
@@ -199,22 +196,41 @@ class MultipleAnswer extends Question {
 				$weighting = abs($weighting);
 				$weighting = -$weighting;
 			}
-    		if($weighting > 0)
-            {
+    		if($weighting > 0) {
                 $questionWeighting += $weighting;
             }
-
         	$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
-
         }
 
     	// saves the answers into the data base
         $objAnswer -> save();
 
         // sets the total weighting of the question
-        $this -> updateWeighting($questionWeighting);
-        $this -> save();
-
+        $this->updateWeighting($questionWeighting);
+        $this->save();
+	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td><i>'.get_lang("Choice").'</i> </td>
+				<td><i>'. get_lang("ExpectedChoice").'</i></td>
+				<td><i>'. get_lang("Answer").'</i></td>';
+				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+				} else { 
+					$header .= '<td>&nbsp;</td>';
+				}
+        $header .= '
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	    
 	}
 
 }

+ 23 - 1
main/exercice/multiple_answer_combination.class.php

@@ -221,7 +221,29 @@ class MultipleAnswerCombination extends Question {
         // sets the total weighting of the question
         $this -> updateWeighting($questionWeighting);
         $this -> save();
-
+	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td><i>'.get_lang("Choice").'</i> </td>
+				<td><i>'. get_lang("ExpectedChoice").'</i></td>
+				<td><i>'. get_lang("Answer").'</i></td>';
+				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+				} else { 
+					$header .= '<td>&nbsp;</td>';
+				}
+        $header .= '
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	  
 	}
 
 }

+ 23 - 0
main/exercice/multiple_answer_true_false.class.php

@@ -275,5 +275,28 @@ class MultipleAnswerTrueFalse extends Question {
         $this -> updateWeighting($questionWeighting);
         $this -> save();
 	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td><i>'.get_lang("Choice").'</i> </td>
+				<td><i>'. get_lang("ExpectedChoice").'</i></td>
+				<td><i>'. get_lang("Answer").'</i></td>';
+				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+				} else { 
+					$header .= '<td>&nbsp;</td>';
+				}
+        $header .= '
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	  
+	}
 }
 endif;

+ 12 - 4
main/exercice/question.class.php

@@ -1218,13 +1218,11 @@ abstract class Question
 		echo '</ul>';
 	}
 
-	static function get_types_information()
-	{
+	static function get_types_information(){
 		return self::$questionTypes;
 	}
 
-	static function updateId()
-	{
+	static function updateId() {
 		return self::$questionTypes;
 	}
     
@@ -1259,6 +1257,16 @@ abstract class Question
         $result = Database::select('*', $TBL_EXERCICE_QUESTION_OPTION, array('where'=>array('question_id = ?' =>$question_id), 'order'=>'id ASC'));
         return $result;        
     }
+    
+	function return_header($feedback_type, $counter = null) {
+	    $counter_label = '';
+	    if (!is_null($counter)) {
+	        $counter = intval($counter);
+	    }	
+	    echo Display::div(get_lang("Question").' '.($counter_label).' : '.$this->question, array('id'=>'question_title', 'class'=>'sectiontitle'));
+	    echo Display::div($this->description, array('id'=>'question_description'));	    
+	}
+	
 }
 endif;
 ?>

+ 23 - 1
main/exercice/unique_answer.class.php

@@ -370,7 +370,29 @@ class UniqueAnswer extends Question {
         // sets the total weighting of the question
         $this -> updateWeighting($questionWeighting);
         $this -> save();
-
+	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td><i>'.get_lang("Choice").'</i> </td>
+				<td><i>'. get_lang("ExpectedChoice").'</i></td>
+				<td><i>'. get_lang("Answer").'</i></td>';
+				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+				} else { 
+					$header .= '<td>&nbsp;</td>';
+				}
+        $header .= '
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	
 	}
 }
 endif;

+ 24 - 2
main/exercice/unique_answer_no_option.class.php

@@ -449,7 +449,7 @@ class UniqueAnswerNoOption extends Question {
         $comment    = trim($form -> getSubmitValue('comment['.$i.']'));
         $weighting  = trim($form -> getSubmitValue('weighting['.$i.']'));
         $goodAnswer= ($correct == $i) ? true : false;
-        $dest       = '';
+        $dest       = ''; 
             
         $objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i,NULL,NULL,$dest);
         
@@ -459,7 +459,29 @@ class UniqueAnswerNoOption extends Question {
         // sets the total weighting of the question
         $this -> updateWeighting($questionWeighting);
         $this -> save();
-
+	}
+	
+	function return_header($feedback_type, $counter = null) {
+	    parent::return_header($feedback_type, $counter);
+	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+			<tr>
+			<td>&nbsp;</td>
+			</tr>
+			<tr>
+				<td><i>'.get_lang("Choice").'</i> </td>
+				<td><i>'. get_lang("ExpectedChoice").'</i></td>
+				<td><i>'. get_lang("Answer").'</i></td>';
+				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+				} else { 
+					$header .= '<td>&nbsp;</td>';
+				}
+        $header .= '
+			</tr>
+			<tr>
+			<td>&nbsp;</td>
+			</tr>';
+        return $header;	
 	}
 }
 endif;