MDL-18229 gradebook: Single view navigation corrected.

Usernames link to user profiles.
Activities to their activity page.
This commit is contained in:
Zachary Durber 2014-09-23 06:40:02 +00:00
parent 4229e9fa8d
commit 508f23f1e5
5 changed files with 149 additions and 36 deletions

View File

@ -1,5 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The gradebook simple view - base class for the table
*
* @package simple_view
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once $CFG->dirroot . '/grade/report/single_view/classes/uilib.php';
interface selectable_items {
@ -53,7 +76,7 @@ abstract class single_view_screen {
'id' => $this->courseid,
'item' => $screen,
'itemid' => $itemid,
'group' => $this->groupid
'group' => $this->groupid,
));
if ($display) {
@ -198,20 +221,20 @@ abstract class single_view_screen {
$data->$name = null;
}
// Same value; skip
// Same value; skip.
if ($oldvalue == $posted) {
continue;
}
$msg = $element->set($posted);
// Optional type
// Optional type.
if (!empty($msg)) {
$warnings[] = $msg;
}
}
// Some post-processing
// Some post-processing.
$event_data = new stdClass;
$event_data->warnings = $warnings;
$event_data->post_data = $data;
@ -258,17 +281,17 @@ abstract class single_view_tablelike extends single_view_screen implements tabba
return (count($this->definition()) * $this->total) + $this->index;
}
// Special injection for bulk operations
// Special injection for bulk operations.
public function process($data) {
$bulk = $this->factory()->create('bulk_insert')->format($this->item);
// Bulk insert messages the data to be passed in
// ie: for all grades of empty grades apply the specified value
// ie: for all grades of empty grades apply the specified value.
if ($bulk->is_applied($data)) {
$filter = $bulk->get_type($data);
$insert_value = $bulk->get_insert_value($data);
// Appropriately massage data that may not exist
// Appropriately massage data that may not exist.
if ($this->supports_paging()) {
// TODO: this only works with the grade screen...
$grade_item = grade_item::fetch(array(
@ -320,7 +343,7 @@ abstract class single_view_tablelike extends single_view_screen implements tabba
public function format_definition($line, $grade) {
foreach ($this->definition() as $i => $field) {
// Table tab index
// Table tab index.
$tab = ($i * $this->total) + $this->index;
$html = $this->factory()->create($field)->format($grade, $tab);
@ -339,7 +362,7 @@ abstract class single_view_tablelike extends single_view_screen implements tabba
$table->head = $this->headers();
// To be used for extra formatting
// To be used for extra formatting.
$this->index = 0;
$this->total = count($this->items);

View File

@ -1,5 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The gradebook simple view - UI factory
*
* @package simple_view
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class single_view_ui_factory {
public abstract function create($type);
@ -110,7 +133,6 @@ class single_view_checkbox_attribute extends single_view_ui_element {
var $is_checked;
var $tabindex;
// UCSB 2014-02-28 - add $locked to disable override checkbox when grade is locked
function __construct($name, $is_checked = false, $tabindex = null, $locked=0) {
$this->is_checked = $is_checked;
$this->tabindex = $tabindex;
@ -130,7 +152,7 @@ class single_view_checkbox_attribute extends single_view_ui_element {
'value' => 1
);
// UCSB fixed user should not be able to override locked grade
// UCSB fixed user should not be able to override locked grade.
if ( $this->locked) {
$attributes['disabled'] = 'DISABLED';
}
@ -310,7 +332,7 @@ class single_view_finalgrade_ui extends single_view_grade_attribute_format imple
var $name = 'finalgrade';
function get_value() {
// Manual item raw grade support
// Manual item raw grade support.
$val = $this->grade->grade_item->is_manual_item() && (!is_null($this->grade->rawgrade)) ?
$this->grade->rawgrade : $this->grade->finalgrade;
@ -325,15 +347,14 @@ class single_view_finalgrade_ui extends single_view_grade_attribute_format imple
$locked = 0;
$gradeitemlocked = 0;
$overridden = 0;
// UCSB - 2.24.2014
// disable editing if grade item or grade score is locked
// if any of these items are set, then we will disable editing
// at some point, we might want to show the reason for the lock
// this code could be simplified, but its more readable for steve's little mind
/* Disable editing if grade item or grade score is locked
* if any of these items are set, then we will disable editing
* at some point, we might want to show the reason for the lock
* this code could be simplified, but its more readable for steve's little mind
*/
if (!empty($this->grade->locked)) $locked = 1;
if (!empty($this->grade->grade_item->locked)) $gradeitemlocked = 1;
if ($this->grade->grade_item->is_overridable_item() and !$this->grade->is_overridden()) $overridden = 1;
//$overridden = $this->grade->grade_item->is_overridable_item() and !$this->grade->is_overridden();
return ($locked || $gradeitemlocked || $overridden);
}
@ -384,7 +405,6 @@ class single_view_finalgrade_ui extends single_view_grade_attribute_format imple
$errorstr = '';
if (is_null($finalgrade)) {
// ok
} else {
$bounded = $grade_item->bounded_grade($finalgrade);
if ($bounded > $finalgrade) {
@ -424,11 +444,11 @@ class single_view_feedback_ui extends single_view_grade_attribute_format impleme
$locked = 0;
$gradeitemlocked = 0;
$overridden = 0;
// UCSB - 2.24.2014
// disable editing if grade item or grade score is locked
// if any of these items are set, then we will disable editing
// at some point, we might want to show the reason for the lock
// this code could be simplified, but its more readable for steve's little mind
/* Disable editing if grade item or grade score is locked
* if any of these items are set, then we will disable editing
* at some point, we might want to show the reason for the lock
* this code could be simplified, but its more readable for steve's little mind
*/
if (!empty($this->grade->locked)) $locked = 1;
if (!empty($this->grade->grade_item->locked)) $gradeitemlocked = 1;
if ($this->grade->grade_item->is_overridable_item() and !$this->grade->is_overridden()) $overridden = 1;
@ -461,7 +481,6 @@ class single_view_feedback_ui extends single_view_grade_attribute_format impleme
}
}
// UCSB 2014-02-28 implement be_disabled to disable checkbox if grade/gradeitem is locked
class single_view_override_ui extends single_view_grade_attribute_format implements be_checked, be_disabled {
var $name = 'override';
@ -480,7 +499,6 @@ class single_view_override_ui extends single_view_grade_attribute_format impleme
if (!$this->grade->grade_item->is_overridable_item()) {
return new single_view_empty_element();
}
// UCSB 2014-02-28: add param is_disabled to disable override checkbox if grade is locked
return new single_view_checkbox_attribute(
$this->get_name(),
$this->is_checked(),
@ -524,7 +542,7 @@ class single_view_exclude_ui extends single_view_grade_attribute_format implemen
$grade_item = $this->grade->grade_item;
// Fill in arbitrary grade to be excluded
// Fill in arbitrary grade to be excluded.
$grade_item->update_final_grade(
$this->grade->userid, null, 'single_view', null, FORMAT_MOODLE
);

View File

@ -1,5 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The gradebook simple view - grades view (for an activity)
*
* @package simple_view
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class single_view_grade extends single_view_tablelike
implements selectable_items, item_filtering {
@ -69,7 +92,7 @@ class single_view_grade extends single_view_tablelike
return;
}
// Only page when necessary
// Only page when necessary.
if (count($this->items) > $this->perpage) {
$this->requires_paging = true;
@ -125,14 +148,15 @@ class single_view_grade extends single_view_tablelike
$grade = $this->fetch_grade_or_default($this->item, $item->id);
// UCSB add lock icon indicator
// UCSB add lock icon indicator.
$lockicon = '';
// CODE to make steve happy for his simple mind
// CODE to make steve happy for his simple mind.
$locked_grade = $locked_grade_item = 0;
if ( ! empty($grade->locked) ) $locked_grade = 1;
if ( ! empty($grade->grade_item->locked) ) $locked_grade_item = 1;
if ( $locked_grade || $locked_grade_item ) // check both grade and grade item
// check both grade and grade item.
if ( $locked_grade || $locked_grade_item )
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked') . ' ';
if (!empty($item->alternatename)) {
@ -142,11 +166,12 @@ class single_view_grade extends single_view_tablelike
}
$item->imagealt = $fullname;
$url = new moodle_url("/user/view.php", array('id' => $item->id, 'course' => $this->courseid));
$line = array(
$OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', get_string('filtergrades', 'gradereport_single_view', $fullname))),
$OUTPUT->user_picture($item),
$this->format_link('user', $item->id, $fullname),
html_writer::tag('a', $fullname, array('href' => $url)),
$this->item_range()
);
return $this->format_definition($line, $grade);

View File

@ -1,5 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The gradebook simple view - initial view to select your search options
*
* @package simple_view
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class single_view_select extends single_view_screen {
public function init($self_item_is_empty = false) {
global $DB;

View File

@ -1,5 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The gradebook simple view - grades view (for a user)
*
* @package simple_view
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class single_view_user extends single_view_tablelike implements selectable_items {
private $categories = array();
@ -65,21 +88,22 @@ class single_view_user extends single_view_tablelike implements selectable_items
$grade = $this->fetch_grade_or_default($item, $this->item->id);
$lockicon = '';
// UCSB add lock icon indicator
// UCSB add lock icon indicator.
$locked_grade = $locked_grade_item = 0;
if ( ! empty($grade->locked) ) $locked_grade = 1;
if ( ! empty($grade->grade_item->locked) ) $locked_grade_item = 1;
if ( $locked_grade || $locked_grade_item ) // check both grade and grade item
if ( $locked_grade || $locked_grade_item ) // check both grade and grade item.
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked');
$url = new moodle_url("/mod/$item->itemmodule/view.php", array('id' => $item->iteminstance));
$line = array(
$OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', get_string('filtergrades', 'gradereport_single_view', $item->get_name()))),
$this->format_icon($item) . $lockicon,
$this->format_link('grade', $item->id, $item->get_name()),
html_writer::tag('a', $item->get_name(), array('href' => $url)),
$this->category($item),
$this->factory()->create('range')->format($item)
);
return $this->format_definition($line, $grade);
}