diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index b20467dbc5..150c8ec1b8 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -131,7 +131,7 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp $sql = 'DELETE FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . ' WHERE exe_id = ' . $_GET['did']; //_GET[did] filtered by entry condition Database::query($sql); $filter=Security::remove_XSS($_GET['filter']); - header('Location: exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '&exerciseId='.$exerciseId); + header('Location: exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '&exerciseId='.$exerciseId.'&filter_by_user='.$_GET['filter_by_user']); exit; } @@ -572,9 +572,7 @@ if ($is_allowedToEdit && $origin != 'learnpath') { }); '; - echo '
'; - //echo Display::tag('p', get_lang("CSVOrExcel")); - //Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'','32') + echo '
'; echo Display::tag('p', Display::input('radio', 'export_format', 'csv', array('checked'=>'1', 'id'=>'export_format_csv_label')). Display::tag('label', get_lang('ExportAsCSV'), array('for'=>'export_format_csv_label'))); echo Display::tag('p', Display::input('radio', 'export_format', 'xls', array('id'=>'export_format_xls_label')). Display::tag('label', get_lang('ExportAsXLS'), array('for'=>'export_format_xls_label'))); echo Display::tag('p', Display::input('checkbox', 'load_extra_data', '0',array('id'=>'load_extra_data_id')). Display::tag('label', get_lang('LoadExtraData'), array('for'=>'load_extra_data_id'))); @@ -616,7 +614,7 @@ if ($show == 'result') { default : null; } - if (!empty($_GET['exerciseId'])) { + if (!empty($_GET['exerciseId']) && empty($_GET['filter_by_user'])) { if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { $view_result = ''.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').''; } else { @@ -653,31 +651,7 @@ if ($show == 'test') { } } -if ($show == 'test') { - ?> - - - '; if (!empty($exercise_list)) { - //echo '
'; - //echo '
'; - //echo Display::tag('ul', $lis); /* Listing exercises */ if ($origin != 'learnpath') { @@ -841,7 +812,6 @@ if ($show == 'test') { if ($session_id == $row['session_id']) { $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'])); } - //$actions .= '
'; $random_label = ''; if ($row['random'] > 0) { @@ -951,16 +921,6 @@ if ($show == 'test') { $attempt_text = get_lang('CantShowResults'); } } - //User Attempts - /* - if (empty($row['max_attempt'])) { - //$item .= Display::tag('td',$num); - } else { - if (empty($num)) { - $num = ''; - } - //$item .= Display::tag('td',$num.' / '.$row['max_attempt']); - }*/ if (empty($num)) { $num = ''; @@ -1058,14 +1018,8 @@ if ($show == 'test') { } $count ++; } - //echo '
'; } - echo ''; - /*} else { - echo '
'; - echo Display::display_warning_message(get_lang('NoExercises')); - echo '
'; - }*/ + echo ''; Display :: display_footer(); exit; } diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 49d8691498..e09cbc0282 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1089,7 +1089,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } } if (api_is_platform_admin() || $is_tutor) { - $html_link.=' '.Display :: return_icon('delete.png', get_lang('Delete')).''; + + $html_link.=' '.Display :: return_icon('delete.png', get_lang('Delete')).''; + $html_link.=' '; } } else { diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 39b4bf6372..844c304ef9 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -1834,39 +1834,42 @@ function api_is_course_tutor() { * @return boolean True if current user is a course or session coach */ function api_is_coach($session_id = 0, $course_code = '') { - global $_user; - global $sessionIsCoach; - if (!empty($session_id)) { $session_id = intval($session_id); } else { $session_id = api_get_session_id(); - } + } if (!empty($course_code)) { $course_code = Database::escape_string($course_code); } else { $course_code = api_get_course_id(); } - - $sql = "SELECT DISTINCT id, name, date_start, date_end - FROM session - INNER JOIN session_rel_course_rel_user session_rc_ru - ON session_rc_ru.id_user = '".Database::escape_string($_user['user_id'])."' - WHERE session_rc_ru.course_code = '$course_code' AND session_rc_ru.status = 2 AND session_rc_ru.id_session = '$session_id' - ORDER BY date_start, date_end, name"; - - $result = Database::query($sql); - $sessionIsCoach = Database::store_result($result); - - $sql = "SELECT DISTINCT id, name, date_start, date_end - FROM session - WHERE session.id_coach = '".Database::escape_string($_user['user_id'])."' - AND id = '$session_id' - ORDER BY date_start, date_end, name"; - - $result = Database::query($sql); - $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result)); + + if (!empty($course_code)) { + $sql = "SELECT DISTINCT id, name, date_start, date_end + FROM session INNER JOIN session_rel_course_rel_user session_rc_ru + ON session_rc_ru.id_user = '".api_get_user_id()."' + WHERE session_rc_ru.course_code = '$course_code' AND session_rc_ru.status = 2 AND session_rc_ru.id_session = '$session_id' + ORDER BY date_start, date_end, name"; + + $result = Database::query($sql); + $sessionIsCoach = Database::store_result($result); + } + + if (!empty($session_id)) { + $sql = "SELECT DISTINCT id, name, date_start, date_end + FROM session + WHERE session.id_coach = '".api_get_user_id()."' AND id = '$session_id' + ORDER BY date_start, date_end, name"; + + $result = Database::query($sql); + if (!empty($sessionIsCoach)) { + $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result)); + } else { + $sessionIsCoach = Database::store_result($result); + } + } return (count($sessionIsCoach) > 0); } diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 3e7a86e8b7..2224b68c47 100755 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -104,7 +104,7 @@ function rsort_sessions($a, $b) { /* * MAIN CODE */ -$is_coach = api_is_coach(); +$is_coach = api_is_coach($_GET['session_id']); $is_platform_admin = api_is_platform_admin(); $is_drh = api_is_drh(); $is_session_admin = api_is_session_admin(); @@ -146,12 +146,12 @@ if (api_is_allowed_to_create_course()) { if (!$is_coach && !$is_platform_admin) { $view = 'teacher'; } - + if ($view == 'teacher' && empty($session_id)) { $menu_items[] = get_lang('TeacherInterface'); if ($nb_teacher_courses) { - $title = get_lang('YourCourseList'); + $title = get_lang('Courses'); } } else { @@ -213,11 +213,10 @@ if ($nb_teacher_courses > 0 ) { if (!empty($session_id)) { echo ''.Display::return_icon('back.png', get_lang('Back'),'','32').''; - } - echo Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',32),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); - - - //echo Display::url(Display::return_icon('printer.png', get_lang('Print'),'',32),"javascript: void(0);", array('onclick'=>'window.print();')); + } else { + echo Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',32),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); + } + echo ''. Display::return_icon('printer.png', get_lang('Print'),'','32').''; if (empty($session_id)) { @@ -229,8 +228,6 @@ if ($nb_teacher_courses > 0 ) { } } } - } else { - // } echo '
'; @@ -238,7 +235,6 @@ if ($nb_teacher_courses > 0 ) { echo ''; - //Display::display_warning_message(get_lang('HaveNoCourse')); } echo Display::tag('h2', $title);