Julio Montoya 15 years ago
parent
commit
c36617a394

+ 7 - 0
documentation/changelog.html

@@ -98,6 +98,13 @@
   	</ul>
 	</li>
 	  
+</ul>
+<li>Exercises tool
+    <ul>
+        <li>If the option is selected glossary terms shows the tools lessons (SCORM) and exercises, in the description of exercise may see terms that may be responses to the question</li>
+    </ul>
+    </li>
+      
 </ul>
 <br />
 <h1>Dokeos 1.8.6.1 - August 2009</h1>

+ 6 - 8
main/exercice/exercice.php

@@ -471,7 +471,7 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor
 		switch ($_POST['export_format']) {
 			case 'xls' :
 				$export = new ExerciseResult();
-				$export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields']);
+				$export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter']);
 				exit;
 				break;
 			case 'csv' :
@@ -795,9 +795,11 @@ if (($is_allowedToEdit) and ($origin != 'learnpath')) {
 			echo '<form id="form1a" name="form1a" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '">';
 			echo '<input type="hidden" name="export_report" value="export_report">';
 			echo '<input type="hidden" name="export_format" value="csv">';
+			echo '<input type="hidden" name="export_filter" value="'.(empty($filter)?1:intval($filter)).'">';
 			echo '</form>';
 			echo '<form id="form1b" name="form1b" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '">';
 			echo '<input type="hidden" name="export_report" value="export_report">';
+			echo '<input type="hidden" name="export_filter" value="'.(empty($filter)?1:intval($filter)).'">';
 			echo '<input type="hidden" name="export_format" value="xls">';
 			echo '</form>';
 			//echo '<form id="form1c" name="form1c" method="post" action="'.api_get_self().'?show='.Security::remove_XSS($_GET['show']).'">';
@@ -1130,12 +1132,8 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 		  <th><?php echo (($is_allowedToEdit||$is_tutor)?get_lang("CorrectTest"):get_lang("ViewTest")); ?></th>
 		 </tr>-->
 		<?php
-
-	$session_id_and = '';
-	if (api_get_session_id() != 0) {
-		$session_id_and = ' AND session_id = ' . api_get_session_id() . ' ';
-	}
-
+	
+	$session_id_and = ' AND ce.session_id = ' . api_get_session_id() . ' ';
 	if ($is_allowedToEdit || $is_tutor) {
 		$user_id_and = '';
 		if (!empty ($_POST['filter_by_user'])) {
@@ -1164,7 +1162,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
 
 	} else {
 		// get only this user's results
-		$user_id_and = ' AND te.exe_user_id = ' . Database :: escape_string(api_get_user_id()) . ' ';
+		$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
 
 				$sql="SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." as users,ce.title, te.exe_result ,
 							 te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email, UNIX_TIMESTAMP(te.start_date), steps_counter,cuser.user_id,te.exe_duration, ce.results_disabled

+ 83 - 37
main/exercice/exercise_result.class.php

@@ -109,7 +109,7 @@ class ExerciseResult
 	 * @param	string		The document path (for HotPotatoes retrieval)
 	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
 	 */
-	function _getExercisesReporting($document_path,$user_id=null)
+	function _getExercisesReporting($document_path,$user_id=null,$filter=0)
 	{
 		$return = array();
     	$TBL_EXERCISES          = Database::get_course_table(TABLE_QUIZ_TEST);
@@ -121,37 +121,43 @@ class ExerciseResult
 		$TBL_TRACK_EXERCISES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 		$TBL_TRACK_HOTPOTATOES	= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
 		$TBL_TRACK_ATTEMPT		= Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+		$TBL_COURSE_REL_USER 	= Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 
     	$cid = api_get_course_id();
+    	$user_id = intval($user_id);
+    	$session_id_and = ' AND ce.session_id = ' . api_get_session_id() . ' ';
 		if(empty($user_id))
 		{
-			//get all results (ourself and the others) as an admin should see them
-			//AND exe_user_id <> $_user['user_id']  clause has been removed
+				
 			$sql="SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)").", ce.title, te.exe_result ,
-						te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_id, user.email, user.user_id
-				  FROM $TBL_EXERCISES ce , $TBL_TRACK_EXERCISES te, $TBL_USER user
-				  WHERE te.exe_exo_id = ce.id AND user_id=te.exe_user_id AND te.exe_cours_id='$cid'
-				  ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC";
+								 te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, user.email, user.user_id
+						  FROM $TBL_EXERCISES AS ce , $TBL_TRACK_EXERCISES AS te, $TBL_USER AS user,$TBL_COURSE_REL_USER AS cuser
+						  WHERE  user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($cid) . "'
+						  AND cuser.status<>1 $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
+						  AND cuser.course_code=te.exe_cours_id ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC";
 
 			$hpsql="SELECT ".(api_is_western_name_order() ? "CONCAT(tu.firstname,' ',tu.lastname)" : "CONCAT(tu.lastname,' ',tu.firstname)").", tth.exe_name,
-						tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date), tu.email, tu.user_id
-					FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
-					WHERE  tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".$cid."'
-					ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
-
+								tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date), tu.email, tu.user_id
+							FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
+							WHERE  tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($cid) . " $user_id_and '
+							ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
+			
+			
 		}
 		else
 		{ // get only this user's results
-			  $sql="SELECT '',ce.title, te.exe_result , te.exe_weighting, " .
-			  		"UNIX_TIMESTAMP(te.exe_date),te.exe_id
-				  FROM $TBL_EXERCISES ce , $TBL_TRACK_EXERCISES te
-				  WHERE te.exe_exo_id = ce.id AND te.exe_user_id='".Database::escape_string($user_id)."' AND te.exe_cours_id='".Database::escape_string($cid)."'
-				  ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC";
 
-			$hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
-					FROM $TBL_TRACK_HOTPOTATOES
-					WHERE exe_user_id = '".Database::escape_string($user_id)."' AND exe_cours_id = '".Database::escape_string($cid)."'
-					ORDER BY exe_cours_id ASC, exe_date ASC";
+					$sql="SELECT '', ce.title, te.exe_result ,
+								 te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id
+							  FROM $TBL_EXERCISES AS ce , $TBL_TRACK_EXERCISES AS te, $TBL_USER AS user,$TBL_COURSE_REL_USER AS cuser
+							  WHERE  user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($cid) . "'
+							  AND cuser.status<>1 AND te.exe_user_id='".Database::escape_string($user_id)."' $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
+							  AND cuser.course_code=te.exe_cours_id ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
+	
+					$hpsql = "SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
+							FROM $TBL_TRACK_HOTPOTATOES
+							WHERE exe_user_id = '" . $user_id . "' AND exe_cours_id = '" . Database :: escape_string($cid) . "'
+							ORDER BY exe_cours_id ASC, exe_date DESC";
 
 		}
 
@@ -160,12 +166,36 @@ class ExerciseResult
 
 		$NoTestRes = 0;
 		$NoHPTestRes = 0;
-		$j=0;
+		$j=0;				
+		
+		if ($filter) {
+			switch ($filter) {
+				case 1 :
+						$filter_by_not_revised = true;
+						break;
+				case 2 :
+						$filter_by_revised = true;
+						break;
+				default :
+						null;
+			}
+		}
+		
 		//Print the results of tests
 		if(is_array($results))
 		{
 			for($i = 0; $i < sizeof($results); $i++)
 			{
+				
+				$revised = false;
+				$sql_exe = 'SELECT exe_id FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING) . '
+							WHERE author != ' . "''" . ' AND exe_id = ' . "'" . Database :: escape_string($results[$i][5]) . "'" . ' LIMIT 1';
+				$query = Database::query($sql_exe, __FILE__, __LINE__);
+					
+				if (Database :: num_rows($query) > 0) $revised = true;
+				if ($filter_by_not_revised && $revised == true) continue;				
+				if ($filter_by_revised && $revised == false) continue;
+								
 				$return[$i] = array();
 				$id = $results[$i][5];
 				$mailid = $results[$i][6];
@@ -210,7 +240,7 @@ class ExerciseResult
 				$return[$j+$i]['max'] = $hpresults[$i][3];
 			}
 		}
-		$this->results = $return;
+		$this->results = $return;	
 		return true;
 	}
 	/**
@@ -220,10 +250,10 @@ class ExerciseResult
 	 * @param	boolean		Whether to include user fields or not
 	 * @return	boolean		False on error
 	 */
-	public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields)
+	public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = array(), $export_filter = 0)
 	{
 		global $charset;
-		$this->_getExercisesReporting($document_path,$user_id);
+		$this->_getExercisesReporting($document_path,$user_id,$export_filter);
 		$filename = 'exercise_results_'.date('YmdGis').'.csv';
 		if(!empty($user_id))
 		{
@@ -302,10 +332,10 @@ class ExerciseResult
 	 * Exports the complete report as an XLS file
 	 * @return	boolean		False on error
 	 */
-	public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields)
+	public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields=array(), $export_filter = 0) 
 	{
 		global $charset;
-		$this->_getExercisesReporting($document_path,$user_id);
+		$this->_getExercisesReporting($document_path,$user_id,$export_filter);
 		$filename = 'exercise_results_'.date('YmdGis').'.xls';
 		if(!empty($user_id))
 		{
@@ -317,11 +347,23 @@ class ExerciseResult
 		$worksheet =& $workbook->addWorksheet('Report '.date('YmdGis'));
 		$line = 0;
 		$column = 0; //skip the first column (row titles)
-		if(!empty($this->results[0]['user']))
-		{
-			$worksheet->write($line,$column,get_lang('User'));
-			$column++;
+		
+		// check if exists column 'user'
+		$with_column_user = false;		
+		foreach ($this->results as $result) {			
+			if (!empty($result['user'])) {
+				$with_column_user = true;
+				break;
+			}
+		}
+
+		if($with_column_user) {
+		   	$worksheet->write($line,$column,get_lang('User'));
+				$column++;
 		}
+		
+		$export_user_fields = true;
+		
 		if($export_user_fields)
 		{
 			//show user fields section with a big th colspan that spans over all fields
@@ -350,12 +392,16 @@ class ExerciseResult
 				$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['user']), ENT_QUOTES, $charset));
 				$column++;
 			}
-			//show user fields data, if any, for this user
-			$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
-			foreach($user_fields_values as $value)
-			{
-				$worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
-				$column++;
+
+			if($export_user_fields)
+			{			
+				//show user fields data, if any, for this user
+				$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
+				foreach($user_fields_values as $value)
+				{
+					$worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
+					$column++;
+				}
 			}
 			$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
 			$column++;

BIN
tests/procedures/spanish/tests.xls