Forráskód Böngészése

Should fix exercise report for hotpotatoes see #5376

Yoselyn Castillo 12 éve
szülő
commit
ad7dfe04e7

+ 2 - 2
main/exercice/exercice.php

@@ -871,7 +871,7 @@ if (isset($attribute['path']) && is_array($attribute['path'])) {
                 $nbrActiveTests = $nbrActiveTests +1;
                 $item .= Display::tag('td', '<a href="showinframes.php?'.api_get_cidreq().'&file='.$path.'&cid='.api_get_course_id().'&uid='.api_get_user_id().'"'.(!$active?'class="invisible"':'').'">'.$title.'</a>');
                 //$item .= Display::tag('td', '');
-                $actions ='<a href="exercise_report.php?' . api_get_cidreq() . '&path='.$path.'">' . Display :: return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_SMALL).'</a>';
+                $actions ='<a href="hotpotatoes_exercise_report.php?' . api_get_cidreq() . '&path='.$path.'&filter_by_user='.api_get_user_id().'">' . Display :: return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_SMALL).'</a>';
                 $item .= Display::tag('td', $actions);
                 echo Display::tag('tr',$item, array('class'=>$class));
             }
@@ -894,4 +894,4 @@ if (empty($exercise_list) && $hotpotatoes_exist == false) {
 }
 if ($origin != 'learnpath') { //so we are not in learnpath tool
 	Display :: display_footer();
-}
+}

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

@@ -799,11 +799,11 @@ function get_count_exam_results($exercise_id, $extra_where_conditions) {
 }
 
 function get_count_exam_hotpotatoes_results($in_hotpot_path) {
-    return get_exam_results_hotpotatoes_data(0, 0, '', '', $in_hotpot_path, true);
+    return get_exam_results_hotpotatoes_data(0, 0, '', '', $in_hotpot_path, true, '');
 }
 
 //function get_exam_results_hotpotatoes_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) {
-function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false) {
+function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false, $where_condition) {
     
     $tab_res = array();
     $course_code = api_get_course_id();
@@ -826,7 +826,7 @@ function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_co
     }
     
     // get a number of sorted results
-    $sql .= " ORDER BY $in_column $in_direction  LIMIT $in_from, $in_number_of_items";
+    $sql .= " $where_condition ORDER BY $in_column $in_direction  LIMIT $in_from, $in_number_of_items";
     
     $res = Database::query($sql);
     while ($data = Database::fetch_array($res)) {

+ 12 - 1
main/exercice/hotpotatoes_exercise_report.php

@@ -62,7 +62,7 @@ if (empty($hotpotatoes_path)) {
 }
 
 if (!$is_allowedToEdit) {
-    api_not_allowed();
+   // api_not_allowed();
 }
 
 if (!empty($_REQUEST['path'])) {
@@ -347,6 +347,17 @@ if ($is_allowedToEdit || $is_tutor) {
         // may be empty string but is defined
         return "<span title=\""+tabLoginx[0]+rowObject[2]+tabLoginx[1]+"\">"+cellvalue+"</span>";
     }';
+} else {
+    //The order is important you need to check the the $column variable in the model.ajax.php file
+	$columns        = array(get_lang('StartDate'),  get_lang('Score'),  get_lang('Actions'));
+
+  //Column config
+  // @todo fix search firstname/lastname that doesn't work. rmove search for the moment
+	$column_model   = array(
+                        array('name'=>'exe_date',		    'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'false'),
+            			array('name'=>'score',			    'index'=>'exe_result',	'width'=>'50',   'align'=>'left', 'search' => 'false'),
+            			array('name'=>'actions',        'index'=>'actions',     'width'=>'60',  'align'=>'left', 'search' => 'false')
+                       );
 }
 
 //Autowidth

+ 10 - 2
main/inc/ajax/model.ajax.php

@@ -130,6 +130,11 @@ switch ($action) {
 	case 'get_hotpotatoes_exercise_results':
 		require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';		
         $hotpot_path = $_REQUEST['path'];
+        if (isset($_GET['filter_by_user']) && !empty($_GET['filter_by_user'])) {            
+            $filter_user = intval($_GET['filter_by_user']);
+            $where_condition .= " AND thp.exe_user_id  = '$filter_user'";
+           
+        } 
 		$count = get_count_exam_hotpotatoes_results($hotpot_path);        
 		break;
     case 'get_sessions':           
@@ -255,7 +260,10 @@ switch ($action) {
         //used inside get_exam_results_data()
 		$documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; 		
 		$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');
-		$result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);        
+        if (!$is_allowedToEdit) {
+            $columns = array('exe_date',  'score',  'actions');
+        }
+		$result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path,'', $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);        
 		break;
     case 'get_sessions':
         $columns = array('name', 'nbr_courses', 'nbr_users', 'category_name', 'date_start','date_end', 'coach_name', 'session_active', 'visibility');            
@@ -486,4 +494,4 @@ if (in_array($action, $allowed_actions)) {
 
     echo json_encode($response);
 }
-exit;
+exit;