mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-19797 Optimising output code and JS/CSS requires. Also improved CSS for grader report
This commit is contained in:
parent
8f3b787b1d
commit
1c1f64a2a6
@ -15,14 +15,23 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once 'edit_form.php';
|
||||
/**
|
||||
* Edit form for grade letters.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @copyright 2008 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../config.php');
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
require_once($CFG->dirroot.'/grade/lib.php');
|
||||
require_once('edit_form.php');
|
||||
|
||||
$contextid = optional_param('id', SYSCONTEXTID, PARAM_INT);
|
||||
|
||||
$PAGE->set_url('grade/edit/letter/edit.php');
|
||||
|
||||
if (!$context = get_context_instance_by_id($contextid)) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
@ -131,4 +140,3 @@ if ($admin) {
|
||||
$mform->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
?>
|
||||
|
@ -15,6 +15,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* List of grade letters.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @copyright 2008 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->libdir.'/gradelib.php';
|
||||
@ -22,10 +30,12 @@ require_once $CFG->libdir.'/gradelib.php';
|
||||
$courseid = optional_param('id', SITEID, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
|
||||
$PAGE->set_url('grade/edit/letter/index.php', array('id' => $courseid));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:manageletters', $context)) {
|
||||
@ -59,8 +69,7 @@ $table->size = array('30%', '30%', '40%');
|
||||
$table->align = array('left', 'left', 'left');
|
||||
$table->width = '30%';
|
||||
$table->data = $data;
|
||||
$table->tablealign = 'center';
|
||||
echo $OUTPUT->table($table);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
?>
|
||||
|
@ -15,6 +15,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Edit and review page for grade categories and items.
|
||||
*
|
||||
* @package moodlecore
|
||||
* @copyright 2008 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once '../../../config.php';
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/lib.php'; // for preferences
|
||||
@ -28,6 +36,7 @@ $PAGE->requires->yui_lib('element');
|
||||
$PAGE->requires->yui_lib('container');
|
||||
$PAGE->requires->yui_lib('animation');
|
||||
$PAGE->requires->js('grade/edit/tree/functions.js');
|
||||
$PAGE->requires->css('/grade/edit/tree/tree.css');
|
||||
|
||||
$courseid = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', 0, PARAM_ALPHA);
|
||||
@ -36,6 +45,8 @@ $category = optional_param('category', null, PARAM_INT);
|
||||
$aggregationtype = optional_param('aggregationtype', null, PARAM_INT);
|
||||
$showadvanced = optional_param('showadvanced', -1, PARAM_BOOL); // sticky editting mode
|
||||
|
||||
$PAGE->set_url('grade/edit/tree/index.php', array('id' => $courseid));
|
||||
|
||||
/// Make sure they can even access this course
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
@ -199,8 +210,6 @@ if ($grade_edit_tree->moving) {
|
||||
$USER->gradeediting[$course->id] = 0;
|
||||
}
|
||||
|
||||
$CFG->stylesheets[] = $CFG->wwwroot.'/grade/edit/tree/tree.css';
|
||||
|
||||
$current_view_str = '';
|
||||
if ($current_view != '') {
|
||||
if ($current_view == 'simpleview') {
|
||||
|
@ -74,9 +74,9 @@ class grade_edit_tree {
|
||||
* Recursive function for building the table holding the grade categories and items,
|
||||
* with CSS indentation and styles.
|
||||
*
|
||||
* @param array $element The current tree element being rendered
|
||||
* @param boolean $totals Whether or not to print category grade items (category totals)
|
||||
* @param array $parents An array of parent categories for the current element (used for indentation and row classes)
|
||||
* @param array $element The current tree element being rendered
|
||||
* @param boolean $totals Whether or not to print category grade items (category totals)
|
||||
* @param array $parents An array of parent categories for the current element (used for indentation and row classes)
|
||||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
@ -108,13 +108,22 @@ class grade_edit_tree {
|
||||
|
||||
if ($element['type'] == 'item' or ($element['type'] == 'category' and $element['depth'] > 1)) {
|
||||
if ($this->element_deletable($element)) {
|
||||
$actions .= '<a href="index.php?id='.$COURSE->id.'&action=delete&eid='
|
||||
. $eid.'&sesskey='.sesskey().'"><img src="'.$OUTPUT->old_icon_url('t/delete') . '" class="iconsmall" alt="'
|
||||
. get_string('delete').'" title="'.get_string('delete').'"/></a>';
|
||||
$actionicon = new moodle_action_icon();
|
||||
$actionicon->link->url = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'delete', 'eid' => $eid, 'sesskey' => sesskey()));
|
||||
$actionicon->image->src = $OUTPUT->old_icon_url('t/delete');
|
||||
$actionicon->image->alt = get_string('delete');
|
||||
$actionicon->image->title = get_string('delete');
|
||||
$actionicon->image->add_class('iconsmall');
|
||||
$actions .= $OUTPUT->action_icon($actionicon);
|
||||
}
|
||||
$actions .= '<a href="index.php?id='.$COURSE->id.'&action=moveselect&eid='
|
||||
. $eid.'&sesskey='.sesskey().'"><img src="'.$OUTPUT->old_icon_url('t/move') . '" class="iconsmall" alt="'
|
||||
. get_string('move').'" title="'.get_string('move').'"/></a>';
|
||||
|
||||
$actionicon = new moodle_action_icon();
|
||||
$actionicon->link->url = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'moveselect', 'eid' => $eid, 'sesskey' => sesskey()));
|
||||
$actionicon->image->src = $OUTPUT->old_icon_url('t/move');
|
||||
$actionicon->image->alt = get_string('move');
|
||||
$actionicon->image->title = get_string('move');
|
||||
$actionicon->image->add_class('iconsmall');
|
||||
$actions .= $OUTPUT->action_icon($actionicon);
|
||||
}
|
||||
|
||||
$actions .= $this->gtree->get_hiding_icon($element, $this->gpr);
|
||||
@ -171,7 +180,7 @@ class grade_edit_tree {
|
||||
$first = '';
|
||||
|
||||
if ($child_el['object']->itemtype == 'course' || $child_el['object']->itemtype == 'category') {
|
||||
$first = '&first=1';
|
||||
$first = array('first' => 1);
|
||||
$child_eid = $eid;
|
||||
}
|
||||
|
||||
@ -181,9 +190,17 @@ class grade_edit_tree {
|
||||
$strmovehere = get_string('movehere');
|
||||
$actions = ''; // no action icons when moving
|
||||
|
||||
$moveto = '<tr><td colspan="12"><a href="index.php?id='.$COURSE->id.'&action=move&eid='.$this->moving.'&moveafter='
|
||||
. $child_eid.'&sesskey='.sesskey().$first.'"><img class="movetarget" src="'.$CFG->wwwroot.'/pix/movehere.gif" alt="'
|
||||
. s($strmovehere).'" title="'.s($strmovehere).'" /></a></td></tr>';
|
||||
$moveicon = new moodle_action_icon();
|
||||
$moveicon->link->url = new moodle_url('index.php', array('id' => $COURSE->id, 'action' => 'move', 'eid' => $this->moving, 'moveafter' => $child_eid, 'sesskey' => sesskey()));
|
||||
if ($first) {
|
||||
$moveicon->link->url->params($first);
|
||||
}
|
||||
$moveicon->image->add_class('movetarget');
|
||||
$moveicon->image->src = $OUTPUT->old_icon_url('movehere');
|
||||
$moveicon->image->alt = $strmovehere;
|
||||
$moveicon->image->title = $strmovehere;
|
||||
|
||||
$moveto = '<tr><td colspan="12">'.$OUTPUT->action_icon($moveicon) .'</td></tr>';
|
||||
}
|
||||
|
||||
$newparents = $parents;
|
||||
@ -314,6 +331,8 @@ class grade_edit_tree {
|
||||
* @return string HTML
|
||||
*/
|
||||
function get_weight_input($item, $type) {
|
||||
global $OUTPUT;
|
||||
|
||||
if (!is_object($item) || get_class($item) !== 'grade_item') {
|
||||
throw new Exception('grade_edit_tree::get_weight_input($item) was given a variable that is not of the required type (grade_item object)');
|
||||
return false;
|
||||
@ -323,18 +342,30 @@ class grade_edit_tree {
|
||||
return '';
|
||||
}
|
||||
|
||||
$weightfield = new html_field();
|
||||
|
||||
$parent_category = $item->get_parent_category();
|
||||
$parent_category->apply_forced_settings();
|
||||
$aggcoef = $item->get_coefstring();
|
||||
|
||||
if ((($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoef') && $type == 'weight') ||
|
||||
($aggcoef == 'aggregationcoefextra' && $type == 'extra')) {
|
||||
return '<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'"
|
||||
value="'.format_float($item->aggregationcoef, 4).'" />';
|
||||
$weightfield->type = 'text';
|
||||
$weightfield->id = "aggregationcoef_$item->id";
|
||||
$weightfield->name = "aggregationcoef_$item->id";
|
||||
$weightfield->value = format_float($item->aggregationcoef, 4);
|
||||
|
||||
return $OUTPUT->field($weightfield);;
|
||||
} elseif ($aggcoef == 'aggregationcoefextrasum' && $type == 'extra') {
|
||||
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
|
||||
return '<input type="hidden" name="extracredit_'.$item->id.'" value="0" />
|
||||
<input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" value="1" '."$checked />\n";
|
||||
$weightfield->type = 'hidden';
|
||||
$weightfield->name = "extracredit_$item->id";
|
||||
$weightfield->value = 0;
|
||||
|
||||
$extracredit = html_select_option::make_checkbox(1, ($item->aggregationcoef > 0), ' ');
|
||||
$extracredit->id = "extracredit_$item->id";
|
||||
$extracredit->name = "extracredit_$item->id";
|
||||
return $OUTPUT->field($weightfield) . $OUTPUT->checkbox($extracredit);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -673,7 +704,7 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
|
||||
}
|
||||
|
||||
public function get_item_cell($item, $params) {
|
||||
global $DB;
|
||||
global $DB, $OUTPUT;
|
||||
|
||||
// If the parent aggregation is Sum of Grades, this cannot be changed
|
||||
$parent_cat = $item->get_parent_category();
|
||||
@ -686,7 +717,10 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
|
||||
} elseif ($item->is_external_item()) {
|
||||
$grademax = format_float($item->grademax, $item->get_decimals());
|
||||
} else {
|
||||
$grademax = '<input type="text" size="4" id="grademax'.$item->id.'" name="grademax_'.$item->id.'" value="'.format_float($item->grademax, $item->get_decimals()).'" />';
|
||||
$grademaxinput = html_field::make_text("grademax_$item->id", format_float($item->grademax, $item->get_decimals()), get_string('grademax', 'grades'));
|
||||
$grademaxinput->id = "grademax_$item->id";
|
||||
$grademaxinput->title = get_string('grademax', 'grades');
|
||||
$grademax = $OUTPUT->field($grademaxinput);
|
||||
}
|
||||
|
||||
return '<td class="cell">'.$grademax.'</td>';
|
||||
@ -715,15 +749,22 @@ class grade_edit_tree_column_aggregateonlygraded extends grade_edit_tree_column_
|
||||
}
|
||||
|
||||
public function get_category_cell($category, $levelclass, $params) {
|
||||
$onlygradedcheck = ($category->aggregateonlygraded == 1) ? 'checked="checked"' : '';
|
||||
$hidden = '<input type="hidden" name="aggregateonlygraded_'.$category->id.'" value="0" />';
|
||||
$aggregateonlygraded ='<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.$category->id.'" value="1" '.$onlygradedcheck . ' />';
|
||||
global $OUTPUT;
|
||||
|
||||
$hidden = new html_field();
|
||||
$hidden->type = 'hidden';
|
||||
$hidden->name = "aggregateonlygraded_$category->id";
|
||||
$hidden->value = 0;
|
||||
|
||||
$aggregateonlygraded = html_select_option::make_checkbox(1, ($category->aggregateonlygraded == 1), ' ');
|
||||
$aggregateonlygraded->id = "aggregateonlygraded_$category->id";
|
||||
$aggregateonlygraded->name = "aggregateonlygraded_$category->id";
|
||||
|
||||
if ($this->forced) {
|
||||
$aggregateonlygraded = ($category->aggregateonlygraded) ? get_string('yes') : get_string('no');
|
||||
}
|
||||
|
||||
return '<td class="cell '.$levelclass.'">'.$hidden.$aggregateonlygraded.'</td>';
|
||||
return '<td class="cell '.$levelclass.'">'.$OUTPUT->field($hidden).$OUTPUT->checkbox($aggregateonlygraded).'</td>';
|
||||
}
|
||||
|
||||
public function get_item_cell($item, $params) {
|
||||
|
164
grade/lib.php
164
grade/lib.php
@ -1063,35 +1063,31 @@ class grade_plugin_return {
|
||||
/**
|
||||
* Add return tracking params into url
|
||||
*
|
||||
* @param string $url A URL
|
||||
* @param moodle_url $url A URL
|
||||
*
|
||||
* @return string $url with erturn tracking params
|
||||
*/
|
||||
public function add_url_params($url) {
|
||||
public function add_url_params(moodle_url $url) {
|
||||
if (empty($this->type)) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if (strpos($url, '?') === false) {
|
||||
$url .= '?gpr_type='.$this->type;
|
||||
} else {
|
||||
$url .= '&gpr_type='.$this->type;
|
||||
}
|
||||
$url->param('gpr_type', $this->type);
|
||||
|
||||
if (!empty($this->plugin)) {
|
||||
$url .= '&gpr_plugin='.$this->plugin;
|
||||
$url->param('gpr_plugin', $this->plugin);
|
||||
}
|
||||
|
||||
if (!empty($this->courseid)) {
|
||||
$url .= '&gpr_courseid='.$this->courseid;
|
||||
$url->param('gpr_courseid' ,$this->courseid);
|
||||
}
|
||||
|
||||
if (!empty($this->userid)) {
|
||||
$url .= '&gpr_userid='.$this->userid;
|
||||
$url->param('gpr_userid', $this->userid);
|
||||
}
|
||||
|
||||
if (!empty($this->page)) {
|
||||
$url .= '&gpr_page='.$this->page;
|
||||
$url->param('gpr_page', $this->page);
|
||||
}
|
||||
|
||||
return $url;
|
||||
@ -1436,8 +1432,6 @@ class grade_structure {
|
||||
}
|
||||
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
if ($element['type'] == 'item' or $element['type'] == 'category') {
|
||||
}
|
||||
|
||||
$object = $element['object'];
|
||||
|
||||
@ -1447,32 +1441,29 @@ class grade_structure {
|
||||
case 'courseitem':
|
||||
$stredit = get_string('editverbose', 'grades', $strparams);
|
||||
if (empty($object->outcomeid) || empty($CFG->enableoutcomes)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/item.php?courseid='.
|
||||
$this->courseid.'&id='.$object->id;
|
||||
$url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/item.php',
|
||||
array('courseid' => $this->courseid, 'id' => $object->id));
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/outcomeitem.php?courseid='.
|
||||
$this->courseid.'&id='.$object->id;
|
||||
$url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/outcomeitem.php',
|
||||
array('courseid' => $this->courseid, 'id' => $object->id));
|
||||
}
|
||||
$url = $gpr->add_url_params($url);
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$stredit = get_string('editverbose', 'grades', $strparams);
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/category.php?courseid='.
|
||||
$this->courseid.'&id='.$object->id;
|
||||
$url = $gpr->add_url_params($url);
|
||||
$url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/category.php',
|
||||
array('courseid' => $this->courseid, 'id' => $object->id));
|
||||
break;
|
||||
|
||||
case 'grade':
|
||||
$stredit = $streditgrade;
|
||||
if (empty($object->id)) {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/grade.php?courseid='.
|
||||
$this->courseid.'&itemid='.$object->itemid.'&userid='.$object->userid;
|
||||
$url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/grade.php',
|
||||
array('courseid' => $this->courseid, 'itemid' => $object->itemid, 'userid' => $object->userid));
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/grade.php?courseid='.
|
||||
$this->courseid.'&id='.$object->id;
|
||||
$url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/grade.php',
|
||||
array('courseid' => $this->courseid, 'id' => $object->id));
|
||||
}
|
||||
$url = $gpr->add_url_params($url);
|
||||
if (!empty($object->feedback)) {
|
||||
$feedback = addslashes_js(trim(format_string($object->feedback, $object->feedbackformat)));
|
||||
}
|
||||
@ -1483,8 +1474,14 @@ class grade_structure {
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
return '<a href="'.$url.'"><img src="'.$OUTPUT->old_icon_url('t/edit') . '" ' .
|
||||
'class="iconsmall" alt="'.s($stredit).'" title="'.s($stredit).'"/></a>';
|
||||
$url = $gpr->add_url_params($url);
|
||||
$editicon = new moodle_action_icon();
|
||||
$editicon->link->url = $url;
|
||||
$editicon->image->src = $OUTPUT->old_icon_url('t/edit');
|
||||
$editicon->image->alt = $stredit;
|
||||
$editicon->image->title = $stredit;
|
||||
$editicon->image->add_class('iconsmall');
|
||||
return $OUTPUT->action_icon($editicon);
|
||||
|
||||
} else {
|
||||
return '';
|
||||
@ -1511,6 +1508,12 @@ class grade_structure {
|
||||
$strshow = get_string('showverbose', 'grades', $strparams);
|
||||
$strhide = get_string('hideverbose', 'grades', $strparams);
|
||||
|
||||
$hideicon = new moodle_action_icon();
|
||||
$hideicon->image->add_class('iconsmall');
|
||||
$hideicon->link->add_class('hide');
|
||||
$hideicon->link->url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/action.php',
|
||||
array('id' => $this->courseid, 'sesskey' => sesskey(), 'eid' => $element['eid']));
|
||||
|
||||
if ($element['object']->is_hidden()) {
|
||||
$icon = 'show';
|
||||
$tooltip = $strshow;
|
||||
@ -1522,24 +1525,20 @@ class grade_structure {
|
||||
userdate($element['object']->get_hidden()));
|
||||
}
|
||||
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id=' .
|
||||
$this->courseid.'&action=show&sesskey='.sesskey() .
|
||||
'&eid='.$element['eid'];
|
||||
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'" class="hide"><img alt="'.s($strshow).
|
||||
'" src="'.$OUTPUT->old_icon_url('t/' . $icon) . '" ' .
|
||||
'class="iconsmall" title="'.s($tooltip).'"/></a>';
|
||||
$hideicon->link->url->param('action', 'show');
|
||||
$hideicon->image->src = $OUTPUT->old_icon_url('t/' . $icon);
|
||||
$hideicon->image->alt = $strshow;
|
||||
$hideicon->image->title = $tooltip;
|
||||
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.
|
||||
$this->courseid.'&action=hide&sesskey='.sesskey()
|
||||
. '&eid='.$element['eid'];
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'" class="hide"><img src="'.
|
||||
$OUTPUT->old_icon_url('t/hide') . '" class="iconsmall" alt="'.s($strhide).'" title="'.s($strhide).'"/></a>';
|
||||
$hideicon->link->url->param('action', 'hide');
|
||||
$hideicon->image->src = $OUTPUT->old_icon_url('t/hide');
|
||||
$hideicon->image->alt = $strhide;
|
||||
$hideicon->image->title = $strhide;
|
||||
}
|
||||
return $action;
|
||||
|
||||
$hideicon->link->url = $gpr->add_url_params($hideicon->link->url);
|
||||
return $OUTPUT->action_icon($hideicon);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1557,14 +1556,26 @@ class grade_structure {
|
||||
$strunlock = get_string('unlockverbose', 'grades', $strparams);
|
||||
$strlock = get_string('lockverbose', 'grades', $strparams);
|
||||
|
||||
$lockicon = new moodle_action_icon();
|
||||
$lockicon->link->url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/action.php', array(
|
||||
'id' => $this->courseid,
|
||||
'sesskey' => sesskey(),
|
||||
'eid' => $element['eid']));
|
||||
$lockicon->link->url = $gpr->add_url_params($lockicon->link->url);
|
||||
$lockicon->image->add_class('iconsmall');
|
||||
|
||||
// Don't allow an unlocking action for a grade whose grade item is locked: just print a state icon
|
||||
if ($element['type'] == 'grade' && $element['object']->grade_item->is_locked()) {
|
||||
$strparamobj = new stdClass();
|
||||
$strparamobj->itemname = $element['object']->grade_item->itemname;
|
||||
$strnonunlockable = get_string('nonunlockableverbose', 'grades', $strparamobj);
|
||||
$action = '<img src="'.$OUTPUT->old_icon_url('t/unlock_gray') . '" alt="'.
|
||||
s($strnonunlockable).'" class="iconsmall" title="'.
|
||||
s($strnonunlockable).'"/>';
|
||||
|
||||
$lockicon = new html_image();
|
||||
$lockicon->image->src = $OUTPUT->old_icon_url('t/unlock_gray');
|
||||
$lockicon->image->alt = s($strnonunlockable);
|
||||
$lockicon->image->title = s($strnonunlockable);
|
||||
$lockicon->image->add_class('iconsmall');
|
||||
$action = $OUTPUT->image($lockicon);
|
||||
} else if ($element['object']->is_locked()) {
|
||||
$icon = 'unlock';
|
||||
$tooltip = $strunlock;
|
||||
@ -1580,27 +1591,25 @@ class grade_structure {
|
||||
!has_capability('moodle/grade:unlock', $this->context)) {
|
||||
return '';
|
||||
}
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.
|
||||
$this->courseid.'&action=unlock&sesskey='.sesskey() .
|
||||
'&eid='.$element['eid'];
|
||||
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'" class="lock"><img src="'.$OUTPUT->old_icon_url('t/'.$icon).'" alt="'.s($strunlock).
|
||||
'" class="iconsmall" title="'.s($tooltip).'"/></a>';
|
||||
$lockicon->link->url->param('action', 'unlock');
|
||||
$lockicon->link->add_class('lock');
|
||||
$lockicon->image->src = $OUTPUT->old_icon_url('t/'.$icon);
|
||||
$lockicon->image->alt = $strunlock;
|
||||
$lockicon->image->title = $tooltip;
|
||||
$action = $OUTPUT->action_icon($lockicon);
|
||||
|
||||
} else {
|
||||
if (!has_capability('moodle/grade:manage', $this->context) and
|
||||
!has_capability('moodle/grade:lock', $this->context)) {
|
||||
return '';
|
||||
}
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/action.php?id='.
|
||||
$this->courseid.'&action=lock&sesskey='.sesskey() .
|
||||
'&eid='.$element['eid'];
|
||||
|
||||
$url = $gpr->add_url_params($url);
|
||||
$action = '<a href="'.$url.'" class="lock"><img src="'.
|
||||
$OUTPUT->old_icon_url('t/lock') . '" class="iconsmall" alt="'.
|
||||
s($strlock).'" title="' . s($strlock).'"/></a>';
|
||||
$lockicon->link->url->param('action', 'lock');
|
||||
$lockicon->link->add_class('lock');
|
||||
$lockicon->image->src = $OUTPUT->old_icon_url('t/lock');
|
||||
$lockicon->image->alt = $strlock;
|
||||
$lockicon->image->title = $strlock;
|
||||
$action = $OUTPUT->action_icon($lockicon);
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
@ -1619,12 +1628,9 @@ class grade_structure {
|
||||
return '';
|
||||
}
|
||||
|
||||
$calculation_icon = '';
|
||||
|
||||
$type = $element['type'];
|
||||
$object = $element['object'];
|
||||
|
||||
|
||||
if ($type == 'item' or $type == 'courseitem' or $type == 'categoryitem') {
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
$streditcalculation = get_string('editcalculationverbose', 'grades', $strparams);
|
||||
@ -1640,16 +1646,20 @@ class grade_structure {
|
||||
$icon = 't/calc_off';
|
||||
}
|
||||
|
||||
$url = $CFG->wwwroot.'/grade/edit/tree/calculation.php?courseid='.
|
||||
$this->courseid.'&id='.$object->id;
|
||||
$url = $gpr->add_url_params($url);
|
||||
$calculation_icon = '<a href="'. $url.'" class="calculation">' .
|
||||
'<img src="'.$OUTPUT->old_icon_url($icon).'" class="iconsmall" alt="' .
|
||||
s($streditcalculation).'" title="'.s($streditcalculation).'" /></a>'. "\n";
|
||||
$calcicon = new moodle_action_icon();
|
||||
$calcicon->link->url = new moodle_url($CFG->wwwroot.'/grade/edit/tree/calculation.php',
|
||||
array('courseid' => $this->courseid, 'id' => $object->id));
|
||||
|
||||
$calcicon->link->url = $gpr->add_url_params($calcicon->link->url);
|
||||
$calcicon->image->src = $OUTPUT->old_icon_url($icon);
|
||||
$calcicon->add_class('iconsmall');
|
||||
$calcicon->alt = $streditcalculation;
|
||||
$calcicon->title = $streditcalculation;
|
||||
return $OUTPUT->action_icon($calcicon) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $calculation_icon;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1663,12 +1673,6 @@ class grade_structure {
|
||||
*/
|
||||
class grade_seq extends grade_structure {
|
||||
|
||||
/**
|
||||
* A string of GET URL variables, namely courseid and sesskey, used in most URLs built by this class.
|
||||
* @var string $commonvars
|
||||
*/
|
||||
public $commonvars;
|
||||
|
||||
/**
|
||||
* 1D array of elements
|
||||
*/
|
||||
@ -1686,7 +1690,6 @@ class grade_seq extends grade_structure {
|
||||
global $USER, $CFG;
|
||||
|
||||
$this->courseid = $courseid;
|
||||
$this->commonvars = "&sesskey=".sesskey()."&id=$this->courseid";
|
||||
$this->context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
// get course grade tree
|
||||
@ -1813,12 +1816,6 @@ class grade_tree extends grade_structure {
|
||||
*/
|
||||
public $top_element;
|
||||
|
||||
/**
|
||||
* A string of GET URL variables, namely courseid and sesskey, used in most URLs built by this class.
|
||||
* @var string $commonvars
|
||||
*/
|
||||
public $commonvars;
|
||||
|
||||
/**
|
||||
* 2D array of grade items and categories
|
||||
* @var array $levels
|
||||
@ -1846,7 +1843,6 @@ class grade_tree extends grade_structure {
|
||||
global $USER, $CFG;
|
||||
|
||||
$this->courseid = $courseid;
|
||||
$this->commonvars = "&sesskey=".sesskey()."&id=$this->courseid";
|
||||
$this->levels = array();
|
||||
$this->context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
||||
|
@ -35,6 +35,7 @@ $toggle = optional_param('toggle', NULL, PARAM_INT);
|
||||
$toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
|
||||
|
||||
$PAGE->set_url('grade/report/grader/index.php', compact('courseid', 'page', 'perpageurl', 'edit', 'sortitemid'));
|
||||
$PAGE->requires->css('lib/yui/container/assets/skins/sam/container.css');
|
||||
|
||||
/// basic access checks
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
@ -110,13 +111,14 @@ $reportname = get_string('modulename', 'gradereport_grader');
|
||||
// Initialise the grader report object
|
||||
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
|
||||
|
||||
$PAGE->requires->yui_lib('event')->in_head(); // TODO change the JS so we can remove the ->in_head()
|
||||
$PAGE->requires->yui_lib('json')->in_head();
|
||||
$PAGE->requires->yui_lib('connection')->in_head();
|
||||
$PAGE->requires->yui_lib('dragdrop')->in_head();
|
||||
$PAGE->requires->yui_lib('element')->in_head();
|
||||
$PAGE->requires->yui_lib('container')->in_head();
|
||||
$PAGE->requires->js('grade/report/grader/functions.js')->in_head();
|
||||
$PAGE->requires->yui_lib('event');
|
||||
$PAGE->requires->yui_lib('json');
|
||||
$PAGE->requires->yui_lib('connection');
|
||||
$PAGE->requires->yui_lib('dragdrop');
|
||||
$PAGE->requires->yui_lib('element');
|
||||
$PAGE->requires->yui_lib('container');
|
||||
$PAGE->requires->js('grade/report/grader/functions.js');
|
||||
$PAGE->requires->js('grade/report/grader/grader.js');
|
||||
|
||||
if ($report->get_pref('enableajax')) {
|
||||
$report = new grade_report_grader_ajax($courseid, $gpr, $context, $page, $sortitemid);
|
||||
@ -206,161 +208,4 @@ echo '<div id="hiddentooltiproot">tooltip panel</div>';
|
||||
if ($report->get_pref('enableajax')) {
|
||||
require_once 'ajax.php';
|
||||
}
|
||||
|
||||
// Print YUI tooltip code
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
YAHOO.namespace("graderreport");
|
||||
|
||||
function init() {
|
||||
// Adjust height of header c0
|
||||
var rows = document.getElementsByClassName('heading_name_row');
|
||||
var header_cell_region = YAHOO.util.Dom.getRegion(rows[rows.length-1].firstChild);
|
||||
var height = header_cell_region.bottom - header_cell_region.top;
|
||||
YAHOO.util.Dom.setStyle('studentheader', 'height', height + 'px');
|
||||
|
||||
// attach event listener to the table for mouseover and mouseout
|
||||
var table = document.getElementById('user-grades');
|
||||
YAHOO.util.Event.on(table, 'mouseover', YAHOO.graderreport.mouseoverHandler);
|
||||
YAHOO.util.Event.on(table, 'mouseout', YAHOO.graderreport.mouseoutHandler);
|
||||
|
||||
// Make single panel that can be dynamically re-rendered wit the right data.
|
||||
YAHOO.graderreport.panelEl = new YAHOO.widget.Panel("tooltipPanel", {
|
||||
|
||||
draggable: false,
|
||||
visible: false,
|
||||
close: false,
|
||||
preventcontextoverlap: true,
|
||||
underlay: 'none'
|
||||
});
|
||||
|
||||
YAHOO.graderreport.panelEl.render(table);
|
||||
|
||||
}
|
||||
|
||||
YAHOO.graderreport.mouseoverHandler = function (e) {
|
||||
|
||||
var tempNode = '';
|
||||
var searchString = '';
|
||||
var tooltipNode = '';
|
||||
|
||||
// get the element that we just moved the mouse over
|
||||
var elTarget = YAHOO.util.Event.getTarget(e);
|
||||
|
||||
|
||||
// if it was part of the yui panel, we don't want to redraw yet
|
||||
searchString = /fullname|itemname|feedback/;
|
||||
if (elTarget.className.search(searchString) > -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// move up until we are in the actual cell, not any other child div or span
|
||||
while (elTarget.id != 'user-grades') {
|
||||
if(elTarget.nodeName.toUpperCase() == "TD") {
|
||||
break;
|
||||
} else {
|
||||
elTarget = elTarget.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
// only make a tooltip for cells with grades
|
||||
if (elTarget.className.search('grade cell') > -1) {
|
||||
|
||||
// each time we go over a new cell, we need to put it's tooltip into a div to stop it from
|
||||
// popping up on top of the panel.
|
||||
|
||||
// don't do anything if we have already made the tooltip div
|
||||
var makeTooltip = true
|
||||
for (var k=0; k < elTarget.childNodes.length; k++) {
|
||||
if (typeof(elTarget.childNodes[k].className) != 'undefined') {
|
||||
if (elTarget.childNodes[k].className.search('tooltipDiv') > -1) {
|
||||
makeTooltip = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if need to, make the tooltip div and append it to the cell
|
||||
if (makeTooltip) {
|
||||
|
||||
tempNode = document.createElement("div");
|
||||
tempNode.className = "tooltipDiv";
|
||||
tempNode.innerHTML = elTarget.title;
|
||||
elTarget.appendChild(tempNode);
|
||||
elTarget.title = null;
|
||||
}
|
||||
|
||||
// Get the tooltip div
|
||||
elChildren = elTarget.childNodes;
|
||||
for (var m=0; m < elChildren.length; m++) {
|
||||
if (typeof(elChildren[m].className) != 'undefined') {
|
||||
if (elChildren[m].className.search('tooltipDiv') > -1) {
|
||||
tooltipNode = elChildren[m];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//build and show the tooltip
|
||||
YAHOO.graderreport.panelEl.setBody(tooltipNode.innerHTML);
|
||||
YAHOO.graderreport.panelEl.render(elTarget);
|
||||
YAHOO.graderreport.panelEl.show()
|
||||
}
|
||||
}
|
||||
|
||||
// only hide the overlay if the mouse has not moved over it
|
||||
YAHOO.graderreport.mouseoutHandler = function (e) {
|
||||
|
||||
var classVar = '';
|
||||
var searchString = '';
|
||||
var newTargetClass = '';
|
||||
var newTarget = YAHOO.util.Event.getRelatedTarget(e);
|
||||
|
||||
// deals with an error if the mouseout event is over the lower scrollbar
|
||||
try {
|
||||
classVar = newTarget.className;
|
||||
} catch (err) {
|
||||
YAHOO.graderreport.panelEl.hide()
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we are over any part of the panel, do not hide
|
||||
// do this by walking up the DOM till we reach table level, looking for panel tag
|
||||
while ((typeof(newTarget.id) == 'undefined') || (newTarget.id != 'user-grades')) {
|
||||
|
||||
try {
|
||||
newTargetClass = newTarget.className;
|
||||
} catch (err) {
|
||||
// we've gone over the scrollbar again
|
||||
YAHOO.graderreport.panelEl.hide()
|
||||
return false;
|
||||
}
|
||||
searchString = /yui-panel|grade cell/;
|
||||
if (newTargetClass.search(searchString) > -1) {
|
||||
// we're in the panel so don't hide it
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newTarget.nodeName.toUpperCase() == "HTML") {
|
||||
// we missed the user-grades table altogether by moving down off screen to read a long one
|
||||
YAHOO.graderreport.panelEl.hide()
|
||||
break;
|
||||
}
|
||||
|
||||
newTarget = newTarget.parentNode;
|
||||
}
|
||||
|
||||
// no panel so far and we went up to the
|
||||
YAHOO.graderreport.panelEl.hide()
|
||||
|
||||
}
|
||||
|
||||
|
||||
YAHOO.util.Event.onDOMReady(init);
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
?>
|
||||
|
@ -932,7 +932,7 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
|
||||
function get_studentnameshtml() {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $OUTPUT;
|
||||
$studentshtml = '';
|
||||
|
||||
$showuserimage = $this->get_pref('showuserimage');
|
||||
|
@ -218,7 +218,6 @@ vertical-align:middle;
|
||||
.grade-report-grader table {
|
||||
border-collapse:collapse;
|
||||
background-color:#fff;
|
||||
font-size:10px;
|
||||
border-color:#cecece;
|
||||
}
|
||||
|
||||
@ -387,7 +386,7 @@ padding-top:20px;
|
||||
.grade-report-grader .right_scroller {
|
||||
width:auto;
|
||||
clear:none;
|
||||
overflow-x:auto;
|
||||
overflow-x:scroll;
|
||||
}
|
||||
|
||||
.grade-report-grader table tr.avg,.grade-report-grader table tr.groupavg td,.grade-report-grader table tr.avg td,.grade-report-grader table tr.groupavg th,.grade-report-grader table tr.avg th,.grade-report-grader table tr.controls_row,.grade-report-grader table tr.controls_row th,.grade-report-grader table tr.range_row,.grade-report-grader table tr.range_row th,div.right_scroller tr {
|
||||
@ -442,37 +441,6 @@ white-space:nowrap;
|
||||
width:2000px;
|
||||
}
|
||||
|
||||
.ie .right_scroller {
|
||||
padding-bottom:15px;
|
||||
overflow-y:hidden;
|
||||
}
|
||||
|
||||
.ie table#fixed_column th {
|
||||
height:40.5px;
|
||||
}
|
||||
|
||||
.ie table#fixed_column tr.avg th {
|
||||
height:21px;
|
||||
}
|
||||
|
||||
.ie div.left_scroller td {
|
||||
height:42px;
|
||||
}
|
||||
|
||||
.ie6 div.left_scroller {
|
||||
margin-top:40px;
|
||||
}
|
||||
|
||||
.ie6 div.right_scroller {
|
||||
margin-top:40px;
|
||||
width:auto;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.ie6 .excludedfloater {
|
||||
font-size:7px;
|
||||
}
|
||||
|
||||
.grade_icons img.ajax {
|
||||
float:right;
|
||||
}
|
||||
@ -520,7 +488,7 @@ background-color:#f3ead8;
|
||||
}
|
||||
|
||||
.grade-report-grader div.left_scroller tr,.grade-report-grader div.right_scroller tr,.grade-report-grader div.left_scroller td,.grade-report-grader div.right_scroller td,.grade-report-grader div.left_scroller th,.grade-report-grader div.right_scroller th {
|
||||
height:4em;
|
||||
height:4.5em;
|
||||
font-size:10px;
|
||||
}
|
||||
|
||||
@ -558,12 +526,6 @@ vertical-align:middle;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
<?php include($CFG->dirroot.'/lib/yui/container/assets/skins/sam/container.css') ?>
|
||||
.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(<?php echo $CFG->wwwroot."/lib/yui" ?>/assets/skins/sam/sprite.png) repeat-x 0 -200px;}
|
||||
.yui-skin-sam .container-close{border-color: #45c;position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(<?php echo $CFG->wwwroot."/lib/yui" ?>/assets/skins/sam/sprite.png) no-repeat 0 -300px;cursor:pointer;}
|
||||
.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(<?php echo $CFG->wwwroot."/lib/yui" ?>/assets/skins/sam/sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}
|
||||
|
||||
.grade-report-grader .yui-overlay a.container-close {
|
||||
margin-top: -3px;
|
||||
}
|
||||
@ -572,4 +534,34 @@ vertical-align:middle;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ie .right_scroller {
|
||||
padding-bottom:15px;
|
||||
overflow-y:hidden;
|
||||
}
|
||||
|
||||
.ie table#fixed_column th {
|
||||
height:4.5em;
|
||||
}
|
||||
|
||||
.ie table#fixed_column tr.avg th {
|
||||
height:2.1em;
|
||||
}
|
||||
|
||||
.ie div.left_scroller td {
|
||||
height:4.5em;
|
||||
}
|
||||
|
||||
.ie div.left_scroller {
|
||||
margin-top:-0.6em;
|
||||
margin-right: -0.6em;
|
||||
}
|
||||
|
||||
.ie6 div.right_scroller {
|
||||
margin-top:4em;
|
||||
width:auto;
|
||||
position:absolute;
|
||||
}
|
||||
|
||||
.ie6 .excludedfloater {
|
||||
font-size:7px;
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ class html_field extends labelled_html_component {
|
||||
* @param int $maxlength Sets the maxlength attribute of the field. Not set by default
|
||||
* @return html_field The field component
|
||||
*/
|
||||
public static function make_text($name='unnamed', $value, $alt, $maxlength=0) {
|
||||
public static function make_text($name='unnamed', $value, $alt='', $maxlength=0) {
|
||||
$field = new html_field();
|
||||
if (empty($alt)) {
|
||||
$alt = get_string('textfield');
|
||||
@ -1605,7 +1605,7 @@ class moodle_paging_bar extends moodle_html_component {
|
||||
* @return void
|
||||
*/
|
||||
public function prepare() {
|
||||
if (empty($this->totalcount)) {
|
||||
if (!isset($this->totalcount) || is_null($this->totalcount)) {
|
||||
throw new coding_exception('moodle_paging_bar requires a totalcount value.');
|
||||
}
|
||||
if (!isset($this->page) || is_null($this->page)) {
|
||||
|
@ -1802,23 +1802,31 @@ class moodle_core_renderer extends moodle_renderer_base {
|
||||
* @return string the HTML for the <input>
|
||||
*/
|
||||
public function textfield($field) {
|
||||
return $this->output_tag('span', array('class' => "textfield $field->name"), $this->field($field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an <input/> element
|
||||
*
|
||||
* @param html_field $field a html_field object
|
||||
* @return string the HTML for the <input>
|
||||
*/
|
||||
public function field($field) {
|
||||
$field = clone($field);
|
||||
$field->prepare();
|
||||
$this->prepare_event_handlers($field);
|
||||
$output = $this->output_start_tag('span', array('class' => "textfield $field->name"));
|
||||
if (!empty($field->label)) {
|
||||
if (!empty($field->label->text)) {
|
||||
$output .= $this->label($field->label);
|
||||
}
|
||||
$output .= $this->output_empty_tag('input', array(
|
||||
'type' => 'text',
|
||||
return $this->output_empty_tag('input', array(
|
||||
'type' => $field->type,
|
||||
'name' => $field->name,
|
||||
'id' => $field->id,
|
||||
'value' => $field->value,
|
||||
'style' => $field->style,
|
||||
'alt' => $field->alt,
|
||||
'title' => $field->title,
|
||||
'maxlength' => $field->maxlength));
|
||||
$output .= $this->output_end_tag('span');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user