MDL-11835 Implemented changes discussed in http://moodle.org/mod/forum/discuss.php?d=85908. Also added item name and module name and category name (for category totals) in alt tags of icons
This commit is contained in:
+41
-13
@@ -836,6 +836,32 @@ class grade_structure {
|
||||
function get_item_eid($grade_item) {
|
||||
return 'i'.$grade_item->id;
|
||||
}
|
||||
|
||||
function get_params_for_iconstr($element) {
|
||||
$strparams = new stdClass();
|
||||
$strparams->category = '';
|
||||
$strparams->itemname = '';
|
||||
$strparams->itemmodule = '';
|
||||
if (!method_exists($element['object'], 'get_name')) {
|
||||
return $strparams;
|
||||
}
|
||||
|
||||
$strparams->itemname = $element['object']->get_name();
|
||||
|
||||
// If element name is categorytotal, get the name of the parent category
|
||||
if ($strparams->itemname == get_string('categorytotal', 'grades')) {
|
||||
$parent = $element['object']->get_parent_category();
|
||||
$strparams->category = $parent->get_name() . ' ';
|
||||
} else {
|
||||
$strparams->category = '';
|
||||
}
|
||||
|
||||
$strparams->itemmodule = null;
|
||||
if (isset($element['object']->itemmodule)) {
|
||||
$strparams->itemmodule = $element['object']->itemmodule;
|
||||
}
|
||||
return $strparams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return edit icon for give element
|
||||
@@ -860,6 +886,10 @@ class grade_structure {
|
||||
$strfeedback = get_string('feedback');
|
||||
}
|
||||
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
if ($element['type'] == 'item' or $element['type'] == 'category') {
|
||||
}
|
||||
|
||||
$object = $element['object'];
|
||||
$overlib = '';
|
||||
|
||||
@@ -867,6 +897,7 @@ class grade_structure {
|
||||
case 'item':
|
||||
case 'categoryitem':
|
||||
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;
|
||||
} else {
|
||||
@@ -876,6 +907,7 @@ class grade_structure {
|
||||
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);
|
||||
break;
|
||||
@@ -919,12 +951,9 @@ class grade_structure {
|
||||
return '';
|
||||
}
|
||||
|
||||
static $strshow = null;
|
||||
static $strhide = null;
|
||||
if (is_null($strshow)) {
|
||||
$strshow = get_string('show');
|
||||
$strhide = get_string('hide');
|
||||
}
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
$strshow = get_string('showverbose', 'grades', $strparams);
|
||||
$strhide = get_string('hideverbose', 'grades', $strparams);
|
||||
|
||||
if ($element['object']->is_hidden()) {
|
||||
$icon = 'show';
|
||||
@@ -957,12 +986,9 @@ class grade_structure {
|
||||
function get_locking_icon($element, $gpr) {
|
||||
global $CFG;
|
||||
|
||||
static $strunlock = null;
|
||||
static $strlock = null;
|
||||
if (is_null($strunlock)) {
|
||||
$strunlock = get_string('unlock', 'grades');
|
||||
$strlock = get_string('lock', 'grades');
|
||||
}
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
$strunlock = get_string('unlockverbose', 'grades', $strparams);
|
||||
$strlock = get_string('lockverbose', 'grades', $strparams);
|
||||
|
||||
if ($element['object']->is_locked()) {
|
||||
$icon = 'unlock';
|
||||
@@ -1009,9 +1035,11 @@ class grade_structure {
|
||||
|
||||
$type = $element['type'];
|
||||
$object = $element['object'];
|
||||
|
||||
|
||||
if ($type == 'item' or $type == 'courseitem' or $type == 'categoryitem') {
|
||||
$streditcalculation = get_string('editcalculation', 'grades');
|
||||
$strparams = $this->get_params_for_iconstr($element);
|
||||
$streditcalculation = get_string('editcalculationverbose', 'grades', $strparams);
|
||||
|
||||
// show calculation icon only when calculation possible
|
||||
if ((!$object->is_external_item() or $object->is_outcome_item())
|
||||
|
||||
@@ -163,6 +163,7 @@ $reporthtml = '<script src="functions.js" type="text/javascript"></script>';
|
||||
|
||||
$reporthtml .= '<table id="user-grades" class="gradestable flexible boxaligncenter generaltable">';
|
||||
$reporthtml .= $report->get_headerhtml();
|
||||
$reporthtml .= $report->get_iconshtml();
|
||||
$reporthtml .= $report->get_rangehtml();
|
||||
$reporthtml .= $report->get_studentshtml();
|
||||
$reporthtml .= $report->get_avghtml(true);
|
||||
|
||||
@@ -566,7 +566,7 @@ class grade_report_grader extends grade_report {
|
||||
// Element is a category
|
||||
else if ($type == 'category') {
|
||||
$headerhtml .= '<th class="header '. $columnclass.' category'.$catlevel.'" '.$colspan.' scope="col">'
|
||||
. $element['object']->get_name();
|
||||
. shorten_text($element['object']->get_name());
|
||||
$headerhtml .= $this->get_collapsing_icon($element);
|
||||
|
||||
// Print icons
|
||||
@@ -597,8 +597,9 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
|
||||
$headerlink = $this->gtree->get_element_header($element, true, $this->get_pref('showactivityicons'), false);
|
||||
$headerhtml .= '<th class="header '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex)">'. $headerlink . $arrow;
|
||||
$headerhtml .= $this->get_icons($element) . '</th>';
|
||||
$headerhtml .= '<th class="header '.$columnclass.' '.$type.$catlevel.$hidden.'" scope="col" onclick="set_col(this.cellIndex)">'
|
||||
. shorten_text($headerlink) . $arrow;
|
||||
$headerhtml .= '</th>';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1041,6 +1042,34 @@ class grade_report_grader extends grade_report {
|
||||
}
|
||||
return $scalehtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and return the HTML row of ranges for each column (i.e. range).
|
||||
* @return string HTML
|
||||
*/
|
||||
function get_iconshtml() {
|
||||
global $USER;
|
||||
|
||||
$iconshtml = '';
|
||||
if ($USER->gradeediting[$this->courseid]) {
|
||||
|
||||
$iconshtml = '<tr class="r'.$this->rowcount++.'">'
|
||||
. '<th class="header c0 range" scope="row">'.$this->get_lang_string('controls','grades').'</th>';
|
||||
|
||||
$columncount = 1;
|
||||
foreach ($this->gtree->items as $itemid=>$unused) {
|
||||
// emulate grade element
|
||||
$item =& $this->gtree->items[$itemid];
|
||||
|
||||
$eid = $this->gtree->get_item_eid($item);
|
||||
$element = $this->gtree->locate_element($eid);
|
||||
|
||||
$iconshtml .= '<td class="cell c'.$columncount++.' icons">' . $this->get_icons($element) . '</td>';
|
||||
}
|
||||
$iconshtml .= '</tr>';
|
||||
}
|
||||
return $iconshtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a grade_category, grade_item or grade_grade, this function
|
||||
|
||||
@@ -59,6 +59,9 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades {
|
||||
border-width:1px;
|
||||
@@ -112,6 +115,7 @@
|
||||
.grade-report-grader table#user-grades th.category {
|
||||
border-width:1px 1px 0px 1px;
|
||||
border-style:solid;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades th.user {
|
||||
@@ -124,6 +128,11 @@
|
||||
.grade-report-grader table#user-grades td.topleft {
|
||||
border-width:0px 1px 0px 1px;
|
||||
border-style:solid;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.grade-report-grader table#participants th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.grade-report-grader table#user-grades td.fillerfirst {
|
||||
@@ -139,8 +148,10 @@
|
||||
.grade-report-grader table#user-grades th.item {
|
||||
border-width:1px 1px 1px 1px;
|
||||
border-style:solid;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
.grade-report-grader div.gradertoggle {
|
||||
display: inline;
|
||||
margin-left: 20px;
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.com //
|
||||
// //
|
||||
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.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("HTML/QuickForm/link.php");
|
||||
|
||||
/**
|
||||
* HTML class for a multiple checkboxes state controller
|
||||
*
|
||||
* @author Nicolas Connault <[email protected]>
|
||||
* @version 1.0
|
||||
* @since PHP4.04pl1
|
||||
* @access public
|
||||
*/
|
||||
class MoodleQuickForm_selectallornone extends HTML_QuickForm_link {
|
||||
/**
|
||||
* The original state of the checkboxes controlled by this element. This determines whether the first click of this element will switch them all to
|
||||
* checked or to unchecked. It doesn't change the checked state of the original elements (there could be a mixed of checked/unchecked there), but
|
||||
* there has to be a decision as to which action will be taken by clicking "select all/select none" the first time.
|
||||
* @var int $originalValue
|
||||
*/
|
||||
var $_originalValue = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param string $elementName The name of the group of advcheckboxes this element controls
|
||||
* @param string $text The text of the link. Defaults to "select all/none"
|
||||
* @param array $attributes associative array of HTML attributes
|
||||
* @param int $originalValue The original general state of the checkboxes before the user first clicks this element
|
||||
*/
|
||||
function MoodleQuickForm_selectallornone($elementName=null, $text=null, $attributes=null, $originalValue=0) {
|
||||
if (is_null($originalValue)) {
|
||||
$originalValue = 0;
|
||||
}
|
||||
|
||||
global $FULLME;
|
||||
$this->_originalValue = $originalValue;
|
||||
|
||||
if (is_null($elementName)) {
|
||||
return;
|
||||
}
|
||||
$elementLabel = ' ';
|
||||
$strselectallornone = get_string('selectallornone', 'form');
|
||||
$attributes['onmouseover'] = "window.status='" . $strselectallornone . "';";
|
||||
$attributes['onmouseout'] = "window.status='';";
|
||||
$attributes['onclick'] = "html_quickform_toggle_checkboxes($elementName); return false;";
|
||||
$select_value = optional_param('select'. $elementName, $originalValue, PARAM_INT);
|
||||
|
||||
if ($select_value == 0) {
|
||||
$new_select_value = 1;
|
||||
} else {
|
||||
$new_select_value = 0;
|
||||
}
|
||||
|
||||
$old_selectstr = "&select$elementName=$select_value";
|
||||
$new_selectstr = "&select$elementName=$new_select_value";
|
||||
$new_fullme = str_replace($old_selectstr, '', $FULLME);
|
||||
|
||||
$href = "$new_fullme$new_selectstr";
|
||||
|
||||
if (empty($text)) {
|
||||
$text = $strselectallornone;
|
||||
}
|
||||
$this->HTML_QuickForm_link($elementName, $elementLabel, $href, $text, $attributes);
|
||||
}
|
||||
|
||||
function toHtml() {
|
||||
if (is_null($this->_originalValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group = $this->_attributes['name'];
|
||||
if ($this->_flagFrozen) {
|
||||
$js = '';
|
||||
} else {
|
||||
$js = "<script type=\"text/javascript\">\n//<![CDATA[\n";
|
||||
if (!defined('HTML_QUICKFORM_SELECTALLORNONE_EXISTS')) {
|
||||
$js .= <<<EOS
|
||||
function html_quickform_toggle_checkboxes(group) {
|
||||
var checkboxes = getElementsByClassName(document, 'input', 'checkboxgroup' + group);
|
||||
var newvalue = false;
|
||||
var global = eval('html_quickform_checkboxgroup' + group + ';');
|
||||
if (global == 1) {
|
||||
eval('html_quickform_checkboxgroup' + group + ' = 0;');
|
||||
newvalue = '';
|
||||
} else {
|
||||
eval('html_quickform_checkboxgroup' + group + ' = 1;');
|
||||
newvalue = 'checked';
|
||||
}
|
||||
|
||||
for (i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = newvalue;
|
||||
}
|
||||
}
|
||||
EOS;
|
||||
define('HTML_QUICKFORM_SELECTALLORNONE_EXISTS', true);
|
||||
}
|
||||
$js .= "var html_quickform_checkboxgroup$group=$this->_originalValue;";
|
||||
|
||||
$js .= "//]]>\n</script>";
|
||||
}
|
||||
return $js . parent::toHtml();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user