mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-18229 gradereport: Fixes and improvements from review.
Added pagination back in with some general fixes. AMOS BEGIN CPY [override,mod_quiz],[override,gradereport_singleview] AMOS END
This commit is contained in:
parent
2fd9718d8b
commit
8ec7b088ef
14 changed files with 151 additions and 188 deletions
|
@ -1,21 +0,0 @@
|
|||
LSU Single view
|
||||
==============
|
||||
|
||||
Single view is a simple Moodle Gradebook plugin which allows teahers to do some awesome things.
|
||||
|
||||
Single view allows for editing of multiple grades for a single grade item and all grade items for a single user.
|
||||
|
||||
It allows the instructor to insert an arbitrary value ofr all students for a single item (incredibly useful) or all items for a single student (less useful).
|
||||
|
||||
Single view also allows for inserting an arbitrary value for all empty items, allowing you to add zero grades for empties in one step.
|
||||
|
||||
It also allows for bulk overrides.
|
||||
|
||||
Single view works best with the LSU Gradebook.
|
||||
|
||||
Installation Instructions
|
||||
==============
|
||||
|
||||
1. Drop into your grade/reports folder.
|
||||
2. Click Notifications.
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
require_once $CFG->dirroot . '/grade/report/singleview/classes/uilib.php';
|
||||
|
||||
interface selectable_items {
|
||||
interface gradereport_selectable_items {
|
||||
public function description();
|
||||
|
||||
public function options();
|
||||
|
@ -33,11 +33,11 @@ interface selectable_items {
|
|||
public function item_type();
|
||||
}
|
||||
|
||||
interface item_filtering {
|
||||
interface gradereport_item_filtering {
|
||||
public static function filter($item);
|
||||
}
|
||||
|
||||
abstract class singleview_screen {
|
||||
abstract class gradereport_singleview_screen {
|
||||
var $courseid;
|
||||
|
||||
var $itemid;
|
||||
|
@ -61,7 +61,10 @@ abstract class singleview_screen {
|
|||
$this->course = $DB->get_record('course', array('id' => $courseid));
|
||||
|
||||
$this->page = optional_param('page', 0, PARAM_INT);
|
||||
$this->perpage = optional_param('perpage', 300, PARAM_INT);
|
||||
$this->perpage = optional_param('perpage', 100, PARAM_INT);
|
||||
if ($this->perpage > 100) {
|
||||
$this->perpage = 100;
|
||||
}
|
||||
|
||||
$this->init(empty($itemid));
|
||||
}
|
||||
|
@ -136,7 +139,7 @@ abstract class singleview_screen {
|
|||
public abstract function html();
|
||||
|
||||
public function supports_paging() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function pager() {
|
||||
|
@ -147,7 +150,6 @@ abstract class singleview_screen {
|
|||
global $OUTPUT;
|
||||
|
||||
list($___, $item) = explode('singleview_', get_class($this));
|
||||
|
||||
return $OUTPUT->paging_bar(
|
||||
count($this->items), $this->page, $this->perpage,
|
||||
new moodle_url('/grade/report/singleview/index.php', array(
|
||||
|
@ -174,7 +176,7 @@ abstract class singleview_screen {
|
|||
|
||||
public function factory() {
|
||||
if (empty($this->__factory)) {
|
||||
$this->__factory = new singleview_grade_ui_factory();
|
||||
$this->__factory = new gradereport_singleview_grade_ui_factory();
|
||||
}
|
||||
|
||||
return $this->__factory;
|
||||
|
@ -250,8 +252,8 @@ abstract class singleview_screen {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class singleview_tablelike extends singleview_screen implements tabbable {
|
||||
var $items;
|
||||
abstract class gradereport_singleview_tablelike extends gradereport_singleview_screen implements tabbable {
|
||||
public $items;
|
||||
|
||||
protected $headers = array();
|
||||
|
||||
|
@ -284,13 +286,11 @@ abstract class singleview_tablelike extends singleview_screen implements tabbabl
|
|||
// 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.
|
||||
if ($bulk->is_applied($data)) {
|
||||
$filter = $bulk->get_type($data);
|
||||
$insert_value = $bulk->get_insert_value($data);
|
||||
|
||||
// Appropriately massage data that may not exist.
|
||||
if ($this->supports_paging()) {
|
||||
// TODO: this only works with the grade screen...
|
||||
|
@ -301,7 +301,7 @@ abstract class singleview_tablelike extends singleview_screen implements tabbabl
|
|||
|
||||
$null = $grade_item->gradetype == GRADE_TYPE_SCALE ? -1 : '';
|
||||
|
||||
foreach ($this->all_items as $itemid => $item) {
|
||||
foreach ($this->items as $itemid => $item) {
|
||||
$field = "finalgrade_{$grade_item->id}_{$itemid}";
|
||||
if (isset($data->$field)) {
|
||||
continue;
|
||||
|
@ -346,14 +346,13 @@ abstract class singleview_tablelike extends singleview_screen implements tabbabl
|
|||
// Table tab index.
|
||||
$tab = ($i * $this->total) + $this->index;
|
||||
$html = $this->factory()->create($field)->format($grade, $tab);
|
||||
|
||||
|
||||
if ($field == 'finalgrade' and !empty($this->structure)) {
|
||||
$html .= $this->structure->get_grade_analysis_icon($grade);
|
||||
}
|
||||
|
||||
$line[] = $html;
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,21 +23,21 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
abstract class singleview_ui_factory {
|
||||
abstract class gradereport_singleview_ui_factory {
|
||||
public abstract function create($type);
|
||||
|
||||
protected function wrap($class) {
|
||||
return new singleview_factory_class_wrap($class);
|
||||
return new gradereport_singleview_factory_class_wrap($class);
|
||||
}
|
||||
}
|
||||
|
||||
class singleview_grade_ui_factory extends singleview_ui_factory {
|
||||
class gradereport_singleview_grade_ui_factory extends gradereport_singleview_ui_factory {
|
||||
public function create($type) {
|
||||
return $this->wrap("singleview_{$type}_ui");
|
||||
return $this->wrap("gradereport_singleview_{$type}_ui");
|
||||
}
|
||||
}
|
||||
|
||||
class singleview_factory_class_wrap {
|
||||
class gradereport_singleview_factory_class_wrap {
|
||||
public function __construct($class) {
|
||||
$this->class = $class;
|
||||
}
|
||||
|
@ -50,9 +50,10 @@ class singleview_factory_class_wrap {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class singleview_ui_element {
|
||||
abstract class gradereport_singleview_ui_element {
|
||||
public $name;
|
||||
public $value;
|
||||
public $label;
|
||||
|
||||
public function __construct($name, $value, $label) {
|
||||
$this->name = $name;
|
||||
|
@ -75,7 +76,7 @@ abstract class singleview_ui_element {
|
|||
abstract public function html();
|
||||
}
|
||||
|
||||
class singleview_empty_element extends singleview_ui_element {
|
||||
class gradereport_singleview_empty_element extends gradereport_singleview_ui_element {
|
||||
public function __construct($msg = null) {
|
||||
if (is_null($msg)) {
|
||||
$this->text = get_string('notavailable', 'gradereport_singleview');
|
||||
|
@ -89,7 +90,7 @@ class singleview_empty_element extends singleview_ui_element {
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_text_attribute extends singleview_ui_element {
|
||||
class gradereport_singleview_text_attribute extends gradereport_singleview_ui_element {
|
||||
private $isdisabled;
|
||||
private $tabindex;
|
||||
|
||||
|
@ -141,7 +142,7 @@ class singleview_text_attribute extends singleview_ui_element {
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_checkbox_attribute extends singleview_ui_element {
|
||||
class gradereport_singleview_checkbox_attribute extends gradereport_singleview_ui_element {
|
||||
private $ischecked;
|
||||
private $tabindex;
|
||||
|
||||
|
@ -204,7 +205,7 @@ class singleview_checkbox_attribute extends singleview_ui_element {
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_dropdown_attribute extends singleview_ui_element {
|
||||
class gradereport_singleview_dropdown_attribute extends gradereport_singleview_ui_element {
|
||||
private $selected;
|
||||
private $options;
|
||||
private $isdisabled;
|
||||
|
@ -245,7 +246,7 @@ class singleview_dropdown_attribute extends singleview_ui_element {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class singleview_grade_attribute_format extends singleview_attribute_format implements unique_name, tabbable {
|
||||
abstract class gradereport_singleview_grade_attribute_format extends gradereport_singleview_attribute_format implements unique_name, tabbable {
|
||||
public $name;
|
||||
public $label;
|
||||
|
||||
|
@ -286,14 +287,14 @@ interface be_disabled {
|
|||
}
|
||||
|
||||
interface be_checked {
|
||||
public function ischecked();
|
||||
public function is_checked();
|
||||
}
|
||||
|
||||
interface tabbable {
|
||||
public function get_tabindex();
|
||||
}
|
||||
|
||||
class singleview_bulk_insert_ui extends singleview_ui_element {
|
||||
class gradereport_singleview_bulk_insert_ui extends gradereport_singleview_ui_element {
|
||||
public function __construct($item) {
|
||||
$this->name = 'bulk_' . $item->id;
|
||||
$this->applyname = $this->name_for('apply');
|
||||
|
@ -314,23 +315,21 @@ class singleview_bulk_insert_ui extends singleview_ui_element {
|
|||
}
|
||||
|
||||
public function html() {
|
||||
$s = function($key) {
|
||||
return get_string($key, 'gradereport_singleview');
|
||||
};
|
||||
|
||||
$apply = html_writer::checkbox($this->applyname, 1, false, ' ' . $s('bulk'));
|
||||
$insertgrade = get_string('bulkinsertgrade', 'gradereport_singleview');
|
||||
$insertappliesto = get_string('bulkappliesto', 'gradereport_singleview');
|
||||
|
||||
$apply = html_writer::checkbox($this->applyname, 1, false, $insertgrade);
|
||||
$insertoptions = array(
|
||||
'all' => $s('all_grades'),
|
||||
'blanks' => $s('blanks')
|
||||
'all' => get_string('all_grades', 'gradereport_singleview'),
|
||||
'blanks' => get_string('blanks', 'gradereport_singleview')
|
||||
);
|
||||
|
||||
$select = html_writer::select(
|
||||
$insertoptions, $this->selectname, 'blanks', false
|
||||
);
|
||||
|
||||
$label = html_writer::tag('label', $s('for'));
|
||||
$text = new singleview_text_attribute($this->insertname, "0", 'bulk');
|
||||
$label = html_writer::tag('label', $insertappliesto);
|
||||
$text = new gradereport_singleview_text_attribute($this->insertname, "0", 'bulk');
|
||||
return implode(' ', array($apply, $text->html(), $label, $select));
|
||||
}
|
||||
|
||||
|
@ -339,7 +338,7 @@ class singleview_bulk_insert_ui extends singleview_ui_element {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class singleview_attribute_format {
|
||||
abstract class gradereport_singleview_attribute_format {
|
||||
abstract public function determine_format();
|
||||
|
||||
public function __toString() {
|
||||
|
@ -347,7 +346,7 @@ abstract class singleview_attribute_format {
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_finalgrade_ui extends singleview_grade_attribute_format implements unique_value, be_disabled {
|
||||
class gradereport_singleview_finalgrade_ui extends gradereport_singleview_grade_attribute_format implements unique_value, be_disabled {
|
||||
|
||||
public $name = 'finalgrade';
|
||||
|
||||
|
@ -402,7 +401,7 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
|
|||
$options[$i + 1] = $name;
|
||||
}
|
||||
|
||||
return new singleview_dropdown_attribute(
|
||||
return new gradereport_singleview_dropdown_attribute(
|
||||
$this->get_name(),
|
||||
$options,
|
||||
$this->get_value(),
|
||||
|
@ -411,7 +410,7 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
|
|||
$this->get_tabindex()
|
||||
);
|
||||
} else {
|
||||
return new singleview_text_attribute(
|
||||
return new gradereport_singleview_text_attribute(
|
||||
$this->get_name(),
|
||||
$this->get_value(),
|
||||
$this->get_label(),
|
||||
|
@ -466,7 +465,7 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_feedback_ui extends singleview_grade_attribute_format implements unique_value, be_disabled {
|
||||
class gradereport_singleview_feedback_ui extends gradereport_singleview_grade_attribute_format implements unique_value, be_disabled {
|
||||
|
||||
public $name = 'feedback';
|
||||
|
||||
|
@ -503,7 +502,7 @@ class singleview_feedback_ui extends singleview_grade_attribute_format implement
|
|||
}
|
||||
|
||||
public function determine_format() {
|
||||
return new singleview_text_attribute(
|
||||
return new gradereport_singleview_text_attribute(
|
||||
$this->get_name(),
|
||||
$this->get_value(),
|
||||
$this->get_label(),
|
||||
|
@ -529,19 +528,19 @@ class singleview_feedback_ui extends singleview_grade_attribute_format implement
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_override_ui extends singleview_grade_attribute_format implements be_checked, be_disabled {
|
||||
class gradereport_singleview_override_ui extends gradereport_singleview_grade_attribute_format implements be_checked, be_disabled {
|
||||
public $name = 'override';
|
||||
|
||||
public function ischecked() {
|
||||
public function is_checked() {
|
||||
return $this->grade->is_overridden();
|
||||
}
|
||||
|
||||
public function is_disabled() {
|
||||
$lockedgrade = $lockedgradeitem = 0;
|
||||
if ( ! empty($this->grade->locked) ) {
|
||||
if (!empty($this->grade->locked)) {
|
||||
$lockedgrade = 1;
|
||||
}
|
||||
if ( ! empty($this->grade->grade_item->locked) ) {
|
||||
if (!empty($this->grade->grade_item->locked)) {
|
||||
$lockedgradeitem = 1;
|
||||
}
|
||||
return ($lockedgrade || $lockedgradeitem);
|
||||
|
@ -556,12 +555,12 @@ class singleview_override_ui extends singleview_grade_attribute_format implement
|
|||
|
||||
function determine_format() {
|
||||
if (!$this->grade->grade_item->is_overridable_item()) {
|
||||
return new singleview_empty_element();
|
||||
return new gradereport_singleview_empty_element();
|
||||
}
|
||||
return new singleview_checkbox_attribute(
|
||||
return new gradereport_singleview_checkbox_attribute(
|
||||
$this->get_name(),
|
||||
$this->get_label(),
|
||||
$this->ischecked(),
|
||||
$this->is_checked(),
|
||||
null,
|
||||
$this->is_disabled()
|
||||
);
|
||||
|
@ -580,18 +579,18 @@ class singleview_override_ui extends singleview_grade_attribute_format implement
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_exclude_ui extends singleview_grade_attribute_format implements be_checked {
|
||||
class gradereport_singleview_exclude_ui extends gradereport_singleview_grade_attribute_format implements be_checked {
|
||||
var $name = 'exclude';
|
||||
|
||||
function ischecked() {
|
||||
function is_checked() {
|
||||
return $this->grade->is_excluded();
|
||||
}
|
||||
|
||||
function determine_format() {
|
||||
return new singleview_checkbox_attribute(
|
||||
return new gradereport_singleview_checkbox_attribute(
|
||||
$this->get_name(),
|
||||
$this->get_label(),
|
||||
$this->ischecked()
|
||||
$this->is_checked()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -633,7 +632,7 @@ class singleview_exclude_ui extends singleview_grade_attribute_format implements
|
|||
}
|
||||
}
|
||||
|
||||
class singleview_range_ui extends singleview_attribute_format {
|
||||
class gradereport_singleview_range_ui extends gradereport_singleview_attribute_format {
|
||||
function __construct($item) {
|
||||
$this->item = $item;
|
||||
}
|
||||
|
@ -644,6 +643,6 @@ class singleview_range_ui extends singleview_attribute_format {
|
|||
$min = format_float($this->item->grademin, $decimals);
|
||||
$max = format_float($this->item->grademax, $decimals);
|
||||
|
||||
return new singleview_empty_element("$min - $max");
|
||||
return new gradereport_singleview_empty_element("$min - $max");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Displays the Single view
|
||||
* Displays the Single view
|
||||
*
|
||||
* @package gradereport_singleview
|
||||
* @copyright 2014 Moodle
|
||||
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
@ -46,7 +46,7 @@ if (!$course = $DB->get_record('course', $courseparams)) {
|
|||
print_error('nocourseid');
|
||||
}
|
||||
|
||||
if (!in_array($itemtype, grade_report_singleview::valid_screens())) {
|
||||
if (!in_array($itemtype, gradereport_singleview::valid_screens())) {
|
||||
print_error('notvalid', 'gradereport_singleview', '', $itemtype);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ $USER->grade_last_report[$course->id] = 'singleview';
|
|||
|
||||
grade_regrade_final_grades($courseid);
|
||||
|
||||
$report = new grade_report_singleview(
|
||||
$report = new gradereport_singleview(
|
||||
$courseid, $gpr, $context,
|
||||
$itemtype, $itemid, $groupid
|
||||
);
|
||||
|
@ -111,12 +111,12 @@ if ($data = data_submitted()) {
|
|||
|
||||
$graderrightnav = $graderleftnav = null;
|
||||
if ($report->screen instanceof selectable_items
|
||||
&& class_exists($report::classname($report->screen->item_type()))) {
|
||||
&& class_exists(gradereport_singleview::classname($report->screen->item_type()))) {
|
||||
|
||||
$optionkeys = array_keys($report->screen->options());
|
||||
$optionitemid = array_shift($optionkeys);
|
||||
|
||||
$relreport = new grade_report_singleview(
|
||||
$relreport = new gradereport_singleview(
|
||||
$courseid, $gpr, $context,
|
||||
$report->screen->item_type(), $optionitemid, $groupid
|
||||
);
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
$string['all_grades'] = 'All grades';
|
||||
$string['assessmentname'] = 'Assessment Name';
|
||||
$string['blanks'] = 'Empty grades';
|
||||
$string['bulk'] = 'Insert';
|
||||
$string['bulkappliesto'] = 'for';
|
||||
$string['bulkinsertgrade'] = 'Bulk insert';
|
||||
$string['bulkfor'] = 'Grades for {$a}';
|
||||
$string['exclude'] = 'Exclude';
|
||||
$string['excludeall'] = 'Exclude all grades';
|
||||
|
@ -35,14 +36,13 @@ $string['excludefor'] = 'Exclude for {$a}';
|
|||
$string['excludenone'] = 'Exclude no grades';
|
||||
$string['feedbackfor'] = 'Feedback for {$a}';
|
||||
$string['filtergrades'] = 'Show grades for {$a}.';
|
||||
$string['for'] = 'for';
|
||||
$string['gradefor'] = 'Grade for {$a}';
|
||||
$string['noscreens'] = 'Could not find a suitable Single view screen.';
|
||||
$string['notallowed'] = 'Not allowed to quick edit this item';
|
||||
$string['notvalid'] = 'Not a valid Single view screen: {$a}';
|
||||
$string['override'] = 'Override';
|
||||
$string['overrideall'] = 'Override all grades';
|
||||
$string['overridefor'] = 'Override for {$a}';
|
||||
$string['overridenone'] = 'Override no grades';
|
||||
$string['pluginname'] = 'Single view';
|
||||
$string['singleview:view'] = 'View the '.$string['pluginname'].' report';
|
||||
$string['noscreens'] = 'Could not find a suitable Single view screen.';
|
||||
$string['notallowed'] = 'Not allowed to quick edit this item';
|
||||
$string['notvalid'] = 'Not a valid Single view screen: {$a}';
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
* Base lib class for singleview functionality.
|
||||
*
|
||||
* @package gradereport_singleview
|
||||
* @copyright 2014 Moodle
|
||||
* @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/lib.php');
|
||||
require_once($CFG->dirroot . '/grade/report/singleview/classes/lib.php');
|
||||
|
||||
class grade_report_singleview extends grade_report {
|
||||
class gradereport_singleview extends grade_report {
|
||||
|
||||
public static function valid_screens() {
|
||||
$screendir = dirname(__FILE__) . '/screens';
|
||||
|
@ -54,11 +54,11 @@ class grade_report_singleview extends grade_report {
|
|||
|
||||
require_once $screendir . '/lib.php';
|
||||
|
||||
return 'singleview_' . $screen;
|
||||
return 'gradereport_singleview_' . $screen;
|
||||
}
|
||||
|
||||
public static function filters() {
|
||||
$classnames = array('grade_report_singleview', 'classname');
|
||||
$classnames = array('gradereport_singleview', 'classname');
|
||||
$classes = array_map($classnames, self::valid_screens());
|
||||
|
||||
$screens = array_filter($classes, function($screen) {
|
||||
|
@ -115,10 +115,10 @@ class grade_report_singleview extends grade_report {
|
|||
}
|
||||
}
|
||||
|
||||
function grade_report_singleview_profilereport($course, $user) {
|
||||
function gradereport_singleview_profilereport($course, $user) {
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
if (!function_exists('grade_report_user_profilereport')) {
|
||||
if (!function_exists('gradereport_user_profilereport')) {
|
||||
require_once $CFG->dirroot . '/grade/report/user/lib.php';
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ function grade_report_singleview_profilereport($course, $user) {
|
|||
);
|
||||
|
||||
if (!$can_use) {
|
||||
grade_report_user_profilereport($course, $user);
|
||||
gradereport_user_profilereport($course, $user);
|
||||
} else {
|
||||
$gpr = new grade_plugin_return(array(
|
||||
'type' => 'report',
|
||||
|
@ -140,7 +140,7 @@ function grade_report_singleview_profilereport($course, $user) {
|
|||
'userid' => $user->id
|
||||
));
|
||||
|
||||
$report = new grade_report_singleview($course->id, $gpr, $context, 'user', $user->id);
|
||||
$report = new gradereport_singleview($course->id, $gpr, $context, 'user', $user->id);
|
||||
|
||||
echo $OUTPUT->heading($report->screen->heading());
|
||||
echo $report->output();
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
class singleview_grade extends singleview_tablelike
|
||||
implements selectable_items, item_filtering {
|
||||
class gradereport_singleview_grade extends gradereport_singleview_tablelike
|
||||
implements gradereport_selectable_items, gradereport_item_filtering {
|
||||
|
||||
private $totalitemcount = 0;
|
||||
|
||||
private $requiresextra = false;
|
||||
|
||||
private $requirespaging = false;
|
||||
private $requirespaging = true;
|
||||
|
||||
public $structure;
|
||||
|
||||
|
@ -84,28 +86,17 @@ class singleview_grade extends singleview_tablelike
|
|||
$roleids = explode(',', get_config('moodle', 'gradebookroles'));
|
||||
|
||||
$this->items = get_role_users(
|
||||
$roleids, $this->context, false, '',
|
||||
'u.lastname, u.firstname', null, $this->groupid,
|
||||
$this->perpage * $this->page, $this->perpage
|
||||
);
|
||||
$roleids, $this->context, false, '',
|
||||
'u.lastname, u.firstname', null, $this->groupid,
|
||||
$this->perpage * $this->page, $this->perpage
|
||||
);
|
||||
|
||||
$this->totalitemcount = count_role_users($roleids, $this->context);
|
||||
|
||||
if ($selfitemisempty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only page when necessary.
|
||||
if (count($this->items) > $this->perpage) {
|
||||
$this->requirespaging = true;
|
||||
|
||||
$this->all_items = $this->items;
|
||||
|
||||
$this->items = get_role_users(
|
||||
$roleids, $this->context, false, '',
|
||||
'u.lastname, u.firstname', null, $this->groupid,
|
||||
$this->perpage * $this->page, $this->perpage
|
||||
);
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
||||
$params = array(
|
||||
|
@ -115,12 +106,12 @@ class singleview_grade extends singleview_tablelike
|
|||
|
||||
$this->item = grade_item::fetch($params);
|
||||
|
||||
$filterfun = grade_report_singleview::filters();
|
||||
$filterfun = gradereport_singleview::filters();
|
||||
|
||||
$allowed = $filterfun($this->item);
|
||||
|
||||
if (empty($allowed)) {
|
||||
print_error('not_allowed', 'gradereport_singleview');
|
||||
print_error('notallowed', 'gradereport_singleview');
|
||||
}
|
||||
|
||||
$this->requiresextra = !$this->item->is_manual_item();
|
||||
|
@ -132,16 +123,16 @@ class singleview_grade extends singleview_tablelike
|
|||
}
|
||||
|
||||
public function original_headers() {
|
||||
$headers = array(
|
||||
return array(
|
||||
'', // For filter icon.
|
||||
'', // For user picture.
|
||||
get_string('firstname') . ' (' . get_string('alternatename') . ') ' . get_string('lastname'),
|
||||
get_string('range', 'grades'),
|
||||
get_string('grade', 'grades'),
|
||||
get_string('feedback', 'grades')
|
||||
get_string('feedback', 'grades'),
|
||||
$this->make_toggle_links('override'),
|
||||
$this->make_toggle_links('exclude')
|
||||
);
|
||||
|
||||
return $this->additional_headers($headers);
|
||||
}
|
||||
|
||||
public function format_line($item) {
|
||||
|
@ -179,20 +170,10 @@ class singleview_grade extends singleview_tablelike
|
|||
html_writer::link($url, $fullname),
|
||||
$this->item_range()
|
||||
);
|
||||
|
||||
|
||||
return $this->format_definition($line, $grade);
|
||||
}
|
||||
|
||||
public function additional_headers($headers) {
|
||||
if ($this->requiresextra) {
|
||||
$headers[] = $this->make_toggle_links('override');
|
||||
}
|
||||
|
||||
$headers[] = $this->make_toggle_links('exclude');
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public function item_range() {
|
||||
if (empty($this->range)) {
|
||||
$this->range = $this->factory()->create('range')->format($this->item);
|
||||
|
@ -209,7 +190,7 @@ class singleview_grade extends singleview_tablelike
|
|||
global $OUTPUT;
|
||||
|
||||
return $OUTPUT->paging_bar(
|
||||
count($this->all_items), $this->page, $this->perpage,
|
||||
$this->totalitemcount, $this->page, $this->perpage,
|
||||
new moodle_url('/grade/report/singleview/index.php', array(
|
||||
'perpage' => $this->perpage,
|
||||
'id' => $this->courseid,
|
||||
|
|
|
@ -23,10 +23,15 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
class singleview_select extends singleview_screen {
|
||||
class gradereport_singleview_select extends gradereport_singleview_screen {
|
||||
public function init($selfitemisempty = false) {
|
||||
global $DB;
|
||||
|
||||
$this->items = get_role_users(
|
||||
'', $this->context, false, '',
|
||||
'u.lastname, u.firstname', null, $this->groupid,
|
||||
$this->perpage * $this->page, $this->perpage
|
||||
);
|
||||
$this->item = $DB->get_record('course', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
|
@ -35,14 +40,14 @@ class singleview_select extends singleview_screen {
|
|||
|
||||
$html = '';
|
||||
|
||||
$types = grade_report_singleview::valid_screens();
|
||||
$types = gradereport_singleview::valid_screens();
|
||||
|
||||
foreach ($types as $type) {
|
||||
$class = grade_report_singleview::classname($type);
|
||||
$class = gradereport_singleview::classname($type);
|
||||
|
||||
$screen = new $class($this->courseid, null, $this->groupid);
|
||||
|
||||
if (!$screen instanceof selectable_items) {
|
||||
if (!$screen instanceof gradereport_selectable_items) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -65,7 +70,7 @@ class singleview_select extends singleview_screen {
|
|||
}
|
||||
|
||||
if (empty($html)) {
|
||||
$OUTPUT->notification(get_string('no_screens', 'gradereport_singleview'));
|
||||
$OUTPUT->notification(get_string('noscreens', 'gradereport_singleview'));
|
||||
}
|
||||
|
||||
return $html;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
class singleview_user extends singleview_tablelike implements selectable_items {
|
||||
class gradereport_singleview_user extends gradereport_singleview_tablelike implements gradereport_selectable_items {
|
||||
|
||||
private $categories = array();
|
||||
|
||||
|
@ -64,7 +64,7 @@ class singleview_user extends singleview_tablelike implements selectable_items {
|
|||
}
|
||||
}
|
||||
|
||||
$this->items = array_filter($seq->items, grade_report_singleview::filters());
|
||||
$this->items = array_filter($seq->items, gradereport_singleview::filters());
|
||||
|
||||
unset($seq);
|
||||
|
||||
|
@ -105,10 +105,15 @@ class singleview_user extends singleview_tablelike implements selectable_items {
|
|||
$lockeditemgrade = 1;
|
||||
}
|
||||
// Check both grade and grade item.
|
||||
if ( $lockeditem || $lockeditemgrade )
|
||||
if ($lockeditem || $lockeditemgrade) {
|
||||
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked');
|
||||
}
|
||||
|
||||
$url = new moodle_url("/mod/$item->itemmodule/view.php", array('id' => $item->cmid));
|
||||
$realuserid = '';
|
||||
if (isset($item->cmid)) {
|
||||
$realuserid = $item->cmid;
|
||||
}
|
||||
$url = new moodle_url("/mod/$item->itemmodule/view.php", array('id' => $realuserid));
|
||||
$iconstring = get_string('filtergrades', 'gradereport_singleview', $item->get_name());
|
||||
$grade->label = $item->get_name();
|
||||
|
||||
|
@ -152,10 +157,6 @@ class singleview_user extends singleview_tablelike implements selectable_items {
|
|||
}
|
||||
|
||||
public function heading() {
|
||||
if (!empty($this->item->alternatename)) {
|
||||
return $this->item->alternatename . ' (' . $this->item->firstname . ') ' . $this->item->lastname;
|
||||
} else {
|
||||
return fullname($this->item);
|
||||
}
|
||||
return fullname($this->item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
input[name^="finalgrade"] {
|
||||
#page-grade-report-singleview-index input[name^="finalgrade"] {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
@core @core_grades @singleview
|
||||
@core @core_grades @gradereport_singleview
|
||||
Feature: We can use Single view
|
||||
As a teacher
|
||||
In order to view a user or an activities grades
|
||||
In order to view and edit grades
|
||||
For users and activities for a course.
|
||||
|
||||
Background:
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | groupmode |
|
||||
| Course 1 | C1 | 0 | 1 |
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email | idnumber | alternatename |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com | t1 | teacherbro |
|
||||
|
@ -31,37 +32,27 @@ Background:
|
|||
| assign | C1 | a2 | Test assignment two | Submit something! | 100 |
|
||||
| assign | C1 | a3 | Test assignment three | Submit something! | 150 |
|
||||
| assign | C1 | a4 | Test assignment four | Submit nothing! | 150 |
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | name | intro | gradecategory | grade |
|
||||
| assign | C1 | a5 | Test assignment five | Submit something! | Sub category 1 | 200
|
||||
| assign | C1 | a6 | Test assignment six | Submit something! | Sub category 1 | 100
|
||||
| assign | C1 | a7 | Test assignment seven | Submit nothing! | Sub category 1 | 150
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | name | intro | gradecategory | grade |
|
||||
| assign | C1 | a8 | Test assignment eight | Submit something! | Sub category 2 | 200
|
||||
| assign | C1 | a9 | Test assignment nine | Submit something! | Sub category 2 | 100
|
||||
| assign | C1 | 10 | Test assignment ten | Submit nothing! | Sub category 2 | 150
|
||||
And I log in as "teacher1"
|
||||
Then I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Grades"
|
||||
|
||||
@javascript
|
||||
Scenario: I can update grades, add feedback and exclude grades.
|
||||
And I click on "Single view" "option"
|
||||
And I click on "studentawesemo (Student) 4" "option"
|
||||
And I click on "Override for Test assignment eight" "checkbox"
|
||||
@javascript
|
||||
Scenario: I can update grades, add feedback and exclude grades.
|
||||
Given I click on "Single view" "option"
|
||||
Then I click on "studentawesemo (Student) 4" "option"
|
||||
And I click on "Override for Test assignment one" "checkbox"
|
||||
And I set the following fields to these values:
|
||||
| Grade for Test assignment eight | 10.00 |
|
||||
| Feedback for Test assignment eight | test data |
|
||||
| Grade for Test assignment one | 10.00 |
|
||||
| Feedback for Test assignment one | test data |
|
||||
And I click on "Exclude for Test assignment four" "checkbox"
|
||||
And I press "Update"
|
||||
Then the following should exist in the "user-grades" table:
|
||||
| Test assignment four |
|
||||
| excluded |
|
||||
Then the following should exist in the "user-grades" table:
|
||||
| Test assignment eight |
|
||||
| Test assignment one |
|
||||
| 10.00 |
|
||||
And I click on "Single view for Test assignment five" "link"
|
||||
And I click on "Single view for Test assignment three" "link"
|
||||
And I click on "Override for studentbro (Student) 1" "checkbox"
|
||||
And I set the following fields to these values:
|
||||
| Grade for studentbro (Student) 1 | 12.05 |
|
||||
|
@ -69,22 +60,30 @@ Scenario: I can update grades, add feedback and exclude grades.
|
|||
And I click on "Exclude for studentjo (Student) 2" "checkbox"
|
||||
And I press "Update"
|
||||
Then the following should exist in the "user-grades" table:
|
||||
| Test assignment five |
|
||||
| Test assignment three |
|
||||
| 12.05 |
|
||||
| Excluded |
|
||||
|
||||
@javascript
|
||||
Scenario: Single view quick links work on grade report.
|
||||
And I follow "Single view for Test assignment one"
|
||||
And I follow "Grader report"
|
||||
@javascript
|
||||
Scenario: Single view quick links work on grade report.
|
||||
Given I follow "Single view for Test assignment one"
|
||||
Then I should see "Test assignment one"
|
||||
Then I follow "Grader report"
|
||||
And I follow "Single view for Student 1"
|
||||
Then I should see "Student 1"
|
||||
|
||||
@javascript
|
||||
Scenario: Navigation works in the Single view.
|
||||
And I click on "Single view" "option"
|
||||
And I click on "studentbro (Student) 1" "option"
|
||||
@javascript
|
||||
Scenario: Navigation works in the Single view.
|
||||
Given I click on "Single view" "option"
|
||||
Then I click on "studentbro (Student) 1" "option"
|
||||
Then I should see "Student 1"
|
||||
And I follow "studentjo (Student) 2"
|
||||
Then I should see "Student 2"
|
||||
And I follow "studentbro (Student) 1"
|
||||
And I click on "Show grades for Test assignment five" "link"
|
||||
And I follow "Test assignment six"
|
||||
And I follow "Test assignment five"
|
||||
Then I should see "Student 1"
|
||||
And I click on "Show grades for Test assignment four" "link"
|
||||
Then I should see "Test assignment four"
|
||||
And I follow "Test assignment three"
|
||||
Then I should see "Test assignment three"
|
||||
And I follow "Test assignment four"
|
||||
Then I should see "Test assignment four"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* Standard version file
|
||||
*
|
||||
* @package gradereport_singleview
|
||||
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
||||
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
|
|
@ -1038,7 +1038,7 @@ class core_plugin_manager {
|
|||
),
|
||||
|
||||
'gradereport' => array(
|
||||
'grader', 'history', 'outcomes', 'overview', 'user'
|
||||
'grader', 'history', 'outcomes', 'overview', 'user', 'singleview'
|
||||
),
|
||||
|
||||
'gradingform' => array(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue