Juan Carlos Raña 13 лет назад
Родитель
Сommit
b08c006f21

+ 7 - 3
main/css/base.css

@@ -67,9 +67,10 @@ label, input, button, select, textarea, p {
     font-size: inherit;
 }
 
+
+
 /* button with image */
-button.add, button.save, button.cancel, button.refresh, button.upload, button.search, 
-button.login, button.plus, button.minus, button.next, button.back, button.arrowl, button.arrowr {
+button.add, button.save, button.cancel, button.refresh, button.upload, button.search, button.login, button.plus, button.minus, button.next, button.back {
     padding-left:30px;
     background-position:8px !important;
     background-repeat:no-repeat;    
@@ -1565,9 +1566,12 @@ a.unread {
 
 div.image-social-content {
     float:left;
+    /*border:1px dotted #ccc;*/
     margin:2px;
     padding: 8px 4px 4px 4px;
-    background: #ffffff;    
+    background: #ffffff;
+    height:105px;
+    width:82px;
     z-index:5;
     cursor:pointer;
     position:relative;

+ 43 - 1
main/css/base_chamilo.css

@@ -1746,7 +1746,49 @@ div.image_friend_network center.friend {
 .friend_invitations {    
     margin: 0 0 4px 12px;
 }
-
+/* button >> */
+button.arrowr {
+    -moz-border-radius-topleft : 5px;
+    -moz-border-radius-bottomright : 5px;
+    -moz-border-radius-bottomleft : 5px;
+    -moz-border-radius-topright : 5px;
+    padding-left:20px;
+    padding-top:20px;
+    background-position:10px;
+    background-color:#E5EDF9;
+    border-color: #D4E2F6;
+    border-width: 1px;
+    display:block;
+    font-size: 100%;
+    line-height :130%;
+    vertical-align:middle;
+}
+/*including "arrowr" image*/
+button.arrowr {
+    background-repeat:no-repeat;
+}
+/* button << */
+button.arrowl {
+    margin:0px;
+    -moz-border-radius-topleft : 5px;
+    -moz-border-radius-bottomright : 5px;
+    -moz-border-radius-bottomleft : 5px;
+    -moz-border-radius-topright : 5px;
+    padding-left:20px;
+    padding-top:20px;
+    background-position:10px;
+    background-color:#E5EDF9;
+    border-color: #D4E2F6;
+    border-width: 1px;
+    display:block;
+    font-size: 100%;
+    line-height :130%;
+    vertical-align:middle;
+}
+/*including "arrowl" image*/
+button.arrowl {
+    background-repeat:no-repeat;
+}
 .u-m-answer {
     float:left;
     width:100%;

+ 10 - 5
main/document/record_audio_wami.php

@@ -186,18 +186,16 @@ echo '</div>';
 		});
 	
 		gui.setPlayEnabled(false);
-
 	}
-	
 
 </script>
 
 
-<div id="wami" style="margin-left: 510px; margin-top:10px;"></div>
+<div id="wami" style="margin-top:10px;"></div>
 
-<div align="center" style="margin-top:140px;">
+<div align="center" style="margin-top:150px;">
 <form name="form_wami_recorder">
-<input placeholder="<?php echo get_lang('InputHereName'); ?>" type="text" id="audio_title"><br/>
+<input placeholder="<?php echo get_lang('InputNameHere'); ?>" type="text" id="audio_title"><br/>
 <button type="button" value="" onclick="setupRecorder()" id="audio_button" /><?php echo get_lang('Activate'); ?></button>
 <button type="button" value="" onclick="newNameRecord()" id="new_name" /><?php echo get_lang('Reload'); ?></button>
 <?php echo Display :: return_icon('info3.gif', get_lang('WamiNeedFilename').' '.get_lang('WamiFlashDialog').' '.get_lang('WamiReload'), array('align' => 'absmiddle', 'hspace' => '3px'), false); ?>
@@ -207,6 +205,13 @@ echo '</div>';
 <?php Display::display_normal_message(get_lang('WamiNeedFilename').' '.get_lang('WamiStartRecorder'), false); ?>
 </div>
 
+<script>
+if (navigator.appName == 'Microsoft Internet Explorer') {
+	document.getElementById('wami').style.marginLeft='400px';
+}else{
+	document.getElementById('wami').style.marginLeft='510px';
+}
+</script>
 
 <?php
 

+ 39 - 67
main/exercice/exercise.class.php

@@ -19,7 +19,7 @@ define('EXERCISE_FEEDBACK_TYPE_EXAM',       2); //NoFeedback 	 - Show score only
 
 define('EXERCISE_MAX_NAME_SIZE',            80);
 
-$debug = true; //All exercise scripts should depend in this debug variable
+$debug = 0; //All exercise scripts should depend in this debug variable
 
 require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
 
@@ -1818,18 +1818,18 @@ class Exercise {
 	public function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array()) {
 		global $_configuration, $feedback_type, $debug;		
 		require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
-        
-        if ($debug) error_log("<------ manage_answer ------> ");
-		if ($debug) error_log('manage_answer called exe_id: '.$exeId);
-		if ($debug) error_log('manage_answer $from:  '.$from);
-		if ($debug) error_log('manage_answer $saved_results: '.$saved_results);
-		if ($debug) error_log('manage_answer $from_database: '.$from_database);
-		if ($debug) error_log('manage_answer $show_result: '.$show_result);
-		if ($debug) error_log('manage_answer $propagate_neg: '.$propagate_neg);
-		if ($debug) error_log('manage_answer $hotspot_delineation_result: '.print_r($hotspot_delineation_result, 1));
+
+		if ($debug) error_log('manage_answer called exe_id '.$exeId);
+		if ($debug) error_log('manage_answer $from  '.$from);
+		if ($debug) error_log('manage_answer $saved_results  '.$saved_results);
+		if ($debug) error_log('manage_answer $from_database '.$from_database);
+		if ($debug) error_log('manage_answer $show_result '.$show_result);
+		if ($debug) error_log('manage_answer $propagate_neg '.$propagate_neg);
+		if ($debug) error_log('manage_answer $hotspot_delineation_result '.print_r($hotspot_delineation_result, 1));
 			
 		$extra_data = array();
-				 
+		$html = '';
+		 
 		$questionId   = intval($questionId);
 		$exeId        = intval($exeId);
 		$TBL_TRACK_ATTEMPT      = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
@@ -1868,8 +1868,9 @@ class Exercise {
 		$objAnswerTmp = new Answer($questionId);
 		$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
 
-		if ($debug) error_log('Count of answers: '.$nbrAnswers);
-		if ($debug) error_log('$answerType: '.$answerType);
+		if ($debug) error_log('Count of answers :'.$nbrAnswers);
+		if ($debug) error_log('$answerType : '.$answerType);
+
 
 		if ($answerType == FREE_ANSWER || $answerType == ORAL_EXPRESSION) {
 			$nbrAnswers = 1;
@@ -1915,26 +1916,18 @@ class Exercise {
 		$organs_at_risk_hit = 0;
 
 		$questionScore = 0;
-		if ($debug) error_log('Start answer loop ');
-        
-        $answer_correct_array = array();
-        
+		 
 		for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
 			$answer             = $objAnswerTmp->selectAnswer($answerId);			
 			$answerComment      = $objAnswerTmp->selectComment($answerId);
 			$answerCorrect      = $objAnswerTmp->isCorrect($answerId);
 			$answerWeighting    = $objAnswerTmp->selectWeighting($answerId);
 			$numAnswer          = $objAnswerTmp->selectAutoId($answerId);
-            
-            $answer_correct_array[$answerId] = (bool)$answerCorrect;
-            
-            if ($debug) error_log("answer auto id: $numAnswer ");
-            if ($debug) error_log("answer correct : $answerCorrect ");
 
 			//delineation
 			$delineation_cord   = $objAnswerTmp->selectHotspotCoordinates(1);
 			$answer_delineation_destination=$objAnswerTmp->selectDestination(1);
-            
+
 			switch ($answerType) {
 				// for unique answer
 				case UNIQUE_ANSWER :
@@ -1989,34 +1982,32 @@ class Exercise {
 						//if no result then the user just hit don't know
 						$studentChoice = 3;
 						$questionScore  +=  $doubt_score;
-					}					
+					}
+					
 					$totalScore = $questionScore;
 					break;
-				case MULTIPLE_ANSWER : //2                    
+				case MULTIPLE_ANSWER :
 					if ($from_database) {
-						$choice = array();
-						$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";                        
+						$choice=array();
+						$queryans = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." where exe_id = '".$exeId."' and question_id= '".$questionId."'";
 						$resultans = Database::query($queryans);
 						while ($row = Database::fetch_array($resultans)) {
 							$ind = $row['answer'];
 							$choice[$ind] = 1;
 						}
-						$numAnswer = $objAnswerTmp->selectAutoId($answerId);
-						$studentChoice = $choice[$numAnswer];  
-                        $real_answers[$answerId] = (bool)$studentChoice;
-						if ($studentChoice == $answerCorrect) {
-							$questionScore  +=$answerWeighting;							                            
+						$numAnswer=$objAnswerTmp->selectAutoId($answerId);
+						$studentChoice=$choice[$numAnswer];
+						if ($studentChoice) {
+							$questionScore  +=$answerWeighting;
+							$totalScore     +=$answerWeighting;
 						}
 					} else {
-						$studentChoice = $choice[$numAnswer];
-						if ($studentChoice == $answerCorrect) {
+						$studentChoice=$choice[$numAnswer];
+						if ($studentChoice) {
 							$questionScore  +=$answerWeighting;
+							$totalScore     +=$answerWeighting;
 						}
-                        $real_answers[$answerId] = (bool)$studentChoice;
 					}
-                    $totalScore     +=$answerWeighting;
-                    
-                    if ($debug) error_log("studentChoice: $studentChoice");
 					break;
 				case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
 					if ($from_database) {
@@ -2345,8 +2336,10 @@ class Exercise {
 						break;
 					}
 					// for hotspot with no order
-				case HOT_SPOT :					
-					if ($from_database) {						
+				case HOT_SPOT :
+					
+					if ($from_database) {
+						
 						if ($show_result) {
 							$TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
 							$query = "SELECT hotspot_correct FROM ".$TBL_TRACK_HOTSPOT." WHERE hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='".Database::escape_string($answerId)."'";
@@ -2412,14 +2405,11 @@ class Exercise {
 					$_SESSION['hotspot_dest'][1]	= $answer_delineation_destination;
 					break;
 			} // end switch Answertype
-            
 
-			global $origin;
+			global $origin, $debug;
 
 			if ($show_result) {
-                
-                if ($debug) error_log('show result '.$show_result);
-                
+
 				if ($from == 'exercise_result') {
 					if ($debug) error_log('Showing questions $from '.$from);
 					//display answers (if not matching type, or if the answer is correct)
@@ -2831,10 +2821,7 @@ class Exercise {
 					}
 				}
 			}
-            if ($debug) error_log(' ------ ');
 		} // end for that loops over all answers of the current question
-        
-        if ($debug) error_log('-- end answer loop --');
 
 		
 		// destruction of Answer
@@ -2846,7 +2833,7 @@ class Exercise {
 		}
 
 		$final_answer = true;
-		foreach ($real_answers as $my_answer) {
+		foreach($real_answers as $my_answer) {
 			if (!$my_answer) {
 				$final_answer = false;
 			}
@@ -2861,19 +2848,6 @@ class Exercise {
 				$totalScore         += $answerWeighting;
 			}
 		}
-        
-        //Fixes multiple answer question in order to be exact 
-        if ($answerType == MULTIPLE_ANSWER) {
-            $diff = @array_diff($answer_correct_array, $real_answers);
-            
-            if ($debug) error_log(" answer_correct_array: ".print_r($answer_correct_array, 1)."");
-            if ($debug) error_log(" real_answers: ".print_r($real_answers, 1)."");
-            if ($debug) error_log(" diff: $diff");
-            
-            if (!empty($diff)) {
-                $questionScore = 0;
-            }
-        } 
 
 		$extra_data = array('final_overlap' => $final_overlap, 'final_missing'=>$final_missing, 'final_excess'=> $final_excess,
         					'overlap_color' => $overlap_color, 'missing_color'=>$missing_color, 'excess_color'=> $excess_color,
@@ -3041,15 +3015,14 @@ class Exercise {
 		// Store results directly in the database
 		// For all in one page exercises, the results will be
 		// stored by exercise_results.php (using the session)
-        
+
 		if ($saved_results) {
-            if ($debug) error_log("Save question results $saved_results");
-            if ($debug) error_log(print_r($choice ,1 ));
-            
 			if (empty($choice)) {
 				$choice = 0;
 			}
 			if ($answerType ==  MULTIPLE_ANSWER_TRUE_FALSE || $answerType ==  MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
+				
+				if ($debug) error_log(print_r($choice ,1 ));
 				if ($choice != 0) {
 					$reply = array_keys($choice);
 					for ($i = 0; $i < sizeof($reply); $i++) {
@@ -3063,7 +3036,6 @@ class Exercise {
 			} elseif ($answerType == MULTIPLE_ANSWER) {
 				if ($choice != 0) {
 					$reply = array_keys($choice);
-                    if ($debug) error_log("reply ".print_r($reply, 1)."");
 					for ($i = 0; $i < sizeof($reply); $i++) {
 						$ans = $reply[$i];
 						exercise_attempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);

+ 1 - 2
main/exercice/exercise_result.php

@@ -45,7 +45,7 @@ api_protect_course_script(true);
 // Database table definitions
 $main_admin_table       = Database::get_main_table(TABLE_MAIN_ADMIN);
 
-if ($debug){ error_log('Entering exercise_result.php: '.print_r($_POST,1));}
+if($debug>0){error_log('Entered exercise_result.php: '.print_r($_POST,1));}
 
 // general parameters passed via POST/GET
 if ( empty ( $origin ) ) {                  $origin                 = Security::remove_XSS($_REQUEST['origin']);}
@@ -165,7 +165,6 @@ $total_score = $total_weight = 0;
 
 // Loop over all question to show results for each of them, one by one
 if (!empty($question_list)) {
-    if ($debug){ error_log('Loopinf question_list '.print_r($question_list,1));}
 	foreach ($question_list as $questionId) {
 	    // destruction of the Question object
 		unset($objQuestionTmp);

+ 2 - 2
main/exercice/exercise_show.php

@@ -42,11 +42,11 @@ $TBL_QUESTIONS         	= Database::get_course_table(TABLE_QUIZ_QUESTION);
 $TBL_REPONSES          	= Database::get_course_table(TABLE_QUIZ_ANSWER);
 $main_user_table 		= Database::get_main_table(TABLE_MAIN_USER);
 $main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-$TBL_TRACK_EXERCICES    	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+$TBL_TRACK_EXERCICES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 $TBL_TRACK_ATTEMPT		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
 // General parameters passed via POST/GET
-if ($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
+if($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
 
 if ( empty ( $formSent ) ) {            $formSent       = $_REQUEST['formSent']; }
 if ( empty ( $exerciseResult ) ) {      $exerciseResult = $_SESSION['exerciseResult'];}

+ 78 - 56
main/exercice/exercise_submit.php

@@ -159,6 +159,7 @@ if ($time_control) {
 	$current_expired_time_key = generate_time_control_key($objExercise->id);
 }
 
+
 $show_clock = true;
 $user_id = api_get_user_id();
 if ($objExercise->selectAttempts() > 0) {
@@ -219,44 +220,42 @@ if ($objExercise->selectAttempts() > 0) {
 
 
 
-if ($debug) { error_log("4. Setting the exe_id: $exe_id");} ;
+if ($debug) { error_log("4. Setting the exe_id $exe_id");} ;
 
 //5. Getting user exercise info (if the user took the exam before) - generating exe_id
 //var_dump($safe_lp_id.' - '.$safe_lp_item_id.' - '.$safe_lp_item_view_id);
 $exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);
 
 if (empty($exercise_stat_info)) {
-    if ($debug)  error_log('5  $exercise_stat_info is empty ');
 	$total_weight = 0;
 	$questionList = $objExercise->get_validated_question_list();	
-	foreach ($questionList as $question_id) {
+	foreach($questionList as $question_id) {
 		$objQuestionTmp = Question::read($question_id);
 		$total_weight += floatval($objQuestionTmp->weighting);
 	}
 	$clock_expired_time = '';
-    
 	if ($time_control) {
 		$expected_time = $current_timestamp + $total_seconds;
 		
-		if ($debug)  error_log('5.1. $current_timestamp '.$current_timestamp);
-		if ($debug)  error_log('5.2. $expected_time '.$expected_time);
+		if ($debug)  error_log('6.3. $current_timestamp '.$current_timestamp);
+		if ($debug)  error_log('6.4. $expected_time '.$expected_time);
 		
 		$clock_expired_time 	= api_get_utc_datetime($expected_time);
-		if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
+		if ($debug) error_log('6.5. $expected_time '.$clock_expired_time);
 		
 		//Sessions  that contain the expired time
 		$_SESSION['expired_time'][$current_expired_time_key] 	 = $clock_expired_time;
-		if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
+		if ($debug) {
+			error_log('6.6. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] );
+		};
 	}
 	$exe_id = $objExercise->save_stat_track_exercise_info($clock_expired_time, $safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id, $questionList, $total_weight);
 	$exercise_stat_info = $objExercise->get_stat_track_exercise_info($safe_lp_id, $safe_lp_item_id, $safe_lp_item_view_id);	
-    if ($debug)  error_log("5.5  exercise_stat_info[] exists getting exe_id $exe_id");
 } else {
 	$exe_id = $exercise_stat_info['exe_id'];
-    if ($debug)  error_log("5  exercise_stat_info[] exists getting exe_id $exe_id ");
 }
 
-if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
+if ($debug) { error_log('5. $objExercise->get_stat_track_exercise_info function called::  '.print_r($exercise_stat_info, 1)); };
 
 if (!empty($exercise_stat_info['questions_to_check'])) {
 	$my_remind_list = $exercise_stat_info['questions_to_check'];
@@ -265,30 +264,29 @@ if (!empty($exercise_stat_info['questions_to_check'])) {
 }
 
 $params = 'exe_id='.$exe_id.'&exerciseId='.$exerciseId.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpath_item_view_id;
-if ($debug) { error_log("6.1 params: ->  $params"); };
+if ($debug) { error_log("5.1 params: ->  $params"); };
 
 if ($reminder == 2 && empty($my_remind_list)) {	
-    if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
 	header('Location: exercise_reminder.php?'.$params);
 	exit;
 }
 
 /*
- * 7. Loading Time control parameters
+ * 6. Loading Time control parameters
  * If the expired time is major that zero(0) then the expired time is compute on this time. Disable for learning path
  */
 
 if ($time_control) {
-	if ($debug) error_log('7.1. Time control is enabled');	
-	if ($debug) error_log('7.2. $current_expired_time_key  '.$current_expired_time_key);
-	if ($debug) error_log('7.3. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]);
+	if ($debug) error_log('6.1. Time control is enabled');	
+	if ($debug) {error_log('6.2. $current_expired_time_key  '.$current_expired_time_key); };
+	if ($debug) { error_log('6.2. $_SESSION[expired_time][$current_expired_time_key]  '.$_SESSION['expired_time'][$current_expired_time_key]); };
 	
     if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
         //Timer - Get expired_time for a student        
         if (!empty($exercise_stat_info)) {
-        	if ($debug) {error_log('7.4 Seems that the session ends and the user want to retake the exam'); };        	
+        	if ($debug) {error_log('6.3 Seems that the session ends and the user want to retake the exam'); };        	
 	        $expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
-			if ($debug) {error_log('7.5 $expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }			
+			if ($debug) {error_log('$expired_time_of_this_attempt: '.$expired_time_of_this_attempt); }			
 	        //Get the last attempt of an exercice
 	    	$last_attempt_date = get_last_attempt_date_of_exercise($exercise_stat_info['exe_id']);
 	    	
@@ -301,33 +299,31 @@ if ($time_control) {
 	    		$diff = $current_timestamp - api_strtotime($last_attempt_date,'UTC');
 	    		$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date,'UTC') + $diff);
 	    	}
-	        if ($debug) {error_log('7.6. $last_attempt_date: '.$last_attempt_date); }
+	        if ($debug) {error_log('6.4. $last_attempt_date: '.$last_attempt_date); }
 	        	
 	        //New expired time - it is due to the possible closure of session
 	        $new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date,'UTC');
-	        if ($debug) {error_log('7.7. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }	        
+	        if ($debug) {error_log('6.5. $new_expired_time_in_seconds: '.$new_expired_time_in_seconds); }	        
 	        
 	        $expected_time	= $current_timestamp + $new_expired_time_in_seconds;
-	        if ($debug) {error_log('7.8. $expected_time1: '.$expected_time); }
+	        if ($debug) {error_log('6.6. $expected_time1: '.$expected_time); }
 	        	        			
 	        $clock_expired_time  = api_get_utc_datetime($expected_time);
-	        if ($debug) {error_log('7.9. $clock_expired_time: '.$clock_expired_time); }
+	        if ($debug) {error_log('6.7. $clock_expired_time: '.$clock_expired_time); }
 	        	              		
 			// First we update the attempt to today
 			// How the expired time is changed into "track_e_exercices" table,then the last attempt for this student should be changed too,so
 	        $sql_track_e_exe = "UPDATE $exercice_attemp_table SET tms = '".api_get_utc_datetime()."' WHERE exe_id = '".$exercise_stat_info['exe_id']."' AND tms = '".$last_attempt_date."' ";
-	        if ($debug) {error_log('7.10. $sql_track_e_exe2: '.$sql_track_e_exe); }
+	        if ($debug) {error_log('6.8. $sql_track_e_exe2: '.$sql_track_e_exe); }
 	        Database::query($sql_track_e_exe);
 	        	
 	        //Sessions  that contain the expired time
 	        $_SESSION['expired_time'][$current_expired_time_key] 		= $clock_expired_time;
-	        if ($debug) {error_log('7.11. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
+	        if ($debug) {error_log('6.9. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key] ); };
         }
     } else {
         $clock_expired_time =  $_SESSION['expired_time'][$current_expired_time_key];
     }
-} else {
-    if ($debug) { error_log("7 No time control"); };
 }
 
 // Get time left for exipiring time
@@ -341,6 +337,24 @@ if ($time_control) { //Sends the exercice form when the expired time is finished
 	$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
 }
 
+/*
+if ($objExercise->type == ONE_PER_PAGE && $objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {	
+	if (!empty($exercise_stat_info)) {
+        $exe_id = $exercise_stat_info['exe_id'];
+        if ($_SERVER['REQUEST_METHOD'] != 'POST') {            
+            $recorded['questionList'] = explode(',', $exercise_stat_info['data_tracking']);            
+            $query = 'SELECT * FROM ' . $exercice_attemp_table . ' WHERE exe_id = ' . $exercise_stat_info['exe_id'] . ' ORDER BY tms ASC';            
+            $result = Database::query($query);
+            while ($row = Database :: fetch_array($result,'ASSOC')) {
+                $recorded['exerciseResult'][$row['question_id']] = 1;
+            }
+            $exerciseResult = $_SESSION['exerciseResult'] = $recorded['exerciseResult'];            
+            $current_question = count($recorded['exerciseResult']);
+            $current_question++;
+            $questionList = $_SESSION['questionList'] = $recorded['questionList'];
+        }
+    }
+}*/
 // if the user has submitted the form
 
 $exercise_title			= $objExercise->selectTitle();
@@ -364,7 +378,7 @@ if (!isset($_SESSION['questionList'])) {
 	}
 }
 
-if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
+if ($debug) error_log('7 Question list loaded '.print_r($questionList, 1));
 
 $quizStartTime = time();
 api_session_register('quizStartTime');
@@ -376,7 +390,7 @@ if (!empty($questionList)) {
 }
 
 if ($formSent && isset($_POST)) {
-    if ($debug) { error_log('9. $formSent was set'); }
+    if ($debug > 0) { error_log('8. $formSent was set'); }
 
     // Initializing
     if (!is_array($exerciseResult)) {
@@ -392,13 +406,13 @@ if ($formSent && isset($_POST)) {
     
     // if the user has answered at least one question
     if (is_array($choice)) {
-        if ($debug) { error_log('9.1. $choice is an array '.print_r($choice, 1)); } 	
+        if ($debug) { error_log('8.1. $choice is an array '.print_r($choice, 1)); } 	
         // Also store hotspot spots in the session ($exerciseResultCoordinates
         // will be stored in the session at the end of this script)
 
         if (isset($_POST['hotspot'])) {
             $exerciseResultCoordinates = $_POST['hotspot'];
-            if ($debug) { error_log('9.2. $_POST[hotspot] data '.print_r($exerciseResultCoordinates, 1)); }     
+            if ($debug) { error_log('8.2. $_POST[hotspot] data '.print_r($exerciseResultCoordinates, 1)); }     
         }        	
         if ($objExercise->type == ALL_ON_ONE_PAGE) {
             // $exerciseResult receives the content of the form.
@@ -419,15 +433,15 @@ if ($formSent && isset($_POST)) {
                     $choice = $exerciseResult[$questionId];                    
                     if (isset($exe_id)) {
                     	//Manage the question and answer attempts
-                        if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
+                        if ($debug > 0) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
                     	$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false, $objExercise->propagate_neg);
                     }
                     //END of saving and qualifying
                 }
             }
         }
-        if ($debug) { error_log('9.3.  $choice is an array - end'); }
-        if ($debug) { error_log('9.4.  $exerciseResult '.print_r($exerciseResult,1)); }
+        if ($debug > 0) { error_log('8.3.  $choice is an array - end'); }
+        if ($debug > 0) { error_log('8.4.  $exerciseResult '.print_r($exerciseResult,1)); }
     }
     
     
@@ -438,11 +452,11 @@ if ($formSent && isset($_POST)) {
 
     // if all questions on one page OR if it is the last question (only for an exercise with one question per page)
     
-    if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count)) {          
+    if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question >= $question_count)) {       
         if (api_is_allowed_to_session_edit()) {
             // goes to the script that will show the result of the exercise
             if ($objExercise->type == ALL_ON_ONE_PAGE) {
-                if ($debug) { error_log('10. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
+                if ($debug) { error_log('Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
                 
                 //We check if the user attempts before sending to the exercise_result.php                
                 if ($objExercise->selectAttempts() > 0) {
@@ -478,20 +492,23 @@ if ($formSent && isset($_POST)) {
                     if ($debug) { error_log('Updating track_e_exercises '.$update_query); }                    
                     Database::query($update_query);*/
                 }                
-                if ($debug) { error_log('10. Redirecting to exercise_show.php'); }
+                if ($debug) { error_log('Redirecting to exercise_show.php'); }
                 //header("Location: exercise_show.php?id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
                 header("Location: exercise_result.php?exe_id=$exe_id&origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
                 exit;
             }            
         } else {
-            if ($debug) { error_log('10. Redirecting to exercise_submit.php'); }
+            if ($debug) { error_log('Redirecting to exercise_submit.php'); }
             header("Location: exercise_submit.php?exerciseId=$exerciseId&origin=$origin");
             exit;            
         }
     }
-    if ($debug) { error_log('11. $formSent was set - end'); }
-} else {
-    if ($debug) { error_log('9. $formSent was NOT sent'); }
+    
+    if (!empty($remind_list)) {
+         //header("Location: exercise_reminder.php?origin=$origin&learnpath_id=$safe_lp_id&learnpath_item_id=$safe_lp_item_id&learnpath_item_view_id=$safe_lp_item_view_id");
+         exit;
+    }
+    if ($debug > 0) { error_log('$formSent was set - end'); }
 }
 
 // if questionNum comes from POST and not from GET
@@ -503,13 +520,12 @@ if (!$current_question || $_REQUEST['num']) {
         $current_question++;
     }
 }
-
 if ($question_count != 0) {
 	if (($objExercise->type == ALL_ON_ONE_PAGE || $current_question > $question_count)) {       
 	    if (api_is_allowed_to_session_edit()) {
 	        // goes to the script that will show the result of the exercise
 	        if ($objExercise->type == ALL_ON_ONE_PAGE) {
-	            if ($debug) { error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
+	            if ($debug) { error_log('Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php'); }
 	            
 	            //We check if the user attempts before sending to the exercise_result.php
 	            if ($objExercise->selectAttempts() > 0) {
@@ -538,10 +554,10 @@ if ($question_count != 0) {
 	            
 	                if ($check) {
 	                	$sql_exe_result = "";                    	
-	                    if ($debug) { error_log('12. exercise_time_control_is_valid is valid'); }
+	                    if ($debug) { error_log('exercise_time_control_is_valid is valid'); }
 	                } else {
 	                	$sql_exe_result = ", exe_result = 0";
-	                    if ($debug) { error_log('12. exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
+	                    if ($debug) { error_log('exercise_time_control_is_valid is NOT valid then exe_result = 0 '); }
 	                }
 	                /*
 	                //Clean incomplete - @todo why setting to blank the status?                  
@@ -610,6 +626,12 @@ if (api_is_course_admin() && $origin != 'learnpath') {
     }
     echo '</div>';
 }
+/*
+$exercise_header = Display::div($exercise_title, array('class'=>'exercise_title'));
+if (!empty($exercise_description)) {
+	$exercise_header .= Display::div($exercise_description, array('class'=>'exercise_description'));
+}
+echo Display::div($exercise_header, array('class'=>'exercise_header'));*/
 
 $is_visible_return = $objExercise->is_visible($learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
 if ($is_visible_return['value'] == false) {
@@ -622,7 +644,7 @@ if ($is_visible_return['value'] == false) {
 
 $limit_time_exists = (($objExercise->start_time != '0000-00-00 00:00:00') || ($objExercise->end_time != '0000-00-00 00:00:00')) ? true : false;
 
-if ($limit_time_exists) {    
+if ($limit_time_exists) {	    
     $exercise_start_time 	= api_strtotime($objExercise->start_time, 'UTC');
     $exercise_end_time 		= api_strtotime($objExercise->end_time, 'UTC');
     $time_now 				= time();
@@ -677,15 +699,16 @@ if ($origin != 'learnpath') {
    echo '<div id="highlight-plugin" class="glossary-content">';
 }
 
+//var_dump('$remind_question_id . '.$remind_question_id);
+
 if ($reminder == 2)  {
-    if ($debug) { error_log('. $reminder == 2'); }
  
     $data_tracking  = $exercise_stat_info['data_tracking'];
     $data_tracking  = explode(',', $data_tracking);
       
     $current_question = 1; //set by default the 1st question    
     
-    if (!empty($my_remind_list)) {
+    if (!empty($my_remind_list)) { 
     	//Checking which questions we are going to call from the remind list      
 		for ($i = 0; $i < count($data_tracking); $i++) {
 			for($j = 0; $j < count($my_remind_list); $j++) {				
@@ -718,9 +741,8 @@ if ($reminder == 2)  {
 				}
 			}  
         }
-    } else {
+    } else {    	
     	if ($objExercise->review_answers) {
-            if ($debug) { error_log('. redirecting to exercise_reminder.php '); }
 	    	header("Location: exercise_reminder.php?$params");
 	    	exit;
     	}
@@ -825,8 +847,10 @@ if (!empty($error)) {
                             
            		// Only for the first time
            		
+           		
+           		
           		$("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('loading1.gif')).'");                                
-                    $.ajax({
+                    $.ajax({ 
                         url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
                         data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,                                 
                         success: function(return_value) {
@@ -843,12 +867,10 @@ if (!empty($error)) {
 								} else {
 									url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'";
 								}								
-								window.location = url;								
+								window.location = url;
+								
                         	}
-                        },
-                        error: function() {
-                            $("#save_for_now_"+question_id).html("'.addslashes(Display::return_icon('error.png', get_lang('Error'), array(), ICON_SIZE_SMALL)).'");
-                        }
+                        },                                 
                     });   
                 return false;
             }

+ 14 - 32
main/inc/ajax/exercise.ajax.php

@@ -15,8 +15,6 @@ api_protect_course_script(true);
 $action = $_REQUEST['a'];
 $course_id = api_get_course_int_id();
 
-if ($debug) error_log("$action ajax call");
-
 switch ($action) {
     case 'get_live_stats':
         if (!api_is_allowed_to_edit(null, true)) {
@@ -123,8 +121,8 @@ switch ($action) {
             Display::display_confirmation_message(get_lang('Saved'));
         }
         break;
-    case 'add_question_to_reminder':          
-    	$objExercise  = $_SESSION['objExercise'];    	
+    case 'add_question_to_reminder':    	    	
+    	$objExercise             = $_SESSION['objExercise'];    	
     	if (empty($objExercise)) {
     		echo 0;
     		exit;
@@ -137,24 +135,19 @@ switch ($action) {
         if (api_is_allowed_to_session_edit()) {
         	            
             //"all" or "simple" strings means that there's one or all questions           
-            $type                   = $_REQUEST['type'];            
+            $type                    = $_REQUEST['type'];            
             
             //Normal questions choices
-            $choice                 = $_REQUEST['choice'];
+            $choice                  = $_REQUEST['choice'];
             
             //All Hotspot coordinates from all questions 
-            $hot_spot_coordinates   = $_REQUEST['hotspot'];            
+            $hot_spot_coordinates    = $_REQUEST['hotspot'];
+            
             
             //There is a reminder?
-            $remind_list            = isset($_REQUEST['remind_list']) && !empty($_REQUEST['remind_list'])? array_keys($_REQUEST['remind_list']) : null;
+            $remind_list             = isset($_REQUEST['remind_list']) && !empty($_REQUEST['remind_list'])? array_keys($_REQUEST['remind_list']) : null;
                
-            $exe_id                 = $_REQUEST['exe_id'];
-            
-            if ($debug) error_log("exe_id = $exe_id ");
-            if ($debug) error_log("type = $type ");
-            if ($debug) error_log("choice = ".print_r($choice, 1)." ");
-            if ($debug) error_log("hot_spot_coordinates = $hot_spot_coordinates ");
-            if ($debug) error_log("remind_list = $remind_list ");            
+            $exe_id = $_REQUEST['exe_id'];
             
             //Exercise information            
             $question_id             = intval($_REQUEST['question_id']);            
@@ -164,8 +157,7 @@ switch ($action) {
             if (empty($question_list) || empty($objExercise)) {
                 echo 0;
                 exit;
-            }
-            
+            }            
             //Getting information of the current exercise    
             $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);           
             
@@ -240,16 +232,12 @@ switch ($action) {
             
             //Looping the question list
             
-            foreach ($question_list as $my_question_id) {
-                if ($debug) error_log("Saving question_id = $my_question_id ");                
-                
+            foreach($question_list as $my_question_id) {                
                 if ($type == 'simple' && $question_id != $my_question_id) {
                     continue;
                 }             
                  
                 $my_choice = $choice[$my_question_id];
-                
-                if ($debug) error_log("my_choice = ".print_r($my_choice, 1)."");
                                 
                // creates a temporary Question object
             	$objQuestionTmp        = Question::read($my_question_id);
@@ -267,8 +255,7 @@ switch ($action) {
             	$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$my_question_id];
             	
             	// Deleting old attempt
-                if (isset($attempt_list) && !empty($attempt_list[$my_question_id])) {          
-                    if ($debug) error_log("delete_attempt  exe_id : $exe_id, my_question_id: $my_question_id");
+                if (isset($attempt_list) && !empty($attempt_list[$my_question_id])) {                    
                     delete_attempt($exe_id, api_get_user_id() , api_get_course_id(), api_get_session_id(), $my_question_id);
                     if ($objQuestionTmp->type  == HOT_SPOT) {            	        
             	        delete_attempt_hotspot($exe_id, api_get_user_id() , api_get_course_id(), $my_question_id);
@@ -279,18 +266,13 @@ switch ($action) {
             	// We're inside *one* question. Go through each possible answer for this question
             	$result = $objExercise->manage_answer($exe_id, $my_question_id, $my_choice,'exercise_result', $hot_spot_coordinates, true, false, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result, true);
             	  	
-                $total_score     += $result['score'];
-                
-                if ($debug) error_log("total_score: $total_score ");
-                if ($debug) error_log("total_weight: $total_weight ");
-                                
+                $total_score     += $result['score'];    
+              	
                 update_event_exercice($exe_id, $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $exercise_stat_info['orig_lp_id'], $exercise_stat_info['orig_lp_item_id'], $exercise_stat_info['orig_lp_item_view_id'], $exercise_stat_info['exe_duration'], $question_list, 'incomplete', $remind_list);
                 
                  // Destruction of the Question object
             	unset($objQuestionTmp); 
-                if ($debug) error_log(" -- end question -- ");
-            }   
-            if ($debug) error_log(" ------ end ajax call ------- ");            
+            }            
         }
         
         if ($objExercise->type == ONE_PER_PAGE) {

+ 12 - 16
main/inc/ajax/social.ajax.php

@@ -77,7 +77,8 @@ switch ($action) {
 		if (api_is_anonymous()) {
 			echo '';
 			break;
-		}		
+		}
+		$list_path_friends	= array();
 		$user_id	= api_get_user_id();
 		$name_search= Security::remove_XSS($_POST['search_name_q']);		
 		$number_friends = 0;
@@ -96,32 +97,27 @@ switch ($action) {
 			$number_loop   = ($number_friends/$number_of_images);
 			$loop_friends  = ceil($number_loop);
 			$j=0;
-			$friend_html.= '<ul class="thumbnails">';
-			for ($k=0;$k<$loop_friends;$k++) {				
+			$friend_html.= '<br /><table width="100%" border="0" cellpadding="0" cellspacing="0" >';
+			for ($k=0;$k<$loop_friends;$k++) {
+				$friend_html.='<tr><td valign="top">';
 				if ($j==$number_of_images) {
 					$number_of_images=$number_of_images*2;
 				}
 				while ($j<$number_of_images) {
 					if (isset($friends[$j])) {
-                        $friend_html.='<li class="span2">';
 						$friend = $friends[$j];
 						$user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
 						$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
-						$friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
-                        $friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />';
-                        $friend_html.='<div class="caption">';
-						$friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'"><h5>'.$user_name.'</h5></a>';
-						$friend_html.='<p><button class="btn" onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'>'.get_lang('Delete').'</button></p>';
-                        $friend_html.='</div>';
-                        $friend_html.='</div>';
-                        
-                        $friend_html.='</li>';
+						$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
+						$friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" style="width:60px;height:60px;border:3pt solid #eee" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
+						$friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="'.api_get_path(WEB_IMG_PATH).'blank.gif" alt="" title=""  class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';				
 					}
 					$j++;
-				}				
+				}
+				$friend_html.='</td></tr>';
 			}
-			$friend_html.='</ul>';
-		}        
+			$friend_html.='<br/></table>';
+		}
 		echo $friend_html;	
 		break;		
 	case 'toogle_course':

+ 2 - 2
main/inc/lib/course.lib.php

@@ -2918,7 +2918,8 @@ class CourseManager {
     }
     
     /**
-     * Display courses (without special courses) as several HTML divs of course categories
+     * Display courses (without special courses) as several HTML divs
+     * of course categories, as class userportal-catalog-item.
      * @uses display_courses_in_category() to display the courses themselves
      * @param int        user id
      * @param bool      Whether to show the document quick-loader or not
@@ -2985,7 +2986,6 @@ class CourseManager {
         }
         // Use user's classification for courses (if any).
         $sql_select_courses .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
-        
         $result = Database::query($sql_select_courses);        
         $key = 0;
         $status_icon = '';

+ 22 - 39
main/inc/lib/events.lib.inc.php

@@ -331,7 +331,8 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
 		if (!exercise_time_control_is_valid($exo_id)) {
 			$score = 0;		
 	    }
-	                  
+	    $now = time();
+              
         /*  start_date wouldn't be updated
         $start_date_condition = '';        
 	    //Validation in case of wrong start_date
@@ -376,9 +377,6 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
 				 WHERE exe_id = '".Database::escape_string($exeid)."'";
 		$res = Database::query($sql);
         
-        if ($debug) error_log('update_event_exercice called ');
-        if ($debug) error_log("$sql");
-        
         //Deleting control time session track		
 		//exercise_time_control_delete($exo_id);
 		return $res;        
@@ -450,71 +448,56 @@ function create_event_exercice($exo_id) {
  * @param	integer	Position
  * @return	boolean	Result of the insert query
  */
-function exercise_attempt($score, $answer, $question_id, $exe_id, $position, $exercise_id = 0, $nano = null) {	
+function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0, $nano = null) {	
     require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
-    global $debug;
-	$score          = Database::escape_string($score);
-	$answer         = Database::escape_string($answer);
-	$question_id    = Database::escape_string($question_id);
-	$exe_id          = Database::escape_string($exe_id);
-	$position 		= Database::escape_string($position);
-    $now            = api_get_utc_datetime();
-	$user_id        = api_get_user_id();
+	$score 	= Database::escape_string($score);
+	$answer = Database::escape_string($answer);
+	$quesId = Database::escape_string($quesId);
+	$exeId 	= Database::escape_string($exeId);
+	$j 		= Database::escape_string($j);
 		
 	$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-    
-    if ($debug) error_log("----- entering exercise_attempt function ------");
-    
-    if ($debug) error_log("answer: $answer");
-    if ($debug) error_log("score: $score");
-    if ($debug) error_log("question_id : $question_id");
-    if ($debug) error_log("position: $position");
 
-	//Validation in case of fraud with actived control time	    	
+	//Validation in case of fraud with actived control time	
+	
     if (!exercise_time_control_is_valid($exercise_id)) {
-        if ($debug) error_log("exercise_time_control_is_valid is false");
     	$score = 0;
     	$answer = 0;
     	$j = 0;
 	}
-	
-    
+	$reallyNow 	= api_get_utc_datetime();
+	$user_id 	= api_get_user_id();
 	if (!empty($user_id)) {
 		$user_id = "'".$user_id."'";
 	} else {
 		// anonymous
 		$user_id = api_get_anonymous_id();
 	}		
-    
-	$file = '';	
+	$file = '';
+	
 	if (isset($nano)) {	
-		$file = Database::escape_string(basename($nano->load_filename_if_exists(false)));
+		$file = basename($nano->load_filename_if_exists(false));
 	}
     
 	$sql = "INSERT INTO $TBL_TRACK_ATTEMPT (exe_id, user_id, question_id, answer, marks, course_code, session_id, position, tms, filename)
 			  VALUES (
-			  ".$exe_id.",
+			  ".$exeId.",
 			  ".$user_id.",
-			   '".$question_id."',
+			   '".$quesId."',
 			   '".$answer."',
 			   '".$score."',
 			   '".api_get_course_id()."',
 			   '".api_get_session_id()."',
-			   '".$position."',
-			   '".$now."',
+			   '".$j."',
+			   '".$reallyNow."',
 			   '".$file."'
 			)";		
-    
-    if ($debug) error_log("Saving question attempt: ");
-    if ($debug) error_log($sql);
-    if ($debug) error_log("");
-    
-	if (!empty($question_id) && !empty($exe_id) && !empty($user_id)) {
+    //error_log($sql);
+	if (!empty($quesId) && !empty($exeId) && !empty($user_id)) {
 		$res = Database::query($sql);		
 		if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){
 			$recording_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
-            if ($debug) error_log("Saving e attempt recording ");
-			$recording_changes = "INSERT INTO $recording_table (exe_id, question_id, marks, insert_date, author, session_id) VALUES ('$exe_id','$question_id','$score','".api_get_utc_datetime()."','', '".api_get_session_id()."') ";
+			$recording_changes = "INSERT INTO $recording_table (exe_id, question_id, marks, insert_date, author, session_id) VALUES ('$exeId','$quesId','$score','".api_get_utc_datetime()."','', '".api_get_session_id()."') ";
 			Database::query($recording_changes);			
 		}		
 		return $res;

+ 4 - 10
main/inc/lib/plugin.class.php

@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Base class for plugins.
+ * Base class for plugins
  *
  * @copyright (c) 2012 University of Geneva
  * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
@@ -14,11 +14,11 @@ class Plugin
     protected $author = '';
     protected $fields = array();
 
-    protected function __construct($version, $author, $fields = array())
+    protected function __construct($version, $author, $settings = array())
     {
         $this->version = $version;
-        $this->author = $author;      
-        $this->fields = $fields;
+        $this->author = $author;
+        $this->fields = $settings;
 
         global $language_files;
         $language_files[] = 'plugin_' . $this->get_name();
@@ -105,12 +105,6 @@ class Plugin
             {
                 $result->add_html_editor($name, $this->get_lang($name));
             }
-            else if ($type == 'text')
-            {
-                $a = array('maxlength' => 255);
-                $result->addElement($type, $name, $this->get_lang($name), $a);
-                $result->addRule($name, '', 'maxlength', 255);
-            }
             else
             {
                 $result->addElement($type, $name, $this->get_lang($name));

+ 20 - 19
main/inc/lib/usermanager.lib.php

@@ -1748,7 +1748,6 @@ class UserManager {
 		$tbl_session_user			= Database :: get_main_table(TABLE_MAIN_SESSION_USER);
 		$tbl_session				= Database :: get_main_table(TABLE_MAIN_SESSION);		
 		$tbl_session_course_user	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-        
 		if ($user_id != strval(intval($user_id))) return array();
 
 		$categories = array();
@@ -1756,8 +1755,7 @@ class UserManager {
 		if ($fill_first) {
 			$categories[0] = array();
 		}
-        
-		// Get the list of sessions where the user is subscribed as student
+		// get the list of sessions where the user is subscribed as student
 
 		$condition_date_end = "";
 		if ($is_time_over) {
@@ -1766,10 +1764,11 @@ class UserManager {
 			$condition_date_end = " AND (date_end >= CURDATE() OR date_end = '0000-00-00') ";
 		}
 
-		$sessions_sql = "SELECT DISTINCT id, session_category_id, session.name 
-                        FROM $tbl_session_user, $tbl_session 
-                        WHERE id_session=id AND id_user=$user_id $condition_date_end 
-                        ORDER BY session_category_id, date_start, date_end";
+		$sessions_sql = "SELECT DISTINCT id, session_category_id, session.name "
+                        ." FROM $tbl_session_user, $tbl_session "
+                        ." WHERE id_session=id AND id_user=$user_id " 
+                        ." $condition_date_end "
+                        ." ORDER BY session_category_id, date_start, date_end";
         $result = Database::query($sessions_sql);
         if (Database::num_rows($result) > 0) {
             while ($row = Database::fetch_array($result)) {
@@ -1778,16 +1777,17 @@ class UserManager {
             }
         }
 
-        // Get the list of sessions where the user is subscribed as coach in a 
+        // get the list of sessions where the user is subscribed as coach in a 
         // course, from table session_rel_course_rel_user
 
-		$sessions_sql = "SELECT DISTINCT id, session_category_id, session.name 
-                            FROM $tbl_session as session  INNER JOIN $tbl_session_course_user as session_rel_course_user 
-                            ON  session_rel_course_user.id_session = session.id  AND 
-                                session_rel_course_user.id_user = $user_id AND 
-                                session_rel_course_user.status = 2 $condition_date_end 
-                            ORDER BY session_category_id, date_start, date_end";
-        
+		$sessions_sql = "SELECT DISTINCT id, session_category_id, session.name "
+                        ." FROM $tbl_session as session "
+                        ." INNER JOIN $tbl_session_course_user as session_rel_course_user "
+                          ." ON session_rel_course_user.id_session = session.id "
+                          ." AND session_rel_course_user.id_user = $user_id "
+                          ." AND session_rel_course_user.status = 2	$condition_date_end "
+                        ." ORDER BY session_category_id, date_start, date_end";
+
         $result = Database::query($sessions_sql);
         if (Database::num_rows($result)>0) {
             while ($row = Database::fetch_array($result)) {
@@ -1796,10 +1796,11 @@ class UserManager {
             }
         }
 
-        // Get the list of sessions where the user is subscribed as a session coach
-        $sessions_sql = "SELECT DISTINCT id, session_category_id, session.name FROM $tbl_session as session 
-                            WHERE session.id_coach = $user_id $condition_date_end 
-                            ORDER BY session_category_id, date_start, date_end";
+        // get the list of sessions where the user is subscribed as session coach
+        $sessions_sql = "SELECT DISTINCT id, session_category_id, session.name "
+                        ." FROM $tbl_session as session "
+                        ." WHERE session.id_coach = $user_id $condition_date_end "
+                        ." ORDER BY session_category_id, date_start, date_end";
 
 		$result = Database::query($sessions_sql);
 		if (Database::num_rows($result)>0) {

+ 24 - 28
main/inc/lib/userportal.lib.php

@@ -924,14 +924,13 @@ class IndexManager {
 		}
         
 		if (!empty($courses_tree)) {
-			foreach ($courses_tree as $cat => $sessions) {
-                //Getting session categories
-				$courses_tree[$cat]['details'] = SessionManager::get_session_category($cat);                
-				if ($cat == 0) {        
+			foreach ($courses_tree as $cat => $sessions) {                
+				$courses_tree[$cat]['details'] = SessionManager::get_session_category($cat);
+                //Get courses
+				if ($cat == 0) {                    
 					$courses_tree[$cat]['courses'] = CourseManager::get_courses_list_by_user_id($user_id, false);                            
 				}
 				$courses_tree[$cat]['sessions'] = array_flip(array_flip($sessions));
-                
                 //Get courses in sessions
 				if (count($courses_tree[$cat]['sessions']) > 0) {
 					foreach ($courses_tree[$cat]['sessions'] as $k => $s_id) {                        
@@ -947,28 +946,27 @@ class IndexManager {
 		if ($load_history) {
 			$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));			
 			if (empty($courses_tree)) {
-				$html .=  Display::return_message(get_lang('YouDoNotHaveAnySessionInItsHistory'), 'warning');
+				$html .=  get_lang('YouDoNotHaveAnySessionInItsHistory');
 			}
-        }
-        
-        //Loading courses 
-        if ($load_history == false) {            
-            //Display special courses
-            $html .= CourseManager :: display_special_courses($user_id, $this->load_directories_preview);                        
-            //Display courses
-            $html .= CourseManager :: display_courses($user_id, $this->load_directories_preview);
-        }
+		}	
 		
-        //Loading sessions inside/outside session categories
-        
 		if (is_array($courses_tree)) {
-            foreach ($courses_tree as $key => $category) {                
-                //Category = 0
+            foreach ($courses_tree as $key => $category) {
                 if ($key == 0) {
-					// Sessions and courses that are not in a session category (Independent sessions)
+					// Sessions and courses that are not in a session category.
+                    
+                    // If we're not in the history view...
+					if (!isset($_GET['history'])) {						                        // 
+                        //Display special courses
+						$html .= CourseManager :: display_special_courses($user_id, $this->load_directories_preview);                        
+                        //Display courses
+                        $html .= CourseManager :: display_courses($user_id, $this->load_directories_preview);
+					}
+                    
+					// Independent sessions
 					foreach ($category['sessions'] as $session) {
 		
-						// Don't show empty sessions (with any course added)
+						// Don't show empty sessions.
 						if (count($session['courses']) < 1) {
 							continue;
 						}
@@ -980,7 +978,6 @@ class IndexManager {
 						$session_now = time();
 						$html_courses_session = '';
 						$count_courses_session = 0;
-                        
 						foreach ($session['courses'] as $course) {
 							$is_coach_course = api_is_coach($session['details']['id'], $course['code']);
 							$allowed_time = 0;
@@ -994,7 +991,6 @@ class IndexManager {
 							if ($session_now > $allowed_time) {
 								//read only and accesible
 								if (api_get_setting('hide_courses_in_sessions') == 'false') {
-                                    //Loading courses inside the session
 									$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item', true, $this->load_directories_preview);									
 									$html_courses_session .= $c[1];
 								}
@@ -1004,7 +1000,8 @@ class IndexManager {
 		
 						if ($count_courses_session > 0) {
 							$params = array();                            							
-							$params['icon'] =  Display::return_icon('window_list.png', null, array('id' => 'session_img_'.$session['details']['id']), ICON_SIZE_LARGE);		
+							$params['icon'] =  Display::return_icon('window_list.png', null, array('id' => 'session_img_'.$session['details']['id']), ICON_SIZE_LARGE);
+		
 							$session_box = Display :: get_session_title_box($session['details']['id']);
 							$extra_info = (!empty($session_box['coach']) ? $session_box['coach'].' | ' : '').$session_box['dates'];		
                             if (api_is_drh()) {
@@ -1027,14 +1024,13 @@ class IndexManager {
                             $html .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session);
 						}
 					}
-				} else {           
+				} else {                    
 					// All sessions included in.
 					if (!empty($category['details'])) {
-                        
 						$count_courses_session = 0;
-						$html_sessions = '';                 
+						$html_sessions = '';                        
 						foreach ($category['sessions'] as $session) {
-							// Don't show empty sessions (with no course)
+							// Don't show empty sessions.
 							if (count($session['courses']) < 1) {
 								continue;
 							}

+ 15 - 19
main/social/friends.php

@@ -49,8 +49,8 @@ function search_image_social()  {
 		type: "POST",
 		url: "'.api_get_path(WEB_AJAX_PATH).'social.ajax.php?a=show_my_friends",
 		data: "search_name_q="+name_search,
-		success: function(data) {
-			$("#friends").html(data);
+		success: function(datos) {
+			$("#friend_table").html(datos);
 		}
 	});
 }
@@ -99,42 +99,38 @@ if (isset($name_search) && $name_search!='undefined') {
 	$friends = SocialManager::get_friends($user_id);
 }
 
-$social_right_content = '<div class="span8">';
+$social_right_content .= '<div class="span8">';
 
 if (count($friends) == 0 ) {
 	$social_right_content .= get_lang('NoFriendsInYourContactList').'<br /><br />';
 	$social_right_content .= '<a class="btn" href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';	
 } else {
-	$social_right_content .= get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;';
+	$social_right_content = get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;';
 	$social_right_content .= '<input class="social-search-image" type="text" id="id_search_image" name="id_search_image" onkeyup="search_image_social()" />';
     
-    $friend_html = '<div id="friends">';
+    $friend_html = '';
 
     $number_friends = count($friends);
     $j=0;		    
     
-    $friend_html.= '<ul class="thumbnails">';
-    for ($k=0;$k<$number_friends;$k++) {        
+    $friend_html.= '<table id="friend_table" width="95%" border="0" cellpadding="0" cellspacing="0" bgcolor="" >';
+    for ($k=0;$k<$number_friends;$k++) {
+        $friend_html.='<tr><td valign="top">';
+
         while ($j<$number_friends) {
-            
             if (isset($friends[$j])) {
-                $friend_html.='<li class="span2">';
                 $friend = $friends[$j];
                 $user_name = api_xml_http_response_encode($friend['firstName'].' '.$friend['lastName']);
                 $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
-                $friend_html.='<div class="thumbnail" onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
-                $friend_html.='<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" />                                    ';
-                $friend_html.='<div class="caption">                                   
-                               <a href="profile.php?u='.$friend['friend_user_id'].'"> <h5>'.$user_name.'</h5></a>';
-                $friend_html.='<p><button onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].'  />'.get_lang('Delete').'</button></p>
-                        </div>';				
-                $friend_html.='</li>';
+                $friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$friends[$j]['friend_user_id'].'>';
+                $friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" style="height:60px;" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
+                $friend_html.='<img onclick="delete_friend(this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title=""  class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';				
             }
             $j++;
-        }        
+        }
+        $friend_html.='</td></tr>';
     }
-    $friend_html.='</ul>';
-    $friend_html.='</div>';
+    $friend_html.='</table>';
     $social_right_content .=  $friend_html;
 }
 $social_right_content .= '</div>';