MDL-19797 Upgraded most output code in grader report

This commit is contained in:
nicolasconnault 2009-08-28 05:29:05 +00:00
parent c402af03a8
commit 319770d747
8 changed files with 311 additions and 223 deletions

View file

@ -13,6 +13,10 @@ function set_row(idx) {
} }
} }
function yui_set_row(e) {
set_row(this.parentNode.rowIndex);
}
/** highlight/unset the column of a table **/ /** highlight/unset the column of a table **/
function set_col(idx) { function set_col(idx) {
var table = document.getElementById('user-grades'); var table = document.getElementById('user-grades');

View file

@ -180,22 +180,14 @@ $reporthtml .= $report->get_endhtml();
$reporthtml .= '</div>'; $reporthtml .= '</div>';
// print submit button // print submit button
if ($USER->gradeediting[$course->id] and !$report->get_pref('enableajax')) { if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading')) && !$report->get_pref('enableajax')) {
echo '<form action="index.php" method="post">'; $form = new html_form();
echo '<div>'; $form->url = new moodle_url('index.php', array('id' => $courseid, 'report' => 'grader'));
echo '<input type="hidden" value="'.$courseid.'" name="id" />'; $form->button->text = get_string('update');
echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />'; $form->button->add_class('submit');
echo '<input type="hidden" value="grader" name="report"/>'; echo $OUTPUT->form($form, $reporthtml);
} } else {
echo $reporthtml;
echo $reporthtml;
// print submit button
if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback')
||
$report->get_pref('quickgrading')) && !$report->get_pref('enableajax')) {
echo '<div class="submit"><input type="submit" value="'.get_string('update').'" /></div>';
echo '</div></form>';
} }
// prints paging bar at bottom for large pages // prints paging bar at bottom for large pages
@ -203,7 +195,7 @@ if (!empty($studentsperpage) && $studentsperpage >= 20) {
echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl)); echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
} }
echo '<div id="hiddentooltiproot">tooltip panel</div>'; echo $OUTPUT->container('tooltip panel', '', 'hiddentooltiproot');
// Print AJAX code // Print AJAX code
if ($report->get_pref('enableajax')) { if ($report->get_pref('enableajax')) {
require_once 'ajax.php'; require_once 'ajax.php';

View file

@ -63,9 +63,9 @@ class grade_report_grader extends grade_report {
/** /**
* The bound params for $userselect * The bound params for $userselect
* @var array $userselect_params * @var array $userselectparams
*/ */
public $userselect_params = array(); public $userselectparams = array();
/** /**
* List of collapsed categories from user preference * List of collapsed categories from user preference
@ -84,7 +84,7 @@ class grade_report_grader extends grade_report {
* */ * */
public $canviewhidden; public $canviewhidden;
var $preferences_page=false; var $preferencespage=false;
/** /**
* Constructor. Sets local copies of user preferences and initialises grade_tree. * Constructor. Sets local copies of user preferences and initialises grade_tree.
@ -125,17 +125,15 @@ class grade_report_grader extends grade_report {
$this->sortitemid = $sortitemid; $this->sortitemid = $sortitemid;
// base url for sorting by first/last name // base url for sorting by first/last name
$this->baseurl = new moodle_url('index.php', array('id' => $this->courseid));
$studentsperpage = $this->get_pref('studentsperpage'); $studentsperpage = $this->get_pref('studentsperpage');
$perpage = '';
$curpage = '';
if (!empty($studentsperpage)) { if (!empty($studentsperpage)) {
$perpage = '&amp;perpage='.$studentsperpage; $this->baseurl->params(array('perpage' => $studentsperpage, 'page' => $this->page));
$curpage = '&amp;page='.$this->page;
} }
$this->baseurl = 'index.php?id='.$this->courseid. $perpage.$curpage.'&amp;';
$this->pbarurl = 'index.php?id='.$this->courseid.$perpage.'&amp;'; $this->pbarurl = new moodle_url('index.php', array('id' => $this->courseid, 'perpage' => $studentsperpage));
$this->setup_groups(); $this->setup_groups();
@ -174,9 +172,9 @@ class grade_report_grader extends grade_report {
// skip, not a grade nor feedback // skip, not a grade nor feedback
if (strpos($varname, 'grade') === 0) { if (strpos($varname, 'grade') === 0) {
$data_type = 'grade'; $datatype = 'grade';
} else if (strpos($varname, 'feedback') === 0) { } else if (strpos($varname, 'feedback') === 0) {
$data_type = 'feedback'; $datatype = 'feedback';
} else { } else {
continue; continue;
} }
@ -192,15 +190,15 @@ class grade_report_grader extends grade_report {
continue; continue;
} }
if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) { // we must verify course id here! if (!$gradeitem = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) { // we must verify course id here!
print_error('invalidgradeitmeid'); print_error('invalidgradeitmeid');
} }
// Pre-process grade // Pre-process grade
if ($data_type == 'grade') { if ($datatype == 'grade') {
$feedback = false; $feedback = false;
$feedbackformat = false; $feedbackformat = false;
if ($grade_item->gradetype == GRADE_TYPE_SCALE) { if ($gradeitem->gradetype == GRADE_TYPE_SCALE) {
if ($postedvalue == -1) { // -1 means no grade if ($postedvalue == -1) { // -1 means no grade
$finalgrade = null; $finalgrade = null;
} else { } else {
@ -215,7 +213,7 @@ class grade_report_grader extends grade_report {
if (is_null($finalgrade)) { if (is_null($finalgrade)) {
// ok // ok
} else { } else {
$bounded = $grade_item->bounded_grade($finalgrade); $bounded = $gradeitem->bounded_grade($finalgrade);
if ($bounded > $finalgrade) { if ($bounded > $finalgrade) {
$errorstr = 'lessthanmin'; $errorstr = 'lessthanmin';
} else if ($bounded < $finalgrade) { } else if ($bounded < $finalgrade) {
@ -226,11 +224,11 @@ class grade_report_grader extends grade_report {
$user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname'); $user = $DB->get_record('user', array('id' => $userid), 'id, firstname, lastname');
$gradestr = new object(); $gradestr = new object();
$gradestr->username = fullname($user); $gradestr->username = fullname($user);
$gradestr->itemname = $grade_item->get_name(); $gradestr->itemname = $gradeitem->get_name();
$warnings[] = get_string($errorstr, 'grades', $gradestr); $warnings[] = get_string($errorstr, 'grades', $gradestr);
} }
} else if ($data_type == 'feedback') { } else if ($datatype == 'feedback') {
$finalgrade = false; $finalgrade = false;
$trimmed = trim($postedvalue); $trimmed = trim($postedvalue);
if (empty($trimmed)) { if (empty($trimmed)) {
@ -258,7 +256,7 @@ class grade_report_grader extends grade_report {
} }
} }
$grade_item->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE); $gradeitem->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE);
} }
return $warnings; return $warnings;
@ -328,10 +326,10 @@ class grade_report_grader extends grade_report {
public function load_users() { public function load_users() {
global $CFG, $DB; global $CFG, $DB;
list($usql, $gbr_params) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0'); list($usql, $gbrparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
if (is_numeric($this->sortitemid)) { if (is_numeric($this->sortitemid)) {
$params = array_merge(array('gitemid'=>$this->sortitemid), $gbr_params, $this->groupwheresql_params); $params = array_merge(array('gitemid'=>$this->sortitemid), $gbrparams, $this->groupwheresql_params);
// the MAX() magic is required in order to please PG // the MAX() magic is required in order to please PG
$sort = "MAX(g.finalgrade) $this->sortorder"; $sort = "MAX(g.finalgrade) $this->sortorder";
@ -357,7 +355,7 @@ class grade_report_grader extends grade_report {
$sort = "u.idnumber $this->sortorder"; break; $sort = "u.idnumber $this->sortorder"; break;
} }
$params = array_merge($gbr_params, $this->groupwheresql_params); $params = array_merge($gbrparams, $this->groupwheresql_params);
$sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, u.imagealt, u.picture, u.idnumber $sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, u.imagealt, u.picture, u.idnumber
FROM {user} u FROM {user} u
JOIN {role_assignments} ra ON u.id = ra.userid JOIN {role_assignments} ra ON u.id = ra.userid
@ -427,37 +425,37 @@ class grade_report_grader extends grade_report {
* @return string HTML code * @return string HTML code
*/ */
public function get_toggles_html() { public function get_toggles_html() {
global $CFG, $USER, $COURSE; global $CFG, $USER, $COURSE, $OUTPUT;
$html = '<div id="grade-report-toggles">'; $html = '';
if ($USER->gradeediting[$this->courseid]) { if ($USER->gradeediting[$this->courseid]) {
if (has_capability('moodle/grade:manage', $this->context) or has_capability('moodle/grade:hide', $this->context)) { if (has_capability('moodle/grade:manage', $this->context) or has_capability('moodle/grade:hide', $this->context)) {
$html .= $this->print_toggle('eyecons', true); $html .= $this->print_toggle('eyecons');
} }
if (has_capability('moodle/grade:manage', $this->context) if (has_capability('moodle/grade:manage', $this->context)
or has_capability('moodle/grade:lock', $this->context) or has_capability('moodle/grade:lock', $this->context)
or has_capability('moodle/grade:unlock', $this->context)) { or has_capability('moodle/grade:unlock', $this->context)) {
$html .= $this->print_toggle('locks', true); $html .= $this->print_toggle('locks');
} }
if (has_capability('moodle/grade:manage', $this->context)) { if (has_capability('moodle/grade:manage', $this->context)) {
$html .= $this->print_toggle('quickfeedback', true); $html .= $this->print_toggle('quickfeedback');
} }
if (has_capability('moodle/grade:manage', $this->context)) { if (has_capability('moodle/grade:manage', $this->context)) {
$html .= $this->print_toggle('calculations', true); $html .= $this->print_toggle('calculations');
} }
} }
if ($this->canviewhidden) { if ($this->canviewhidden) {
$html .= $this->print_toggle('averages', true); $html .= $this->print_toggle('averages');
} }
$html .= $this->print_toggle('ranges', true); $html .= $this->print_toggle('ranges');
if (!empty($CFG->enableoutcomes)) { if (!empty($CFG->enableoutcomes)) {
$html .= $this->print_toggle('nooutcomes', true); $html .= $this->print_toggle('nooutcomes');
} }
$html .= '</div>';
return $html; return $OUTPUT->container($html, 'grade-report-toggles');
} }
/** /**
@ -466,54 +464,53 @@ class grade_report_grader extends grade_report {
* @param bool $return Whether to return the HTML string rather than printing it * @param bool $return Whether to return the HTML string rather than printing it
* @return void * @return void
*/ */
public function print_toggle($type, $return=false) { public function print_toggle($type) {
global $CFG, $OUTPUT; global $CFG, $OUTPUT;
$icons = array('eyecons' => 't/hide.gif', $icons = array('eyecons' => 't/hide',
'calculations' => 't/calc.gif', 'calculations' => 't/calc',
'locks' => 't/lock.gif', 'locks' => 't/lock',
'averages' => 't/mean.gif', 'averages' => 't/mean',
'quickfeedback' => 't/feedback.gif', 'quickfeedback' => 't/feedback',
'nooutcomes' => 't/outcomes.gif'); 'nooutcomes' => 't/outcomes');
$pref_name = 'grade_report_show' . $type; $prefname = 'grade_report_show' . $type;
if (array_key_exists($pref_name, $CFG)) { if (array_key_exists($prefname, $CFG)) {
$show_pref = get_user_preferences($pref_name, $CFG->$pref_name); $showpref = get_user_preferences($prefname, $CFG->$prefname);
} else { } else {
$show_pref = get_user_preferences($pref_name); $showpref = get_user_preferences($prefname);
} }
$strshow = $this->get_lang_string('show' . $type, 'grades'); $strshow = $this->get_lang_string('show' . $type, 'grades');
$strhide = $this->get_lang_string('hide' . $type, 'grades'); $strhide = $this->get_lang_string('hide' . $type, 'grades');
$show_hide = 'show'; $showhide = 'show';
$toggle_action = 1; $toggleaction = 1;
if ($show_pref) { if ($showpref) {
$show_hide = 'hide'; $showhide = 'hide';
$toggle_action = 0; $toggleaction = 0;
} }
if (array_key_exists($type, $icons)) { if (array_key_exists($type, $icons)) {
$image_name = $icons[$type]; $imagename = $icons[$type];
} else { } else {
$image_name = "t/$type.gif"; $imagename = "t/$type.gif";
} }
$string = ${'str' . $show_hide}; $string = ${'str' . $showhide};
$img = '<img src="'.$OUTPUT->old_icon_url($image_name).'" class="iconsmall" alt="' $toggleicon = new moodle_action_icon();
.$string.'" title="'.$string.'" />'. "\n"; $toggleicon->image->src = $OUTPUT->old_icon_url($imagename);
$toggleicon->image->add_class('iconsmall');
$toggleicon->alt = $string;
$toggleicon->title = $string;
$toggleicon->link->url = $this->baseurl->out(false, array('toggle' => $toggleaction, 'toggle_type' => $type), false);
$retval = '<div class="gradertoggle">' . $img . '<a href="' . $this->baseurl . "&amp;toggle=$toggle_action&amp;toggle_type=$type\">" $retval = $OUTPUT->container($OUTPUT->action_icon($toggleicon, 'gradertoggle'));
. $string . '</a></div>';
if ($return) { return $retval;
return $retval;
} else {
echo $retval;
}
} }
/** /**
@ -521,7 +518,7 @@ class grade_report_grader extends grade_report {
* @return string $headerhtml * @return string $headerhtml
*/ */
public function get_headerhtml() { public function get_headerhtml() {
global $CFG, $USER; global $CFG, $USER, $OUTPUT;
$this->rowcount = 0; $this->rowcount = 0;
$fixedstudents = $this->is_fixed_students(); $fixedstudents = $this->is_fixed_students();
@ -560,7 +557,7 @@ class grade_report_grader extends grade_report {
$numrows = count($this->gtree->get_levels()); $numrows = count($this->gtree->get_levels());
$columns_to_unset = array(); $columnstounset = array();
foreach ($this->gtree->get_levels() as $key=>$row) { foreach ($this->gtree->get_levels() as $key=>$row) {
$columncount = 0; $columncount = 0;
@ -574,9 +571,12 @@ class grade_report_grader extends grade_report {
} else { } else {
$headerhtml .= '<tr class="heading r'.$this->rowcount++.'">'; $headerhtml .= '<tr class="heading r'.$this->rowcount++.'">';
if ($key == $numrows - 1) { if ($key == $numrows - 1) {
$headerhtml .= '<th class="header c'.$columncount++.'" scope="col"><a href="'.$this->baseurl.'&amp;sortitemid=firstname">' $sortfirstname = html_link::make(clone($this->baseurl), $strfirstname);
. $strfirstname . '</a> ' $sortfirstname->url->param('sortitemid', 'firstname');
. $firstarrow. '/ <a href="'.$this->baseurl.'&amp;sortitemid=lastname">' . $strlastname . '</a>'. $lastarrow .'</th>'; $sortlastname = html_link::make(clone($this->baseurl), $strlastname);
$sortlastname->url->param('sortitemid', 'lastname');
$headerhtml .= '<th class="header c'.$columncount++.'" scope="col">' . $OUTPUT->link($sortfirstname)
. $firstarrow. '/ ' . $OUTPUT->link($sortlastname) . $lastarrow .'</th>';
if ($showuseridnumber) { if ($showuseridnumber) {
if ('idnumber' == $this->sortitemid) { if ('idnumber' == $this->sortitemid) {
if ($this->sortorder == 'ASC') { if ($this->sortorder == 'ASC') {
@ -587,8 +587,9 @@ class grade_report_grader extends grade_report {
} else { } else {
$idnumberarrow = ''; $idnumberarrow = '';
} }
$headerhtml .= '<th class="header c'.$columncount++.' useridnumber" scope="col"><a href="'.$this->baseurl.'&amp;sortitemid=idnumber">' $sortidnumber = html_link::make(clone($this->baseurl), get_string('idnumber'));
. get_string('idnumber') . '</a> ' . $idnumberarrow . '</th>'; $sortidnumber->url->param('sortitemid', 'idnumber');
$headerhtml .= '<th class="header cc'.$columncount++.' useridnumber" scope="col">' . $OUTPUT->link($sortidnumber) . $idnumberarrow . '</th>';
} }
} else { } else {
$colspan=''; $colspan='';
@ -606,9 +607,9 @@ class grade_report_grader extends grade_report {
foreach ($row as $columnkey => $element) { foreach ($row as $columnkey => $element) {
$sort_link = ''; $sortlink = clone($this->baseurl);
if (isset($element['object']->id)) { if (isset($element['object']->id)) {
$sort_link = $this->baseurl.'&amp;sortitemid=' . $element['object']->id; $sortlink->param('sortitemid', $element['object']->id);
} }
$eid = $element['eid']; $eid = $element['eid'];
@ -656,12 +657,12 @@ class grade_report_grader extends grade_report {
if ($element['object']->id == $this->sortitemid) { if ($element['object']->id == $this->sortitemid) {
if ($this->sortorder == 'ASC') { if ($this->sortorder == 'ASC') {
$arrow = $this->get_sort_arrow('up', $sort_link); $arrow = $this->get_sort_arrow('up', $sortlink);
} else { } else {
$arrow = $this->get_sort_arrow('down', $sort_link); $arrow = $this->get_sort_arrow('down', $sortlink);
} }
} else { } else {
$arrow = $this->get_sort_arrow('move', $sort_link); $arrow = $this->get_sort_arrow('move', $sortlink);
} }
$hidden = ''; $hidden = '';
@ -699,27 +700,27 @@ class grade_report_grader extends grade_report {
$fixedstudents = $this->is_fixed_students(); $fixedstudents = $this->is_fixed_students();
// Preload scale objects for items with a scaleid // Preload scale objects for items with a scaleid
$scales_list = array(); $scaleslist = array();
$tabindices = array(); $tabindices = array();
foreach ($this->gtree->get_items() as $item) { foreach ($this->gtree->get_items() as $item) {
if (!empty($item->scaleid)) { if (!empty($item->scaleid)) {
$scales_list[] = $item->scaleid; $scaleslist[] = $item->scaleid;
} }
$tabindices[$item->id]['grade'] = $gradetabindex; $tabindices[$item->id]['grade'] = $gradetabindex;
$tabindices[$item->id]['feedback'] = $gradetabindex + $numusers; $tabindices[$item->id]['feedback'] = $gradetabindex + $numusers;
$gradetabindex += $numusers * 2; $gradetabindex += $numusers * 2;
} }
$scales_array = array(); $scalesarray = array();
if (!empty($scales_list)) { if (!empty($scaleslist)) {
$scales_array = $DB->get_records_list('scale', 'id', $scales_list); $scalesarray = $DB->get_records_list('scale', 'id', $scaleslist);
} }
$row_classes = array(' even ', ' odd '); $rowclasses = array(' even ', ' odd ');
$row_classes = array(' even ', ' odd '); $rowclasses = array(' even ', ' odd ');
foreach ($this->users as $userid => $user) { foreach ($this->users as $userid => $user) {
@ -727,26 +728,26 @@ class grade_report_grader extends grade_report {
$altered = array(); $altered = array();
$unknown = array(); $unknown = array();
} else { } else {
$hiding_affected = grade_grade::get_hiding_affected($this->grades[$userid], $this->gtree->get_items()); $hidingaffected = grade_grade::get_hiding_affected($this->grades[$userid], $this->gtree->get_items());
$altered = $hiding_affected['altered']; $altered = $hidingaffected['altered'];
$unknown = $hiding_affected['unknown']; $unknown = $hidingaffected['unknown'];
unset($hiding_affected); unset($hidingaffected);
} }
$columncount = 0; $columncount = 0;
if ($fixedstudents) { if ($fixedstudents) {
$studentshtml .= '<tr class="r'.$this->rowcount++ . $row_classes[$this->rowcount % 2] . '">'; $studentshtml .= '<tr class="r'.$this->rowcount++ . $rowclasses[$this->rowcount % 2] . '">';
} else { } else {
// Student name and link // Student name and link
$user_pic = null; $userpic = null;
if ($showuserimage) { if ($showuserimage) {
$user_pic = '<div class="userpic">' . $OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)) . '</div>'; $userpic = $OUTPUT->container($OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)), 'userpic');
} }
$studentshtml .= '<tr class="r'.$this->rowcount++ . $row_classes[$this->rowcount % 2] . '">' $userlink = html_link::make(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user));
.'<th class="c'.$columncount++.' user" scope="row" onclick="set_row(this.parentNode.rowIndex);">'.$user_pic $studentshtml .= '<tr class="r'.$this->rowcount++ . $rowclasses[$this->rowcount % 2] . '">'
.'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->course->id.'">' .'<th class="c'.$columncount++.' user" scope="row" onclick="set_row(this.parentNode.rowIndex);">'.$userpic
.fullname($user).'</a></th>'; .$OUTPUT->link($userlink).'</th>';
if ($showuseridnumber) { if ($showuseridnumber) {
$studentshtml .= '<th class="c'.$columncount++.' useridnumber" onclick="set_row(this.parentNode.rowIndex);">'. $studentshtml .= '<th class="c'.$columncount++.' useridnumber" onclick="set_row(this.parentNode.rowIndex);">'.
@ -775,7 +776,8 @@ class grade_report_grader extends grade_report {
if (!$this->canviewhidden and $grade->is_hidden()) { if (!$this->canviewhidden and $grade->is_hidden()) {
if (!empty($CFG->grade_hiddenasdate) and $grade->get_datesubmitted() and !$item->is_category_item() and !$item->is_course_item()) { if (!empty($CFG->grade_hiddenasdate) and $grade->get_datesubmitted() and !$item->is_category_item() and !$item->is_course_item()) {
// the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records // the problem here is that we do not have the time when grade value was modified, 'timemodified' is general modification date for grade_grades records
$studentshtml .= '<td class="cell c'.$columncount++.'"><span class="datesubmitted">'.userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')).'</span></td>'; $studentshtml .= '<td class="cell c'.$columncount++.'">'
. $OUTPUT->span(userdate($grade->get_datesubmitted(),get_string('strftimedatetimeshort')), 'datesubmitted') . '</td>';
} else { } else {
$studentshtml .= '<td class="cell c'.$columncount++.'">-</td>'; $studentshtml .= '<td class="cell c'.$columncount++.'">-</td>';
} }
@ -801,20 +803,17 @@ class grade_report_grader extends grade_report {
// $cellclasses .= ' excluded'; // $cellclasses .= ' excluded';
} }
$grade_title = '<div class="fullname">'.fullname($user).'</div>'; $gradetitle = $OUTPUT->container(fullname($user), 'fullname');
$grade_title .= '<div class="itemname">'.$item->get_name(true).'</div>'; $gradetitle .= $OUTPUT->container($item->get_name(true), 'itemname');
if (!empty($grade->feedback) && !$USER->gradeediting[$this->courseid]) { if (!empty($grade->feedback) && !$USER->gradeediting[$this->courseid]) {
$grade_title .= '<div class="feedback">' $gradetitle .= $OUTPUT->container(wordwrap(trim(format_string($grade->feedback, $grade->feedbackformat)), 34, '<br/ >'), 'feedback');
.wordwrap(trim(format_string($grade->feedback, $grade->feedbackformat)), 34, '<br/ >') . '</div>';
} else {
} }
$studentshtml .= '<td class="'.$cellclasses.'" title="'.s($grade_title).'">'; $studentshtml .= '<td class="'.$cellclasses.'" title="'.s($gradetitle).'">';
if ($grade->is_excluded()) { if ($grade->is_excluded()) {
$studentshtml .= '<span class="excludedfloater">'.get_string('excluded', 'grades') . '</span> '; $studentshtml .= $OUTPUT->span(get_string('excluded', 'grades'), 'excludedfloater');
} }
// Do not show any icons if no grade (no record in DB to match) // Do not show any icons if no grade (no record in DB to match)
@ -838,12 +837,12 @@ class grade_report_grader extends grade_report {
// or a drop down (for scales) // or a drop down (for scales)
// grades in item of type grade category or course are not directly editable // grades in item of type grade category or course are not directly editable
if ($item->needsupdate) { if ($item->needsupdate) {
$studentshtml .= '<span class="gradingerror'.$hidden.'">'.get_string('error').'</span>'; $studentshtml .= $OUTPUT->span(get_string('error'), "gradingerror$hidden");
} else if ($USER->gradeediting[$this->courseid]) { } else if ($USER->gradeediting[$this->courseid]) {
if ($item->scaleid && !empty($scales_array[$item->scaleid])) { if ($item->scaleid && !empty($scalesarray[$item->scaleid])) {
$scale = $scales_array[$item->scaleid]; $scale = $scalesarray[$item->scaleid];
$gradeval = (int)$gradeval; // scales use only integers $gradeval = (int)$gradeval; // scales use only integers
$scales = explode(",", $scale->scale); $scales = explode(",", $scale->scale);
// reindex because scale is off 1 // reindex because scale is off 1
@ -875,10 +874,10 @@ class grade_report_grader extends grade_report {
// invalid grade if gradeval < 1 // invalid grade if gradeval < 1
if ($gradeval < 1) { if ($gradeval < 1) {
$studentshtml .= '<span class="gradevalue'.$hidden.$gradepass.'">-</span>'; $studentshtml .= $OUTPUT->span('-', "gradevalue$hidden$gradepass");
} else { } else {
$gradeval = $grade->grade_item->bounded_grade($gradeval); //just in case somebody changes scale $gradeval = $grade->grade_item->bounded_grade($gradeval); //just in case somebody changes scale
$studentshtml .= '<span class="gradevalue'.$hidden.$gradepass.'">'.$scales[$gradeval-1].'</span>'; $studentshtml .= $OUTPUT->span($scales[$gradeval-1], "gradevalue$hidden$gradepass");
} }
} else { } else {
// no such scale, throw error? // no such scale, throw error?
@ -889,10 +888,10 @@ class grade_report_grader extends grade_report {
$value = format_float($gradeval, $decimalpoints); $value = format_float($gradeval, $decimalpoints);
$studentshtml .= '<input type="hidden" name="oldgrade_'.$userid.'_'.$item->id.'" value="'.$value.'" />'; $studentshtml .= '<input type="hidden" name="oldgrade_'.$userid.'_'.$item->id.'" value="'.$value.'" />';
$studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade'] $studentshtml .= '<input size="6" tabindex="' . $tabindices[$item->id]['grade']
. '" type="text" title="'. $strgrade .'" name="grade_' . '" type="text" class="text" title="'. $strgrade .'" name="grade_'
.$userid.'_' .$item->id.'" value="'.$value.'" />'; .$userid.'_' .$item->id.'" value="'.$value.'" />';
} else { } else {
$studentshtml .= '<span class="gradevalue'.$hidden.$gradepass.'">'.format_float($gradeval, $decimalpoints).'</span>'; $studentshtml .= $OUTPUT->span(format_float($gradeval, $decimalpoints), "gradevalue$hidden$gradepass");
} }
} }
@ -913,10 +912,9 @@ class grade_report_grader extends grade_report {
// If feedback present, surround grade with feedback tooltip: Open span here // If feedback present, surround grade with feedback tooltip: Open span here
if ($item->needsupdate) { if ($item->needsupdate) {
$studentshtml .= '<span class="gradingerror'.$hidden.$gradepass.'">'.get_string('error').'</span>'; $studentshtml .= $OUTPUT->span(get_string('error'), "gradingerror$hidden$gradepass");
} else { } else {
$studentshtml .= '<span class="gradevalue'.$hidden.$gradepass.'">'.grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null).'</span>'; $studentshtml .= $OUTPUT->span(grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null), "gradevalue$hidden$gradepass");
} }
} }
@ -965,92 +963,155 @@ class grade_report_grader extends grade_report {
} }
if ($fixedstudents) { if ($fixedstudents) {
$studentshtml .= '<div class="left_scroller"> $fixedcolumntable = new html_table();
<table id="fixed_column" class="fixed_grades_column"> $fixedcolumntable->id = 'fixed_column';
<tbody class="leftbody">'; $fixedcolumntable->add_class('fixed_grades_column');
$fixedcolumntable->bodyclasses = array('leftbody');
$colspan = ''; $colspan = null;
if ($showuseridnumber) { if ($showuseridnumber) {
$colspan = 'colspan="2"'; $colspan = 2;
} }
$levels = count($this->gtree->levels) - 1; $levels = count($this->gtree->levels) - 1;
for ($i = 0; $i < $levels; $i++) { for ($i = 0; $i < $levels; $i++) {
$studentshtml .= ' $fillercell = new html_table_cell();
<tr class="heading name_row"> $fillercell->add_classes(array('fixedcolumn', 'cell', 'c0', 'topleft'));
<td '.$colspan.' class="fixedcolumn cell c0 topleft"> </td> $fillercell->text = ' ';
</tr> $fillercell->colspan = $colspan;
'; $fixedcolumntable->data[] = html_table_row::make(array($fillercell));
} }
$studentshtml .= '<tr class="heading"><th id="studentheader" class="header c0" scope="col"><a href="'.$this->baseurl.'&amp;sortitemid=firstname">' $sortfirstname = html_link::make(clone($this->baseurl), $strfirstname);
. $strfirstname . '</a> ' $sortfirstname->url->param('sortitemid', 'firstname');
. $firstarrow. '/ <a href="'.$this->baseurl.'&amp;sortitemid=lastname">' . $strlastname . '</a>'. $lastarrow .'</th>'; $sortlastname = html_link::make(clone($this->baseurl), $strlastname);
$sortlastname->url->param('sortitemid', 'lastname');
$headerrow = new html_table_row();
$headerrow->add_class('heading');
$studentheader = new html_table_cell();
$studentheader->add_classes(array('header', 'c0'));
$studentheader->scope = 'col';
$studentheader->header = true;
$studentheader->id = 'studentheader';
$studentheader->text = $OUTPUT->link($sortfirstname) . $firstarrow. '/ ' . $OUTPUT->link($sortlastname) . $lastarrow;
$headerrow->cells[] = $studentheader;
if ($showuseridnumber) { if ($showuseridnumber) {
$sortidnumberlink = html_link::make(clone($this->baseurl), get_string('idnumber'));
$sortidnumberlink->url->param('sortitemid', 'idnumber');
$idnumberheader = new html_table_cell();
$idnumberheader->add_classes(array('header', 'c0', 'useridnumber'));
$idnumberheader->scope = 'col';
$idnumberheader->header = true;
$idnumberheader->text = $OUTPUT->link($sortidnumberlink);
if ('idnumber' == $this->sortitemid) { if ('idnumber' == $this->sortitemid) {
if ($this->sortorder == 'ASC') { if ($this->sortorder == 'ASC') {
$idnumberarrow = print_arrow('up', $strsortasc, true); $idnumberheader->text .= print_arrow('up', $strsortasc, true);
} else { } else {
$idnumberarrow = print_arrow('down', $strsortdesc, true); $idnumberheader->text .= print_arrow('down', $strsortdesc, true);
} }
} else {
$idnumberarrow = '';
} }
$studentshtml .= '<th class="header c0 useridnumber" scope="col"><a href="'.$this->baseurl.'&amp;sortitemid=idnumber">' $headerrow->cells[] = $idnumberheader;
. get_string('idnumber') . '</a> ' . $idnumberarrow . '</th>';
} }
$studentshtml .= '</tr>'; $fixedcolumntable->data[] = $headerrow;
if ($USER->gradeediting[$this->courseid]) { if ($USER->gradeediting[$this->courseid]) {
$studentshtml .= '<tr class="controls"><th class="header c0 controls" scope="row" '.$colspan.'>'.$this->get_lang_string('controls','grades').'</th></tr>'; $controlsrow = new html_table_row();
$controlsrow->add_class('controls');
$controlscell = new html_table_cell();
$controlscell->add_classes(array('header', 'c0', 'controls'));
$controlscell->colspan = $colspan;
$controlscell->text = $this->get_lang_string('controls','grades');
$controlsrow->cells[] = $controlscell;
$fixedcolumntable->data[] = $controlsrow;
} }
$row_classes = array(' even ', ' odd '); $rowclasses = array('even', 'odd');
foreach ($this->users as $userid => $user) { foreach ($this->users as $userid => $user) {
$userrow = new html_table_row();
$userrow->add_classes(array('r'.$this->rowcount++, $rowclasses[$this->rowcount % 2]));
$usercell = new html_table_cell();
$usercell->add_classes(array('c0', 'user'));
$usercell->header = true;
$usercell->scope = 'row';
$usercell->add_action('click', 'yui_set_row');
$user_pic = null;
if ($showuserimage) { if ($showuserimage) {
$user_pic = '<div class="userpic">' . $OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)) . "</div>\n"; $usercell->text = $OUTPUT->container($OUTPUT->user_picture(moodle_user_picture::make($user, $this->courseid)), 'userpic');
} }
$studentshtml .= '<tr class="r'.$this->rowcount++ . $row_classes[$this->rowcount % 2] . '">' $usercell->text .= $OUTPUT->link(html_link::make(new moodle_url($CFG->wwwroot.'/user/view.php', array('id' => $user->id, 'course' => $this->course->id)), fullname($user)));
.'<th class="c0 user" scope="row" onclick="set_row(this.parentNode.rowIndex);">'.$user_pic $userrow->cells[] = $usercell;
.'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$this->course->id.'">'
.fullname($user)."</a></th>\n";
if ($showuseridnumber) { if ($showuseridnumber) {
$studentshtml .= '<th class="header c0 useridnumber" onclick="set_row(this.parentNode.rowIndex);">'. $user->idnumber."</th>\n"; $idnumbercell = new html_table_cell();
$idnumbercell->add_classes(array('header', 'c0', 'useridnumber'));
$idnumbercell->header = true;
$idnumbercell->scope = 'row';
$idnumbercell->add_action('click', 'yui_set_row');
$userrow->cells[] = $idnumbercell;
} }
$studentshtml .= "</tr>\n"; $fixedcolumntable->data[] = $userrow;
} }
if ($this->get_pref('showranges')) { if ($this->get_pref('showranges')) {
$studentshtml .= '<tr class="range r'.$this->rowcount++.'">' . '<th class="header c0 range " '.$colspan.' scope="row">'.$this->get_lang_string('range','grades').'</th></tr>'; $rangerow = new html_table_row();
$rangerow->add_classes(array('range', 'r'.$this->rowcount++));
$rangecell = new html_table_cell();
$rangecell->add_classes(array('header', 'c0', 'range'));
$rangecell->colspan = $colspan;
$rangecell->header = true;
$rangecell->scope = 'row';
$rangecell->text = $this->get_lang_string('range','grades');
$rangerow->cells[] = $rangecell;
$fixedcolumntable->data[] = $rangerow;
} }
// Averages heading // Averages heading
$straverage_group = get_string('groupavg', 'grades'); $straveragegroup = get_string('groupavg', 'grades');
$straverage = get_string('overallaverage', 'grades'); $straverage = get_string('overallaverage', 'grades');
$showaverages = $this->get_pref('showaverages'); $showaverages = $this->get_pref('showaverages');
$showaverages_group = $this->currentgroup && $showaverages; $showaveragesgroup = $this->currentgroup && $showaverages;
if ($showaverages_group) { if ($showaveragesgroup) {
$studentshtml .= '<tr class="groupavg r'.$this->rowcount++.'"><th class="header c0" '.$colspan.'scope="row">'.$straverage_group.'</th></tr>'; $groupavgrow = new html_table_row();
$groupavgrow->add_classes(array('groupavg', 'r'.$this->rowcount++));
$groupavgcell = new html_table_cell();
$groupavgcell->add_classes(array('header', 'c0', 'range'));
$groupavgcell->colspan = $colspan;
$groupavgcell->header = true;
$groupavgcell->scope = 'row';
$groupavgcell->text = $straveragegroup;
$groupavgrow->cells[] = $groupavgcell;
$fixedcolumntable->data[] = $groupavgrow;
} }
if ($showaverages) { if ($showaverages) {
$studentshtml .= '<tr class="avg r'.$this->rowcount++.'"><th class="header c0" '.$colspan.'scope="row">'.$straverage.'</th></tr>'; $avgrow = new html_table_row();
$avgrow->add_classes(array('avg', 'r'.$this->rowcount++));
$avgcell = new html_table_cell();
$avgcell->add_classes(array('header', 'c0', 'range'));
$avgcell->colspan = $colspan;
$avgcell->header = true;
$avgcell->scope = 'row';
$avgcell->text = $straverage;
$avgrow->cells[] = $avgcell;
$fixedcolumntable->data[] = $avgrow;
} }
$studentshtml .= '</tbody> $studentshtml .= $OUTPUT->container($OUTPUT->table($fixedcolumntable), 'left_scroller');
</table> $studentshtml .= '
</div>
<div class="right_scroller"> <div class="right_scroller">
<table id="user-grades" class=""> <table id="user-grades" class="">
<tbody class="righttest">'; <tbody class="righttest">';
@ -1105,14 +1166,14 @@ class grade_report_grader extends grade_report {
$showaverages = $this->currentgroup && $this->get_pref('showaverages'); $showaverages = $this->currentgroup && $this->get_pref('showaverages');
$groupsql = $this->groupsql; $groupsql = $this->groupsql;
$groupwheresql = $this->groupwheresql; $groupwheresql = $this->groupwheresql;
$groupwheresql_params = $this->groupwheresql_params; $groupwheresqlparams = $this->groupwheresql_params;
$avgcssclass = 'groupavg'; $avgcssclass = 'groupavg';
} else { } else {
$straverage = get_string('overallaverage', 'grades'); $straverage = get_string('overallaverage', 'grades');
$showaverages = $this->get_pref('showaverages'); $showaverages = $this->get_pref('showaverages');
$groupsql = ""; $groupsql = "";
$groupwheresql = ""; $groupwheresql = "";
$groupwheresql_params = array(); $groupwheresqlparams = array();
} }
if ($shownumberofgrades) { if ($shownumberofgrades) {
@ -1121,10 +1182,10 @@ class grade_report_grader extends grade_report {
$totalcount = $this->get_numusers($grouponly); $totalcount = $this->get_numusers($grouponly);
list($usql, $roles_params) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0'); list($usql, $rolesparams) = $DB->get_in_or_equal(explode(',', $this->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
if ($showaverages) { if ($showaverages) {
$params = array_merge(array('courseid'=>$this->courseid), $roles_params, $groupwheresql_params); $params = array_merge(array('courseid'=>$this->courseid), $rolesparams, $groupwheresqlparams);
// find sums of all grade items in course // find sums of all grade items in course
$SQL = "SELECT g.itemid, SUM(g.finalgrade) AS sum $SQL = "SELECT g.itemid, SUM(g.finalgrade) AS sum
@ -1139,10 +1200,10 @@ class grade_report_grader extends grade_report {
AND g.finalgrade IS NOT NULL AND g.finalgrade IS NOT NULL
$groupwheresql $groupwheresql
GROUP BY g.itemid"; GROUP BY g.itemid";
$sum_array = array(); $sumarray = array();
if ($sums = $DB->get_records_sql($SQL, $params)) { if ($sums = $DB->get_records_sql($SQL, $params)) {
foreach ($sums as $itemid => $csum) { foreach ($sums as $itemid => $csum) {
$sum_array[$itemid] = $csum->sum; $sumarray[$itemid] = $csum->sum;
} }
} }
@ -1151,7 +1212,7 @@ class grade_report_grader extends grade_report {
// MDL-10875 Empty grades must be evaluated as grademin, NOT always 0 // MDL-10875 Empty grades must be evaluated as grademin, NOT always 0
// This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table) // This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)
$params = array_merge(array('courseid'=>$this->courseid), $roles_params, $groupwheresql_params); $params = array_merge(array('courseid'=>$this->courseid), $rolesparams, $groupwheresqlparams);
$SQL = "SELECT gi.id, COUNT(u.id) AS count $SQL = "SELECT gi.id, COUNT(u.id) AS count
FROM {grade_items} gi FROM {grade_items} gi
CROSS JOIN {user} u CROSS JOIN {user} u
@ -1165,7 +1226,7 @@ class grade_report_grader extends grade_report {
$groupwheresql $groupwheresql
GROUP BY gi.id"; GROUP BY gi.id";
$ungraded_counts = $DB->get_records_sql($SQL, $params); $ungradedcounts = $DB->get_records_sql($SQL, $params);
$fixedstudents = $this->is_fixed_students(); $fixedstudents = $this->is_fixed_students();
if (!$fixedstudents) { if (!$fixedstudents) {
@ -1184,21 +1245,21 @@ class grade_report_grader extends grade_report {
continue; continue;
} }
if (!isset($sum_array[$item->id])) { if (!isset($sumarray[$item->id])) {
$sum_array[$item->id] = 0; $sumarray[$item->id] = 0;
} }
if (empty($ungraded_counts[$itemid])) { if (empty($ungradedcounts[$itemid])) {
$ungraded_count = 0; $ungradedcount = 0;
} else { } else {
$ungraded_count = $ungraded_counts[$itemid]->count; $ungradedcount = $ungradedcounts[$itemid]->count;
} }
if ($meanselection == GRADE_REPORT_MEAN_GRADED) { if ($meanselection == GRADE_REPORT_MEAN_GRADED) {
$mean_count = $totalcount - $ungraded_count; $meancount = $totalcount - $ungradedcount;
} else { // Bump up the sum by the number of ungraded items * grademin } else { // Bump up the sum by the number of ungraded items * grademin
$sum_array[$item->id] += $ungraded_count * $item->grademin; $sumarray[$item->id] += $ungradedcount * $item->grademin;
$mean_count = $totalcount; $meancount = $totalcount;
} }
$decimalpoints = $item->get_decimals(); $decimalpoints = $item->get_decimals();
@ -1222,16 +1283,16 @@ class grade_report_grader extends grade_report {
$decimalpoints = $averagesdecimalpoints; $decimalpoints = $averagesdecimalpoints;
} }
if (!isset($sum_array[$item->id]) || $mean_count == 0) { if (!isset($sumarray[$item->id]) || $meancount == 0) {
$avghtml .= '<td class="cell c' . $columncount++.'">-</td>'; $avghtml .= '<td class="cell c' . $columncount++.'">-</td>';
} else { } else {
$sum = $sum_array[$item->id]; $sum = $sumarray[$item->id];
$avgradeval = $sum/$mean_count; $avgradeval = $sum/$meancount;
$gradehtml = grade_format_gradevalue($avgradeval, $item, true, $displaytype, $decimalpoints); $gradehtml = grade_format_gradevalue($avgradeval, $item, true, $displaytype, $decimalpoints);
$numberofgrades = ''; $numberofgrades = '';
if ($shownumberofgrades) { if ($shownumberofgrades) {
$numberofgrades = " ($mean_count)"; $numberofgrades = " ($meancount)";
} }
$avghtml .= '<td class="cell c' . $columncount++.'">'.$gradehtml.$numberofgrades.'</td>'; $avghtml .= '<td class="cell c' . $columncount++.'">'.$gradehtml.$numberofgrades.'</td>';
@ -1275,9 +1336,9 @@ class grade_report_grader extends grade_report {
$hidden = ' hidden '; $hidden = ' hidden ';
} }
$formatted_range = $item->get_formatted_range($rangesdisplaytype, $rangesdecimalpoints); $formattedrange = $item->get_formatted_range($rangesdisplaytype, $rangesdecimalpoints);
$rangehtml .= '<th class="header c'.$columncount++.' range"><span class="rangevalues'.$hidden.'">'. $formatted_range .'</span></th>'; $rangehtml .= '<th class="header c'.$columncount++.' range"><span class="rangevalues'.$hidden.'">'. $formattedrange .'</span></th>';
} }
$rangehtml .= '</tr>'; $rangehtml .= '</tr>';
@ -1333,39 +1394,39 @@ class grade_report_grader extends grade_report {
* @return string HTML * @return string HTML
*/ */
protected function get_icons($element) { protected function get_icons($element) {
global $CFG, $USER; global $CFG, $USER, $OUTPUT;
if (!$USER->gradeediting[$this->courseid]) { if (!$USER->gradeediting[$this->courseid]) {
return '<div class="grade_icons" />'; return '<div class="grade_icons" />';
} }
// Init all icons // Init all icons
$edit_icon = ''; $editicon = '';
if ($element['type'] != 'categoryitem' && $element['type'] != 'courseitem') { if ($element['type'] != 'categoryitem' && $element['type'] != 'courseitem') {
$edit_icon = $this->gtree->get_edit_icon($element, $this->gpr); $editicon = $this->gtree->get_edit_icon($element, $this->gpr);
} }
$edit_calculation_icon = ''; $editcalculationicon = '';
$show_hide_icon = ''; $showhideicon = '';
$lock_unlock_icon = ''; $lockunlockicon = '';
if (has_capability('moodle/grade:manage', $this->context)) { if (has_capability('moodle/grade:manage', $this->context)) {
if ($this->get_pref('showcalculations')) { if ($this->get_pref('showcalculations')) {
$edit_calculation_icon = $this->gtree->get_calculation_icon($element, $this->gpr); $editcalculationicon = $this->gtree->get_calculation_icon($element, $this->gpr);
} }
if ($this->get_pref('showeyecons')) { if ($this->get_pref('showeyecons')) {
$show_hide_icon = $this->gtree->get_hiding_icon($element, $this->gpr); $showhideicon = $this->gtree->get_hiding_icon($element, $this->gpr);
} }
if ($this->get_pref('showlocks')) { if ($this->get_pref('showlocks')) {
$lock_unlock_icon = $this->gtree->get_locking_icon($element, $this->gpr); $lockunlockicon = $this->gtree->get_locking_icon($element, $this->gpr);
} }
} }
return '<div class="grade_icons">'.$edit_icon.$edit_calculation_icon.$show_hide_icon.$lock_unlock_icon.'</div>'; return $OUTPUT->container($editicon.$editcalculationicon.$showhideicon.$lockunlockicon, 'grade_icons');
} }
/** /**
@ -1376,26 +1437,32 @@ class grade_report_grader extends grade_report {
protected function get_collapsing_icon($element) { protected function get_collapsing_icon($element) {
global $OUTPUT; global $OUTPUT;
$contract_expand_icon = ''; $icon = '';
// If object is a category, display expand/contract icon // If object is a category, display expand/contract icon
if ($element['type'] == 'category') { if ($element['type'] == 'category') {
// Load language strings // Load language strings
$strswitch_minus = $this->get_lang_string('aggregatesonly', 'grades'); $strswitchminus = $this->get_lang_string('aggregatesonly', 'grades');
$strswitch_plus = $this->get_lang_string('gradesonly', 'grades'); $strswitchplus = $this->get_lang_string('gradesonly', 'grades');
$strswitch_whole = $this->get_lang_string('fullmode', 'grades'); $strswitchwhole = $this->get_lang_string('fullmode', 'grades');
$expand_contract = 'switch_minus'; // Default: expanded $contractexpandicon = new moodle_action_icon();
$contractexpandicon->link->url = new moodle_url($this->gpr->get_return_url(null, array('target'=>$element['eid'], 'action'=>'switch_minus', 'sesskey'=>sesskey())));
$contractexpandicon->image->add_class('iconsmall');
$contractexpandicon->image->src = $OUTPUT->old_icon_url('t/switch_minus');
$contractexpandicon->image->alt = $strswitchminus;
if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) { if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) {
$expand_contract = 'switch_plus'; $contractexpandicon->image->src = $OUTPUT->old_icon_url('t/switch_plus');
$contractexpandicon->image->alt = $strswitchplus;
$contractexpandicon->link->url->param('action', 'switch_plus');
} elseif (in_array($element['object']->id, $this->collapsed['gradesonly'])) { } elseif (in_array($element['object']->id, $this->collapsed['gradesonly'])) {
$expand_contract = 'switch_whole'; $contractexpandicon->image->src = $OUTPUT->old_icon_url('t/switch_whole');
$contractexpandicon->image->alt = $strswitchwhole;
$contractexpandicon->link->url->param('action', 'switch_whole');
} }
$url = $this->gpr->get_return_url(null, array('target'=>$element['eid'], 'action'=>$expand_contract, 'sesskey'=>sesskey())); $icon = $OUTPUT->action_icon($contractexpandicon);
$contract_expand_icon = '<a href="'.$url.'"><img src="'.$OUTPUT->old_icon_url('t/' . $expand_contract) . '" class="iconsmall" alt="'
.${'str'.$expand_contract}.'" title="'.${'str'.$expand_contract}.'" /></a>';
} }
return $contract_expand_icon; return $icon;
} }
/** /**

View file

@ -323,12 +323,16 @@ vertical-align:middle;
padding:0; padding:0;
} }
.grade-report-grader td input { .grade-report-grader td input.text {
border:1px solid #666; border:1px solid #666;
margin-left:10px; margin-left:10px;
margin-right:10px; margin-right:10px;
} }
.grade-report-grader td input.submit {
margin: 10px 10px 0px 10px;
}
.grade-report-grader table#quick_edit td.fullname { .grade-report-grader table#quick_edit td.fullname {
border-left:none; border-left:none;
padding-left:5px; padding-left:5px;

View file

@ -316,15 +316,18 @@ abstract class grade_report {
/** /**
* Returns an arrow icon inside an <a> tag, for the purpose of sorting a column. * Returns an arrow icon inside an <a> tag, for the purpose of sorting a column.
* @param string $direction * @param string $direction
* @param string $sort_link * @param moodle_url $sort_link
* @param string HTML * @param string HTML
*/ */
protected function get_sort_arrow($direction='move', $sort_link=null) { protected function get_sort_arrow($direction='move', $sortlink=null) {
global $OUTPUT;
$matrix = array('up' => 'desc', 'down' => 'asc', 'move' => 'desc'); $matrix = array('up' => 'desc', 'down' => 'asc', 'move' => 'desc');
$strsort = $this->get_lang_string('sort' . $matrix[$direction]); $strsort = $this->get_lang_string('sort' . $matrix[$direction]);
$arrow = print_arrow($direction, $strsort, true); $arrow = print_arrow($direction, $strsort, true);
$html = '<a href="'.$sort_link .'" title="'.$strsort.'">' . $arrow . '</a>'; $link = html_link::make($sortlink, $arrow);
$link->title = $strsort;
$html = $OUTPUT->link($link);
return $html; return $html;
} }
} }

View file

@ -475,6 +475,7 @@ $string['savepreferences'] = 'Save preferences';
$string['scaledpct'] = 'Scaled %%'; $string['scaledpct'] = 'Scaled %%';
$string['scaleidhelp'] = 'When using the scale grade type, a scale can be selected. The scale for an activity-based grade item is selected on the update activity page.'; $string['scaleidhelp'] = 'When using the scale grade type, a scale can be selected. The scale for an activity-based grade item is selected on the update activity page.';
$string['scalestandardhelp'] = 'A standard scale is one that is available site-wide, for all courses.'; $string['scalestandardhelp'] = 'A standard scale is one that is available site-wide, for all courses.';
$string['scaleconfirmdelete'] = 'Are you sure you wish to delete the scale \"$a\"?';
$string['seeallcoursegrades'] = 'See all course grades'; $string['seeallcoursegrades'] = 'See all course grades';
$string['selectdestination'] = 'Select destination of $a'; $string['selectdestination'] = 'Select destination of $a';
$string['selectalloroneuser'] = 'Select all or one user'; $string['selectalloroneuser'] = 'Select all or one user';

View file

@ -1052,6 +1052,19 @@ class html_table extends labelled_html_component {
* @var bool true causes the contents of the heading cells to be rotated 90 degrees. * @var bool true causes the contents of the heading cells to be rotated 90 degrees.
*/ */
public $rotateheaders = false; public $rotateheaders = false;
/**
* @var array $headclasses Array of CSS classes to apply to the table's thead.
*/
public $headclasses = array();
/**
* @var array $bodyclasses Array of CSS classes to apply to the table's tbody.
*/
public $bodyclasses = array();
/**
* @var array $footclasses Array of CSS classes to apply to the table's tfoot.
*/
public $footclasses = array();
/** /**
* @see moodle_html_component::prepare() * @see moodle_html_component::prepare()
@ -1416,12 +1429,8 @@ class html_form extends moodle_html_component {
* @return void * @return void
*/ */
public function __construct() { public function __construct() {
static $yes;
$this->button = new html_button(); $this->button = new html_button();
if (!isset($yes)) { $this->button->text = get_string('yes');
$yes = get_string('yes');
$this->button->text = $yes;
}
} }
/** /**

View file

@ -1554,10 +1554,18 @@ class moodle_core_renderer extends moodle_renderer_base {
/** /**
* Prints an inline span element with optional text contents. * Prints an inline span element with optional text contents.
* *
* @param html_span $span A html_span object * @param mixed $span A html_span object or some string content to wrap in a span
* @param mixed $classes A space-separated list or an array of classes. Only used if $span is a string
* @return string A HTML fragment * @return string A HTML fragment
*/ */
public function span($span) { public function span($span, $classes='') {
if (!($span instanceof html_span)) {
$text = $span;
$span = new html_span();
$span->contents = $text;
$span->add_classes($classes);
}
$span = clone($span); $span = clone($span);
$span->prepare(); $span->prepare();
$this->prepare_event_handlers($span); $this->prepare_event_handlers($span);
@ -2028,7 +2036,7 @@ class moodle_core_renderer extends moodle_renderer_base {
if (!empty($table->head)) { if (!empty($table->head)) {
$countcols = count($table->head); $countcols = count($table->head);
$output .= $this->output_start_tag('thead', array()) . "\n"; $output .= $this->output_start_tag('thead', $table->headclasses) . "\n";
$output .= $this->output_start_tag('tr', array()) . "\n"; $output .= $this->output_start_tag('tr', array()) . "\n";
$keys = array_keys($table->head); $keys = array_keys($table->head);
$lastkey = end($keys); $lastkey = end($keys);
@ -2077,7 +2085,7 @@ class moodle_core_renderer extends moodle_renderer_base {
$oddeven = 1; $oddeven = 1;
$keys = array_keys($table->data); $keys = array_keys($table->data);
$lastrowkey = end($keys); $lastrowkey = end($keys);
$output .= $this->output_start_tag('tbody', array()) . "\n"; $output .= $this->output_start_tag('tbody', $table->bodyclasses) . "\n";
foreach ($table->data as $key => $row) { foreach ($table->data as $key => $row) {
if (($row === 'hr') && ($countcols)) { if (($row === 'hr') && ($countcols)) {