MDL-18229 gradebook: Updating code to Moodle standard.

This commit is contained in:
Zachary Durber
2014-10-14 10:26:46 +08:00
parent 92c61fee64
commit 65c134f98a
10 changed files with 328 additions and 326 deletions
+4 -6
View File
@@ -18,7 +18,7 @@
/**
* The gradebook simple view - base class for the table
*
* @package singleview
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -213,7 +213,9 @@ abstract class singleview_screen {
$oldname = "old$name";
$posted = $data->$name;
$oldvalue = $data->$oldname;
if (isset($data->$oldname)) {
$oldvalue = $data->$oldname;
}
$format = $element->determine_format();
@@ -240,8 +242,6 @@ abstract class singleview_screen {
$event_data->post_data = $data;
$event_data->instance = $this;
qe_events_trigger(get_class($this) . '_edited', $event_data);
return $event_data->warnings;
}
@@ -378,8 +378,6 @@ abstract class singleview_tablelike extends singleview_screen implements tabbabl
$data->table = $table;
$data->instance = $this;
qe_events_trigger($underlying . '_table_built', $data);
$button_attr = array('class' => 'singleview_buttons submit');
$button_html = implode(' ', $this->buttons());
+108 -93
View File
@@ -18,7 +18,7 @@
/**
* The gradebook simple view - UI factory
*
* @package singleview
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -38,11 +38,11 @@ class singleview_grade_ui_factory extends singleview_ui_factory {
}
class singleview_factory_class_wrap {
function __construct($class) {
public function __construct($class) {
$this->class = $class;
}
function format() {
public function format() {
$args = func_get_args();
$reflect = new ReflectionClass($this->class);
@@ -54,28 +54,28 @@ abstract class singleview_ui_element {
var $name;
var $value;
function __construct($name, $value) {
public function __construct($name, $value) {
$this->name = $name;
$this->value = $value;
}
function is_checkbox() {
public function is_checkbox() {
return false;
}
function is_textbox() {
public function is_textbox() {
return false;
}
function is_dropdown() {
public function is_dropdown() {
return false;
}
abstract function html();
abstract public function html();
}
class singleview_empty_element extends singleview_ui_element {
function __construct($msg = null) {
public function __construct($msg = null) {
if (is_null($msg)) {
$this->text = get_string('notavailable', 'gradereport_singleview');
} else {
@@ -83,26 +83,26 @@ class singleview_empty_element extends singleview_ui_element {
}
}
function html() {
public function html() {
return $this->text;
}
}
class singleview_text_attribute extends singleview_ui_element {
var $is_disabled;
var $tabindex;
private $isdisabled;
private $tabindex;
function __construct($name, $value, $is_disabled = false, $tabindex = null) {
$this->is_disabled = $is_disabled;
public function __construct($name, $value, $isdisabled = false, $tabindex = null) {
$this->isdisabled = $isdisabled;
$this->tabindex = $tabindex;
parent::__construct($name, $value);
}
function is_textbox() {
public function is_textbox() {
return true;
}
function html() {
public function html() {
$attributes = array(
'type' => 'text',
'name' => $this->name,
@@ -112,7 +112,7 @@ class singleview_text_attribute extends singleview_ui_element {
if (!empty($this->tabindex)) {
$attributes['tabindex'] = $this->tabindex;
}
if ($this->is_disabled) {
if ($this->isdisabled) {
$attributes['disabled'] = 'DISABLED';
}
@@ -122,29 +122,29 @@ class singleview_text_attribute extends singleview_ui_element {
'value' => $this->value
);
return (
html_writer::empty_tag('input', $attributes) .
return (
html_writer::empty_tag('input', $attributes) .
html_writer::empty_tag('input', $hidden)
);
}
}
class singleview_checkbox_attribute extends singleview_ui_element {
var $is_checked;
var $tabindex;
private $ischecked;
private $tabindex;
function __construct($name, $is_checked = false, $tabindex = null, $locked=0) {
$this->is_checked = $is_checked;
public function __construct($name, $ischecked = false, $tabindex = null, $locked=0) {
$this->ischecked = $ischecked;
$this->tabindex = $tabindex;
$this->locked = $locked;
parent::__construct($name, 1);
}
function is_checkbox() {
public function is_checkbox() {
return true;
}
function html() {
public function html() {
$attributes = array(
'type' => 'checkbox',
@@ -172,7 +172,7 @@ class singleview_checkbox_attribute extends singleview_ui_element {
$attributes['tabindex'] = $this->tabindex;
}
if ($this->is_checked) {
if ($this->ischecked) {
$attributes['checked'] = 'CHECKED';
$hidden['value'] = 1;
}
@@ -186,23 +186,23 @@ class singleview_checkbox_attribute extends singleview_ui_element {
}
class singleview_dropdown_attribute extends singleview_ui_element {
var $selected;
var $options;
var $is_disabled;
private $selected;
private $options;
private $isdisabled;
function __construct($name, $options, $selected = '', $is_disabled = false, $tabindex = null) {
public function __construct($name, $options, $selected = '', $isdisabled = false, $tabindex = null) {
$this->selected = $selected;
$this->options = $options;
$this->tabindex = $tabindex;
$this->is_disabled = $is_disabled;
$this->isdisabled = $isdisabled;
parent::__construct($name, $selected);
}
function is_dropdown() {
public function is_dropdown() {
return true;
}
function html() {
public function html() {
$old = array(
'type' => 'hidden',
'name' => 'old' . $this->name,
@@ -214,7 +214,7 @@ class singleview_dropdown_attribute extends singleview_ui_element {
$attributes['tabindex'] = $this->tabindex;
}
if (!empty($this->is_disabled)) {
if (!empty($this->isdisabled)) {
$attributes['disabled'] = 'DISABLED';
}
@@ -227,20 +227,20 @@ class singleview_dropdown_attribute extends singleview_ui_element {
}
abstract class singleview_grade_attribute_format extends singleview_attribute_format implements unique_name, tabbable {
var $name;
public $name;
function __construct() {
public function __construct() {
$args = func_get_args();
$this->get_arg_or_nothing($args, 0, 'grade');
$this->get_arg_or_nothing($args, 1, 'tabindex');
}
function get_name() {
public function get_name() {
return "{$this->name}_{$this->grade->itemid}_{$this->grade->userid}";
}
function get_tabindex() {
public function get_tabindex() {
return isset($this->tabindex) ? $this->tabindex : null;
}
@@ -254,62 +254,62 @@ abstract class singleview_grade_attribute_format extends singleview_attribute_fo
}
interface unique_name {
function get_name();
public function get_name();
}
interface unique_value {
function get_value();
public function get_value();
}
interface be_disabled {
function is_disabled();
public function is_disabled();
}
interface be_checked {
function is_checked();
public function ischecked();
}
interface tabbable {
function get_tabindex();
public function get_tabindex();
}
class singleview_bulk_insert_ui extends singleview_ui_element {
function __construct($item) {
public function __construct($item) {
$this->name = 'bulk_' . $item->id;
$this->applyname = $this->name_for('apply');
$this->selectname = $this->name_for('type');
$this->insertname = $this->name_for('value');
}
function is_applied($data) {
public function is_applied($data) {
return isset($data->{$this->applyname});
}
function get_type($data) {
public function get_type($data) {
return $data->{$this->selectname};
}
function get_insert_value($data) {
public function get_insert_value($data) {
return $data->{$this->insertname};
}
function html() {
$_s = function($key) {
public function html() {
$s = function($key) {
return get_string($key, 'gradereport_singleview');
};
$apply = html_writer::checkbox($this->applyname, 1, false, ' ' . $_s('bulk'));
$apply = html_writer::checkbox($this->applyname, 1, false, ' ' . $s('bulk'));
$insert_options = array(
'all' => $_s('all_grades'),
'blanks' => $_s('blanks')
$insertoptions = array(
'all' => $s('all_grades'),
'blanks' => $s('blanks')
);
$select = html_writer::select(
$insert_options, $this->selectname, 'blanks', false
$insertoptions, $this->selectname, 'blanks', false
);
$label = html_writer::tag('label', $_s('for'));
$label = html_writer::tag('label', $s('for'));
$text = new singleview_text_attribute($this->insertname, "0");
return implode(' ', array($apply, $text->html(), $label, $select));
}
@@ -320,18 +320,18 @@ class singleview_bulk_insert_ui extends singleview_ui_element {
}
abstract class singleview_attribute_format {
abstract function determine_format();
abstract public function determine_format();
function __toString() {
public function __toString() {
return $this->determine_format()->html();
}
}
class singleview_finalgrade_ui extends singleview_grade_attribute_format implements unique_value, be_disabled {
var $name = 'finalgrade';
public $name = 'finalgrade';
function get_value() {
public function get_value() {
// Manual item raw grade support.
$val = $this->grade->grade_item->is_manual_item() && (!is_null($this->grade->rawgrade)) ?
$this->grade->rawgrade : $this->grade->finalgrade;
@@ -343,7 +343,7 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
}
}
function is_disabled() {
public function is_disabled() {
$locked = 0;
$gradeitemlocked = 0;
$overridden = 0;
@@ -352,13 +352,19 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
* 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;
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;
}
return ($locked || $gradeitemlocked || $overridden);
}
function determine_format() {
public function determine_format() {
if ($this->grade->grade_item->load_scale()) {
$scale = $this->grade->grade_item->load_scale();
@@ -385,15 +391,15 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
}
}
function set($value) {
public function set($value) {
global $DB;
$userid = $this->grade->userid;
$grade_item = $this->grade->grade_item;
$gradeitem = $this->grade->grade_item;
$feedback = false;
$feedbackformat = false;
if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
if ($gradeitem->gradetype == GRADE_TYPE_SCALE) {
if ($value == -1) {
$finalgrade = null;
} else {
@@ -404,9 +410,8 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
}
$errorstr = '';
if (is_null($finalgrade)) {
} else {
$bounded = $grade_item->bounded_grade($finalgrade);
if ($finalgrade) {
$bounded = $gradeitem->bounded_grade($finalgrade);
if ($bounded > $finalgrade) {
$errorstr = 'lessthanmin';
} else if ($bounded < $finalgrade) {
@@ -427,20 +432,20 @@ class singleview_finalgrade_ui extends singleview_grade_attribute_format impleme
$errorstr = get_string($errorstr, 'grades', $gradestr);
}
$grade_item->update_final_grade($userid, $finalgrade, 'singleview', $feedback, FORMAT_MOODLE);
$gradeitem->update_final_grade($userid, $finalgrade, 'singleview', $feedback, FORMAT_MOODLE);
return $errorstr;
}
}
class singleview_feedback_ui extends singleview_grade_attribute_format implements unique_value, be_disabled {
var $name = 'feedback';
public $name = 'feedback';
function get_value() {
public function get_value() {
return $this->grade->feedback ? $this->grade->feedback : '';
}
function is_disabled() {
public function is_disabled() {
$locked = 0;
$gradeitemlocked = 0;
$overridden = 0;
@@ -449,13 +454,19 @@ class singleview_feedback_ui extends singleview_grade_attribute_format implement
* 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;
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;
}
return ($locked || $gradeitemlocked || $overridden);
}
function determine_format() {
public function determine_format() {
return new singleview_text_attribute(
$this->get_name(),
$this->get_value(),
@@ -464,11 +475,11 @@ class singleview_feedback_ui extends singleview_grade_attribute_format implement
);
}
function set($value) {
public function set($value) {
$finalgrade = false;
$trimmed = trim($value);
if (empty($trimmed)) {
$feedback = NULL;
$feedback = null;
} else {
$feedback = $value;
}
@@ -482,17 +493,21 @@ class singleview_feedback_ui extends singleview_grade_attribute_format implement
}
class singleview_override_ui extends singleview_grade_attribute_format implements be_checked, be_disabled {
var $name = 'override';
public $name = 'override';
function is_checked() {
public function ischecked() {
return $this->grade->is_overridden();
}
function is_disabled() {
$locked_grade = $locked_grade_item = 0;
if ( ! empty($this->grade->locked) ) $locked_grade = 1;
if ( ! empty($this->grade->grade_item->locked) ) $locked_grade_item = 1;
return ($locked_grade || $locked_grade_item);
public function is_disabled() {
$lockedgrade = $lockedgradeitem = 0;
if ( ! empty($this->grade->locked) ) {
$lockedgrade = 1;
}
if ( ! empty($this->grade->grade_item->locked) ) {
$lockedgradeitem = 1;
}
return ($lockedgrade || $lockedgradeitem);
}
function determine_format() {
@@ -501,7 +516,7 @@ class singleview_override_ui extends singleview_grade_attribute_format implement
}
return new singleview_checkbox_attribute(
$this->get_name(),
$this->is_checked(),
$this->ischecked(),
null,
$this->is_disabled()
);
@@ -523,14 +538,14 @@ class singleview_override_ui extends singleview_grade_attribute_format implement
class singleview_exclude_ui extends singleview_grade_attribute_format implements be_checked {
var $name = 'exclude';
function is_checked() {
function ischecked() {
return $this->grade->is_excluded();
}
function determine_format() {
return new singleview_checkbox_attribute(
$this->get_name(),
$this->is_checked()
$this->ischecked()
);
}
@@ -540,10 +555,10 @@ class singleview_exclude_ui extends singleview_grade_attribute_format implements
return false;
}
$grade_item = $this->grade->grade_item;
$gradeitem = $this->grade->grade_item;
// Fill in arbitrary grade to be excluded.
$grade_item->update_final_grade(
$gradeitem->update_final_grade(
$this->grade->userid, null, 'singleview', null, FORMAT_MOODLE
);
@@ -553,7 +568,7 @@ class singleview_exclude_ui extends singleview_grade_attribute_format implements
);
$this->grade = grade_grade::fetch($grade_params);
$this->grade->grade_item = $grade_item;
$this->grade->grade_item = $gradeitem;
}
$state = $value == 0 ? false : true;
+22 -25
View File
@@ -1,28 +1,27 @@
<?php // $Id: access.php,v 1.5 2008-05-10 06:34:23 pcali1 Exp $
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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 - Database file
*
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
@@ -36,5 +35,3 @@ $capabilities = array(
)
)
);
?>
+50 -52
View File
@@ -1,48 +1,48 @@
<?php
///////////////////////////////////////////////////////////////////////////
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
require_once '../../../config.php';
require_once $CFG->dirroot.'/lib/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/singleview/lib.php';
/**
* Displays the Single view
*
* @package gradereport_singleview
* @copyright 2014 Moodle
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../../config.php');
require_once($CFG->dirroot.'/lib/gradelib.php');
require_once($CFG->dirroot.'/grade/lib.php');
require_once($CFG->dirroot.'/grade/report/singleview/lib.php');
$courseid = required_param('id', PARAM_INT);
$groupid = optional_param('group', null, PARAM_INT);
// Making this work with profile reports
$userid = optional_param('userid', null, PARAM_INT);
$default_type = $userid ? 'user' : 'select';
$defaulttype = $userid ? 'user' : 'select';
$itemid = optional_param('itemid', $userid, PARAM_INT);
$itemtype = optional_param('item', $default_type, PARAM_TEXT);
$itemtype = optional_param('item', $defaulttype, PARAM_TEXT);
$course_params = array('id' => $courseid);
$courseparams = array('id' => $courseid);
$PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $course_params));
$PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $courseparams));
if (!$course = $DB->get_record('course', $course_params)) {
if (!$course = $DB->get_record('course', $courseparams)) {
print_error('nocourseid');
}
@@ -54,11 +54,11 @@ require_login($course);
$context = context_course::instance($course->id);
// This is the normal requirements
// This is the normal requirements.
require_capability('gradereport/singleview:view', $context);
require_capability('moodle/grade:viewall', $context);
require_capability('moodle/grade:edit', $context);
// End permission
// End permission.
$gpr = new grade_plugin_return(array(
'type' => 'report',
@@ -66,7 +66,7 @@ $gpr = new grade_plugin_return(array(
'courseid' => $courseid
));
/// last selected report session tracking
// Last selected report session tracking.
if (!isset($USER->grade_last_report)) {
$USER->grade_last_report = array();
}
@@ -83,19 +83,19 @@ $reportname = $report->screen->heading();
$pluginname = get_string('pluginname', 'gradereport_singleview');
$report_url = new moodle_url('/grade/report/grader/index.php', $course_params);
$edit_url = new moodle_url('/grade/report/singleview/index.php', $course_params);
$reporturl = new moodle_url('/grade/report/grader/index.php', $courseparams);
$editurl = new moodle_url('/grade/report/singleview/index.php', $courseparams);
$PAGE->navbar->ignore_active(true);
$PAGE->navbar->add(get_string('courses'));
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', $course_params));
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', $courseparams));
$PAGE->navbar->add(get_string('gradeadministration', 'grades'));
$PAGE->navbar->add(get_string('pluginname', 'gradereport_grader'), $report_url);
$PAGE->navbar->add(get_string('pluginname', 'gradereport_grader'), $reporturl);
if ($reportname != $pluginname) {
$PAGE->navbar->add($pluginname, $edit_url);
$PAGE->navbar->add($pluginname, $editurl);
$PAGE->navbar->add($reportname);
} else {
$PAGE->navbar->add($pluginname);
@@ -105,16 +105,16 @@ if ($data = data_submitted()) {
$warnings = $report->process_data($data);
if (empty($warnings)) {
redirect($report_url);
redirect($reporturl);
}
}
$graderrightnav = $graderleftnav = null;
if ($report->screen instanceof selectable_items
&& class_exists($report::classname($report->screen->item_type()))) { //should be ok for user and grade for now, allows other cross singleview nav too.
&& class_exists($report::classname($report->screen->item_type()))) {
$optionkeys = array_keys($report->screen->options());
$optionitemid = array_shift($optionkeys); //just any one thanks
$optionitemid = array_shift($optionkeys);
$relreport = new grade_report_singleview(
$courseid, $gpr, $context,
@@ -125,26 +125,26 @@ if ($report->screen instanceof selectable_items
$i = array_search($itemid, $reloptionssorting);
$navparams = array('item' => $itemtype, 'id' => $courseid, 'group' => $groupid);
if ($i>0) {
$navparams['itemid'] = $reloptionssorting[$i-1];
if ($i > 0) {
$navparams['itemid'] = $reloptionssorting[$i - 1];
$link = new moodle_url('/grade/report/singleview/index.php', $navparams);
$navprev=html_writer::link($link, $reloptions[$reloptionssorting[$i-1]]);
$navprev = html_writer::link($link, $reloptions[$reloptionssorting[$i - 1]]);
$graderleftnav = html_writer::tag('small', $navprev, array('class' => 'itemnav previtem'));
}
if ($i<count($reloptionssorting)-1) {
$navparams['itemid'] = $reloptionssorting[$i+1];
if ($i < count($reloptionssorting) - 1) {
$navparams['itemid'] = $reloptionssorting[$i + 1];
$link = new moodle_url('/grade/report/singleview/index.php', $navparams);
$navnext=html_writer::link($link, $reloptions[$reloptionssorting[$i+1]]);
$navnext = html_writer::link($link, $reloptions[$reloptionssorting[$i + 1]]);
$graderrightnav = html_writer::tag('small', $navnext, array('class' => 'itemnav nextitem'));
}
}
print_grade_page_head($course->id, 'report', 'singleview', $reportname);
if(!is_null($graderleftnav)) {
if (!is_null($graderleftnav)) {
echo $graderleftnav;
}
if(!is_null($graderrightnav)) {
if (!is_null($graderrightnav)) {
echo $graderrightnav;
}
@@ -176,5 +176,3 @@ if(!is_null($graderrightnav)) {
}
echo $OUTPUT->footer();
?>
@@ -1,44 +1,39 @@
<?php
///////////////////////////////////////////////////////////////////////////
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Strings for Single view
*
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// General Strings
$string['all_grades'] = 'All grades';
$string['assessmentname'] = 'Assessment Name';
$string['blanks'] = 'Empty grades';
$string['bulk'] = 'Insert';
$string['exclude'] = 'Exclude';
$string['filtergrades'] = 'Show grades for {$a}.';
$string['for'] = 'for';
$string['override'] = 'Override';
$string['pluginname'] = 'Single view';
$string['singleview:view'] = 'View the '.$string['pluginname'].' report';
$string['not_allowed'] = 'Not allowed to quick edit this item';
$string['filtergrades'] = 'Show grades for {$a}.';
$string['no_screens'] = 'Could not find a suitable Single view screen.';
$string['exclude'] = 'Exclude';
$string['override'] = 'Override';
$string['assessmentname'] = 'Assessment Name';
$string['notavailable'] = 'NA';
$string['bulk'] = 'Insert';
$string['blanks'] = 'Empty grades';
$string['for'] = 'for';
$string['all_grades'] = 'All grades';
// Error Strings
$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}';
+22 -35
View File
@@ -1,26 +1,27 @@
<?php
///////////////////////////////////////////////////////////////////////////
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Base lib class for singleview functionality.
*
* @package gradereport_singleview
* @copyright 2014 Moodle
* @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');
@@ -91,9 +92,6 @@ class grade_report_singleview extends grade_report {
$this->screen = new $class($courseid, $itemid, $groupid);
// TODO update events to new model
qe_events_trigger($class . '_instantiated', $this->screen);
// Load custom or predifined js
$this->screen->js();
@@ -148,14 +146,3 @@ function grade_report_singleview_profilereport($course, $user) {
echo $report->output();
}
}
/**
* qe_events_trigger hack for using legacy events without debug screaming at us
*/
function qe_events_trigger($eventname, $eventdata) {
if (function_exists('events_trigger_legacy')) {
events_trigger_legacy($eventname, $eventdata);
} else {
events_trigger($eventname, $eventdata);
}
}
+40 -36
View File
@@ -18,7 +18,7 @@
/**
* The gradebook simple view - grades view (for an activity)
*
* @package singleview
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -26,25 +26,25 @@
class singleview_grade extends singleview_tablelike
implements selectable_items, item_filtering {
private $requires_extra = false;
private $requiresextra = false;
private $requires_paging = false;
private $requirespaging = false;
var $structure;
public $structure;
private static $allow_categories;
private static $allowcategories;
public static function allow_categories() {
if (is_null(self::$allow_categories)) {
self::$allow_categories = get_config('moodle', 'grade_overridecat');
public static function allowcategories() {
if (is_null(self::$allowcategories)) {
self::$allowcategories = get_config('moodle', 'grade_overridecat');
}
return self::$allow_categories;
return self::$allowcategories;
}
public static function filter($item) {
return (
self::allow_categories() or !(
self::allowcategories() or !(
$item->is_course_item() or $item->is_category_item()
)
);
@@ -55,13 +55,13 @@ class singleview_grade extends singleview_tablelike
}
public function options() {
return array_map(function($user) {
return array_map(function($user) {
if (!empty($user->alternatename)) {
return $user->alternatename . ' (' . $user->firstname . ') ' . $user->lastname;
} else {
return fullname($user);
}
}, $this->items);
}
}, $this->items);
}
public function item_type() {
@@ -71,7 +71,7 @@ class singleview_grade extends singleview_tablelike
public function original_definition() {
$def = array('finalgrade', 'feedback');
if ($this->requires_extra) {
if ($this->requiresextra) {
$def[] = 'override';
}
@@ -80,21 +80,22 @@ class singleview_grade extends singleview_tablelike
return $def;
}
public function init($self_item_is_empty = false) {
public function init($selfitemisempty = false) {
$roleids = explode(',', get_config('moodle', 'gradebookroles'));
$this->items = get_role_users(
$roleids, $this->context, false, '',
'u.lastname, u.firstname', null, $this->groupid
);
$roleids, $this->context, false, '',
'u.lastname, u.firstname', null, $this->groupid,
$this->perpage * $this->page, $this->perpage
);
if ($self_item_is_empty) {
if ($selfitemisempty) {
return;
}
// Only page when necessary.
if (count($this->items) > $this->perpage) {
$this->requires_paging = true;
$this->requirespaging = true;
$this->all_items = $this->items;
@@ -114,15 +115,15 @@ class singleview_grade extends singleview_tablelike
$this->item = grade_item::fetch($params);
$filter_fun = grade_report_singleview::filters();
$filterfun = grade_report_singleview::filters();
$allowed = $filter_fun($this->item);
$allowed = $filterfun($this->item);
if (empty($allowed)) {
print_error('not_allowed', 'gradereport_singleview');
}
$this->requires_extra = !$this->item->is_manual_item();
$this->requiresextra = !$this->item->is_manual_item();
$this->setup_structure();
@@ -132,8 +133,8 @@ class singleview_grade extends singleview_tablelike
public function original_headers() {
$headers = array(
'', // for filter icon.
'', // for user picture.
'', // For filter icon.
'', // For user picture.
get_string('firstname') . ' (' . get_string('alternatename') . ') ' . get_string('lastname'),
get_string('range', 'grades'),
get_string('grade', 'grades'),
@@ -148,15 +149,17 @@ class singleview_grade extends singleview_tablelike
$grade = $this->fetch_grade_or_default($this->item, $item->id);
// UCSB add lock icon indicator.
$lockicon = '';
// 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;
// check both grade and grade item.
if ( $locked_grade || $locked_grade_item )
$lockedgrade = $lockedgradeitem = 0;
if (!empty($grade->locked)) {
$lockedgrade = 1;
}
if (!empty($grade->grade_item->locked)) {
$lockedgradeitem = 1;
}
// Check both grade and grade item.
if ( $lockedgrade || $lockedgradeitem )
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked') . ' ';
if (!empty($item->alternatename)) {
@@ -167,9 +170,10 @@ class singleview_grade extends singleview_tablelike
$item->imagealt = $fullname;
$url = new moodle_url("/user/view.php", array('id' => $item->id, 'course' => $this->courseid));
$iconstring = get_string('filtergrades', 'gradereport_singleview', $fullname);
$line = array(
$OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', get_string('filtergrades', 'gradereport_singleview', $fullname))),
$line = array(
$OUTPUT->action_icon($this->format_link('user', $item->id), new pix_icon('t/editstring', $iconstring)),
$OUTPUT->user_picture($item),
html_writer::link($url, $fullname),
$this->item_range()
@@ -178,7 +182,7 @@ class singleview_grade extends singleview_tablelike
}
public function additional_headers($headers) {
if ($this->requires_extra) {
if ($this->requiresextra) {
$headers[] = $this->make_toggle_links('override');
}
@@ -196,7 +200,7 @@ class singleview_grade extends singleview_tablelike
}
public function supports_paging() {
return $this->requires_paging;
return $this->requirespaging;
}
public function pager() {
@@ -18,13 +18,13 @@
/**
* The gradebook simple view - initial view to select your search options
*
* @package singleview
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class singleview_select extends singleview_screen {
public function init($self_item_is_empty = false) {
public function init($selfitemisempty = false) {
global $DB;
$this->item = $DB->get_record('course', array('id' => $this->courseid));
+26 -18
View File
@@ -18,7 +18,7 @@
/**
* The gradebook simple view - grades view (for a user)
*
* @package singleview
* @package gradereport_singleview
* @copyright 2014 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -27,14 +27,16 @@ class singleview_user extends singleview_tablelike implements selectable_items {
private $categories = array();
var $structure;
public $structure;
public function description() {
return get_string('gradeitems', 'grades');;
}
public function options() {
return array_map(function($item) { return $item->get_name(); }, $this->items);
return array_map(function($item) {
return $item->get_name();
}, $this->items);
}
public function item_type() {
@@ -45,10 +47,10 @@ class singleview_user extends singleview_tablelike implements selectable_items {
return false;
}
public function init($self_item_is_empty = false) {
public function init($selfitemisempty = false) {
global $DB;
if (!$self_item_is_empty) {
if (!$selfitemisempty) {
$this->item = $DB->get_record('user', array('id' => $this->itemid));
}
@@ -76,8 +78,8 @@ class singleview_user extends singleview_tablelike implements selectable_items {
public function original_headers() {
return array(
'', // for filter icon.
'', // for activity icon.
'', // For filter icon.
'', // For activity icon.
get_string('assessmentname', 'gradereport_singleview'),
get_string('gradecategory', 'grades'),
get_string('range', 'grades'),
@@ -95,16 +97,22 @@ class singleview_user extends singleview_tablelike implements selectable_items {
$lockicon = '';
// 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.
$lockicon = $OUTPUT->pix_icon('t/locked', 'grade is locked');
$lockeditem = $lockeditemgrade = 0;
if (!empty($grade->locked)) {
$lockeditem = 1;
}
if (!empty($grade->grade_item->locked)) {
$lockeditemgrade = 1;
}
// Check both grade and grade item.
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));
$iconstring = get_string('filtergrades', 'gradereport_singleview', $item->get_name());
$line = array(
$OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', get_string('filtergrades', 'gradereport_singleview', $item->get_name()))),
$OUTPUT->action_icon($this->format_link('grade', $item->id), new pix_icon('t/editstring', $iconstring)),
$this->format_icon($item) . $lockicon,
html_writer::link($url, $item->get_name()),
$this->category($item),
@@ -143,10 +151,10 @@ 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);
}
if (!empty($this->item->alternatename)) {
return $this->item->alternatename . ' (' . $this->item->firstname . ') ' . $this->item->lastname;
} else {
return fullname($this->item);
}
}
}
+22 -22
View File
@@ -1,27 +1,27 @@
<?php
///////////////////////////////////////////////////////////////////////////
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Standard version file
*
* @package gradereport_singleview
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$plugin->version = 2013081002;
$plugin->requires = 2010090501;