2007-07-30 22:56:45 +00:00
|
|
|
<?php // $Id$
|
|
|
|
// Allows a creator to edit custom outcomes, and also display help about outcomes
|
|
|
|
|
|
|
|
require_once '../../../config.php';
|
|
|
|
require_once $CFG->dirroot.'/grade/lib.php';
|
|
|
|
require_once $CFG->libdir.'/gradelib.php';
|
|
|
|
|
|
|
|
$courseid = optional_param('id', 0, PARAM_INT);
|
|
|
|
$action = optional_param('action', '', PARAM_ALPHA);
|
|
|
|
|
|
|
|
/// Make sure they can even access this course
|
|
|
|
if ($courseid) {
|
|
|
|
if (!$course = get_record('course', 'id', $courseid)) {
|
|
|
|
print_error('nocourseid');
|
|
|
|
}
|
|
|
|
require_login($course);
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
require_capability('moodle/grade:manage', $context);
|
|
|
|
|
2007-08-01 04:34:08 +00:00
|
|
|
if (empty($CFG->enableoutcomes)) {
|
|
|
|
redirect('../../index.php?id='.$courseid);
|
|
|
|
}
|
|
|
|
|
2007-07-30 22:56:45 +00:00
|
|
|
} else {
|
|
|
|
require_once $CFG->libdir.'/adminlib.php';
|
|
|
|
admin_externalpage_setup('outcomes');
|
|
|
|
}
|
|
|
|
|
|
|
|
/// return tracking object
|
|
|
|
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'outcome', 'courseid'=>$courseid));
|
|
|
|
|
|
|
|
|
|
|
|
$strgrades = get_string('grades');
|
|
|
|
$pagename = get_string('outcomes', 'grades');
|
|
|
|
|
|
|
|
$navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
|
|
|
array('name'=>$pagename, 'link'=>'', 'type'=>'misc'));
|
|
|
|
$navigation = build_navigation($navlinks);
|
|
|
|
|
|
|
|
$strshortname = get_string('shortname');
|
|
|
|
$strfullname = get_string('fullname');
|
|
|
|
$strscale = get_string('scale');
|
|
|
|
$strstandardoutcome = get_string('outcomesstandard', 'grades');
|
|
|
|
$strcustomoutcomes = get_string('outcomescustom', 'grades');
|
|
|
|
$strdelete = get_string('delete');
|
|
|
|
$stredit = get_string('edit');
|
|
|
|
$srtcreatenewoutcome = get_string('outcomecreate', 'grades');
|
2007-07-31 12:03:45 +00:00
|
|
|
$stritems = get_string('items', 'grades');
|
|
|
|
$strcourses = get_string('courses');
|
2007-07-30 22:56:45 +00:00
|
|
|
$stredit = get_string('edit');
|
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
case 'delete':
|
|
|
|
if (!confirm_sesskey()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$outcomeid = required_param('outcomeid', PARAM_INT);
|
|
|
|
if (!$outcome = grade_outcome::fetch(array('id'=>$outcomeid))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($outcome->courseid)) {
|
|
|
|
require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
|
|
|
|
} else if ($outcome->courseid != $courseid) {
|
|
|
|
error('Incorrect courseid!');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$outcome->can_delete()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: add confirmation
|
|
|
|
$outcome->delete();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-31 09:15:39 +00:00
|
|
|
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
|
|
|
$caneditsystemscales = has_capability('moodle/course:managescales', $systemcontext);
|
|
|
|
|
2007-07-30 22:56:45 +00:00
|
|
|
if ($courseid) {
|
|
|
|
/// Print header
|
|
|
|
print_header_simple($strgrades.': '.$pagename, ': '.$strgrades, $navigation, '', '', true, '', navmenu($course));
|
|
|
|
/// Print the plugin selector at the top
|
|
|
|
print_grade_plugin_selector($courseid, 'edit', 'outcome');
|
|
|
|
|
2007-07-31 09:15:39 +00:00
|
|
|
$caneditcoursescales = has_capability('moodle/course:managescales', $context);
|
|
|
|
|
2007-07-31 09:10:35 +00:00
|
|
|
$currenttab = 'outcomes';
|
|
|
|
require('tabs.php');
|
|
|
|
|
2007-07-30 22:56:45 +00:00
|
|
|
} else {
|
|
|
|
admin_externalpage_print_header();
|
2007-07-31 09:15:39 +00:00
|
|
|
|
|
|
|
$caneditcoursescales = $caneditsystemscales;
|
2007-07-30 22:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-31 09:15:39 +00:00
|
|
|
|
2007-07-30 22:56:45 +00:00
|
|
|
if ($courseid and $outcomes = grade_outcome::fetch_all_local($courseid)) {
|
2007-07-31 09:15:39 +00:00
|
|
|
|
2007-07-30 22:56:45 +00:00
|
|
|
print_heading($strcustomoutcomes);
|
|
|
|
$data = array();
|
|
|
|
foreach($outcomes as $outcome) {
|
|
|
|
$line = array();
|
|
|
|
$line[] = $outcome->get_name();
|
|
|
|
$line[] = $outcome->get_shortname();
|
|
|
|
|
|
|
|
$scale = $outcome->load_scale();
|
2007-07-31 09:15:39 +00:00
|
|
|
if (empty($scale->id)) { // hopefully never happens
|
|
|
|
$line[] = $scale->get_name();
|
|
|
|
} else {
|
|
|
|
if (empty($scale->courseid)) {
|
|
|
|
$caneditthisscale = $caneditsystemscales;
|
|
|
|
} else if ($scale->courseid == $courseid) {
|
|
|
|
$caneditthisscale = $caneditcoursescales;
|
|
|
|
} else {
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
|
|
|
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
|
|
|
}
|
|
|
|
if ($caneditthisscale) {
|
2007-07-31 10:57:05 +00:00
|
|
|
$url = $CFG->wwwroot.'/grade/edit/scale/edit.php?courseid='.$courseid.'&id='.$scale->id;
|
|
|
|
$url = $gpr->add_url_params($url);
|
|
|
|
$line[] = '<a href="'.$url.'">'.$scale->get_name().'</a>';
|
2007-07-31 09:15:39 +00:00
|
|
|
} else {
|
|
|
|
$line[] = $scale->get_name();
|
|
|
|
}
|
|
|
|
}
|
2007-07-30 22:56:45 +00:00
|
|
|
|
2007-07-31 12:03:45 +00:00
|
|
|
$line[] = $outcome->get_item_uses_count();
|
2007-07-30 22:56:45 +00:00
|
|
|
|
|
|
|
$buttons = "";
|
|
|
|
$buttons .= "<a title=\"$stredit\" href=\"edit.php?courseid=$courseid&id=$outcome->id\"><img".
|
|
|
|
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
|
2007-07-31 12:03:45 +00:00
|
|
|
if ($outcome->can_delete()) {
|
2007-07-30 22:56:45 +00:00
|
|
|
$buttons .= "<a title=\"$strdelete\" href=\"index.php?id=$courseid&outcomeid=$outcome->id&action=delete&sesskey=$USER->sesskey\"><img".
|
|
|
|
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
|
|
|
|
}
|
|
|
|
$line[] = $buttons;
|
|
|
|
$data[] = $line;
|
|
|
|
}
|
|
|
|
$table = new object();
|
2007-07-31 12:03:45 +00:00
|
|
|
$table->head = array($strfullname, $strshortname, $strscale, $stritems, $stredit);
|
2007-07-30 22:56:45 +00:00
|
|
|
$table->size = array('30%', '20%', '20%', '20%', '10%');
|
|
|
|
$table->align = array('left', 'left', 'left', 'center', 'center');
|
|
|
|
$table->width = '90%';
|
|
|
|
$table->data = $data;
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($outcomes = grade_outcome::fetch_all_global()) {
|
|
|
|
print_heading($strstandardoutcome);
|
|
|
|
$data = array();
|
|
|
|
foreach($outcomes as $outcome) {
|
|
|
|
$line = array();
|
|
|
|
$line[] = $outcome->get_name();
|
|
|
|
$line[] = $outcome->get_shortname();
|
|
|
|
|
|
|
|
$scale = $outcome->load_scale();
|
2007-07-31 09:15:39 +00:00
|
|
|
if (empty($scale->id)) { // hopefully never happens
|
|
|
|
$line[] = $scale->get_name();
|
|
|
|
} else {
|
|
|
|
if (empty($scale->courseid)) {
|
|
|
|
$caneditthisscale = $caneditsystemscales;
|
|
|
|
} else if ($scale->courseid == $courseid) {
|
|
|
|
$caneditthisscale = $caneditcoursescales;
|
|
|
|
} else {
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
|
|
|
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
|
|
|
}
|
|
|
|
if ($caneditthisscale) {
|
2007-07-31 11:01:10 +00:00
|
|
|
$url = $CFG->wwwroot.'/grade/edit/scale/edit.php?courseid='.$courseid.'&id='.$scale->id;
|
|
|
|
$url = $gpr->add_url_params($url);
|
|
|
|
$line[] = '<a href="'.$url.'">'.$scale->get_name().'</a>';
|
2007-07-31 09:15:39 +00:00
|
|
|
} else {
|
|
|
|
$line[] = $scale->get_name();
|
|
|
|
}
|
|
|
|
}
|
2007-07-30 22:56:45 +00:00
|
|
|
|
2007-07-31 12:03:45 +00:00
|
|
|
$line[] = $outcome->get_course_uses_count();
|
|
|
|
$line[] = $outcome->get_item_uses_count();
|
2007-07-30 22:56:45 +00:00
|
|
|
|
|
|
|
$buttons = "";
|
|
|
|
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
|
|
|
$buttons .= "<a title=\"$stredit\" href=\"edit.php?courseid=$courseid&id=$outcome->id\"><img".
|
|
|
|
" src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
|
|
|
|
}
|
2007-07-31 12:03:45 +00:00
|
|
|
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM)) and $outcome->can_delete()) {
|
2007-07-30 22:56:45 +00:00
|
|
|
$buttons .= "<a title=\"$strdelete\" href=\"index.php?id=$courseid&outcomeid=$outcome->id&action=delete&sesskey=$USER->sesskey\"><img".
|
|
|
|
" src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
|
|
|
|
}
|
|
|
|
$line[] = $buttons;
|
|
|
|
$data[] = $line;
|
|
|
|
}
|
|
|
|
$table = new object();
|
2007-07-31 12:03:45 +00:00
|
|
|
$table->head = array($strfullname, $strshortname, $strscale, $strcourses, $stritems, $stredit);
|
|
|
|
$table->size = array('30%', '20%', '20%', '10%', '10%', '10%');
|
|
|
|
$table->align = array('left', 'left', 'left', 'center', 'center', 'center');
|
2007-07-30 22:56:45 +00:00
|
|
|
$table->width = '90%';
|
|
|
|
$table->data = $data;
|
|
|
|
print_table($table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo '<div class="buttons">';
|
|
|
|
print_single_button('edit.php', array('courseid'=>$courseid), $srtcreatenewoutcome);
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
if ($courseid) {
|
|
|
|
print_footer($course);
|
|
|
|
} else {
|
|
|
|
admin_externalpage_print_footer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|