adding some strings
[moodle-linuxchix.git] / grade / report / outcomes / site.php
bloba098b6e7d30badf4457a63c544f42e17b398c3cf
1 <?php
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');
10 // setting up params
11 $courseid = optional_param('id', SITEID, PARAM_INT); // course id
12 require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYSTEM));
13 /// check capability
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);
19 $perpage = 30;
21 // form processing
22 if ($deleteid && confirm_sesskey()) {
23 require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM));
24 if ($confirm) {
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);
29 } else {
30 $strgrades = get_string('grades');
31 $stroutcomes = get_string('outcomes', 'grades');
32 $navlinks = array();
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);
38 /// Print header
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.'&amp;confirm=1&amp;sesskey='.sesskey(),
44 'site.php');
45 print_footer();
46 exit;
50 /// display information
51 admin_externalpage_setup('gradereportoutcomes');
52 admin_externalpage_print_header();
54 // Add tabs
55 $currenttab = 'siteoutcomes';
56 include('tabs.php');
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'),
66 get_string('scale'),
67 get_string('course'),
68 '',
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');
80 $table->setup();
82 while ($outcome = rs_fetch_next_record($outcomes)) {
83 $data = array();
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;
92 // get course
93 if ($outcome->courseid) {
94 $course = get_record('course', 'id', $outcome->courseid);
95 $data[] = $course->shortname;
96 } else {
97 $data[] = get_string('site');
100 // add operations
101 if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM))) {
103 $data[] = '<a href="editoutcomes.php?id='.$outcome->id.'&amp;sesskey='.sesskey().'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
104 <a href="site.php?deleteid='.$outcome->id.'&amp;sesskey='.sesskey().'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/delete.gif"/></a>'; // icons and links
106 } else {
107 $data[] = '';
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();