|
| 1 | +<?php |
| 2 | + |
| 3 | +/* For licensing terms, see /license.txt */ |
| 4 | + |
| 5 | +$cidReset = true; |
| 6 | +require_once __DIR__.'/../inc/global.inc.php'; |
| 7 | + |
| 8 | +if (api_get_configuration_value('show_all_my_gradebooks_page') !== true) { |
| 9 | + api_not_allowed(true); |
| 10 | +} |
| 11 | + |
| 12 | +// Setting the tabs |
| 13 | +$this_section = SECTION_COURSES; |
| 14 | + |
| 15 | +$htmlHeadXtra[] = '<script> |
| 16 | +var show_icon = "'.Display::returnIconPath('view_more_stats.gif').'"; |
| 17 | +var hide_icon = "'.Display::returnIconPath('view_less_stats.gif').'"; |
| 18 | +
|
| 19 | +$(function() { |
| 20 | + $("body").on("click", ".view_children", function() { |
| 21 | + var id = $(this).attr("data-cat-id"); |
| 22 | + $(".hidden_"+id).removeClass("hidden"); |
| 23 | + $(this).removeClass("view_children"); |
| 24 | + $(this).find("img").attr("src", hide_icon); |
| 25 | + $(this).attr("class", "hide_children"); |
| 26 | + }); |
| 27 | +
|
| 28 | + $("body").on("click", ".hide_children", function(event) { |
| 29 | + var id = $(this).attr("data-cat-id"); |
| 30 | + $(".hidden_"+id).addClass("hidden"); |
| 31 | + $(this).removeClass("hide_children"); |
| 32 | + $(this).addClass("view_children"); |
| 33 | + $(this).find("img").attr("src", show_icon); |
| 34 | + }); |
| 35 | +
|
| 36 | + for (i=0;i<$(".actions").length;i++) { |
| 37 | + if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null || $(".actions:eq("+i+")").html().split("<TBODY></TBODY>").length==2) { |
| 38 | + $(".actions:eq("+i+")").hide(); |
| 39 | + } |
| 40 | + } |
| 41 | +}); |
| 42 | +</script>'; |
| 43 | + |
| 44 | +Display::display_header(get_lang('GlobalGradebook')); |
| 45 | + |
| 46 | +api_block_anonymous_users(); |
| 47 | + |
| 48 | +$user_id = api_get_user_id(); |
| 49 | +$userCoursesList = CourseManager::get_courses_list_by_user_id ($user_id, true, false, false, [], true, true); |
| 50 | + |
| 51 | +foreach ($userCoursesList as $course) { |
| 52 | + $course_code = $course['code']; |
| 53 | + $stud_id = $user_id; |
| 54 | + $session_id = $course['session_id']; |
| 55 | + $course_id = $course['real_id']; |
| 56 | + $courseInfo = api_get_course_info($course_code); |
| 57 | + |
| 58 | + if (!empty($course['session_name'])) { |
| 59 | + $title = "<h2>" . $courseInfo['title'] . " (" . $course['session_name'] . ")</h2>"; |
| 60 | + } else { |
| 61 | + $title = "<h2>" . $courseInfo['title'] . "</h2>"; |
| 62 | + } |
| 63 | + |
| 64 | + $cats = Category::load( |
| 65 | + null, |
| 66 | + null, |
| 67 | + $course_code, |
| 68 | + null, |
| 69 | + null, |
| 70 | + $session_id, |
| 71 | + false |
| 72 | + ); |
| 73 | + |
| 74 | +$showTitle = true; |
| 75 | + foreach ($cats as $cat) { |
| 76 | + $allcat = $cat->get_subcategories($stud_id, $course_code, $session_id); |
| 77 | + $alleval = $cat->get_evaluations($stud_id, false, $course_code, $session_id); |
| 78 | + $alllink = $cat->get_links($stud_id, true, $course_code, $session_id); |
| 79 | + |
| 80 | + if ($cat->get_parent_id() != 0) { |
| 81 | + $i++; |
| 82 | + } else { |
| 83 | + if (empty($allcat) && empty($alleval) && empty($alllink)) { |
| 84 | + continue; |
| 85 | + } |
| 86 | + if ($showTitle) { |
| 87 | + echo $title; |
| 88 | + $showTitle = false; |
| 89 | + } |
| 90 | + // This is the father |
| 91 | + // Create gradebook/add gradebook links. |
| 92 | + DisplayGradebook::header( |
| 93 | + $cat, |
| 94 | + 0, |
| 95 | + $cat->get_id(), |
| 96 | + false, |
| 97 | + false, |
| 98 | + null, |
| 99 | + false, |
| 100 | + false, |
| 101 | + [] |
| 102 | + ); |
| 103 | + |
| 104 | + $gradebookTable = new GradebookTable( |
| 105 | + $cat, |
| 106 | + $allcat, |
| 107 | + $alleval, |
| 108 | + $alllink, |
| 109 | + null, |
| 110 | + false, |
| 111 | + null, |
| 112 | + api_get_user_id(), |
| 113 | + [], |
| 114 | + [] |
| 115 | + ); |
| 116 | + |
| 117 | + $table = ''; |
| 118 | + $table = $gradebookTable->return_table(); |
| 119 | + echo $table; |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | + |
0 commit comments