ソースを参照

Fixing attempt delete error in exercises see #5373

Julio Montoya 12 年 前
コミット
8e01d315b4

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

@@ -1094,18 +1094,18 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
                             $actions .="<a href='exercise_show.php?".api_get_cidreq()."&action=qualify&id=$id'>".Display :: return_icon('quiz.gif', get_lang('Qualify'));
                             $actions .='&nbsp;';
                         }
-                        $actions .="</a>";                     
-                        if ($is_allowedToEdit) {
-                            if ($filter==2){
-                                $actions .=' <a href="exercise_history.php?'.api_get_cidreq().'&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
-                            }
-                        }
-                        if (api_is_platform_admin()) {     
-                            if ($locked == false) {
-                                $actions .=' <a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';                            
-                                $actions .='&nbsp;';
-                            }
+                        $actions .="</a>";
+                                                
+                        if ($filter == 2) {
+                            $actions .=' <a href="exercise_history.php?'.api_get_cidreq().'&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
+                        }                        
+                        
+                        //Admin can always delete the attempt
+                        if ($locked == false || api_is_platform_admin()) {
+                            $actions .=' <a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';                            
+                            $actions .='&nbsp;';
                         }
+                        
                     } else {
                     	$attempt_url 	= api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$results[$i]['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750';
                     	$attempt_link 	= Display::url(get_lang('Show'), $attempt_url, array('class'=>'ajax btn'));                    	

+ 0 - 1
main/exercice/exercise_report.php

@@ -238,7 +238,6 @@ if ( ($is_allowedToEdit || $is_tutor || api_is_coach()) && $_GET['delete'] == 'd
         Database::query($sql);
         header('Location: exercise_report.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&exerciseId='.$exercise_id);
         exit;
-
     }
 }
 

+ 1 - 1
main/inc/ajax/model.ajax.php

@@ -223,7 +223,7 @@ switch ($action) {
         //used inside get_exam_results_data()
 		$documentPath				= api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document"; 		
 		if ($is_allowedToEdit) {
-			$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score','status','actions');
+			$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions');
 		} else {
 			//$columns = array('exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions');
 		}