Julio Montoya 13 tahun lalu
induk
melakukan
14d26d44bf

+ 3 - 4
main/auth/inscription.php

@@ -114,10 +114,9 @@ if (api_get_setting('use_custom_pages') == 'true') {
 				@api_mail($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin);
 			}
 			CustomPages::displayPage('registration-feedback');
-	}
-	}
-	else {
-	CustomPages::displayPage('registration');
+		}
+	} else {
+		CustomPages::displayPage('registration');
 	}
 }
 $tool_name = get_lang('Registration',null,(!empty($_POST['language'])?$_POST['language']:$_user['language']));

+ 7 - 0
main/coursecopy/classes/CourseRestorer.class.php

@@ -1034,6 +1034,13 @@ class CourseRestorer
 
 					// check resources inside html from fckeditor tool and copy correct urls into recipient course
 					$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($quiz->description, $this->course->code, $this->course->destination_path);
+					
+					global $_custom;					
+					if (isset($_custom['exercises_clean_dates_when_restoring']) && $_custom['exercises_clean_dates_when_restoring']) {
+						$quiz->start_time = null;
+						$quiz->end_time   = null;
+					}
+					
 
 					// Normal tests are stored in the database.
 					$sql = "INSERT INTO ".$table_qui." SET

+ 57 - 2
main/css/base.css

@@ -3416,7 +3416,7 @@ div.admin_section h4 {
     display: block;
     font-size: 100%;
     line-height: 150%;
-    margin: -27px 0 0 23px;
+    margin: -16px 0 0 23px;
     padding: 0 0 5px;
     width: 88%;
 }
@@ -3796,4 +3796,59 @@ form div.error input, form div.error textarea {
 
 .invisible h2 {
     color: #999;
-}
+}
+
+
+
+/************************************************************************************
+REFLECTION
+*************************************************************************************/
+
+
+.image-wrap {
+    margin-right: 10px;
+    position: relative; 
+    display: inline-block; 
+    width: 64px; 
+    height: 64px;'
+}
+.box-image {
+    margin: 0 0 50px;
+    border-top: solid 1px #ccc;
+}
+
+
+
+.reflection .image-wrap {
+    -webkit-box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+    -moz-box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+    box-shadow: inset 0 0 1px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.5);
+    -webkit-transition: .5s;
+    -moz-transition: .5s;
+    transition: .5s;
+    -webkit-border-radius: 20px;
+    -moz-border-radius: 20px;
+    border-radius: 20px;
+}
+.reflection .image-wrap:after {
+    position: absolute;
+    content: ' ';
+    width: 100%;
+    height: 30px;
+    bottom: -31px;
+    left: 0;
+    -webkit-border-top-left-radius: 20px;
+    -webkit-border-top-right-radius: 20px;
+    -moz-border-radius-topleft: 20px;
+    -moz-border-radius-topright: 20px;
+    border-top-left-radius: 20px;
+    border-top-right-radius: 20px;
+    background: -moz-linear-gradient(top, rgba(0,0,0,.3) 0%, rgba(255,255,255,0) 100%);
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,.3)), color-stop(100%,rgba(255,255,255,0)));
+    background: linear-gradient(top, rgba(0,0,0,.3) 0%,rgba(255,255,255,0) 100%);
+}
+.reflection .image-wrap:hover {
+    position: relative;
+    top: -8px;
+}
+

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

@@ -47,6 +47,7 @@ class Exercise {
 	public $expired_time;
 	public $course;
 	public $propagate_neg;
+	public $review_answers; //
 
 	 
 	/**
@@ -70,12 +71,13 @@ class Exercise {
 		$this->results_disabled = 1;
 		$this->expired_time 	= '0000-00-00 00:00:00';
 		$this->propagate_neg    = 0;
+		$this->review_answers	= false;
 
 		if (!empty($course_id)) {
-			$this->course_id        =  intval($course_id);
-			$course_info            =  api_get_course_info_by_id($this->course_id);
+			$this->course_id    =  intval($course_id);
+			$course_info        =  api_get_course_info_by_id($this->course_id);
 		} else {
-			$course_info = api_get_course_info();
+			$course_info 		= api_get_course_info();
 		}
 		$this->course   = $course_info;
 
@@ -92,7 +94,6 @@ class Exercise {
 		$TBL_EXERCICE_QUESTION  = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION,$this->course['db_name']);
 		$TBL_EXERCICES          = Database::get_course_table(TABLE_QUIZ_TEST,$this->course['db_name']);
 		$TBL_QUESTIONS          = Database::get_course_table(TABLE_QUIZ_QUESTION,$this->course['db_name']);
-		#$TBL_REPONSES           = Database::get_course_table(TABLE_QUIZ_ANSWER);
 		$id  = intval($id);
 		$sql = "SELECT * FROM $TBL_EXERCICES WHERE id = ".$id;
 		$result = Database::query($sql);
@@ -112,7 +113,9 @@ class Exercise {
 			$this->attempts 		= $object->max_attempt;
 			$this->feedbacktype 	= $object->feedback_type;
 			$this->propagate_neg    = $object->propagate_neg;
-				
+		
+			$this->review_answers   = (isset($object->review_answers) && $object->review_answers == 1) ? true : false;  
+			
 			if ($object->end_time != '0000-00-00 00:00:00') {
 				$this->end_time 	= api_get_local_time($object->end_time);
 			}
@@ -423,6 +426,9 @@ class Exercise {
 	function updatePropagateNegative($value) {
 		$this->propagate_neg = $value;
 	}
+	function updateReviewAnswers($value) {
+		$this->review_answers = (isset($value) && $value) ? true : false;
+	}
 
 	/**
 	 * changes the exercise sound file
@@ -543,6 +549,8 @@ class Exercise {
 		$random_answers = $this->random_answers;
 		$active 		= $this->active;
 		$propagate_neg  = $this->propagate_neg;
+		$review_answers = (isset($this->review_answers) && $this->review_answers) ? 1 : 0;
+		
 		$session_id 	= api_get_session_id();
 		 
 		//If direct we do not show results
@@ -574,10 +582,11 @@ class Exercise {
 					max_attempt    ='".Database::escape_string($attempts)."',
         			expired_time   ='".Database::escape_string($expired_time)."',
         			propagate_neg  ='".Database::escape_string($propagate_neg)."',
+        			review_answers  ='".Database::escape_string($review_answers)."',
 					results_disabled='".Database::escape_string($results_disabled)."'";
 			}
+			
 			$sql .= " WHERE id='".Database::escape_string($id)."'";
-
 			Database::query($sql);
 
 			// update into the item_property table
@@ -588,7 +597,8 @@ class Exercise {
 			}
 		} else {
 			// creates a new exercise
-			$sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers,active, results_disabled, max_attempt, feedback_type, expired_time, session_id)
+			$sql="INSERT INTO $TBL_EXERCICES (c_id, start_time, end_time, title, description, sound, type, random, random_answers,
+											  active, results_disabled, max_attempt, feedback_type, expired_time, session_id, review_answers)
 					VALUES(
 						".api_get_course_int_id().",
 						'$start_time','$end_time',
@@ -603,10 +613,11 @@ class Exercise {
 						'".Database::escape_string($attempts)."',
 						'".Database::escape_string($feedbacktype)."',
 						'".Database::escape_string($expired_time)."',
-						'".Database::escape_string($session_id)."'
+						'".Database::escape_string($session_id)."',
+						'".Database::escape_string($review_answers)."'
 						)";
 			Database::query($sql);
-			$this->id=Database::insert_id();
+			$this->id = Database::insert_id();
 			// insert into the item_property table
 
 			api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizAdded',api_get_user_id());
@@ -883,7 +894,6 @@ class Exercise {
 		$form->add_html_editor('exerciseDescription', get_lang('langExerciseDescription'), false, false, $editor_config);
 		$form->addElement ('html','</div>');
 
-
 		$form->addElement('html','<div class="row">
 			<div class="label">&nbsp;</div>
 			<div class="formw">
@@ -980,8 +990,6 @@ class Exercise {
 				}
 			}
 
-
-
 			$random = array();
 			$option=array();
 			$max = ($this->id > 0) ? $this->selectNbrQuestions() : 10 ;
@@ -1029,6 +1037,9 @@ class Exercise {
 			//$check_option=$this->selectType();
 			$diplay = 'block';							
 			$form->addElement('checkbox', 'propagate_neg',get_lang('PropagateNegativeResults'),null);
+			
+			$form->addElement('checkbox', 'review_answers',get_lang('ReviewAnswers'),null);
+			
 				
 			$form->addElement('html','<div id="divtimecontrol"  style="display:'.$diplay.';">');
 
@@ -1112,6 +1123,9 @@ class Exercise {
 				$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
 				$defaults['results_disabled'] = $this->selectResultsDisabled();
 				$defaults['propagate_neg'] = $this->selectPropagateNeg();
+				
+				$defaults['review_answers'] = $this->review_answers;
+				
 
 				if (($this->start_time!='0000-00-00 00:00:00'))
 				$defaults['activate_start_date_check'] = 1;
@@ -1169,6 +1183,8 @@ class Exercise {
 		$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
 		$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
 		$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
+		
+		$this->updateReviewAnswers($form->getSubmitValue('review_answers'));
 
 		if ($form->getSubmitValue('activate_start_date_check') == 1) {
 			$start_time = $form->getSubmitValue('start_time');
@@ -1429,19 +1445,25 @@ class Exercise {
 
 		$new_exercise_id = $exercise_obj->selectId();
 		$question_list 	 = $exercise_obj->selectQuestionList();
-
-		//Question creation
-		foreach ($question_list as $old_question_id) {
-			$old_question_obj = Question::read($old_question_id);
-			$new_id = $old_question_obj->duplicate();
-
-			$new_question_obj = Question::read($new_id);
-
-			$new_question_obj->addToList($new_exercise_id);
-			// This should be moved to the duplicate function
-			$new_answer_obj = new Answer($old_question_id);
-			$new_answer_obj->read();
-			$new_answer_obj->duplicate($new_id);
+		
+		if (!empty($question_list)) {
+			//Question creation
+			
+			foreach ($question_list as $old_question_id) {
+				$old_question_obj = Question::read($old_question_id);
+				$new_id = $old_question_obj->duplicate();
+				if ($new_id) {
+					$new_question_obj = Question::read($new_id);
+					
+					if (isset($new_question_obj) && $new_question_obj) {	
+						$new_question_obj->addToList($new_exercise_id);
+						// This should be moved to the duplicate function
+						$new_answer_obj = new Answer($old_question_id);
+						$new_answer_obj->read();
+						$new_answer_obj->duplicate($new_id);
+					}
+				}
+			}
 		}
 	}
 
@@ -1563,11 +1585,16 @@ class Exercise {
 			//User
 			if (api_is_allowed_to_session_edit()) {
 				if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum) {
-					$label = get_lang('ReviewQuestions');
-					$class = 'accept';
+					if ($this->review_answers) {
+						$label = get_lang('ReviewQuestions');
+						$class = 'a_button blue medium';
+					} else {
+						$label = get_lang('ValidateAnswers');
+						$class = 'a_button green';
+					}
 				} else {
 					$label = get_lang('NextQuestion');
-					$class = 'next';
+					$class = 'a_button blue medium';
 				}
 				if ($this->type == ONE_PER_PAGE) {	
 
@@ -1577,18 +1604,24 @@ class Exercise {
 					}
 					
 					//Next question
-					$all_button .= '<a href="javascript://" class="a_button blue medium" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
-					
-				
+					$all_button .= '<a href="javascript://" class="'.$class.'" onclick="save_now('.$question_id.'); ">'.$label.'</a>';
 					
 					//$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
 					$all_button .= '<span id="save_for_now_'.$question_id.'"></span>&nbsp;';
 					
 					
 					$html .= $all_button;
-				} else {
-					$all_button = '<a href="javascript://" class="a_button green" onclick="validate_all(); ">'.get_lang('ReviewQuestions').'</a>';
+				} else {					
+					if ($this->review_answers) {
+						$all_label = get_lang('ReviewQuestions');
+						$class = 'a_button blue medium';
+					} else {
+						$all_label = get_lang('ValidateAnswers');
+						$class = 'a_button green';
+					}
+					$all_button = '<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
 					$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
+					
 					$html .= $all_button;
 				}
 	

+ 34 - 17
main/exercice/exercise_submit.php

@@ -105,11 +105,6 @@ $safe_lp_id             = ($learnpath_id == '')             ? 0 : $learnpath_id;
 $safe_lp_item_id        = ($learnpath_item_id == '')        ? 0 : $learnpath_item_id;
 $safe_lp_item_view_id   = ($learnpath_item_view_id == '')   ? 0 : $learnpath_item_view_id;
 
-//if reminder ends we jump to the exexrcise_reminder
-if ($remind_question_id == -1) {
-	header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
-	exit;
-}
 
 //Table calls
 $stat_table 			= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
@@ -153,6 +148,16 @@ if (!is_object($objExercise)) {
     exit;
 }
 
+
+//if reminder ends we jump to the exercise_reminder
+if ($objExercise->review_answers) {
+	if ($remind_question_id == -1) {
+		header('Location: exercise_reminder.php?origin='.$origin.'&exerciseId='.$exerciseId);
+		exit;
+	}
+}
+
+
 $current_timestamp 	= time();
 $my_remind_list 	= array();
 
@@ -509,10 +514,13 @@ if ($question_count != 0) {
 	                
 	                //if ($debug) { error_log('Updating track_e_exercises '.$update_query); }                    
 	                Database::query($update_query);*/
-	            }                           
-	            header('Location: exercise_reminder.php?'.$params);
-	            exit;
-	            //header("Location: exercise_submit.php?exerciseId=$exerciseId");
+	            }        
+	            if ($objExercise->review_answers) {                   
+	            	header('Location: exercise_reminder.php?'.$params);
+	            	exit;
+	            } else {
+	            	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");	            	
+	            }
 	        }            
 	    } else {
 	        if ($debug) { error_log('Redirecting to exercise_submit.php'); }
@@ -718,12 +726,19 @@ if ($reminder == 2)  {
 			}  
         }
     } else {    	
-    	header("Location: exercise_reminder.php?$params");
-    	exit;
+    	if ($objExercise->review_answers) {
+	    	header("Location: exercise_reminder.php?$params");
+	    	exit;
+    	}
     }
     //var_dump($remind_question_id, $my_remind_list, $data_tracking, $current_question);
 }
 
+if ($objExercise->review_answers) {
+	$script_php = 'exercise_reminder.php';
+} else {
+	$script_php = 'exercise_result.php';
+}
 
 if (!empty($error)) {
     Display :: display_error_message($error, false);
@@ -887,7 +902,7 @@ if (!empty($error)) {
                     	if (return_value == "ok") {                                  
                     		//$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
                     		if (validate == "validate") {
-                            	window.location = "exercise_reminder.php?'.$params.'&" + lp_data;
+                            	window.location = "'.$script_php.'?'.$params.'&" + lp_data;
                             } else {
                             	$("#save_all_reponse").html("'.addslashes(Display::return_icon('accept.png')).'");
                             }
@@ -988,11 +1003,13 @@ if (!empty($error)) {
 	            $button  = '<a href="javascript://" class="a_button orange medium" onclick="save_now(\''.$questionId.'\'); ">'.get_lang('SaveForNow').'</a>';
 	            $button .= '<span id="save_for_now_'.$questionId.'"></span>&nbsp;';
 	            $exercise_actions  .= Display::span($button, array('class'=>'exercise_save_now_button'));                			      
-			}		
-			
-			$remind_question_div  = Display::input('checkbox', 'remind_list['.$questionId.']',  '', $attributes);
-			$remind_question_div .= Display::tag('label', get_lang('ReviewQuestionLater'), array('for' =>'remind_list['.$questionId.']'));
-			$exercise_actions    .= Display::span($remind_question_div, array('class'=>'exercise_save_now_button'));		
+			}
+					
+			if ($objExercise->review_answers) {
+				$remind_question_div  = Display::input('checkbox', 'remind_list['.$questionId.']',  '', $attributes);
+				$remind_question_div .= Display::tag('label', get_lang('ReviewQuestionLater'), array('for' =>'remind_list['.$questionId.']'));
+				$exercise_actions    .= Display::span($remind_question_div, array('class'=>'exercise_save_now_button'));		
+			}
 			
 			echo Display::div($exercise_actions, array('class'=>'exercise_actions'));		
 		

+ 23 - 13
main/exercice/question.class.php

@@ -107,19 +107,22 @@ abstract class Question
         } else {
             global $course;
             $course_info = api_get_course_info();
-        }
+        }        
+        $course_id = $course_info['real_id'];
 
 		$TBL_EXERCICES         = Database::get_course_table(TABLE_QUIZ_TEST,          $course_info['db_name']);
 		$TBL_QUESTIONS         = Database::get_course_table(TABLE_QUIZ_QUESTION,      $course_info['db_name']);
 		$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION, $course_info['db_name']);
         
-		$sql="SELECT question,description,ponderation,position,type,picture,level,extra FROM $TBL_QUESTIONS WHERE id= $id ";
+		$sql = "SELECT question,description,ponderation,position,type,picture,level,extra FROM $TBL_QUESTIONS WHERE c_id = $course_id AND id = $id ";
         
-		$result=Database::query($sql);
+		$result = Database::query($sql);
 
 		// if the question has been found
 		if ($object = Database::fetch_object($result)) {
+			
 			$objQuestion 				= Question::getInstance($object->type);
+			
 			$objQuestion->id			= $id;
 			$objQuestion->question		= $object->question;
 			$objQuestion->description	= $object->description;
@@ -130,13 +133,15 @@ abstract class Question
 			$objQuestion->level			= (int) $object->level;
             $objQuestion->extra         = $object->extra;
             $objQuestion->course        = $course_info;
-
-			$sql="SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE question_id='".$id."'";
-			$result=Database::query($sql);
+            
+			$sql = "SELECT exercice_id FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND question_id = $id";
+			$result_exercise_list = Database::query($sql);
 
 			// fills the array with the exercises which this question is in
-			while($object=Database::fetch_object($result)) {
-				$objQuestion->exerciseList[]=$object->exercice_id;
+			if ($result_exercise_list) {
+				while ($obj = Database::fetch_object($result_exercise_list)) {
+					$objQuestion->exerciseList[] = $obj->exercice_id;
+				}
 			}
 			return $objQuestion;
 		}
@@ -473,6 +478,7 @@ abstract class Question
 	 * @return - boolean - true if copied, otherwise false
 	 */
 	function exportPicture($questionId, $course_info) {
+		$course_id = $course_info['real_id'];
         $TBL_QUESTIONS  = Database::get_course_table(TABLE_QUIZ_QUESTION, $course_info['db_name']);
         $destination_path    = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/images';
         $source_path         = api_get_path(SYS_COURSE_PATH).$this->course['path'].'/document/images';        		
@@ -482,7 +488,7 @@ abstract class Question
 			$picture=explode('.',$this->picture);
 			$Extension=$picture[sizeof($picture)-1];
 			$picture='quiz-'.$questionId.'.'.$Extension;
-			$sql="UPDATE $TBL_QUESTIONS SET picture='".Database::escape_string($picture)."' WHERE id='".intval($questionId)."'";            
+			$sql="UPDATE $TBL_QUESTIONS SET picture='".Database::escape_string($picture)."' WHERE c_id = $course_id AND id='".intval($questionId)."'";            
 			Database::query($sql);            
 			return @copy($source_path.'/'.$this->picture, $destination_path.'/'.$picture)?true:false;
 		}
@@ -946,20 +952,24 @@ abstract class Question
             $description  = DocumentManager::replace_urls_inside_content_html_from_copy_course($description, $this->course['id'], $course_info['id']);
             $question     = DocumentManager::replace_urls_inside_content_html_from_copy_course($question, $this->course['id'], $course_info['id']);
         }
+        
+        $course_id = $course_info['real_id'];
                 
         $options = self::readQuestionOption($this->id);  
         //Inserting in the new course db / or the same course db
-		$sql="INSERT INTO $TBL_QUESTIONS(question, description, ponderation, position, type, level, extra ) VALUES('".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."' ,'".Database::escape_string($extra)."'  )";
+		$sql = "INSERT INTO $TBL_QUESTIONS (c_id, question, description, ponderation, position, type, level, extra ) 
+				VALUES('$course_id', '".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."' ,'".Database::escape_string($level)."' ,'".Database::escape_string($extra)."'  )";
 		Database::query($sql);    
             
-		$new_question_id =Database::insert_id();        
+		$new_question_id = Database::insert_id();        
         
         if (!empty($options)) {
             //Saving the quiz_options      
             foreach ($options as $item) {
-                $item['question_id'] = $new_question_id;
+                $item['question_id'] 	= $new_question_id;
+                $item['c_id'] 			= $course_id;
                 unset($item['id']); 
-                Database::insert($TBL_QUESTION_OPTIONS,$item);	
+                Database::insert($TBL_QUESTION_OPTIONS, $item);	
             }
         }
         

+ 9 - 31
main/exercice/question_list_admin.inc.php

@@ -19,30 +19,8 @@
 if(!defined('ALLOWED_TO_INCLUDE')) {
 	exit();
 }
-/*
-// moves a question up in the list
-if(isset($_GET['moveUp'])) {
-	$check = Security::get_token('get');
-	if ($check) {
-		$objExercise->moveUp(intval($_GET['moveUp']));
-		$objExercise->save();
-	}
-	Security::clear_token();
-}
-
-// moves a question down in the list
-if(isset($_GET['moveDown'])) {
-	$check = Security::get_token('get');
-	if ($check) {
-		$objExercise->moveDown(intval($_GET['moveDown']));
-		$objExercise->save();
-	}
-	Security::clear_token();
-}
-*/
 // deletes a question from the exercise (not from the data base)
-if($deleteQuestion) {
-
+if ($deleteQuestion) {
 	// if the question exists
 	if($objQuestionTmp = Question::read($deleteQuestion)) {
 		$objQuestionTmp->delete($exerciseId);
@@ -74,8 +52,7 @@ if($deleteQuestion) {
 
 <script>
 $(function() {    
-    $( "#dialog:ui-dialog" ).dialog( "destroy" );
-        
+    $( "#dialog:ui-dialog" ).dialog( "destroy" );        
     $( "#dialog-confirm" ).dialog({
             autoOpen: false,
             show: "blind",                
@@ -162,7 +139,9 @@ echo '</div><div style="clear:both;"></div>';
 echo '<div id="message"></div>';
 $token = Security::get_token();
 //deletes a session when using don't know question type (ugly fix)
-unset($_SESSION['less_answer']); 
+unset($_SESSION['less_answer']);
+ 
+echo '<div id="question_list">';
 
 if ($nbrQuestions) {
     $my_exercise = new Exercise();
@@ -170,9 +149,7 @@ if ($nbrQuestions) {
     $my_exercise->read($_GET['exerciseId']);
 	$questionList=$my_exercise->selectQuestionList();    
         
-	if (is_array($questionList)) {      
-	      
-        echo '<div id="question_list">';        		
+	if (is_array($questionList)) {		
 		foreach($questionList as $id) {
 			//To avoid warning messages
 			if (!is_numeric($id)) {
@@ -220,7 +197,8 @@ if ($nbrQuestions) {
         echo '</div>';
 	}
 }
-echo '</div>';
 if(!$nbrQuestions) {	
   	echo Display::display_warning_message(get_lang('NoQuestion'));
-}
+}
+
+echo '</div>';

+ 2 - 0
main/forum/index.php

@@ -191,6 +191,8 @@ if (api_is_allowed_to_edit(false, true)) {
         echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;gradebook='.$gradebook.'&amp;action=add&amp;content=forum&amp;lp_id='.$lp_id.'"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'','32').'</a>';
     }
 }
+
+var_dump(api_is_coach());
 echo '</div>';
 
 /* Display Forum Categories and the Forums in it */

+ 5 - 4
main/gradebook/lib/fe/flatviewtable.class.php

@@ -31,13 +31,16 @@ class FlatViewTable extends SortableTable
 	function FlatViewTable ($selectcat, $users= array (), $evals= array (), $links= array (), $limit_enabled = false, $offset = 0, $addparams = null) {
 		parent :: __construct ('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0);
 		$this->datagen = new FlatViewDataGenerator($users, $evals, $links);
-
+		
 		$this->selectcat = $selectcat;
 		$this->limit_enabled = $limit_enabled;
 		$this->offset = $offset;
 		if (isset ($addparams)) {
 			$this->set_additional_parameters($addparams);
 		}
+		
+		// step 2: generate rows: students
+		$this->datagen->category = $this->selectcat;
 	}
 
 	/**
@@ -416,7 +419,6 @@ class FlatViewTable extends SortableTable
 		$is_western_name_order = api_is_western_name_order();
 
 		// create page navigation if needed
-
 		$totalitems = $this->datagen->get_total_items_count();
 		if ($this->limit_enabled && $totalitems > LIMIT) {
 			$selectlimit = LIMIT;
@@ -493,8 +495,7 @@ class FlatViewTable extends SortableTable
 
 		//$this->set_header($column++, get_lang('Total'));
 
-		// step 2: generate rows: students
-
+		
 		$data_array = $this->datagen->get_data($users_sorting, $from, $this->per_page, $this->offset, $selectlimit);
 
 		$table_data = array();

+ 58 - 8
main/gradebook/lib/flatview_data_generator.class.php

@@ -22,7 +22,8 @@ class FlatViewDataGenerator
 	private $users;
 	private $evals;
 	private $links;
-	private $evals_links;
+	private $evals_links;	
+	public  $category = array();
 
 	/**
 	 * Constructor
@@ -59,10 +60,24 @@ class FlatViewDataGenerator
 		$headers[] = get_lang('FirstName');
 		if (!isset($items_count)) {
 			$items_count = count($this->evals_links) - $items_start;
+		}		
+		
+		$count_categories = 1;
+		
+		if (isset($this->category)) {
+			$categories = Category::load(null, null, null, $this->category->get_id());				
+			if (!empty($categories)) {
+				$count_categories = count($categories) ;
+			}
 		}
+		
+		
 		for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
 			$item = $this->evals_links [$count + $items_start];
-			$headers[] = $item->get_name();
+			
+			//$headers[] = $item->get_name().' <br /> '.get_lang('Max').' '.$this->get_max_result_by_link($count + $items_start).' ';
+			$weight = round($item->get_weight()/($count_categories*100), 2);
+			$headers[] = $item->get_name().' <br />'.$weight.' ';
 			if ($show_detail) {
 				$headers[] = $item->get_name().' ('.get_lang('Detail').')';
 			}
@@ -74,6 +89,26 @@ class FlatViewDataGenerator
 		}
 		return $headers;
 	}
+	
+	function get_max_result_by_link($id) {		
+		$usertable = array ();
+		
+		$items_count = count ($this->evals) + count ($this->links);
+		
+		$item_value = 0;
+		$item_total = 0;
+		$max = 0;
+		foreach ($this->users as $user) {
+			$item  = $this->evals_links [$id];					
+			$score = $item->calc_score($user[0]);			
+			$divide=( ($score[1])==0 ) ? 1 : $score[1];
+			//$item_value = round($score[0]/$divide*$item->get_weight(),2);			
+			if ($score[0] > $max) {
+				$max = $score[0];
+			}			
+		}		
+		return $max ;
+	}
 
 	/**
 	 * Get array containing evaluation items
@@ -91,7 +126,8 @@ class FlatViewDataGenerator
 		}
 		return $headers;
 	}
-
+	
+	
 
 	/**
 	 * Get actual array data
@@ -140,12 +176,23 @@ class FlatViewDataGenerator
 
 		$scoredisplay = ScoreDisplay :: instance();
 
-		$data= array ();
+		$data = array ();
 		$displaytype = SCORE_DIV;
 		if ($ignore_score_color) {
 			$displaytype |= SCORE_IGNORE_SPLIT;
 		}
-
+		
+		$count_categories = 1;
+		
+		if (isset($this->category)) {
+			
+			$categories = Category::load(null, null, null, $this->category->get_id());
+			
+			if (!empty($categories)) {				
+				$count_categories = count($categories);				
+			}			
+		}
+		
 		foreach ($selected_users as $user) {
 			$row = array ();
 			$row[] = $user[0];	// user id
@@ -156,7 +203,7 @@ class FlatViewDataGenerator
 			$item_total=0;
 
 			for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
-				$item = $this->evals_links [$count + $items_start];
+				$item  = $this->evals_links [$count + $items_start];
 				$score = $item->calc_score($user[0]);
 				$divide=( ($score[1])==0 ) ? 1 : $score[1];
 				$item_value+=round($score[0]/$divide*$item->get_weight(),2);
@@ -175,8 +222,11 @@ class FlatViewDataGenerator
 					$row[] = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
 				}
 			}
-
-			$total_score = array($item_value,$item_total);
+			
+			$item_value = round($item_value / $count_categories, 2);
+			$item_total = round($item_total / $count_categories, 2);
+			
+			$total_score = array($item_value, $item_total);
 			if (!$show_all) {
 				$row[] = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT_WITH_CUSTOM);
 			} else {

TEMPAT SAMPAH
main/img/icons/22/accept_na.png


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

@@ -626,8 +626,7 @@ function update_Db_course($course_db_name = null) {
     */
 
     // Exercise tool - Tests/exercises
-    $sql = "
-        CREATE TABLE `".$TABLEQUIZ . "` (
+    $sql = "CREATE TABLE `".$TABLEQUIZ . "` (
         $add_to_all_tables        
         id mediumint unsigned NOT NULL auto_increment,
         title varchar(255) NOT NULL,
@@ -646,6 +645,7 @@ function update_Db_course($course_db_name = null) {
         expired_time int NOT NULL default '0',
         session_id smallint default 0,
         propagate_neg INT NOT NULL DEFAULT 0,
+        review_answers INT NOT NULL DEFAULT 0,
         PRIMARY KEY (c_id, id)
         )" . $charset_clause;
     Database::query($sql);

+ 3 - 2
main/inc/lib/message.lib.php

@@ -558,7 +558,7 @@ class MessageManager
         $table_message = Database::get_main_table(TABLE_MESSAGE);
         $current_uid = api_get_user_id();
         $group_id = intval($group_id);
-        $query = "SELECT * FROM $table_message WHERE group_id=$group_id AND msg_status <> ".MESSAGE_STATUS_OUTBOX." ORDER BY id";
+        $query = "SELECT * FROM $table_message WHERE group_id = $group_id AND msg_status <> ".MESSAGE_STATUS_OUTBOX." ORDER BY id ";
         $rs = Database::query($query);
         $data = array();
         $parents = array();
@@ -1004,7 +1004,8 @@ class MessageManager
         $main_message 	= self::get_message_by_id($topic_id);                
         $group_info		= GroupPortalManager::get_group_data($group_id);
         $rows 			= self::get_messages_by_group_by_message($group_id, $topic_id);            
-        $rows 			= self::calculate_children($rows, $topic_id);                
+        $rows 			= self::calculate_children($rows, $topic_id);
+        
         
         $current_user_id  = api_get_user_id();
         

+ 4 - 1
main/inc/lib/system_announcements.lib.php

@@ -290,6 +290,8 @@ class SystemAnnouncementManager {
 	 * @return mixed  insert_id on success, false on failure
 	 */
 	public static function add_announcement($title, $content, $date_start, $date_end, $visible_teacher = 0, $visible_student = 0, $visible_guest = 0, $lang = null, $send_mail = 0, $add_to_calendar = false ) {
+		
+		$original_content = $content;
 		$a_dateS = explode(' ',$date_start);
 		$a_arraySD = explode('-',$a_dateS[0]);
 		$a_arraySH = explode(':',$a_dateS[1]);
@@ -345,7 +347,8 @@ class SystemAnnouncementManager {
 		}
 		if ($add_to_calendar) {
 		    require_once 'calendar.lib.php';
-		    $agenda_id = agenda_add_item($title, $content, $date_start, $date_end);
+		    
+		    $agenda_id = agenda_add_item($title, $original_content, $date_start, $date_end);
 		}		
 		return Database::insert_id();
 	}

+ 8 - 7
main/inc/lib/usermanager.lib.php

@@ -77,10 +77,11 @@ class UserManager {
 	public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '') {
 		global $_user, $userPasswordCrypted;
 
-		$firstName = Security::remove_XSS($firstName);
-		$lastName = Security::remove_XSS($lastName);
-		$loginName = Security::remove_XSS($loginName);
-		$phone = Security::remove_XSS($phone);
+		$firstName 	= Security::remove_XSS($firstName);
+		$lastName	= Security::remove_XSS($lastName);
+		$loginName 	= Security::remove_XSS($loginName);
+		$phone 		= Security::remove_XSS($phone);
+		
 		// database table definition
 		$table_user = Database::get_main_table(TABLE_MAIN_USER);
 
@@ -100,7 +101,7 @@ class UserManager {
 			return api_set_failure('login-pass already taken');
 		}
 		//$password = "PLACEHOLDER";
-		if($encrypt_method == '') {
+		if ($encrypt_method == '') {
 			$password = api_get_encrypted_password($password);
 		} else {
 			if ($userPasswordCrypted === $encrypt_method ) {
@@ -153,7 +154,7 @@ class UserManager {
 
 		} else {
 			//echo "false - failed" ;
-			$return=false;
+			$return = false;
 		}
 
 		if (is_array($extra) && count($extra) > 0) {
@@ -162,7 +163,7 @@ class UserManager {
 				$res = $res && self::update_extra_field_value($return, $fname, $fvalue);
 			}
 		}
-                self::update_extra_field_value($return, 'already_logged_in', 'false');
+		self::update_extra_field_value($return, 'already_logged_in', 'false');
 		return $return;
 	}
 

+ 2 - 0
main/install/migrate-db-1.8.8-1.9.0-pre.sql

@@ -125,4 +125,6 @@ ALTER TABLE lp ADD COLUMN hide_toc_frame TINYINT NOT NULL DEFAULT 0;
 ALTER TABLE lp ADD COLUMN seriousgame_mode TINYINT NOT NULL DEFAULT 0;
 ALTER TABLE lp_item_view modify column suspend_data longtext;
 INSERT INTO course_setting(variable,value,category) VALUES ('course_grading_model','','gradebook');
+ALTER TABLE quiz ADD COLUMN review_answers INT NOT NULL DEFAULT 0;
+
 

+ 229 - 0
main/mySpace/current_courses.php

@@ -0,0 +1,229 @@
+<?php
+
+
+$language_file = array ('registration', 'index', 'tracking', 'exercice','admin');
+
+require_once '../inc/global.inc.php';
+$this_section = SECTION_TRACKING;
+
+require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
+require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php';
+
+$filename = 'reporting.xls';
+
+if (!api_is_allowed_to_create_course()) {
+	api_not_allowed(true);
+}
+
+$user_id = api_get_user_id();
+$my_courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
+$array = array();
+
+$i = 0;
+if (!empty($my_courses)) {
+	foreach ($my_courses as $course) {
+		
+		//Only show open courses
+		if ($course_info['visibility'] == 0) {
+			continue;
+		}
+		//$array[$i]['course'] = $course;
+		
+		$course_code = $course['course_code'];
+		$course_info = api_get_course_info($course_code);
+		
+		$t_lp 	= Database :: get_course_table(TABLE_LP_MAIN, $course_info['dbName']);
+		$sql_lp = "SELECT lp.name, lp.id FROM $t_lp lp WHERE lp.session_id = 0 LIMIT 1";
+		$rs_lp 	= Database::query($sql_lp);
+		
+		$array[$i]['lp'] = '';
+		if (Database :: num_rows($rs_lp) > 0) {			
+			$learnpath = Database :: fetch_row($rs_lp);
+			$array[$i]['lp'] = $learnpath[0];
+		}
+		
+		$teachers = CourseManager::get_teacher_list_from_course_code($course_code);
+		$teacher_list = array();
+		
+		$array[$i]['teachers'] = '';
+		if (!empty($teachers)) {
+			foreach($teachers as $teacher) {
+				$teacher_list[]= $teacher['firstname'].' '.$teacher['lastname'];
+			}		
+			$array[$i]['teachers'] = implode(', ', $teacher_list);
+		}
+				 
+		$array[$i]['course_name'] = $course['title'];
+		
+		
+		$students = CourseManager :: get_student_list_from_course_code($course['course_code'], false);
+		$count_students = 0;
+		$tools = 0;
+		$session_id = 0;
+		$count_students_accessing = 0;
+		$count_students_complete_all_activities = 0;
+		$count_students_complete_all_activities_at_50 = 0;
+		$total_time_spent = 0;
+		$total_tools = 0;		
+		$total_average_progress = 0;
+		
+		if (!empty($students)) {
+			foreach ($students  as $student) {
+				$student_id = $student['user_id'];
+			
+				$avg_student_progress += Tracking :: get_avg_student_progress($student_id, $course_code);
+				$myavg_temp = Tracking :: get_avg_student_score($student_id, $course_code);
+				
+				$avg_progress_in_course = Tracking::get_avg_student_progress($student_id, $course_code, array(), $session_id);
+			
+				if (intval($avg_progress_in_course) == 100) {
+					$count_students_complete_all_activities++;
+				}
+				if (intval($avg_progress_in_course) > 0 && intval($avg_progress_in_course) <= 50) { 
+					$count_students_complete_all_activities_at_50 ++;
+				}				
+				$total_average_progress +=$avg_progress_in_course;
+				
+				$time_spent  = Tracking::get_time_spent_on_the_course($student_id, $course_code, $session_id);				
+				$total_time_spent += $time_spent; 				
+				if (!empty($time_spent)) {
+					$count_students_accessing++;
+				}				
+			}
+			
+			$student_list = array();
+			foreach($students as $student) {
+				$student_list []=$student['user_id'];
+			}
+			
+			$nb_assignments 		= Tracking::count_student_assignments($student_list, $course_code, $session_id);
+			$messages 				= Tracking::count_student_messages($student_list, $course_code, $session_id);
+			$links 					= Tracking::count_student_visited_links($student_list, $course_code, $session_id);
+			$chat_last_connection 	= Tracking::chat_last_connection($student_list, $course_code, $session_id);			
+			$documents				= Tracking::count_student_downloaded_documents($student_list, $course_code, $session_id);
+
+			$total_tools += $nb_assignments +  $messages + $links + $chat_last_connection + $documents;
+			
+		}
+		
+		$student_count = count($students);
+		
+		$array[$i]['count_students'] = $student_count;
+		$array[$i]['count_students_accessing'] = 0;
+		$array[$i]['count_students_accessing_percentage'] = 0;
+		$array[$i]['count_students_complete_all_activities_at_50'] = 0;
+		$array[$i]['count_students_complete_all_activities'] = 0;
+		$array[$i]['average_percentage_activities_completed_per_student'] = 0;
+		$array[$i]['total_time_spent'] = 0;
+		$array[$i]['average_time_spent_per_student'] = 0;
+		$array[$i]['total_time_spent'] = 0;
+		$array[$i]['average_time_spent_per_student'] = 0;		
+		$array[$i]['tools_used'] = 0;		
+		
+		//@todo don't know what means this value
+		$count_students_complete_all_activities_at_50 = 0;
+		
+		if (!empty($student_count)) {
+			$array[$i]['count_students_accessing'] = $count_students_accessing;
+			$array[$i]['count_students_accessing_percentage'] = round($count_students_accessing / $student_count *100 , 0);
+			$array[$i]['count_students_complete_all_activities_at_50'] = $count_students_complete_all_activities_at_50;
+			$array[$i]['count_students_complete_all_activities'] = round($count_students_complete_all_activities / $student_count *100 , 0);;			
+			$array[$i]['average_percentage_activities_completed_per_student'] = round($count_students_complete_all_activities/$student_count*100,2);			
+			$array[$i]['total_time_spent'] = 0;
+			$array[$i]['average_time_spent_per_student'] = 0;
+			
+			if (!empty($total_time_spent)) {
+				$array[$i]['total_time_spent'] = api_time_to_hms($total_time_spent);
+				$array[$i]['average_time_spent_per_student'] = api_time_to_hms($total_time_spent / $student_count);
+			}			
+			$array[$i]['tools_used'] = $total_tools;
+		}	
+		$i++;
+	}
+}
+
+
+$headers = array(
+	get_lang('LearningPath'),
+	get_lang('Teachers'),
+	get_lang('Courses'),
+	get_lang('NumberOfStudents'),
+	get_lang('NumberStudentsAccessingCourse'),
+	get_lang('PercentageStudentsAccessingCourse'),
+	get_lang('NumberStudentsCompleteAllActivities'),
+	get_lang('PercentageStudentsCompleteAllActivities'),
+	get_lang('AverageOfActivitiesCompletedPerStudent'),
+	get_lang('TotalTimeSpentInTheCourse'),
+	get_lang('AverageTimePerStudentInCourse'),
+	get_lang('NumberOfToolsAddedOrUsedByTeachers')
+);
+	
+
+
+if (isset($_GET['export'])) {
+	global $charset;
+	$workbook = new Spreadsheet_Excel_Writer();
+	$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
+	$workbook->send($filename);
+	$workbook->setVersion(8); // BIFF8
+	$worksheet =& $workbook->addWorksheet('Report');
+	//$worksheet->setInputEncoding(api_get_system_encoding());
+	$worksheet->setInputEncoding($charset);
+	
+	$line = 0;
+	$column = 0; //skip the first column (row titles)
+	
+	foreach($headers as $header) {
+		$worksheet->write($line,$column, $header);
+		$column++;
+	}
+	$line++;
+	foreach ($array as $row) {
+		$column = 0;
+		foreach ($row as $item) {
+			$worksheet->write($line,$column,html_entity_decode(strip_tags($item)));
+			$column++;
+		}
+		$line++;
+	}
+	$line++;
+	$workbook->close();
+	exit;
+}
+
+Display::display_header();
+
+if (!class_exists('HTML_Table')) {
+	require_once api_get_path(LIBRARY_PATH).'pear/HTML/Table.php';
+}
+
+$table = new HTML_Table(array('class' => 'data_table'));
+$row = 0;
+$column = 0;
+foreach ($headers as $header) {
+	$table->setHeaderContents($row, $column, $header);
+	$column++;
+}
+$row++;
+
+foreach ($array as $row_table) {	
+	$column = 0;	
+	foreach ($row_table as $cell) {
+		$table->setCellContents($row, $column, $cell);
+		$table->updateCellAttributes($row, $column, 'align="center"');
+		$column++;
+	}
+	$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
+	$row++;
+}
+
+echo '<div class="actions">';
+echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace"><img align="absbottom" src="../img/back.png">&nbsp;'.get_lang('Back').'</a> ';
+echo '<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php?export=1"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('CurrentCoursesReport').'</a> ';
+echo '</div>';
+echo $table->toHtml();
+
+Display::display_footer();

+ 2 - 1
main/template/default/agenda/month.tpl

@@ -79,7 +79,8 @@ $(document).ready(function() {
 		eventRender: function(event, element) {
 			if (event.description) {
 				element.qtip({
-		            content: event.description
+		            content: event.description,
+		            position: { at:'bottom left'},	
 		        });
 			}