|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00026 require_once '../config.php'; 00027 require_once $CFG->dirroot.'/group/lib.php'; 00028 00029 $courseid = required_param('id', PARAM_INT); 00030 00031 $PAGE->set_url('/group/groupings.php', array('id'=>$courseid)); 00032 00033 if (!$course = $DB->get_record('course', array('id'=>$courseid))) { 00034 print_error('nocourseid'); 00035 } 00036 00037 require_login($course); 00038 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00039 require_capability('moodle/course:managegroups', $context); 00040 00041 $strgrouping = get_string('grouping', 'group'); 00042 $strgroups = get_string('groups'); 00043 $strname = get_string('name'); 00044 $strdelete = get_string('delete'); 00045 $stredit = get_string('edit'); 00046 $srtnewgrouping = get_string('creategrouping', 'group'); 00047 $strgroups = get_string('groups'); 00048 $strgroupings = get_string('groupings', 'group'); 00049 $struses = get_string('activities'); 00050 $strparticipants = get_string('participants'); 00051 $strmanagegrping = get_string('showgroupsingrouping', 'group'); 00052 00053 navigation_node::override_active_url(new moodle_url('/group/index.php', array('id'=>$courseid))); 00054 $PAGE->navbar->add($strgroupings); 00055 00057 $PAGE->set_title($strgroupings); 00058 $PAGE->set_heading($course->fullname); 00059 $PAGE->set_pagelayout('standard'); 00060 echo $OUTPUT->header(); 00061 00062 // Add tabs 00063 $currenttab = 'groupings'; 00064 require('tabs.php'); 00065 00066 echo $OUTPUT->heading($strgroupings); 00067 00068 $data = array(); 00069 if ($groupings = $DB->get_records('groupings', array('courseid'=>$course->id), 'name')) { 00070 foreach($groupings as $grouping) { 00071 $line = array(); 00072 $line[0] = format_string($grouping->name); 00073 00074 if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) { 00075 $groupnames = array(); 00076 foreach ($groups as $group) { 00077 $groupnames[] = format_string($group->name); 00078 } 00079 $line[1] = implode(', ', $groupnames); 00080 } else { 00081 $line[1] = get_string('none'); 00082 } 00083 $line[2] = $DB->count_records('course_modules', array('course'=>$course->id, 'groupingid'=>$grouping->id)); 00084 00085 $buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img". 00086 " src=\"" . $OUTPUT->pix_url('t/edit') . "\" class=\"iconsmall\" alt=\"$stredit\" /></a> "; 00087 $buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&delete=1\"><img". 00088 " src=\"" . $OUTPUT->pix_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a> "; 00089 $buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img". 00090 " src=\"" . $OUTPUT->pix_url('i/group') . "\" class=\"icon\" alt=\"$strmanagegrping\" /></a> "; 00091 00092 $line[3] = $buttons; 00093 $data[] = $line; 00094 } 00095 } 00096 $table = new html_table(); 00097 $table->head = array($strgrouping, $strgroups, $struses, $stredit); 00098 $table->size = array('30%', '50%', '10%', '10%'); 00099 $table->align = array('left', 'left', 'center', 'center'); 00100 $table->width = '90%'; 00101 $table->data = $data; 00102 echo html_writer::table($table); 00103 00104 echo $OUTPUT->container_start('buttons'); 00105 echo $OUTPUT->single_button(new moodle_url('grouping.php', array('courseid'=>$courseid)), $srtnewgrouping); 00106 echo $OUTPUT->container_end(); 00107 00108 echo $OUTPUT->footer();