mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-10544 basic UI for outcome item adding/editing implemented - todo: calculation support, lang strings, bugfixing...
whitespace cleanup
This commit is contained in:
parent
4faf5f99be
commit
f10fac9669
@ -12,9 +12,8 @@ if (!$course = get_record('course', 'id', $courseid)) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
//require_capability() here!!
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
|
@ -13,9 +13,8 @@ if (!$course = get_record('course', 'id', $courseid)) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
//require_capability() here!!
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
|
@ -17,7 +17,7 @@ if (!$course = get_record('course', 'id', $courseid)) {
|
||||
// TODO: add proper check that grade is editable
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('gradereport/grader:manage', $context);
|
||||
require_capability('moodle/grade:override', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
|
@ -13,9 +13,8 @@ if (!$course = get_record('course', 'id', $courseid)) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
//require_capability() here!!
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
@ -28,6 +27,12 @@ if ($mform->is_cancelled()) {
|
||||
}
|
||||
|
||||
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
||||
// redirect if outcomeid present
|
||||
if (!empty($item->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
|
||||
// Get Item preferences
|
||||
$item->pref_gradedisplaytype = grade_report::get_pref('gradedisplaytype', $id);
|
||||
$item->pref_decimalpoints = grade_report::get_pref('decimalpoints', $id);
|
||||
@ -41,7 +46,7 @@ if ($data = $mform->get_data()) {
|
||||
$data->calculation = grade_item::normalize_formula($data->calculation, $course->id);
|
||||
}
|
||||
|
||||
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$course->id));
|
||||
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
|
||||
grade_item::set_properties($grade_item, $data);
|
||||
|
||||
if (empty($grade_item->id)) {
|
||||
|
@ -15,17 +15,6 @@ class edit_item_form extends moodleform {
|
||||
$mform->addElement('text', 'iteminfo', get_string('iteminfo', 'grades'));
|
||||
$mform->addElement('text', 'idnumber', get_string('idnumber'));
|
||||
|
||||
// allow setting of outcomes on module items too
|
||||
$options = array(0=>get_string('usenooutcome', 'grades'));
|
||||
|
||||
if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$COURSE->id), true)) {
|
||||
foreach ($outcomes as $outcome) {
|
||||
$options[$outcome->id] = $outcome->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'outcomeid', get_string('outcome', 'grades'), $options);
|
||||
|
||||
$options = array(GRADE_TYPE_NONE=>get_string('typenone', 'grades'),
|
||||
GRADE_TYPE_VALUE=>get_string('typevalue', 'grades'),
|
||||
GRADE_TYPE_SCALE=>get_string('typescale', 'grades'),
|
||||
|
130
grade/edit/outcomeitem.php
Normal file
130
grade/edit/outcomeitem.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once '../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php';
|
||||
require_once 'outcomeitem_form.php';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
|
||||
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);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
$returnurl = $gpr->get_return_url('tree.php?id='.$course->id);
|
||||
|
||||
$mform = new edit_outcomeitem_form(null, array('gpr'=>$gpr));
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
||||
// redirect if outcomeid present
|
||||
if (empty($item->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcome.php?id='.$id.'&courseid='.$courseid;
|
||||
redirect($gpr->add_url_params($url));
|
||||
}
|
||||
|
||||
// $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
|
||||
|
||||
if ($item->itemtype == 'mod') {
|
||||
$cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid);
|
||||
$item->cmid = $cm->id;
|
||||
} else {
|
||||
$item->cmid = 0;
|
||||
}
|
||||
|
||||
$mform->set_data($item);
|
||||
}
|
||||
|
||||
if ($data = $mform->get_data(false)) {
|
||||
if (array_key_exists('calculation', $data)) {
|
||||
// $data->calculation = grade_item::normalize_formula($data->calculation, $course->id);
|
||||
}
|
||||
|
||||
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
|
||||
grade_item::set_properties($grade_item, $data);
|
||||
|
||||
// fix activity links
|
||||
if (empty($data->cmid)) {
|
||||
// manual item
|
||||
$grade_item->itemtype = 'manual';
|
||||
$grade_item->itemmodule = null;
|
||||
$grade_item->iteminstance = null;
|
||||
$grade_item->itemnumber = 0;
|
||||
|
||||
} else {
|
||||
$module = get_record_sql("SELECT cm.*, m.name as modname
|
||||
FROM {$CFG->prefix}modules m, {$CFG->prefix}course_modules cm
|
||||
WHERE cm.id = {$data->cmid} AND cm.module = m.id ");
|
||||
$grade_item->itemtype = 'mod';
|
||||
$grade_item->itemmodule = $module->modname;
|
||||
$grade_item->iteminstance = $module->instance;
|
||||
|
||||
if ($items = grade_item::fetch_all(array('itemtype'=>'mod', 'itemmodule'=>$grade_item->itemmodule,
|
||||
'iteminstance'=>$grade_item->iteminstance, 'courseid'=>$COURSE->id))) {
|
||||
if (!empty($grade_item->id) and in_array($grade_item, $items)) {
|
||||
//no change needed
|
||||
} else {
|
||||
$max = 999;
|
||||
foreach($items as $item) {
|
||||
if (empty($item->outcomeid)) {
|
||||
continue;
|
||||
}
|
||||
if ($item->itemnumber > $max) {
|
||||
$max = $item->itemnumber;
|
||||
}
|
||||
}
|
||||
$grade_item->itemnumber = $max + 1;
|
||||
}
|
||||
} else {
|
||||
$grade_item->itemnumber = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
// fix scale used
|
||||
$outcome = grade_outcome::fetch(array('id'=>$data->outcomeid));
|
||||
$grade_item->gradetype = GRADE_TYPE_SCALE;
|
||||
$grade_item->scaleid = $outcome->scaleid; //TODO: we might recalculate existing outcome grades when changing scale
|
||||
|
||||
if (empty($grade_item->id)) {
|
||||
$grade_item->insert();
|
||||
// move next to activity if adding linked outcome
|
||||
if ($grade_item->itemtype == 'mod') {
|
||||
if ($item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$grade_item->itemmodule,
|
||||
'iteminstance'=>$grade_item->iteminstance, 'itemnumber'=>0, 'courseid'=>$COURSE->id))) {
|
||||
$grade_item->set_parent($item->categoryid);
|
||||
$grade_item->move_after_sortorder($item->sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$grade_item->update();
|
||||
}
|
||||
|
||||
redirect($returnurl, 'temporary debug delay', 5);
|
||||
}
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$strgraderreport = get_string('graderreport', 'grades');
|
||||
$stroutcomesedit = get_string('outcomeitemsedit', 'grades');
|
||||
|
||||
$nav = array(array('name'=>$strgrades,'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
|
||||
array('name'=>$stroutcomesedit, 'link'=>'', 'type'=>'misc'));
|
||||
|
||||
$navigation = build_navigation($nav);
|
||||
|
||||
|
||||
print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $stroutcomesedit, $navigation, '', '', true, '', navmenu($course));
|
||||
|
||||
$mform->display();
|
||||
|
||||
print_footer($course);
|
115
grade/edit/outcomeitem_form.php
Normal file
115
grade/edit/outcomeitem_form.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class edit_outcomeitem_form extends moodleform {
|
||||
function definition() {
|
||||
global $COURSE, $CFG;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
/// visible elements
|
||||
$mform->addElement('header', 'general', get_string('gradeoutcomeitem', 'grades'));
|
||||
|
||||
$mform->addElement('text', 'itemname', get_string('itemname', 'grades'));
|
||||
$mform->addRule('itemname', get_string('required'), 'required', null, 'client');
|
||||
|
||||
$mform->addElement('text', 'iteminfo', get_string('iteminfo', 'grades'));
|
||||
|
||||
$mform->addElement('text', 'idnumber', get_string('idnumber'));
|
||||
|
||||
// allow setting of outcomes on module items too
|
||||
$options = array();
|
||||
if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$COURSE->id), true)) {
|
||||
foreach ($outcomes as $outcome) {
|
||||
$options[$outcome->id] = $outcome->get_name();
|
||||
}
|
||||
}
|
||||
$mform->addElement('select', 'outcomeid', get_string('outcome', 'grades'), $options);
|
||||
|
||||
$options = array(0=>get_string('none'));
|
||||
if ($coursemods = get_course_mods($COURSE->id)) {
|
||||
foreach ($coursemods as $coursemod) {
|
||||
$mod = get_coursemodule_from_id($coursemod->modname, $coursemod->id);
|
||||
$options[$coursemod->id] = format_string($mod->name);
|
||||
}
|
||||
}
|
||||
$mform->addElement('select', 'cmid', get_string('linkedactivity', 'grades'), $options);
|
||||
$mform->setDefault('cmid', 0);
|
||||
|
||||
|
||||
// $mform->addElement('text', 'calculation', get_string('calculation', 'grades'));
|
||||
|
||||
$mform->addElement('text', 'aggregationcoef', get_string('aggregationcoef', 'grades'));
|
||||
$mform->setDefault('aggregationcoef', 0.0);
|
||||
|
||||
$mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
|
||||
|
||||
$mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional'=>true));
|
||||
|
||||
/// hidden params
|
||||
$mform->addElement('hidden', 'id', 0);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'courseid', $COURSE->id);
|
||||
$mform->setType('courseid', PARAM_INT);
|
||||
|
||||
/// add return tracking info
|
||||
$gpr = $this->_customdata['gpr'];
|
||||
$gpr->add_mform_elements($mform);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// buttons
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
|
||||
/// tweak the form - depending on existing data
|
||||
function definition_after_data() {
|
||||
global $CFG, $COURSE;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if ($id = $mform->getElementValue('id')) {
|
||||
$grade_item = grade_item::fetch(array('id'=>$id));
|
||||
|
||||
//remove the aggregation coef element if not needed
|
||||
if ($grade_item->is_course_item()) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
|
||||
} else if ($grade_item->is_category_item()) {
|
||||
$category = $grade_item->get_item_category();
|
||||
$parent_category = $category->get_parent_category();
|
||||
if (!$parent_category->is_aggregationcoef_used()) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
}
|
||||
|
||||
} else {
|
||||
$parent_category = $grade_item->get_parent_category();
|
||||
if (!$parent_category->is_aggregationcoef_used()) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$course_category = grade_category::fetch_course_category($COURSE->id);
|
||||
if (!$course_category->is_aggregationcoef_used()) {
|
||||
$mform->removeElement('aggregationcoef');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// perform extra validation before submission
|
||||
function validation($data){
|
||||
$errors= array();
|
||||
|
||||
if (0 == count($errors)){
|
||||
return true;
|
||||
} else {
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -150,6 +150,7 @@ if ($moving) {
|
||||
} else {
|
||||
print_single_button('category.php', array('courseid'=>$course->id), get_string('addcategory', 'grades'), 'get');
|
||||
print_single_button('item.php', array('courseid'=>$course->id), get_string('additem', 'grades'), 'get');
|
||||
print_single_button('outcomeitem.php', array('courseid'=>$course->id), get_string('addoutcomeitem', 'grades'), 'get');
|
||||
print_single_button('tree.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get');
|
||||
print_single_button('tree.php', array('id'=>$course->id, 'action'=>'synclegacy'), get_string('synclegacygrades', 'grades'), 'get');
|
||||
}
|
||||
@ -182,6 +183,12 @@ function print_grade_tree(&$gtree, $element, $moving, &$gpr) {
|
||||
$actions .= $gtree->get_locking_icon($element, $gpr);
|
||||
|
||||
$name = $object->get_name();
|
||||
|
||||
//TODO: improve outcome visulisation
|
||||
if ($element['type'] == 'item' and !empty($object->outcomeid)) {
|
||||
$name = $name.' ('.get_string('outcome', 'grades').')';
|
||||
}
|
||||
|
||||
if ($object->is_hidden()) {
|
||||
$name = '<span class="dimmed_text">'.$name.'</span>';
|
||||
}
|
||||
|
@ -580,7 +580,11 @@ class grade_tree {
|
||||
case 'item':
|
||||
case 'categoryitem':
|
||||
case 'courseitem':
|
||||
$url = $CFG->wwwroot.'/grade/edit/item.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
if (empty($object->outcomeid)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/item.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/outcomeitem.php?courseid='.$this->courseid.'&id='.$object->id;
|
||||
}
|
||||
$url = $gpr->add_url_params($url);
|
||||
break;
|
||||
|
||||
|
@ -7,21 +7,21 @@
|
||||
|
||||
<?php
|
||||
foreach ($outcomes as $outcome) {
|
||||
|
||||
|
||||
// do not include items already used in course
|
||||
if (in_array($outcome->id, array_keys($courseoutcomes))) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
echo '<option value="'.$outcome->id.'">'.truncate($outcome->fullname, 150).'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
<?php
|
||||
// only show arrows if user has privilages to manage
|
||||
if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
?>
|
||||
<p class="arrow_button">
|
||||
<input name="add" id="add" type="submit" value="<?php echo ' '.$THEME->rarrow.' '.get_string('add'); ?>" title="<?php print_string('add'); ?>" />
|
||||
|
@ -39,8 +39,8 @@ require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYS
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
/// Print header
|
||||
print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
|
||||
|
||||
print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
|
||||
|
||||
$strdeleteoutcomecheck = get_string('deleteoutcomecheck', 'grades');
|
||||
notice_yesno($strdeleteoutcomecheck,
|
||||
'course.php?id='.$courseid.'&deleteid='.$deleteid.'&confirm=1&sesskey='.sesskey(),
|
||||
@ -53,17 +53,17 @@ require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYS
|
||||
if ($data = data_submitted()) {
|
||||
require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
if (!empty($data->add) && !empty($data->addoutcomes)) {
|
||||
/// add all selected to course list
|
||||
/// add all selected to course list
|
||||
foreach ($data->addoutcomes as $add) {
|
||||
$goc -> courseid = $courseid;
|
||||
$goc -> outcomeid = $add;
|
||||
insert_record('grade_outcomes_courses', $goc);
|
||||
}
|
||||
} else if (!empty($data->remove) && !empty($data->removeoutcomes)) {
|
||||
/// remove all selected from course outcomes list
|
||||
/// remove all selected from course outcomes list
|
||||
foreach ($data->removeoutcomes as $remove) {
|
||||
delete_records('grade_outcomes_courses', 'courseid', $courseid, 'outcomeid', $remove);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,17 +92,17 @@ print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, ''
|
||||
FROM '.$CFG->prefix.'grade_outcomes_courses goc,
|
||||
'.$CFG->prefix.'grade_outcomes go
|
||||
WHERE goc.courseid = '.$courseid.'
|
||||
AND goc.outcomeid = go.id');
|
||||
|
||||
AND goc.outcomeid = go.id');
|
||||
|
||||
if (empty($courseoutcomes)) {
|
||||
$courseoutcomes = get_records('grade_outcomes', 'courseid', $courseid);
|
||||
$courseoutcomes = get_records('grade_outcomes', 'courseid', $courseid);
|
||||
} elseif ($mcourseoutcomes = get_records('grade_outcomes', 'courseid', $courseid)) {
|
||||
$courseoutcomes += $mcourseoutcomes;
|
||||
}
|
||||
|
||||
check_theme_arrows();
|
||||
include_once('course.html');
|
||||
|
||||
|
||||
/// interface to add/edit/delete course specific outcomes
|
||||
echo '<p/>';
|
||||
print_string('coursespecoutcome', 'grades'); // course sepcific outcomes
|
||||
@ -110,7 +110,7 @@ print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, ''
|
||||
$totalcount = count_records('grade_outcomes_courses', 'courseid', $courseid);
|
||||
$baseurl = "course.php";
|
||||
print_paging_bar($totalcount, $page, $perpage, $baseurl);
|
||||
|
||||
|
||||
if ($outcomes = get_recordset('grade_outcomes', 'courseid', $courseid, '', '*', $page * $perpage, $perpage)) {
|
||||
|
||||
$tablecolumns = array('outcome', 'scale', 'edit', 'usedgradeitems');
|
||||
@ -138,13 +138,13 @@ print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, ''
|
||||
// full name of the scale used by this outcomes
|
||||
$scale= get_record('scale', 'id', $outcome->scaleid);
|
||||
$data[] = $scale->name;
|
||||
|
||||
|
||||
if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
// add operations
|
||||
$data[] = '<a href="editoutcomes.php?id='.$outcome->id.'&courseid='.$courseid.'&sesskey='.sesskey().'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
|
||||
<a href="course.php?deleteid='.$outcome->id.'&id='.$courseid.'&sesskey='.sesskey().'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/delete.gif"/></a>'; // icons and links
|
||||
} else {
|
||||
$data[] = '';
|
||||
$data[] = '';
|
||||
}
|
||||
// num of gradeitems using this
|
||||
$num = count_records('grade_items', 'outcomeid' ,$outcome->id);
|
||||
@ -157,11 +157,11 @@ print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, ''
|
||||
$table->print_html();
|
||||
}
|
||||
if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
echo '<a href="editoutcomes.php?courseid='.$courseid.'">Add a new outcome</a>';
|
||||
echo '<a href="editoutcomes.php?courseid='.$courseid.'">Add a new outcome</a>';
|
||||
}
|
||||
print_footer();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* truncates a string to a length of num
|
||||
* @param string string
|
||||
* @param int num
|
||||
|
@ -16,7 +16,7 @@ $gradereport_outcomes_capabilities = array(
|
||||
'gradereport/outcomes:manage' => array(
|
||||
'riskbitmask' => RISK_CONFIG,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
|
@ -48,7 +48,7 @@ if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
|
||||
$returnurl = $CFG->wwwroot."/grade/report/outcomes/course.php?id=$courseid";
|
||||
} else {
|
||||
// admin editting site level outcomes
|
||||
require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM));
|
||||
$returnurl = $CFG->wwwroot."/grade/report/outcomes/site.php";
|
||||
}
|
||||
// form processing
|
||||
@ -69,9 +69,9 @@ if ($mform->is_cancelled()) {
|
||||
}
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data->courseid == 0) {
|
||||
$data->courseid = NULL;
|
||||
$data->courseid = NULL;
|
||||
}
|
||||
|
||||
|
||||
if ($data->id) {
|
||||
update_record('grade_outcomes', $data);
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@ require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// setting up params
|
||||
$courseid = optional_param('id', SITEID, PARAM_INT); // course id
|
||||
require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('gradereport/outcomes:view', get_context_instance(CONTEXT_SYSTEM));
|
||||
/// check capability
|
||||
|
||||
$page = optional_param('page', 0, PARAM_INT); // current page
|
||||
@ -26,7 +26,7 @@ $perpage = 30;
|
||||
// delete all outcomes used in grade items
|
||||
delete_records('grade_outcomes_courses', 'outcomeid', $deleteid);
|
||||
delete_records('grade_outcomes', 'id', $deleteid);
|
||||
} else {
|
||||
} else {
|
||||
$strgrades = get_string('grades');
|
||||
$stroutcomes = get_string('outcomes', 'grades');
|
||||
$navlinks = array();
|
||||
@ -36,7 +36,7 @@ $perpage = 30;
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
/// Print header
|
||||
print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
|
||||
print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
|
||||
// prints confirmation
|
||||
$strdeleteoutcomecheck = get_string('deleteoutcomecheck', 'grades');
|
||||
notice_yesno($strdeleteoutcomecheck,
|
||||
@ -99,12 +99,12 @@ $perpage = 30;
|
||||
|
||||
// add operations
|
||||
if (has_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
|
||||
|
||||
$data[] = '<a href="editoutcomes.php?id='.$outcome->id.'&sesskey='.sesskey().'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
|
||||
<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
|
||||
|
||||
|
||||
} else {
|
||||
$data[] = '';
|
||||
$data[] = '';
|
||||
}
|
||||
// num of gradeitems using this
|
||||
$num = count_records('grade_items', 'outcomeid' ,$outcome->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user