| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php //$Id: index.php,v 1.11.2.3 2008/05/29 17:25:30 mudrd8mz Exp $ 2 3 /////////////////////////////////////////////////////////////////////////// 4 // // 5 // NOTICE OF COPYRIGHT // 6 // // 7 // Moodle - Modular Object-Oriented Dynamic Learning Environment // 8 // http://moodle.com // 9 // // 10 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // 11 // // 12 // This program is free software; you can redistribute it and/or modify // 13 // it under the terms of the GNU General Public License as published by // 14 // the Free Software Foundation; either version 2 of the License, or // 15 // (at your option) any later version. // 16 // // 17 // This program is distributed in the hope that it will be useful, // 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 20 // GNU General Public License for more details: // 21 // // 22 // http://www.gnu.org/copyleft/gpl.html // 23 // // 24 /////////////////////////////////////////////////////////////////////////// 25 26 include_once('../../../config.php'); 27 require_once($CFG->libdir . '/gradelib.php'); 28 require_once $CFG->dirroot.'/grade/lib.php'; 29 30 $courseid = required_param('id', PARAM_INT); // course id 31 32 if (!$course = get_record('course', 'id', $courseid)) { 33 print_error('nocourseid'); 34 } 35 36 require_login($course->id); 37 $context = get_context_instance(CONTEXT_COURSE, $course->id); 38 39 require_capability('gradereport/outcomes:view', $context); 40 41 // Build navigation 42 $strgrades = get_string('grades'); 43 $stroutcomes = get_string('outcomes', 'grades'); 44 45 $navigation = grade_build_nav(__FILE__, $stroutcomes, $course->id); 46 47 /// Print header 48 print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true); 49 print_grade_plugin_selector($courseid, 'report', 'outcomes'); 50 51 //first make sure we have proper final grades 52 grade_regrade_final_grades($courseid); 53 54 // Grab all outcomes used in course 55 $report_info = array(); 56 $outcomes = grade_outcome::fetch_all_available($courseid); 57 58 // Get grade_items that use each outcome 59 foreach ($outcomes as $outcomeid => $outcome) { 60 $report_info[$outcomeid]['items'] = get_records_select('grade_items', "outcomeid = $outcomeid AND courseid = $courseid"); 61 $report_info[$outcomeid]['outcome'] = $outcome; 62 63 // Get average grades for each item 64 if (is_array($report_info[$outcomeid]['items'])) { 65 foreach ($report_info[$outcomeid]['items'] as $itemid => $item) { 66 $sql = "SELECT itemid, AVG(finalgrade) AS avg, COUNT(finalgrade) AS count 67 FROM {$CFG->prefix}grade_grades 68 WHERE itemid = $itemid 69 GROUP BY itemid"; 70 $info = get_records_sql($sql); 71 72 if (!$info) { 73 unset($report_info[$outcomeid]['items'][$itemid]); 74 continue; 75 } else { 76 $info = reset($info); 77 $avg = round($info->avg, 2); 78 $count = $info->count; 79 } 80 81 $report_info[$outcomeid]['items'][$itemid]->avg = $avg; 82 $report_info[$outcomeid]['items'][$itemid]->count = $count; 83 } 84 } 85 } 86 87 $html = '<table class="generaltable boxaligncenter" width="90%" cellspacing="1" cellpadding="5" summary="Outcomes Report">' . "\n"; 88 $html .= '<tr><th class="header c0" scope="col">' . get_string('outcomename', 'grades') . '</th>'; 89 $html .= '<th class="header c1" scope="col">' . get_string('courseavg', 'grades') . '</th>'; 90 $html .= '<th class="header c2" scope="col">' . get_string('sitewide', 'grades') . '</th>'; 91 $html .= '<th class="header c3" scope="col">' . get_string('activities', 'grades') . '</th>'; 92 $html .= '<th class="header c4" scope="col">' . get_string('average', 'grades') . '</th>'; 93 $html .= '<th class="header c5" scope="col">' . get_string('numberofgrades', 'grades') . '</th></tr>' . "\n"; 94 95 $row = 0; 96 foreach ($report_info as $outcomeid => $outcomedata) { 97 $rowspan = count($outcomedata['items']); 98 // If there are no items for this outcome, rowspan will equal 0, which is not good 99 if ($rowspan == 0) { 100 $rowspan = 1; 101 } 102 103 $shortname_html = '<tr class="r' . $row . '"><td class="cell c0" rowspan="' . $rowspan . '">' . $outcomedata['outcome']->shortname . "</td>\n"; 104 105 $sitewide = get_string('no'); 106 if (empty($outcomedata['outcome']->courseid)) { 107 $sitewide = get_string('yes'); 108 } 109 110 $sitewide_html = '<td class="cell c2" rowspan="' . $rowspan . '">' . $sitewide . "</td>\n"; 111 112 $outcomedata['outcome']->sum = 0; 113 $scale = new grade_scale(array('id' => $outcomedata['outcome']->scaleid), false); 114 115 $print_tr = false; 116 $items_html = ''; 117 118 if (!empty($outcomedata['items'])) { 119 foreach ($outcomedata['items'] as $itemid => $item) { 120 if ($print_tr) { 121 $row++; 122 $items_html .= "<tr class=\"r$row\">\n"; 123 } 124 125 $grade_item = new grade_item($item, false); 126 127 if ($item->itemtype == 'mod') { 128 $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid); 129 $itemname = '<a href="'.$CFG->wwwroot.'/mod/'.$item->itemmodule.'/view.php?id='.$cm->id.'">'.$grade_item->get_name().'</a>'; 130 } else { 131 $itemname = $grade_item->get_name(); 132 } 133 134 $outcomedata['outcome']->sum += $item->avg; 135 $gradehtml = $scale->get_nearest_item($item->avg); 136 137 $items_html .= "<td class=\"cell c3\">$itemname</td>" 138 . "<td class=\"cell c4\">$gradehtml ($item->avg)</td>" 139 . "<td class=\"cell c5\">$item->count</td></tr>\n"; 140 $print_tr = true; 141 } 142 } else { 143 $items_html .= "<td class=\"cell c3\"> - </td><td class=\"cell c4\"> - </td><td class=\"cell c5\"> 0 </td></tr>\n"; 144 } 145 146 // Calculate outcome average 147 if (is_array($outcomedata['items'])) { 148 $count = count($outcomedata['items']); 149 if ($count > 0) { 150 $avg = $outcomedata['outcome']->sum / $count; 151 } else { 152 $avg = $outcomedata['outcome']->sum; 153 } 154 $avg_html = $scale->get_nearest_item($avg) . " (" . round($avg, 2) . ")\n"; 155 } else { 156 $avg_html = ' - '; 157 } 158 159 $outcomeavg_html = '<td class="cell c1" rowspan="' . $rowspan . '">' . $avg_html . "</td>\n"; 160 161 $html .= $shortname_html . $outcomeavg_html . $sitewide_html . $items_html; 162 $row++; 163 } 164 165 166 167 $html .= '</table>'; 168 print_heading($stroutcomes); 169 170 echo $html; 171 print_footer($course); 172 173 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |