Julio Montoya 13 년 전
부모
커밋
ca8d5a076b

+ 80 - 17
main/exercice/exercice.php

@@ -39,7 +39,7 @@ require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
 require_once 'hotpotatoes.lib.php';
 require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
 require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
-
+require_once api_get_path(LIBRARY_PATH)."groupmanager.lib.php"; // for group filtering
 
 /*	Constants and variables */
 $is_allowedToEdit 			= api_is_allowed_to_edit(null,true);
@@ -60,6 +60,7 @@ $TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TR
 $TBL_LP_ITEM_VIEW 			= Database :: get_course_table(TABLE_LP_ITEM_VIEW);
 $TBL_LP_ITEM 				= Database :: get_course_table(TABLE_LP_ITEM);
 $TBL_LP_VIEW 				= Database :: get_course_table(TABLE_LP_VIEW);
+$TBL_GROUP_REL_USER         = Database :: get_course_table(TABLE_GROUP_USER);	
 
 // document path
 $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
@@ -517,19 +518,20 @@ if ($show == 'test') {
         $res = Database::query("SELECT * FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
                                 WHERE d.id = ip.ref  AND ip.tool = '" . TOOL_DOCUMENT . "'
                                 AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%'
-                                AND ip.visibility='1'");
+                                AND ip.visibility='1' AND d.c_id=".api_get_course_int_id()." AND ip.c_id=".api_get_course_int_id());
         $hp_count = Database :: num_rows($res);    
 	}
 	$total = $total_exercises + $hp_count;		
 }
 
+
 if ($is_allowedToEdit && $origin != 'learnpath') {
 	if ($show != 'result') {
 		echo '<a href="exercise_admin.php?' . api_get_cidreq() . '">' . Display :: return_icon('new_exercice.png', get_lang('NewEx'),'','32').'</a>';
 		echo '<a href="question_create.php?' . api_get_cidreq() . '">' . Display :: return_icon('new_question.png', get_lang('AddQ'),'','32').'</a>';
 		// Question category
 		echo '<a href="tests_category.php">';
-		echo Display::return_icon('question_category.gif', get_lang('QuestionCategory'));
+		echo Display::return_icon('question_category_show.gif', get_lang('QuestionCategory'));
 		echo '</a>';		
 		echo '<a href="question_pool.php">';
 		echo Display::return_icon('database.png', get_lang('langQuestionPool'), array('style'=>'width:32px'));
@@ -806,7 +808,7 @@ if ($show == 'test') {
                         $actions =  Display::url(Display::return_icon('edit.png',get_lang('Edit'),'',22), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);                        
                         $actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">' . Display :: return_icon('test_results.png', get_lang('Results'),'',22).'</a>';                        
                         //Export
-                        $actions .= Display::url(Display::return_icon('cd.gif',          get_lang('CopyExercise')),       '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
+                        $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')),       '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
                         //Clean exercise                    
                         $actions .= Display::url(Display::return_icon('clean.png', get_lang('CleanStudentResults'),'',22),'', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=clean_results&sec_token='.$token.'&exerciseId='.$row['id']));                      
                         //Visible / invisible
@@ -828,16 +830,26 @@ if ($show == 'test') {
                         $actions .= Display::url(Display::return_icon('delete.png', get_lang('Delete'),'',22), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$row['id']));            
                     }
 
+					// Number of questions
                     $random_label = '';                    
                     if ($row['random'] > 0) {
-                       	$random_label = ' ('.get_lang('Random').') ';                       	
-                       	$number_of_questions = $row['random'] . ' ' .$random_label;
-                       	//Bug if we set a random value bigger than the real number of questions 
-                       	if ($row['random'] > $rowi) {
-							$number_of_questions = $rowi. ' ' .$random_label;							
+						if ($row['random_by_category'] > 0) {	
+							if (!class_exists("testcategory.class.php")) include_once "testcategory.class.php" ;
+							$nbQuestionsTotal = Testcategory::getNumberOfQuestionRandomByCategory($exid, $row['random']);
+							$number_of_questions .= $nbQuestionsTotal." ";
+							$number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang("QuestionsLowerCase") : get_lang("QuestionLowerCase") ;
+							$number_of_questions .= " - ";
+							$number_of_questions .= $row['random'].' '.get_lang('QuestionByCategory');
+						} else {
+                       		$random_label = ' ('.get_lang('Random').') ';                       	
+                       	    $number_of_questions = $row['random'] . ' ' .$random_label.' '.$textByCategory;
+                       	    //Bug if we set a random value bigger than the real number of questions 
+                       	    if ($row['random'] > $rowi) {
+    							$number_of_questions = $rowi. ' ' .$random_label;							
+                       	    }
                        	}
                     } else {                    
-                       $number_of_questions = $rowi;
+                        $number_of_questions = $rowi;
                     }                
      
                     //Attempts                    
@@ -961,9 +973,13 @@ if ($show == 'test') {
         } 
     }
     // end exercise list
-        
+
+
+       
     //Hotpotatoes results        
     
+    
+    
     if ($is_allowedToEdit) {
         $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
                 FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
@@ -1056,7 +1072,8 @@ if ($show == 'test') {
 
 // if tracking is enabled
 if ($show == 'result') {
-	$parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook']));
+	$parameters = array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook']));
+	
     $exercise_id = intval($_GET['exerciseId']);
     if (!empty($exercise_id))
         $parameters['exerciseId'] = $exercise_id;
@@ -1074,11 +1091,12 @@ if ($show == 'result') {
 			$table->set_header(0, get_lang('LastName'));
 			$table->set_header(1, get_lang('FirstName'));    			
 		}		
-		$table->set_header(2, get_lang('Exercice'));
-    	$table->set_header(3, get_lang('Duration'),false);
-    	$table->set_header(4, get_lang('Date'));
-    	$table->set_header(5, get_lang('Score'),false);
-    	$table->set_header(6, get_lang('CorrectTest'), false);   
+		$table->set_header(2, get_lang('Group'));
+		$table->set_header(3, get_lang('Exercice'));
+    	$table->set_header(4, get_lang('Duration'),false);
+    	$table->set_header(5, get_lang('Date'));
+    	$table->set_header(6, get_lang('Score'),false);
+    	$table->set_header(7, get_lang('CorrectTest'), false);   
     	
     } else {
         $table->set_header(0, get_lang('Exercice'));
@@ -1093,3 +1111,48 @@ if ($show == 'result') {
 if ($origin != 'learnpath') { //so we are not in learnpath tool
 	Display :: display_footer();
 }
+
+
+// ===========================================================================
+// some functions
+// ===========================================================================
+
+// ---------------------------------------------------------
+// return the HTML code for a menu with students group
+// @input : $in_name : is the name and the id of the <select>
+//          $in_default : default value for option
+// @return : the html code of the <select>
+// ---------------------------------------------------------
+function displayGroupMenu($in_name, $in_default) {
+	// check the default value of option
+	$tabSelected = array($in_default => " selected='selected' ");
+	$res = "";
+	$res .= "<select name='$in_name' id='$in_name' >";
+	$res .= "<option value='-1'".$tabSelected["-1"].">-- ".get_lang('AllGroups')." --</option>";
+	$res .= "<option value='0'".$tabSelected["0"].">- ".get_lang('NotInAGroup')." -</option>";
+	$tabGroups = GroupManager::get_group_list();
+	$currentCatId = 0;
+	for ($i=0; $i < count($tabGroups); $i++) {
+		$tabCategory = GroupManager::get_category_from_group($tabGroups[$i]["id"]);
+		if ($tabCategory["id"] != $currentCatId) {
+			$res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>";
+			$currentCatId = $tabCategory["id"];
+		}
+		$res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".$tabGroups[$i]["name"]."</option>";
+	}
+	$res .= "</select>";
+	return $res;
+}
+
+
+// ------------------------------------------------------
+// return a list of group for user with user_id=in_userid
+// separated with in_separator
+// --------------------------------------------------
+function displayGroupsForUser($in_separator, $in_userid) {
+	$res = implode($in_separator, GroupManager::get_user_group_name($in_userid));
+	if ($res == "") {
+		$res = "<div style='text-align:center'>-</div>";
+	}
+	return $res;
+}

+ 4 - 3
main/exercice/exercise.class.php

@@ -39,14 +39,15 @@ class Exercise {
 	public $random_answers;
 	public $active;
 	public $timeLimit;
-	public $attempts;
-	public $feedbacktype;
+    public $attempts;
+    public $feedbacktype;
 	public $end_time;
 	public $start_time;
 	public $questionList;  // array with the list of this exercise's questions
 	public $results_disabled;
 	public $expired_time;
 	public $course;
+	public $course_id;
 	public $propagate_neg;
 	public $review_answers; //
 	public $randomByCat;
@@ -74,7 +75,7 @@ class Exercise {
 		$this->expired_time 	= '0000-00-00 00:00:00';
 		$this->propagate_neg    = 0;
 		$this->review_answers	= false;
-		$this->randomByCat = 0;	//
+		$this->randomByCat      = 0;	//
 
 		if (!empty($course_id)) {			
 			$course_info        =  api_get_course_info_by_id($course_id);

+ 3 - 1
main/exercice/exercise.lib.php

@@ -71,7 +71,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
         }
         
 		//$s .= '<table width="720" class="exercise_options" style="width: 720px;'.$option_ie.' background-color:#fff;">';
-		
+		$s = '';
 		$s .= '<table class="exercise_options">';
 		// construction of the Answer object (also gets all answers details)
 		$objAnswerTmp = new Answer($questionId);
@@ -142,6 +142,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
         $question_list = array();
             
         if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType ==  MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {            
+            $header = '';
             $header .= Display::tag('th', get_lang('Options'));   
             foreach ($objQuestionTmp->options as $key=>$item) {                
                 $header .= Display::tag('th', $item);                           
@@ -1158,6 +1159,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
     return $list_info;
 }
 
+
 /**
  * Converts the score with the exercise_max_note and exercise_min_score the platform settings + formats the results using the float_format function
  * 

+ 2 - 0
main/exercice/exercise_result.php

@@ -172,6 +172,8 @@ if (!empty($question_list)) {
 		//$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$quesId]; 
 		
 		if ($show_results) {
+		    // show category
+		    Testcategory::displayCategoryAndTitle($objQuestionTmp->id);
 	    	// show titles    	
 	    	echo $objQuestionTmp->return_header($objExercise->feedback_type, $counter);
 	    	$counter++;    	

+ 1 - 1
main/exercice/exercise_show.php

@@ -608,7 +608,7 @@ if ($is_allowedToEdit) {
 		echo '<input type = "hidden" name="total_score"      value="'.$totalScore.'"> ';
 		echo '<input type = "hidden" name="my_exe_exo_id"    value="'.$exercise_id.'"> ';					
 	} else {
-		echo ' <form name="myform" id="myform" action="exercice.php?show=result&action=qualify&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'" method="post">';
+		echo ' <form name="myform" id="myform" action="exercice.php?show=result&action=qualify&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
 	}
 	if ($origin!='learnpath' && $origin!='student_progress') {
 		?>

+ 9 - 9
main/exercice/matching.class.php

@@ -255,15 +255,15 @@ class Matching extends Question {
 	}
 	
 		function return_header($feedback_type, $counter = null) {
-	    parent::return_header($feedback_type, $counter);
-	         
-                            echo '<table width="100%" height="71" border="0" cellspacing="3" cellpadding="3" >';
-                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
-                            echo '<tr>
-                                    <td><span style="font-style: italic;">'.get_lang('ElementList').'</span> </td>
-                                    <td><span style="font-style: italic;">'.get_lang('CorrespondsTo').'</span></td>
-                                  </tr>';
-                            echo '<tr><td colspan="2">&nbsp;</td></tr>';
+    	    parent::return_header($feedback_type, $counter);
+
+            echo '<table width="100%" height="71" border="0" cellspacing="3" cellpadding="3" >';
+            echo '<tr><td colspan="2">&nbsp;</td></tr>';
+            echo '<tr>
+                    <td><span style="font-style: italic;">'.get_lang('ElementList').'</span> </td>
+                    <td><span style="font-style: italic;">'.get_lang('CorrespondsTo').'</span></td>
+                  </tr>';
+            echo '<tr><td colspan="2">&nbsp;</td></tr>';
                     
 		}
 

+ 19 - 14
main/exercice/multiple_answer_true_false.class.php

@@ -280,20 +280,25 @@ class MultipleAnswerTrueFalse extends Question {
 	}
 	
 	function return_header($feedback_type, $counter = null) {
-	    parent::return_header($feedback_type, $counter);
-	    $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
-			<tr>
-			<td>&nbsp;</td>
-			</tr>
-			<tr>
-				<td><i>'.get_lang("Choice").'</i> </td>
-				<td><i>'. get_lang("ExpectedChoice").'</i></td>
-				<td><i>'. get_lang("Answer").'</i></td>';
-				if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
-    				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
-				} else { 
-					$header .= '<td>&nbsp;</td>';
-				}
+	    $header = "";
+	    if ($in_echo == 1) {
+	        parent::return_header($feedback_type, $counter, $in_echo);
+	    } else {
+	        $header = parent::return_header($feedback_type, $counter, $in_echo) . $header;
+	    }    	
+  	    $header .= '<table width="100%" border="0" cellspacing="3" cellpadding="3">
+		<tr>
+		<td>&nbsp;</td>
+		</tr>
+		<tr>
+			<td><i>'.get_lang("Choice").'</i> </td>
+			<td><i>'. get_lang("ExpectedChoice").'</i></td>
+			<td><i>'. get_lang("Answer").'</i></td>';
+			if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { 
+				$header .= '<td><i>'.get_lang("Comment").'</i></td>';
+			} else { 
+				$header .= '<td>&nbsp;</td>';
+			}
         $header .= '
 			</tr>
 			<tr>

+ 1 - 1
main/exercice/question_list_admin.inc.php

@@ -146,7 +146,7 @@ unset($_SESSION['less_answer']);
 // If we are in a test
 $inATest = isset($exerciseId) && $exerciseId > 0;
 if (!$inATest) {
-	echo get_lang("ChoiceQuestionType");
+	echo "<p class='warning-message'>".get_lang("ChoiceQuestionType")."</p>";
 }
 else {
 	echo '<div id="question_list">';

+ 40 - 27
main/exercice/question_pool.php

@@ -225,6 +225,8 @@ if (!empty($gradebook) && $gradebook=='view') {
 
 // if admin of course
 if (!$is_allowedToEdit) {
+        echo "HUBC ".__LINE__." ".__FILE__;
+
     api_not_allowed(true);
 }
 
@@ -289,7 +291,6 @@ echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">';
 // Session list, if sessions are used.
 // ----------------------------------------------------
 $session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
-// hub 13-10-2011
 $tabAttrParam = array('class'=>'chzn-select', 'onchange'=>'submit_form(this)');	// when sessions are used
 $labelFormRow = get_lang('Session');
 if (api_get_setting('use_session_mode') == 'false') {
@@ -300,7 +301,7 @@ $session_select_list = array();
 foreach($session_list as $item) {
 	$session_select_list[$item['id']] = $item['name'];
 }
-$select_session_html =  Display::select('session_id', $session_select_list, $session_id, $tabAttrParam);	// hub 13-10-2011
+$select_session_html =  Display::select('session_id', $session_select_list, $session_id, $tabAttrParam);
 echo Display::form_row($labelFormRow, $select_session_html);	// hub 13-10-2011
 
 // -----------------------------------------------------------------------------
@@ -389,7 +390,8 @@ echo Display::form_row(get_lang('Difficulty'), $select_difficulty_html);
 $question_list = Question::get_types_information();
 $new_question_list = array();
 $new_question_list['-1']  = get_lang('All');
-$objExercise->feedbacktype;
+$objExercise = new Exercise();
+$objExercise->read($fromExercise);
 foreach ($question_list as $key=>$item) {
     if ($objExercise->feedbacktype == EXERCISE_FEEDBACK_TYPE_DIRECT) {
         if (!in_array($key, array(HOT_SPOT_DELINEATION, UNIQUE_ANSWER))) {
@@ -409,8 +411,8 @@ $select_answer_html = Display::select('answerType', $new_question_list, $answerT
 echo Display::form_row(get_lang('AnswerType'), $select_answer_html);
 $button = '<button class="save" type="submit" name="name" value="'.get_lang('Filter').'">'.get_lang('Filter').'</button>'; 
 echo Display::form_row('', $button);
-echo "<input type='hidden' id='course_id_changed' name='course_id_changed' value='0' />"; // hub 13-10-2011
-echo "<input type='hidden' id='exercice_id_changed' name='exercice_id_changed' value='0' />"; // hub 13-10-2011
+echo "<input type='hidden' id='course_id_changed' name='course_id_changed' value='0' />"; 
+echo "<input type='hidden' id='exercice_id_changed' name='exercice_id_changed' value='0' />";
 ?>
 </form>
 <div class="clear"></div>
@@ -457,11 +459,11 @@ elseif ($exerciseId == -1) {
 	if (isset($answerType) && $answerType != -1 ) {
 		$answer_where = ' AND type='.$answerType;
 	}
-	$sql = "SELECT DISTINCT * FROM `chamilo19_main`.`c_quiz_question` AS qu $from WHERE qu.c_id=$selected_course AND qu.id NOT IN (SELECT question_id FROM `chamilo19_main`.`c_quiz_rel_question` WHERE c_id=$selected_course ) $level_where $answer_where";
-  $result = Database::query($sql);
-  while($row = Database::fetch_array($result, 'ASSOC')) {
-      $main_question_list[] = $row;
-  }
+	$sql = "SELECT DISTINCT * FROM $TBL_QUESTIONS qu $from WHERE qu.c_id=$selected_course AND qu.id NOT IN (SELECT question_id FROM $TBL_EXERCICE_QUESTION WHERE c_id=$selected_course ) $level_where $answer_where";
+    $result = Database::query($sql);
+    while($row = Database::fetch_array($result, 'ASSOC')) {
+        $main_question_list[] = $row;
+    }
 } 
 else {
 	// ---------------------------------
@@ -574,27 +576,27 @@ $nbrQuestions = count($main_question_list);
 // ----------------------------------------------------------------------------------------
 if ($fromExercise <= 0) { // NOT IN A TEST - IN THE COURSE
 	if ($selected_course == api_get_course_int_id()) {
-		$actionLabel = get_lang('Action');
+		$actionLabel = get_lang('Modify');
 		$actionIcon1 = "edit";
 		$actionIcon2 = "delete";
 		$questionTagA = 1;	// we are in the course, question title can be a link to the question edit page
 	}
 	else { // NOT IN A TEST - NOT IN THE COURSE
-		$actionLabel = get_lang('Reuse');
+		$actionLabel = get_lang('langReuse');
 		$actionIcon1 = get_lang('mustBeInATest');
 		$actionIcon2 = "";
-		$questionTagA = 0;	// we are not in  this course, to messy if we link to the question in another course
+		$questionTagA = 0;	// we are not in this course, to messy if we link to the question in another course
 	}
 }
 else { // IN A TEST - IN THE COURSE
 	if ($selected_course == api_get_course_int_id()) {
-		$actionLabel = get_lang('Reuse');
+		$actionLabel = get_lang('langReuse');
 		$actionIcon1 = "add";
 		$actionIcon2 = "";
 		$questionTagA = 1;
 	}
 	else { // IN A TEST - NOT IN THE COURSE
-		$actionLabel = get_lang('Reuse');
+		$actionLabel = get_lang('langReuse');
 		$actionIcon1 = "clone";
 		$actionIcon2 = "";
 		$questionTagA = 0;
@@ -604,11 +606,12 @@ else { // IN A TEST - IN THE COURSE
 // display table
 // -------------------
 $header = array();
-$header[] = array(get_lang('Question'), false, array("style"=>"text-align:center"));
-$header[] = array(get_lang('Type'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"));
-$header[] = array(get_lang('QuestionCategory'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"));
-$header[] = array(get_lang('Difficulty'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"));
-$header[] = array($actionLabel, false, array("style"=>"text-align:center"), array("style"=>"text-align:center"));
+$header[] = array(get_lang('QuestionUpperCaseFirstLetter'), false, array("style"=>"text-align:center"), '');
+$header[] = array(get_lang('Type'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), '');
+$header[] = array(get_lang('QuestionCategory'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), '');
+$header[] = array(get_lang('Difficulty'), false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), '');
+$header[] = array($actionLabel, false, array("style"=>"text-align:center"), array("style"=>"text-align:center"), '');
+
 $data = array();
 foreach ($main_question_list as $tabQuestion) {
 	$row = array();
@@ -616,18 +619,26 @@ foreach ($main_question_list as $tabQuestion) {
 	$row[] = get_question_type_for_question($selected_course, $tabQuestion['id']);
 	$row[] = get_question_categorie_for_question($selected_course, $tabQuestion['id']);
 	$row[] = $tabQuestion['level'];
-	$row[] = get_action_icon_for_question($actionIcon1, $fromExercise, $tabQuestion['id'], $tabQuestion['type'], $tabQuestion['question'], $selected_course, $courseCategoryId, $exerciseId, $exerciseLevel, $answerType, $session_id)."&nbsp;".get_action_icon_for_question($actionIcon2, $fromExercise, $tabQuestion['id'], $tabQuestion['type'], $tabQuestion['question'], $selected_course, $courseCategoryId, $exercice_id, $exerciseLevel, $answerType, $session_id);
+	$row[] = get_action_icon_for_question($actionIcon1, $fromExercise, $tabQuestion['id'], $tabQuestion['type'], 
+                $tabQuestion['question'], $selected_course, $courseCategoryId, $exerciseLevel, 
+                $answerType, $session_id).
+                "&nbsp;".
+                get_action_icon_for_question($actionIcon2, $fromExercise, $tabQuestion['id'], $tabQuestion['type'], 
+                $tabQuestion['question'], $selected_course, $courseCategoryId, $exerciseLevel, $answerType, 
+                $session_id);
 	$data[] = $row;
 }
-Display :: display_sortable_table($header, $data, array(), array('per_page_default'=>999,'per_page'=>999,'page_nr'=>1));
+Display :: display_sortable_table($header, $data, '', array('per_page_default'=>999,'per_page'=>999,'page_nr'=>1));
 
 if (!$nbrQuestions) {
 	echo get_lang('NoQuestion');
 }
 
-if (api_get_session_id() == 0 ){
-	echo '<div style="width:100%; border-top:1px dotted #4171B5;"><button class="save" type="submit">'.get_lang('Reuse').'</button></div></form>';
-}
+// The (+) system as now make this button useless
+// Hubert Borderiou 27-10-2011
+//if (api_get_session_id() == 0){
+//	echo '<div style="width:100%; border-top:1px dotted #4171B5;"><button class="save" type="submit">'.get_lang('Reuse').'</button></div></form>';
+//}
 Display::display_footer();
 
 
@@ -673,9 +684,11 @@ function get_a_tag_for_question($in_addA, $in_fromex, $in_questionid, $in_questi
 // 
 // return the <a> html code for delete, add, clone, edit a question
 // hubert.borderiou 13-10-2011
-function get_action_icon_for_question($in_action, $from_exercice, $in_questionid, $in_questiontype, $in_questionname, $in_selected_course, $in_courseCategoryId, $in_exercise_id, $in_exerciseLevel, $in_answerType, $in_session_id) {
+function get_action_icon_for_question($in_action, $from_exercice, $in_questionid, $in_questiontype, $in_questionname, 
+    $in_selected_course, $in_courseCategoryId, $in_exerciseLevel, $in_answerType, $in_session_id
+) {
 	$res = "";
-	$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
+	$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$from_exercice&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
 	switch ($in_action) {
 		case "delete" :	
 			$res = "<a href='".api_get_self()."?".api_get_cidreq()."&exerciseId=$from_exercice&delete=$in_questionid$getParams' onclick='return confirm_your_choice()'>";

+ 9 - 8
main/exercice/testcategory.class.php

@@ -40,7 +40,7 @@ class Testcategory {
 		if ($numrows > 0) {
 			$row = Database::fetch_array($res);
 			$this->id = $row['id'];
-			$this->name = $row['name'];
+			$this->name = $row['title'];
 			$this->description  = $row['description'];
 		}
 	}
@@ -54,7 +54,7 @@ class Testcategory {
 		$v_description = $this->description;
 		$v_description = Database::escape_string($v_description);
 		// check if name already exists
-		$sql_verif = "SELECT count(*) AS nb FROM $t_cattable WHERE name = '$v_name' AND c_id=".api_get_course_int_id();
+		$sql_verif = "SELECT count(*) AS nb FROM $t_cattable WHERE title = '$v_name' AND c_id=".api_get_course_int_id();
 		$result_verif = Database::query($sql_verif, __FILE__, __LINE__);
 		$data_verif = Database::fetch_array($result_verif);
 		// lets add in BDD if not the same name
@@ -92,7 +92,7 @@ class Testcategory {
 		$v_id = Database::escape_string($this->id);
 		$v_name = Database::escape_string($this->name);
 		$v_description = Database::escape_string($this->description);
-		$sql = "UPDATE $t_cattable SET name='$v_name', description='$v_description' WHERE id='$v_id' AND c_id=".api_get_course_int_id();
+		$sql = "UPDATE $t_cattable SET title='$v_name', description='$v_description' WHERE id='$v_id' AND c_id=".api_get_course_int_id();
 		$res = Database::query($sql);
 		if (Database::affected_rows() <= 0) {
 			return false;
@@ -134,10 +134,10 @@ class Testcategory {
 		$in_field = Database::escape_string($in_field);
 		$tabres = array();
 		if ($in_field=="") {
-			$sql = "SELECT * FROM $t_cattable WHERE c_id=$in_courseid ORDER BY name ASC";
+			$sql = "SELECT * FROM $t_cattable WHERE c_id=$in_courseid ORDER BY title ASC";
 			$res = Database::query($sql);
 			while ($row = Database::fetch_array($res)) {
-				$tmpcat = new Testcategory($row['id'], $row['name'], $row['description']);
+				$tmpcat = new Testcategory($row['id'], $row['title'], $row['description']);
 				$tabres[] = $tmpcat;
 			}
 		}
@@ -198,11 +198,11 @@ class Testcategory {
 		$result = "";	// result
 		$t_cattable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);		
 		$catid = Database::escape_string($catid);
-		$sql = "SELECT name FROM $t_cattable WHERE id='$catid' AND c_id=$in_courseid";
+		$sql = "SELECT title FROM $t_cattable WHERE id='$catid' AND c_id=$in_courseid";
 		$res = Database::query($sql);
 		$data = Database::fetch_array($res);
 		if (Database::num_rows($res) > 0) {
-			$result = $data['name'];
+			$result = $data['title'];
 		}
 		return $result;
 	}
@@ -353,7 +353,7 @@ class Testcategory {
 	}
 	
 	/**
-	 * display the category
+	 * display the category and the title
 	 */
 	function displayCategoryAndTitle($in_questionID) {
 		if (Testcategory::getCategoryNameForQuestion($in_questionID) != "") {
@@ -365,6 +365,7 @@ class Testcategory {
 		}
 	}
 	
+	
 	/**
 		* Display signs [+] and/or (>0) after question title if question has options
 		* scoreAlwaysPositive and/or uncheckedMayScore

+ 3 - 3
main/exercice/tests_category.php

@@ -220,7 +220,7 @@ function display_add_category() {
 // ------------------------------------------------------------------------
 function display_categories() {
 	$t_cattable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
-	$sql = "SELECT * FROM $t_cattable ORDER BY name";
+	$sql = "SELECT * FROM $t_cattable ORDER BY title";
 	$res = Database::query($sql, __FILE__, __LINE__);
 	while ($row = Database::fetch_array($res)) {
 		// le titre avec le nombre de questions qui sont dans cette catégorie
@@ -228,7 +228,7 @@ function display_categories() {
 		$nb_question = $tmpobj->getCategoryQuestionsNumber();
 		echo '<div class="sectiontitle" id="id_cat'.$row['id'].'">';
 		echo "<span style='float:right'>".$nb_question.get_lang('NbCategory')."</span>";
-		echo $row['name'];
+		echo $row['title'];
 		echo '</div>';
 		echo '<div class="sectioncomment">';
 		echo $row['description'];
@@ -241,7 +241,7 @@ function display_categories() {
 			echo '</a>';
 		}
 		else {
-			$rowname = protectJSDialogQuote($row['name']);
+			$rowname = protectJSDialogQuote($row['title']);
 			echo '<a href="'.api_get_self().'?action=deletecategory&amp;category_id='.$row['id'].'" ';
 			echo 'onclick="return confirmDelete(\''.protectJSDialogQuote(get_lang('DeleteCategoryAreYouSure').'['.$rowname).'] ?\', \'id_cat'.$row['id'].'\');">';
 			echo Display::return_icon('delete.gif', get_lang('Delete')).'</a>';

BIN
main/img/icons/32/add_question.gif


BIN
main/img/icons/32/fill_in_blanks.gif


BIN
main/img/icons/32/hotspot.gif


BIN
main/img/icons/32/matching.gif


BIN
main/img/icons/32/mcma.gif


BIN
main/img/icons/32/mcmac.gif


BIN
main/img/icons/32/mcmaco.gif


BIN
main/img/icons/32/mcmao.gif


BIN
main/img/icons/32/mcua.gif


BIN
main/img/icons/32/mcuao.gif


BIN
main/img/icons/32/open_answer.gif


BIN
main/img/question_category.gif


BIN
main/img/question_category_show.gif


+ 1 - 0
main/inc/lib/display.lib.php

@@ -693,6 +693,7 @@ class Display {
      *
      */
     public function select($name, $values, $default = -1, $extra_attributes = array(), $show_blank_item = true) {
+        $html = '';
         $extra = '';
         $default_id =  'id="'.$name.'" ';
         foreach($extra_attributes as $key=>$parameter) {

+ 3 - 3
main/inc/lib/groupmanager.lib.php

@@ -1520,7 +1520,8 @@ class GroupManager {
 		$user_id = Database::escape_string($user_id);
 		$course_id = api_get_course_int_id();
 		$sql_groups = 'SELECT name FROM '.$table_group.' g,'.$table_group_user.' gu 
-		               WHERE g.c_id = '.$course_id.' AND  gu.user_id = "'.$user_id.'" AND gu.group_id = g.id';
+		               WHERE gu.c_id= '.$course_id.' AND g.c_id='.$course_id.' AND  gu.user_id="'.$user_id.'" AND gu.group_id=g.id';
+		               
 		$res = Database::query($sql_groups);
 
 		$groups=array();
@@ -1598,6 +1599,5 @@ class GroupManager {
         $complete_user_list = self :: filter_only_students($complete_user_list);
         //now sort by # of group left
         $complete_user_list = TableSort :: sort_table($complete_user_list, 'number_groups_left', SORT_DESC);           
-        return $complete_user_list;
-    }		
+        return $complete_user_list;    }		
 }

+ 44 - 0
main/lang/english/exercice.inc.php

@@ -420,4 +420,48 @@ $ValidateAnswers = "Validate answers";
 $ReviewQuestions = "Review selected questions";
 $YouTriedToResolveThisExerciseEarlier = "You have tried to resolve this question earlier";
 $ThereAreNoQuestionsForThisExercise = "There are no questions for this exercise";
+// question category
+$QuestionByCategory = "question(s) par catégories";
+$QuestionLowerCase = "question";
+$QuestionUpperCaseFirstLetter = "Question";
+$QuestionsLowerCase = "questions";
+$QuestionCategory = "Catégories de questions";
+$Category = "Catégorie";
+$AddACategory = "Ajouter une catégorie de questions";
+$BackToTestList = "Retour à la liste des tests";
+$CategoryName = "Nom de la catégorie";
+$CategoryDescription = "Description de la catégorie<br/><span style='font-size:100%; font-style:italic'>(Invisible pour les apprenants)</span>";
+$AddTestCategory = "Ajouter la catégorie";
+$BackToCategoryList = "Retour à la liste des catégories";
+$AddCategoryDone = "La catégorie a été ajouté.";
+$AddCategoryNameAlreadyExists = "La catégorie n'a pas été ajouté. Une catégorie de même nom existe déjà.";
+$NbCategory = " question(s) de cette catégorie.";
+$CannotDeleteCategory = "Vous ne pouvez pas effacer une catégorie à laquelle des questions sont associées.";
+$DeleteCategoryAreYouSure = "Êtes vous sur de vouloir supprimer la catégorie ";
+$CannotDeleteCategoryError = "Suppression impossible, id de catégorie incorrect. Retourner à la page d'acceuil de votre cours et reéssayez.";
+$DeleteCategoryDone = "La catégorie à bien été supprimée.";
+$CannotEditCategory = "Impossible d'éditer cette catégorie. Retourner à la page d'acceuil de votre cours et reéssayez.";
+$EditCategory = "Éditer un catégorie de question.";
+$ModifyCategory = "Modifier la catégorie";
+$MofidfyCategoryDone = "La catégorie a été modifiée.";
+$ModifyCategoryError = "La catégorie n'a pas été modifiée.";
+$NoCategory = "- Aucune -";
+$QuestionScoreAlwaysPositive = "Score toujours positif&nbsp;?<br/><span style='font-size:75%'>Symbole : (>0)</span>";
+$RandomQuestionByCategory = "Groupes de question aléatoires par catégories ?";
+$AllCategories = "Toutes les catégories";
+$AllLevel = "Toutes les difficultées";
+$AllGroups = "Pas de filtre sur les groupes";
+$NotInAGroup = "Dans aucun groupe";
+$FilterByGroup = "Filtrer l'affichage par groupe : ";
+$DoFilter = "Filtrer";
+$CreateQuestionOutsideExercice = "Gestion de question HORS EXERCICE";
+$ByCategory = "par catégorie";
+$yesWithCategoriesShuffled = "Oui avec les catégories mélangées";
+$yesWithCategoriesSorted = "Oui avec les catégories triées par ordre alphabétique";
+$manageAllQuestions	= "Modifier/Supprimer des questions - Créer des questions hors test";
+$pleaseSelectSomeRandomQuestion = "Éditez le test et selectionner le nombre de questions aléatoires à utiliser.";
+$mustBeInATest = "Vous devez être dans un test pour récupérer des questions d'un autre cours.";
+$RemoveFromTest = "Ôter la question du test.";
+$ChoiceQuestionType = "Création d'une question hors test.<br/>Choisissez le type de la question que vous souhaitez ajouter.";
+$addQuestionToTest = "Ajouter des questions au test";
 ?>

+ 44 - 0
main/lang/french/exercice.inc.php

@@ -413,4 +413,48 @@ $ShowScoreAndRightAnswer = "Mode auto-évaluation: afficher le score et les rép
 $DoNotShowScoreNorRightAnswer = "Mode examen: ne rien divulguer (ni score, ni réponses)";
 $LoadUsersExtraData = "Charger les données de profil des utilisateurs";
 $StartTest = "Démarrer le test";
+// question category
+$QuestionByCategory = "question(s) par catégories";
+$QuestionLowerCase = "question";
+$QuestionUpperCaseFirstLetter = "Question";
+$QuestionsLowerCase = "questions";
+$QuestionCategory = "Catégories de questions";
+$Category = "Catégorie";
+$AddACategory = "Ajouter une catégorie de questions";
+$BackToTestList = "Retour à la liste des tests";
+$CategoryName = "Nom de la catégorie";
+$CategoryDescription = "Description de la catégorie<br/><span style='font-size:100%; font-style:italic'>(Invisible pour les apprenants)</span>";
+$AddTestCategory = "Ajouter la catégorie";
+$BackToCategoryList = "Retour à la liste des catégories";
+$AddCategoryDone = "La catégorie a été ajouté.";
+$AddCategoryNameAlreadyExists = "La catégorie n'a pas été ajouté. Une catégorie de même nom existe déjà.";
+$NbCategory = " question(s) de cette catégorie.";
+$CannotDeleteCategory = "Vous ne pouvez pas effacer une catégorie à laquelle des questions sont associées.";
+$DeleteCategoryAreYouSure = "Êtes vous sur de vouloir supprimer la catégorie ";
+$CannotDeleteCategoryError = "Suppression impossible, id de catégorie incorrect. Retourner à la page d'acceuil de votre cours et reéssayez.";
+$DeleteCategoryDone = "La catégorie à bien été supprimée.";
+$CannotEditCategory = "Impossible d'éditer cette catégorie. Retourner à la page d'acceuil de votre cours et reéssayez.";
+$EditCategory = "Éditer un catégorie de question.";
+$ModifyCategory = "Modifier la catégorie";
+$MofidfyCategoryDone = "La catégorie a été modifiée.";
+$ModifyCategoryError = "La catégorie n'a pas été modifiée.";
+$NoCategory = "- Aucune -";
+$QuestionScoreAlwaysPositive = "Score toujours positif&nbsp;?<br/><span style='font-size:75%'>Symbole : (>0)</span>";
+$RandomQuestionByCategory = "Groupes de question aléatoires par catégories ?";
+$AllCategories = "Toutes les catégories";
+$AllLevel = "Toutes les difficultées";
+$AllGroups = "Pas de filtre sur les groupes";
+$NotInAGroup = "Dans aucun groupe";
+$FilterByGroup = "Filtrer l'affichage par groupe : ";
+$DoFilter = "Filtrer";
+$CreateQuestionOutsideExercice = "Gestion de question HORS EXERCICE";
+$ByCategory = "par catégorie";
+$yesWithCategoriesShuffled = "Oui avec les catégories mélangées";
+$yesWithCategoriesSorted = "Oui avec les catégories triées par ordre alphabétique";
+$manageAllQuestions	= "Modifier/Supprimer des questions - Créer des questions hors test";
+$pleaseSelectSomeRandomQuestion = "Éditez le test et selectionner le nombre de questions aléatoires à utiliser.";
+$mustBeInATest = "Vous devez être dans un test pour récupérer des questions d'un autre cours.";
+$RemoveFromTest = "Ôter la question du test.";
+$ChoiceQuestionType = "Création d'une question hors test.<br/>Choisissez le type de la question que vous souhaitez ajouter.";
+$addQuestionToTest = "Ajouter des questions au test";
 ?>