2 /*********************************
3 * Global outcomes editting page *
4 *********************************/
6 include_once('../../../config.php');
7 require_once($CFG->libdir
.'/adminlib.php');
8 require_once($CFG->libdir
.'/tablelib.php');
11 $courseid = optional_param('id', SITEID
, PARAM_INT
); // course id
12 require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYSTEM
));
15 $page = optional_param('page', 0, PARAM_INT
); // current page
16 $search = optional_param('search', 0, PARAM_TEXT
);
17 $deleteid = optional_param('deleteid', 0, PARAM_INT
); // which outcome to delete
18 $confirm = optional_param('confirm', 0, PARAM_INT
);
22 if ($deleteid && confirm_sesskey()) {
23 require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM
));
25 // delete all outcomes used in courses
26 // delete all outcomes used in grade items
27 delete_records('grade_outcomes_courses', 'outcomeid', $deleteid);
28 delete_records('grade_outcomes', 'id', $deleteid);
30 $strgrades = get_string('grades');
31 $stroutcomes = get_string('outcomes', 'grades');
33 $navlinks[] = array('name' => $strgrades, 'link' => $CFG->wwwroot
. '/grade/index.php?id='.$courseid, 'type' => 'misc');
34 $navlinks[] = array('name' => $stroutcomes, 'link' => '', 'type' => 'misc');
36 $navigation = build_navigation($navlinks);
39 print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
40 // prints confirmation
41 $strdeleteoutcomecheck = get_string('deleteoutcomecheck', 'grades');
42 notice_yesno($strdeleteoutcomecheck,
43 'site.php?deleteid='.$deleteid.'&confirm=1&sesskey='.sesskey(),
50 /// display information
51 admin_externalpage_setup('gradereportoutcomes');
52 admin_externalpage_print_header();
55 $currenttab = 'siteoutcomes';
58 $totalcount = count_records('grade_outcomes');
59 $baseurl = "site.php";
60 print_paging_bar($totalcount, $page, $perpage, $baseurl);
62 if ($outcomes = get_recordset('grade_outcomes', '', '', '', '*', $page * $perpage, $perpage)) {
64 $tablecolumns = array('outcome', 'scale', 'course', 'edit', 'usedgradeitems', 'usedcourses');
65 $tableheaders = array(get_string('outcomes', 'grades'),
69 get_string('activities'),
70 get_string('courses'));
72 $table = new flexible_table('outcomes');
73 $table->define_columns($tablecolumns);
74 $table->define_headers($tableheaders);
75 $table->define_baseurl($baseurl);
76 $table->set_attribute('cellspacing', '0');
77 $table->set_attribute('id', 'user-grade');
78 $table->set_attribute('class', 'boxaligncenter generaltable');
82 while ($outcome = rs_fetch_next_record($outcomes)) {
85 // full name of the outcome
86 $data[] = $outcome->fullname
;
88 // full name of the scale used by this outcomes
89 $scale= get_record('scale', 'id', $outcome->scaleid
);
90 $data[] = $scale->name
;
93 if ($outcome->courseid
) {
94 $course = get_record('course', 'id', $outcome->courseid
);
95 $data[] = $course->shortname
;
97 $data[] = get_string('site');
101 if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM
))) {
103 $data[] = '<a href="editoutcomes.php?id='.$outcome->id
.'&sesskey='.sesskey().'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot
.'/pix/t/edit.gif"/></a>
104 <a href="site.php?deleteid='.$outcome->id
.'&sesskey='.sesskey().'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot
.'/pix/t/delete.gif"/></a>'; // icons and links
109 // num of gradeitems using this
110 $num = count_records('grade_items', 'outcomeid' ,$outcome->id
);
111 $data[] = (int) $num;
113 // num of courses using this outcome
114 $num = count_records('grade_outcomes_courses', 'outcomeid', $outcome->id
);
115 $data[] = (int) $num;
117 $table->add_data($data);
120 $table->print_html();
122 if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM
))) {
123 echo '<a href="editoutcomes.php">'.get_string('addoutcome', 'gradereport_outcomes').'</a>';
125 // print the footer, end of page
126 admin_externalpage_print_footer();