MDL-15680 emoving weights interface (now in contrib).
|
@ -1,71 +0,0 @@
|
|||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
// If the mouse is clicked outside this element, the edit is CANCELLED (even if the mouse clicks another grade/feedback cell)
|
||||
// If ctrl-arrow is used, or if [tab] or [enter] are pressed, the edit is RECORDED and the row is updated. The previous element returns to normal
|
||||
|
||||
YAHOO.namespace("grade_edit_weights");
|
||||
YAHOO.grade_edit_weights.courseid = <?php echo $COURSE->id; ?>;
|
||||
YAHOO.grade_edit_weights.wwwroot = '<?php echo $CFG->wwwroot; ?>';
|
||||
YAHOO.grade_edit_weights.tree = null;
|
||||
YAHOO.grade_edit_weights.treedata = <?php echo $tree_json; ?>;
|
||||
|
||||
YAHOO.grade_edit_weights.buildTreeNode = function(element, parentNode) {
|
||||
var gew = YAHOO.grade_edit_weights;
|
||||
|
||||
if (parentNode === undefined) {
|
||||
parentNode = gew.tree.getRoot();
|
||||
}
|
||||
|
||||
if (element === undefined) {
|
||||
element = gew.treedata;
|
||||
}
|
||||
|
||||
if (element.item.table == 'grade_categories') {
|
||||
var aggregation_types = '<select name="aggregation_'+element.item.id+'">';
|
||||
|
||||
for (var i = 0; i < gew.options.length; i++) {
|
||||
aggregation_types += '<option>' + gew.options[i] + '</option>';
|
||||
}
|
||||
|
||||
var gradecategory = '<span class="gradecategory">'+element.item.name+' '+aggregation_types+'<'+'/span>';
|
||||
var tmpNode = new YAHOO.widget.TextNode(gradecategory, parentNode, parentNode.isRoot());
|
||||
// var tmpNode = new YAHOO.widget.TextNode(element.item.name, parentNode, parentNode.isRoot());
|
||||
for (var i = 0; i < element.children.length; i++) {
|
||||
gew.buildTreeNode(element.children[i], tmpNode, false);
|
||||
}
|
||||
} else if (element.item.itemtype == 'mod') {
|
||||
var gradeitem = '<span class="gradeitem"><input type="text" size="6" name="weight_'+element.item.id+'" value="'+element.item.aggregationcoef+'"/>'+
|
||||
element.item.name + '<'+'/span>';
|
||||
var tmpNode = new YAHOO.widget.HTMLNode(gradeitem, parentNode, false);
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.grade_edit_weights.init = function() {
|
||||
var gew = YAHOO.grade_edit_weights;
|
||||
var div = document.getElementById('weightstree');
|
||||
gew.tree = new YAHOO.widget.TreeView('gradetree');
|
||||
|
||||
//handler for expanding all nodes
|
||||
YAHOO.util.Event.on("expand", "click", function(e) {
|
||||
YAHOO.log("Expanding all TreeView nodes.", "info", "example");
|
||||
gew.tree.expandAll();
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
});
|
||||
|
||||
//handler for collapsing all nodes
|
||||
YAHOO.util.Event.on("collapse", "click", function(e) {
|
||||
YAHOO.log("Collapsing all TreeView nodes.", "info", "example");
|
||||
gew.tree.collapseAll();
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
});
|
||||
|
||||
// gew.buildTreeNode();
|
||||
gew.tree.render();
|
||||
gew.tree.expandAll();
|
||||
};
|
||||
|
||||
YAHOO.util.Event.onDOMReady(YAHOO.grade_edit_weights.init);
|
||||
|
||||
// ]]>
|
||||
</script>
|
Before Width: | Height: | Size: 666 B |
Before Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 142 B |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 651 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 504 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 503 B |
|
@ -1,293 +0,0 @@
|
|||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php'; // for preferences
|
||||
require_once $CFG->dirroot.'/grade/edit/weights/lib.php';
|
||||
|
||||
require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_json', 'yui_connection', 'yui_dragdrop', 'yui_treeview'));
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', 0, PARAM_ALPHA);
|
||||
$eid = optional_param('eid', 0, PARAM_ALPHANUM);
|
||||
$category = optional_param('category', null, PARAM_INT);
|
||||
$aggregationtype = optional_param('aggregationtype', null, PARAM_INT);
|
||||
$showadvanced = optional_param('showadvanced', false, PARAM_BOOL);
|
||||
|
||||
/// Make sure they can even access this course
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
/// return tracking object
|
||||
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'weights', 'courseid'=>$courseid));
|
||||
$returnurl = $gpr->get_return_url(null);
|
||||
|
||||
// Change category aggregation if requested
|
||||
if (!is_null($category) && !is_null($aggregationtype)) {
|
||||
if (!$grade_category = grade_category::fetch(array('id'=>$category, 'courseid'=>$courseid))) {
|
||||
error('Incorrect category id!');
|
||||
}
|
||||
$data->aggregation = $aggregationtype;
|
||||
grade_category::set_properties($grade_category, $data);
|
||||
$grade_category->update();
|
||||
}
|
||||
|
||||
//first make sure we have proper final grades - we need it for locking changes
|
||||
grade_regrade_final_grades($courseid);
|
||||
|
||||
// get the grading tree object
|
||||
// note: total must be first for moving to work correctly, if you want it last moving code must be rewritten!
|
||||
$gtree = new grade_tree($courseid, false, false);
|
||||
|
||||
if (empty($eid)) {
|
||||
$element = null;
|
||||
$object = null;
|
||||
|
||||
} else {
|
||||
if (!$element = $gtree->locate_element($eid)) {
|
||||
print_error('invalidelementid', '', $returnurl);
|
||||
}
|
||||
$object = $element['object'];
|
||||
}
|
||||
|
||||
$switch = grade_get_setting($course->id, 'aggregationposition', $CFG->grade_aggregationposition);
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
$strgraderreport = get_string('graderreport', 'grades');
|
||||
$strcategoriesedit = get_string('categoriesedit', 'grades');
|
||||
$strcategoriesanditems = get_string('categoriesanditems', 'grades');
|
||||
|
||||
$navigation = grade_build_nav(__FILE__, $strcategoriesanditems, array('courseid' => $courseid));
|
||||
$moving = false;
|
||||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if ($eid) {
|
||||
if (!element_deletable($element)) {
|
||||
// no deleting of external activities - they would be recreated anyway!
|
||||
// exception is activity without grading or misconfigured activities
|
||||
break;
|
||||
}
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
$object->delete('grade/report/grader/category');
|
||||
redirect($returnurl);
|
||||
|
||||
} else {
|
||||
print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strcategoriesedit, $navigation, '', '', true, '', navmenu($course));
|
||||
$strdeletecheckfull = get_string('deletecheck', '', $object->get_name());
|
||||
$optionsyes = array('eid'=>$eid, 'confirm'=>1, 'sesskey'=>sesskey(), 'id'=>$course->id, 'action'=>'delete');
|
||||
$optionsno = array('id'=>$course->id);
|
||||
notice_yesno($strdeletecheckfull, 'index.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
print_footer($course);
|
||||
die;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'autosort':
|
||||
//TODO: implement autosorting based on order of mods on course page, categories first, manual items last
|
||||
break;
|
||||
|
||||
case 'synclegacy':
|
||||
grade_grab_legacy_grades($course->id);
|
||||
redirect($returnurl);
|
||||
|
||||
case 'move':
|
||||
if ($eid and confirm_sesskey()) {
|
||||
$moveafter = required_param('moveafter', PARAM_ALPHANUM);
|
||||
if(!$after_el = $gtree->locate_element($moveafter)) {
|
||||
print_error('invalidelementid', '', $returnurl);
|
||||
}
|
||||
$after = $after_el['object'];
|
||||
$parent = $after->get_parent_category();
|
||||
$sortorder = $after->get_sortorder();
|
||||
|
||||
$object->set_parent($parent->id);
|
||||
$object->move_after_sortorder($sortorder);
|
||||
|
||||
redirect($returnurl);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'moveselect':
|
||||
if ($eid and confirm_sesskey()) {
|
||||
$moving = $eid;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Hide advanced columns if moving
|
||||
if ($moving) {
|
||||
$showadvanced = false;
|
||||
}
|
||||
|
||||
$CFG->stylesheets[] = $CFG->wwwroot.'/grade/edit/weights/tree.css';
|
||||
print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strcategoriesedit, $navigation, '', '', true, '', navmenu($course));
|
||||
|
||||
/// Print the plugin selector at the top
|
||||
print_grade_plugin_selector($courseid, 'edit', 'tree');
|
||||
|
||||
print_heading(get_string('weightsedit', 'grades'));
|
||||
|
||||
$form_key = optional_param('sesskey', null, PARAM_ALPHANUM);
|
||||
|
||||
if ($form_key && $data = data_submitted()) {
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
// Grade category text inputs
|
||||
if (preg_match('/(aggregation|droplow|keephigh)_([0-9]*)/', $key, $matches)) {
|
||||
$value = required_param($matches[0], PARAM_INT);
|
||||
$param = $matches[1];
|
||||
$a->id = $matches[2];
|
||||
|
||||
if (!$DB->update_record('grade_categories', array('id' => $matches[2], $param => $value))) {
|
||||
print_error('errorupdatinggradecategoryaggregation', 'grades', $a);
|
||||
}
|
||||
|
||||
// Grade item text inputs
|
||||
} elseif (preg_match('/(aggregationcoef|multfactor|plusfactor)_([0-9]*)/', $key, $matches)) {
|
||||
$value = required_param($matches[0], PARAM_NUMBER);
|
||||
$param = $matches[1];
|
||||
$a->id = $matches[2];
|
||||
|
||||
if (!$DB->update_record('grade_items', array('id' => $matches[2], $param => $value))) {
|
||||
print_error('errorupdatinggradeitemaggregationcoef', 'grades', $a);
|
||||
}
|
||||
|
||||
// Grade item checkbox inputs
|
||||
} elseif (preg_match('/extracredit_original_([0-9]*)/', $key, $matches)) { // Sum extra credit checkbox
|
||||
$extracredit = optional_param("extracredit_{$matches[1]}", null, PARAM_BOOL);
|
||||
$original_value = required_param($matches[0], PARAM_BOOL);
|
||||
$a->id = $matches[1];
|
||||
$newvalue = null;
|
||||
|
||||
if ($original_value == 1 && is_null($extracredit)) {
|
||||
$newvalue = 0;
|
||||
} elseif ($original_value == 0 && $extracredit == 1) {
|
||||
$newvalue = 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$DB->update_record('grade_items', array('id' => $matches[1], 'aggregationcoef' => $newvalue))) {
|
||||
print_error('errorupdatinggradeitemaggregationcoef', 'grades', $a);
|
||||
}
|
||||
|
||||
// Grade category checkbox inputs
|
||||
} elseif (preg_match('/aggregate(onlygraded|subcats|outcomes)_original_([0-9]*)/', $key, $matches)) {
|
||||
$setting = optional_param('aggregate'.$matches[1].'_'.$matches[2], null, PARAM_BOOL);
|
||||
$original_value = required_param($matches[0], PARAM_BOOL);
|
||||
$a->id = $matches[2];
|
||||
|
||||
$newvalue = null;
|
||||
if ($original_value == 1 && is_null($setting)) {
|
||||
$newvalue = 0;
|
||||
} elseif ($original_value == 0 && $setting == 1) {
|
||||
$newvalue = 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$DB->update_record('grade_categories', array('id' => $matches[2], 'aggregate'.$matches[1] => $newvalue))) {
|
||||
print_error('errorupdatinggradecategoryaggregate'.$matches[1], 'grades', $a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// echo '<div id="expandcontractdiv"> <a id="expand" href="#">Expand all</a> <a id="collapse" href="#">Collapse all</a> </div> ';
|
||||
|
||||
print_box_start('gradetreebox generalbox');
|
||||
|
||||
echo '<form method="post" action="'.$returnurl.'">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo build_html_tree(get_tree_json($gtree, $gtree->top_element, 0, $gpr), null, $returnurl, $moving, $eid);
|
||||
|
||||
if ($showadvanced && !$moving) {
|
||||
echo '<input class="advanced" type="submit" value="Update weights" />';
|
||||
}
|
||||
|
||||
echo '</div>
|
||||
</form>';
|
||||
|
||||
print_box_end();
|
||||
|
||||
echo '<div class="buttons">';
|
||||
if ($moving) {
|
||||
print_single_button('index.php', array('id'=>$course->id), get_string('cancel'), 'get');
|
||||
} else {
|
||||
$strshowhideadvanced = get_string('showadvancedcolumns', 'grades');
|
||||
|
||||
if ($showadvanced) {
|
||||
$strshowhideadvanced = get_string('hideadvancedcolumns', 'grades');
|
||||
}
|
||||
|
||||
print_single_button('index.php', array('id'=>$course->id, 'showadvanced' => !$showadvanced), $strshowhideadvanced, 'get');
|
||||
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');
|
||||
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
print_single_button('outcomeitem.php', array('courseid'=>$course->id), get_string('addoutcomeitem', 'grades'), 'get');
|
||||
}
|
||||
|
||||
//print_single_button('index.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get');
|
||||
print_single_button('index.php', array('id'=>$course->id, 'action'=>'synclegacy'), get_string('synclegacygrades', 'grades'), 'get');
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
|
||||
function toggle_advanced_columns() {
|
||||
var advEls = YAHOO.util.Dom.getElementsByClassName("advanced");
|
||||
var shownAdvEls = YAHOO.util.Dom.getElementsByClassName("advancedshown");
|
||||
|
||||
for (var i = 0; i < advEls.length; i++) {
|
||||
YAHOO.util.Dom.replaceClass(advEls[i], "advanced", "advancedshown");
|
||||
}
|
||||
|
||||
for (var i = 0; i < shownAdvEls.length; i++) {
|
||||
YAHOO.util.Dom.replaceClass(shownAdvEls[i], "advancedshown", "advanced");
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
print_footer($course);
|
||||
die;
|
||||
|
||||
?>
|
|
@ -1,315 +0,0 @@
|
|||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function get_tree_json(&$gtree, $element, $totals=false, $gpr) {
|
||||
global $CFG, $COURSE;
|
||||
|
||||
$return_array = array();
|
||||
|
||||
$object = $element['object'];
|
||||
$eid = $element['eid'];
|
||||
$object->name = $gtree->get_element_header($element, false, false, false);
|
||||
|
||||
$return_array['item'] = $object;
|
||||
|
||||
$return_array['item']->actions = $gtree->get_edit_icon($element, $gpr);
|
||||
$return_array['item']->actions .= $gtree->get_calculation_icon($element, $gpr);
|
||||
|
||||
if ($element['type'] == 'item' or ($element['type'] == 'category' and $element['depth'] > 1)) {
|
||||
if (element_deletable($element)) {
|
||||
$return_array['item']->actions .= '<a href="index.php?id='.$COURSE->id.'&action=delete&eid='
|
||||
. $eid.'&sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="'
|
||||
. get_string('delete').'" title="'.get_string('delete').'"/></a>';
|
||||
}
|
||||
$return_array['item']->actions .= '<a href="index.php?id='.$COURSE->id.'&action=moveselect&eid='
|
||||
. $eid.'&sesskey='.sesskey().'"><img src="'.$CFG->pixpath.'/t/move.gif" class="iconsmall" alt="'
|
||||
. get_string('move').'" title="'.get_string('move').'"/></a>';
|
||||
}
|
||||
|
||||
$return_array['item']->actions .= $gtree->get_hiding_icon($element, $gpr);
|
||||
$return_array['item']->actions .= $gtree->get_locking_icon($element, $gpr);
|
||||
$return_array['item']->eid = $element['eid'];
|
||||
$return_array['item']->type = $element['type'];
|
||||
|
||||
if ($element['type'] == 'category') {
|
||||
foreach($element['children'] as $child_el) {
|
||||
if (!empty($child_el['object']->itemtype) && ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') && !$totals) {
|
||||
continue;
|
||||
}
|
||||
$return_array['children'][] = get_tree_json($gtree, $child_el, $totals, $gpr);
|
||||
}
|
||||
}
|
||||
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
function build_html_tree($tree, $element=null, $level=0, $moving=false, $eid) {
|
||||
global $CFG, $COURSE;
|
||||
|
||||
$showadvanced = optional_param('showadvanced', false, PARAM_BOOL);
|
||||
$advclass = ($showadvanced) ? 'shown' : 'hidden';
|
||||
|
||||
$options = array(GRADE_AGGREGATE_MEAN => get_string('aggregatemean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN => get_string('aggregateweightedmean', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN2 => get_string('aggregateweightedmean2', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN => get_string('aggregateextracreditmean', 'grades'),
|
||||
GRADE_AGGREGATE_MEDIAN => get_string('aggregatemedian', 'grades'),
|
||||
GRADE_AGGREGATE_MIN => get_string('aggregatemin', 'grades'),
|
||||
GRADE_AGGREGATE_MAX => get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE => get_string('aggregatemode', 'grades'),
|
||||
GRADE_AGGREGATE_SUM => get_string('aggregatesum', 'grades'));
|
||||
|
||||
$html = '';
|
||||
$root = false;
|
||||
|
||||
if (is_null($element)) {
|
||||
$html .= '<table cellpadding="5" class="generaltable">
|
||||
<tr>
|
||||
<th class="header name">'.get_string('name').'</th>';
|
||||
if (!$moving) {
|
||||
$html .= '
|
||||
<th class="header '.$advclass.'">'.get_string('aggregation', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('weightorextracredit', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('range', 'grades').'</th>
|
||||
<th class="header '.$advclass.'" style="width: 40px">'.get_string('aggregateonlygraded', 'grades').'</th>
|
||||
<th class="header '.$advclass.'" style="width: 40px">'.get_string('aggregatesubcats', 'grades').'</th>
|
||||
<th class="header '.$advclass.'" style="width: 40px">'.get_string('aggregateoutcomes', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('droplow', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('keephigh', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('multfactor', 'grades').'</th>
|
||||
<th class="header '.$advclass.'">'.get_string('plusfactor', 'grades').'</th>
|
||||
<th class="header actions">'.get_string('actions').'</th>
|
||||
';
|
||||
}
|
||||
|
||||
$html .= '</tr>';
|
||||
$element = $tree;
|
||||
$root = true;
|
||||
}
|
||||
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
|
||||
/// prepare move target if needed
|
||||
$last = '';
|
||||
$moveto = '';
|
||||
|
||||
if ($moving) {
|
||||
$strmove = get_string('move');
|
||||
$strmovehere = get_string('movehere');
|
||||
$element['item']->actions = ''; // no action icons when moving
|
||||
$moveto = '<tr><td colspan="12"><a href="index.php?id='.$COURSE->id.'&action=move&eid='.$moving.'&moveafter='
|
||||
. $element['item']->eid.'&sesskey='.sesskey().'"><img class="movetarget" src="'.$CFG->wwwroot.'/pix/movehere.gif" alt="'
|
||||
. $strmovehere.'" title="'.$strmovehere.'" /></a></td></tr>';
|
||||
}
|
||||
|
||||
/// print the list items now
|
||||
if ($moving == $element['item']->eid) {
|
||||
|
||||
// do not diplay children
|
||||
return '<tr><td colspan="12" class="'.$element['item']->type.' moving">'.$element['item']->name.' ('.get_string('move').')</td></tr>';
|
||||
|
||||
}
|
||||
|
||||
if (!empty($element['children'])) { // Grade category
|
||||
$category = grade_category::fetch(array('id' => $element['item']->id));
|
||||
$item = $category->get_grade_item();
|
||||
|
||||
$script = "window.location='index.php?id=$id&category={$category->id}&aggregationtype='+this.value";
|
||||
$aggregation = choose_from_menu($options, 'aggregation_'.$category->id, $category->aggregation, get_string('choose'), $script, 0, true);
|
||||
|
||||
$onlygradedcheck = ($category->aggregateonlygraded == 1) ? 'checked="checked"' : '';
|
||||
$subcatscheck = ($category->aggregatesubcats == 1) ? 'checked="checked"' : '';
|
||||
$outcomescheck = ($category->aggregateoutcomes == 1) ? 'checked="checked"' : '';
|
||||
|
||||
$aggregateonlygraded ='<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.$category->id.'" '.$onlygradedcheck . ' />';
|
||||
$aggregatesubcats = '<input type="checkbox" id="aggregatesubcats_'.$category->id.'" name="aggregatesubcats_'.$category->id.'" ' . $subcatscheck.' />';
|
||||
$aggregateoutcomes = '<input type="checkbox" id="aggregateoutcomes_'.$category->id.'" name="aggregateoutcomes_'.$category->id.'" ' . $outcomescheck.' />';
|
||||
|
||||
$droplow = '<input type="text" size="3" id="droplow_'.$category->id.'" name="droplow_'.$category->id.'" value="'.$category->droplow.'" />';
|
||||
$keephigh = '<input type="text" size="3" id="keephigh_'.$category->id.'" name="keephigh_'.$category->id.'" value="'.$category->keephigh.'" />';
|
||||
|
||||
$hidden = '<input type="hidden" name="aggregateonlygraded_original_'.$category->id.'" value="'.$category->aggregateonlygraded.'" />';
|
||||
$hidden .= '<input type="hidden" name="aggregatesubcats_original_'.$category->id.'" value="'.$category->aggregatesubcats.'" />';
|
||||
$hidden .= '<input type="hidden" name="aggregateoutcomes_original_'.$category->id.'" value="'.$category->aggregateoutcomes.'" />';
|
||||
|
||||
// Add aggregation coef input if not a course item and if parent category has correct aggregation type
|
||||
$aggcoef_input = get_weight_input($item);
|
||||
$dimmed = ($item->hidden) ? " dimmed " : "";
|
||||
|
||||
$html .= '
|
||||
<tr class="category '.$dimmed.'">
|
||||
<td class="cell name" style="padding-left:' . ($level * 20)
|
||||
. 'px; background: #DDDDDD url(img/ln.gif) no-repeat scroll ' . (($level - 1) * 20) . 'px 8px">' . $element['item']->name . $hidden . '</td>';
|
||||
|
||||
if (!$moving) {
|
||||
$html .= '
|
||||
<td class="cell '.$advclass.'">' . $aggregation . '</td>
|
||||
<td class="cell '.$advclass.'">' . $aggcoef_input . '</td>
|
||||
<td class="cell '.$advclass.'">' . $item->get_formatted_range() . '</td>
|
||||
<td class="cell '.$advclass.'">' . $aggregateonlygraded . '</td>
|
||||
<td class="cell '.$advclass.'">' . $aggregatesubcats . '</td>
|
||||
<td class="cell '.$advclass.'">' . $aggregateoutcomes . '</td>
|
||||
<td class="cell '.$advclass.'">' . $droplow . '</td>
|
||||
<td class="cell '.$advclass.'">' . $keephigh . '</td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell actions">' . $element['item']->actions . '</td>';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</tr>
|
||||
'.$moveto;
|
||||
|
||||
foreach ($element['children'] as $child) {
|
||||
$html .= build_html_tree($tree, $child, $level+1, $moving, $eid);
|
||||
}
|
||||
|
||||
} else { // Dealing with a grade item
|
||||
|
||||
$item = grade_item::fetch(array('id' => $element['item']->id));
|
||||
$element['type'] = 'item';
|
||||
$element['object'] = $item;
|
||||
|
||||
$element['item']->name = grade_structure::get_element_icon($element). $element['item']->name;
|
||||
|
||||
if (!empty($item->itemmodule) && $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid)) {
|
||||
|
||||
$dir = $CFG->dirroot.'/mod/'.$item->itemmodule;
|
||||
|
||||
if (file_exists($dir.'/grade.php')) {
|
||||
$url = $CFG->wwwroot.'/mod/'.$item->itemmodule.'/grade.php?id='.$cm->id;
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/mod/'.$item->itemmodule.'/view.php?id='.$cm->id;
|
||||
}
|
||||
|
||||
$element['item']->name = '<a href="'.$url.'">'.$element['item']->name.'</a>';
|
||||
}
|
||||
|
||||
// Determine aggregation coef element
|
||||
$aggcoef_input = get_weight_input($item);
|
||||
$multfactor = '<input type="text" size="3" id="multfactor'.$item->id.'" name="multfactor'.$item->id.'" value="'.$item->multfactor.'" />';
|
||||
$plusfactor = '<input type="text" size="3" id="plusfactor_'.$item->id.'" name="plusfactor_'.$item->id.'" value="'.$item->plusfactor.'" />';
|
||||
|
||||
$dimmed = ($item->hidden) ? " dimmed_text " : "";
|
||||
$html .= '
|
||||
<tr class="item'.$dimmed.'">
|
||||
<td class="cell name" style="padding-left:' . ($level * 20)
|
||||
. 'px; background: #FFFFFF url(img/ln.gif) no-repeat scroll ' . (($level - 1) * 20) . 'px 8px">' . $element['item']->name . '</td>';
|
||||
|
||||
if (!$moving) {
|
||||
$html .= '
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'">' . $aggcoef_input . '</td>
|
||||
<td class="cell '.$advclass.'">' . $item->get_formatted_range() . '</td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'"> - </td>
|
||||
<td class="cell '.$advclass.'">'.$multfactor.'</td>
|
||||
<td class="cell '.$advclass.'">'.$plusfactor.'</td>
|
||||
<td class="cell actions">' . $element['item']->actions . '</td>';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</tr>
|
||||
'.$moveto;
|
||||
}
|
||||
|
||||
|
||||
if ($root) {
|
||||
$html .= "</table>\n";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a grade_item object, returns a labelled input if an aggregation coefficient (weight or extra credit) applies to it.
|
||||
* @param grade_item $item
|
||||
* @return string HTML
|
||||
*/
|
||||
function get_weight_input($item) {
|
||||
if ($item->is_course_item()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parent_category = $item->get_parent_category();
|
||||
|
||||
if ($item->is_category_item()) {
|
||||
$parent_category = $parent_category->get_parent_category();
|
||||
}
|
||||
|
||||
$parent_category->apply_forced_settings();
|
||||
|
||||
if ($parent_category->is_aggregationcoef_used()) {
|
||||
$aggcoef = '';
|
||||
|
||||
if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
|
||||
$aggcoef = 'aggregationcoefweight';
|
||||
} elseif ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
|
||||
$aggcoef = 'aggregationcoefextra';
|
||||
} elseif ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$aggcoef = 'aggregationcoefextrasum';
|
||||
}
|
||||
|
||||
if ($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoefextra') {
|
||||
return '<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'" value="'.$item->aggregationcoef.'" />';
|
||||
} elseif ($aggcoef == 'aggregationcoefextrasum' ) {
|
||||
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
|
||||
$extracredit = ($item->aggregationcoef > 0) ? 1 : 0;
|
||||
|
||||
return '<input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" ' . "$checked />\n"
|
||||
. '<input type="hidden" name="extracredit_original_'.$item->id.'" value="'.$extracredit.'" />';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function element_deletable($element) {
|
||||
global $COURSE;
|
||||
|
||||
if ($element['type'] != 'item') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$grade_item = $element['object'];
|
||||
|
||||
if ($grade_item->itemtype != 'mod' or $grade_item->is_outcome_item() or $grade_item->gradetype == GRADE_TYPE_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$modinfo = get_fast_modinfo($COURSE);
|
||||
if (!isset($modinfo->instances[$grade_item->itemmodule][$grade_item->iteminstance])) {
|
||||
// module does not exist
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,56 +0,0 @@
|
|||
.gradetreebox tr.category td {
|
||||
background-color: #DDDDDD;
|
||||
}
|
||||
|
||||
.gradetreebox .category td.name {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.gradetreebox td.name {
|
||||
|
||||
}
|
||||
|
||||
.gradetreebox th.actions {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.child {
|
||||
background-image: url(img/ln.gif);
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
.shown {
|
||||
}
|
||||
|
||||
img.iconsmall {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
img.icon {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.gradetreebox {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: 10px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.gradetreebox table {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
margin: 20px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.buttons .singlebutton {
|
||||
display: inline;
|
||||
padding: 5px;
|
||||
}
|