$mform =& $this->_form;
$mform->addElement('header', 'general', get_string('outcomes'));
-
+
$mform->addElement('text', 'shortname', get_string('shortname'));
$mform->addRule('shortname', get_string('required'), 'required');
$mform->setType('id', PARAM_TEXT);
-
+
$mform->addElement('text', 'fullname', get_string('fullname'));
$mform->addRule('fullname', get_string('required'), 'required');
$mform->setType('id', PARAM_TEXT);
-
+
$scalearr = array();
if ($scales = get_records('scale')) {
foreach ($scales as $scale) {
- $scalearr[$scale->id] = $scale->name;
+ $scalearr[$scale->id] = $scale->name;
}
}
}
$id = optional_param('id', 0, PARAM_INT); // id of the outcome
-if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
+if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
// optional course id, if set, editting from course
} else {
// admin editting site level outcomes
$mform = new edit_outcomes_form();
if ($id) {
- // form set data
- $mform->set_data(get_record('grade_outcomes', 'id', $id));
+ // form set data
+ $mform->set_data(get_record('grade_outcomes', 'id', $id));
}
if ($mform->is_cancelled()) {
- redirect($returnurl);
+ redirect($returnurl);
}
if ($data = $mform->get_data()) {
if ($data->id) {
redirect($returnurl);
}
+// Add tabs
+$currenttab = 'editoutcomes';
+include('tabs.php');
+
print_header();
$mform->display();
print_footer();
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?php //$Id$
+
+include_once('../../../config.php');
+require_once($CFG->libdir . '/gradelib.php');
+
+$courseid = required_param('id'); // course id
+
+if (!$course = get_record('course', 'id', $courseid)) {
+ print_error('nocourseid');
+}
+
+require_login($course->id);
+
+$context = get_context_instance(CONTEXT_COURSE, $course->id);
+
+// Build navigation
+$strgrades = get_string('grades');
+$stroutcomes = get_string('outcomes', 'grades');
+$navlinks = array();
+$navlinks[] = array('name' => $strgrades, 'link' => $CFG->wwwroot . '/grade/index.php?id='.$courseid, 'type' => 'misc');
+$navlinks[] = array('name' => $stroutcomes, 'link' => '', 'type' => 'misc');
+
+$navigation = build_navigation($navlinks);
+
+/// Print header
+print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
+
+// Add tabs
+$currenttab = 'outcomereport';
+include('tabs.php');
+
+// Grab outcomes in use for this course
+$outcomes = grade_outcome::fetch_all(array('courseid' => $courseid));
+foreach ($outcomes as $outcome) {
+ print_object($outcome->get_grade_info($courseid, true, true));
+}
+// Grab activities that are grading against each outcome (with links to activities)
+
+// Compute average grade across all activities and users for each outcome.
+
+
+print_footer($course);
+
+?>
admin_externalpage_print_header();
/******************* ADD TABS HERE LATER ****************************/
+// Add tabs
+$currenttab = 'outcomesettings';
+include('tabs.php');
$totalcount = count_records('grade_outcomes');
$baseurl = "settings.php";
print_paging_bar($totalcount, $page, $perpage, $baseurl);
if ($outcomes = get_recordset('grade_outcomes', '', '', '', '*', $page * $perpage, $perpage)) {
-
+
$tablecolumns = array('outcome', 'edit', 'usedgradeitems', 'usedcourses');
$tableheaders = array(get_string('outcomes'), get_string('operations'), get_string('usedgradeitem'), get_string('usedcourses'));
-
+
$table = new flexible_table('outcomes');
$table->define_columns($tablecolumns);
$table->define_headers($tableheaders);
$table->define_baseurl($baseurl);
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'user-grade');
- $table->set_attribute('class', 'boxaligncenter generaltable');
-
+ $table->set_attribute('class', 'boxaligncenter generaltable');
+
$table->setup();
-
+
foreach ($outcomes as $outcome) {
$data = array();
$data[] = $outcome['fullname'];
-
+
// add operations
$data[] = '<a href="editoutcomes.php?id='.$outcome['id'].'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
<a href="settings.php?deleteid='.$outcome['id'].'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/delete.gif"/></a>'; // icons and links
-
+
// num of gradeitems using this
$num = count_records('grade_outcomes_courses', 'outcomeid' ,$outcome['id']);
$data[] = (int) $num;
-
+
// num of courses using this outcome
$num = count_records('grade_items', 'outcomeid', $outcome['id']);
$data[] = (int) $num;
$table->add_data($data);
}
-
+
$table->print_html();
}
// print the footer, end of page
admin_externalpage_print_footer();
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?php // $Id$
+ $row = $tabs = array();
+ $row[] = new tabobject('outcomereport',
+ $CFG->wwwroot.'/grade/report/outcomes/index.php?id='.$courseid,
+ get_string('outcomereport', 'grades'));
+
+ $row[] = new tabobject('outcomesettings',
+ $CFG->wwwroot.'/grade/report/outcomes/settings.php?id='.$courseid,
+ get_string('settings'));
+
+ $row[] = new tabobject('editoutcomes',
+ $CFG->wwwroot.'/grade/report/outcomes/editoutcomes.php?courseid='.$courseid,
+ get_string('editoutcomes', 'grades'));
+
+ $tabs[] = $row;
+ echo '<div class="outcomedisplay">';
+ print_tabs($tabs, $currenttab);
+ echo '</div>';
+?>
function get_name() {
return $this->shortname;
}
+
+ /**
+ * Computes then returns extra information about this outcome and other objects that are linked to it.
+ * The average of all grades that use this outcome, for all courses (or 1 course if courseid is given) can
+ * be requested, and is returned as a float if requested alone. If the list of items that use this outcome
+ * is also requested, then a single array is returned, which contains the grade_items AND the average grade
+ * if such is still requested (array('items' => array(...), 'avg' => 2.30)). This combining of two
+ * methods into one is to save on DB queries, since both queries are similar and can be performed together.
+ * @param int $courseid An optional courseid to narrow down the average to 1 course only
+ * @param bool $average Whether or not to return the average grade for this outcome
+ * @param bool $items Whether or not to return the list of items using this outcome
+ * @return float
+ */
+ function get_grade_info($courseid=null, $average=true, $items=false) {
+ if (!isset($this->id)) {
+ debugging("You must setup the outcome's id before calling its get_grade_info() method!");
+ return false; // id must be defined for this to work
+ }
+
+ if ($average === false && $items === false) {
+ debugging('Either the 1st or 2nd param of grade_outcome::get_grade_info() must be true, or both, but not both false!');
+ return false;
+ }
+
+ $wheresql = '';
+ if (!is_null($courseid)) {
+ $wheresql = " AND mdl_grade_items.courseid = $courseid ";
+ }
+
+ $selectadd = '';
+ if ($items !== false) {
+ $selectadd = ', mdl_grade_items.* ';
+ }
+
+ $sql = "SELECT finalgrade $selectadd
+ FROM mdl_grade_grades, mdl_grade_items, mdl_grade_outcomes
+ WHERE mdl_grade_outcomes.id = mdl_grade_items.outcomeid
+ AND mdl_grade_items.id = mdl_grade_grades.itemid
+ AND mdl_grade_outcomes.id = $this->id
+ $wheresql";
+
+ $grades = get_records_sql($sql);
+ $retval = array();
+
+ if ($average !== false && count($grades) > 0) {
+ $count = 0;
+ $total = 0;
+
+ foreach ($grades as $k => $grade) {
+ // Skip null finalgrades
+ if (!is_null($grade->finalgrade)) {
+ $total += $grade->finalgrade;
+ $count++;
+ }
+ unset($grades[$k]->finalgrade);
+ }
+
+ $retval['avg'] = $total / $count;
+ }
+
+ if ($items !== false) {
+ foreach ($grades as $grade) {
+ $retval['items'][$grade->id] = new grade_item($grade);
+ }
+ }
+
+ return $retval;
+ }
}
?>