MDL-30999 grade: updated Grade API phpdocs

This commit is contained in:
Andrew Davis 2012-01-06 11:52:46 +07:00
parent 5fc420e2ed
commit a153c9f2fe
91 changed files with 1463 additions and 823 deletions

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform for editing grade letters
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* List of grade letters.
*
* @package moodlecore
* @package core_grades
* @copyright 2008 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Prints navigation tabs for viewing and editing grade letters
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$row = $tabs = array();
$row[] = new tabobject('lettersview',

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A page for selecting outcomes for use in a course
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->libdir.'/gradelib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* Edit page for grade outcomes.
*
* @package moodlecore
* @package core_grades
* @copyright 2008 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit form for grade outcomes
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,7 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
// Exports selected outcomes in CSV format.
/**
* Exports selected outcomes in CSV format
*
* @package core_grades
* @copyright 2008 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Import outcomes from a file
*
* @package core_grades
* @copyright 2008 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__).'/../../../config.php');
require_once($CFG->dirroot.'/lib/formslib.php');
require_once($CFG->dirroot.'/grade/lib.php');

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A form to allow importing outcomes from a file
*
* @package core_grades
* @copyright 2008 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* Listing page for grade outcomes.
*
* @package moodlecore
* @package core_grades
* @copyright 2008 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Prints navigation tabs for viewing and editing grade outcomes
*
* @package core_grades
* @copyright 2009 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$row = $tabs = array();
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit page for grade scales
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit form for grade scales
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A page for managing custom and standard scales
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->libdir.'/gradelib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A form for editing course grade settings
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A page for editing course grade settings
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->libdir.'/gradelib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Performs actions on grade items and categories like hiding and locking
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit a calculated grade item
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->libdir.'/mathslib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform to allow the editing of a calculated grade item
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit the grade options for an individual grade category
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform to edit the grade options for an individual grade category
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit a user's grade for a particular activity
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform to allow the editing of a user's grade for a particular activity
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit and review page for grade categories and items.
* Edit and review page for grade categories and items
*
* @package moodlecore
* @package core_grades
* @copyright 2008 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Edit the grade options for an individual grade item
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform allowing the editing of the grade options for an individual grade item
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A library of classes used by the grade edit pages
*
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_edit_tree {
public $columns = array();

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A page to create or edit outcome grade items
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once $CFG->dirroot.'/grade/report/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* A moodleform to allow the creation and editing of outcome grade items
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -22,7 +21,7 @@
* area, provides access to the plugin editor and allows user to save the
* current form as a template or re-use some existing form.
*
* @package core
* @package core_grades
* @subpackage grading
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* Allows to choose a form from the list of available templates
*
* @package core
* @package core_grades
* @subpackage grading
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,8 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/*
* Compatibility redirection to reports
/**
* This page is provided for compatability and redirects the user to the default grade report
*
* @package core_grades
* @copyright 2005 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../config.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* Functions used by gradebook plugins and reports.
*
* @package moodlecore
* @package core_grades
* @copyright 2009 Petr Skoda and Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -563,7 +562,7 @@ function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
* A simple class containing info about grade plugins.
* Can be subclassed for special rules
*
* @package moodlecore
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -694,7 +693,7 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
/**
* Utility class used for return tracking when using edit and other forms in grade plugins
*
* @package moodlecore
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -1000,7 +999,7 @@ function grade_build_nav($path, $pagename=null, $id=null) {
/**
* General structure representing grade items in course
*
* @package moodlecore
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -1557,7 +1556,7 @@ class grade_structure {
* Flat structure similar to grade tree.
*
* @uses grade_structure
* @package moodlecore
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -1694,7 +1693,7 @@ class grade_seq extends grade_structure {
* deletion and moving of items and categories within the tree.
*
* @uses grade_structure
* @package moodlecore
* @package core_grades
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,11 +15,21 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Returns the aggregated or calculated course grade(s) in given course.
* @public
* @param int $courseid id of course
* @param int $userid_or_ids optional id of the graded user or array of ids; if userid not used, returns only information about grade_item
* @return information about course grade item scaleid, name, grade and locked status, etc. + user grades
* Functions used to retrieve grades objects
*
* @package core_grades
* @category grade
* @copyright 2008 Petr Skoda and Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Returns the aggregated or calculated course grade(s) for a single course for one or more users
*
* @param int $courseid The ID of course
* @param int|array $userid_or_ids Optional ID of the graded user or array of user IDs; if userid not used, returns only information about grade_item
* @return stdClass Returns an object containing information about course grade item. scaleid, name, grade
* and locked status etc and user course grades: $item->grades[$userid] => $usercoursegrade
*/
function grade_get_course_grades($courseid, $userid_or_ids=null) {
@ -118,10 +127,10 @@ function grade_get_course_grades($courseid, $userid_or_ids=null) {
}
/**
* Returns the aggregated or calculated course grade for the given user(s).
* @public
* @param int $userid
* @param int $courseid optional id of course or array of ids, empty means all uses courses (returns array if not present)
* Returns the aggregated or calculated course grade for a single user for one or more courses
*
* @param int $userid The ID of the single user
* @param int|array $courseid_or_ids Optional ID of course or array of IDs, empty means all of the user's courses
* @return mixed grade info or grades array including item info, false if error
*/
function grade_get_course_grade($userid, $courseid_or_ids=null) {
@ -233,8 +242,9 @@ function grade_get_course_grade($userid, $courseid_or_ids=null) {
/**
* Returns all grade items (including outcomes) or main item for a given activity identified by $cm object.
*
* @param object $cm A course module object (preferably with modname property)
* @return mixed - array of grade item instances (one if $only_main_item true), false if error or not found
* @param cm_info $cm A course module object (preferably with modname property)
* @param bool $only_main_item Limit the search to the primary grade item for the activity, 'itemnumber'==0
* @return mixed An array of grade item instances, one grade item if $only_main_item == true, false if error or not found
*/
function grade_get_grade_items_for_activity($cm, $only_main_item=false) {
global $CFG, $DB;
@ -261,11 +271,11 @@ function grade_get_grade_items_for_activity($cm, $only_main_item=false) {
}
/**
* Returns whether or not user received grades in main grade item for given activity.
* Returns whether or not a user received grades in main grade item for given activity
*
* @param object $cm
* @param int $userid
* @return bool True if graded false if user not graded yet
* @param cm_info $cm The activity context module
* @param int $userid The user ID
* @return bool True if graded, false if user not graded yet
*/
function grade_is_user_graded_in_activity($cm, $userid) {

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file receives ajax callbacks for the grader report
*
* @package gradereport_grader
* @copyright 2008 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability definition for the gradebook grader report
*
* @package gradereport_grader
* @copyright 2007 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'gradereport/grader:view' => array(

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// 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 grader report
*
* @package gradereport_grader
* @copyright 2007 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'gradereport_grader', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'gradereport_grader', language 'en'
*
* @package gradereport_grader
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,8 +15,11 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File in which the grader_report class is defined.
* @package gradebook
* Definition of the grader report class
*
* @package gradereport_grader
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . '/grade/report/lib.php');
@ -26,7 +28,7 @@ require_once($CFG->libdir.'/tablelib.php');
/**
* Class providing an API for the grader report building and displaying.
* @uses grade_report
* @package gradebook
* @package gradereport_grader
*/
class grade_report_grader extends grade_report {
/**

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Grader report preferences configuration page
*
* @package gradereport_grader
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
set_time_limit(0);
require_once '../../../config.php';
require_once $CFG->libdir . '/gradelib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,12 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Form for grader report preferences.
* Form for grader report preferences
*
* @package moodlecore
* @subpackage grade
* @package gradereport_grader
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Allow the editing of grades for a grade item
*
* @package gradereport_grader
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines site config settings for the grader report
*
* @package gradereport_grader
* @copyright 2007 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Outputs navigation tabs for the grader report
*
* @package gradereport_grader
* @copyright 2007 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$row = $tabs = array();
$tabcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
$row[] = new tabobject('graderreport',

View File

@ -15,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
* Version details for the grader report
*
* @package gradereport
* @subpackage grader
* @package gradereport_grader
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Redirects the user to the default grade report
*
* @package core_grades
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../config.php';
$courseid = required_param('id', PARAM_INT);

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,16 +15,18 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File containing the grade_report class.
* @package gradebook
* File containing the grade_report class
*
* @package core_grades
* @copyright 2007 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir.'/gradelib.php');
/**
* An abstract class containing variables and methods used by all or most reports.
* @abstract
* @package gradebook
* @package core_grades
*/
abstract class grade_report {
/**

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines capabilities for the outcomes report
*
* @package gradereport_outcomes
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'gradereport/outcomes:view' => array(

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// 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 outcomes report
*
* @package gradereport_outcomes
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
include_once('../../../config.php');
require_once($CFG->libdir . '/gradelib.php');
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'gradereport_outcomes', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'gradereport_outcomes', language 'en'
*
* @package gradereport_outcomes
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}

View File

@ -15,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
* Version details for the outcomes report
*
* @package gradereport
* @subpackage outcomes
* @package gradereport_outcomes
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines capabilities for the overview report
*
* @package gradereport_overview
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'gradereport/overview:view' => array(

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// 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 overview report
*
* @package gradereport_overview
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'gradereport_overview', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'gradereport_overview', language 'en'
*
* @package gradereport_overview
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,8 +15,11 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File in which the overview_report class is defined.
* @package gradebook
* Definition of the grade_overview_report class
*
* @package gradereport_overview
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . '/grade/report/lib.php');
@ -26,7 +28,7 @@ require_once($CFG->libdir.'/tablelib.php');
/**
* Class providing an API for the overview report building and displaying.
* @uses grade_report
* @package gradebook
* @package gradereport_overview
*/
class grade_report_overview extends grade_report {

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,9 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Renderer for the grade user report
* Renderer for the gradebook overview report
*
* @package moodlecore
* @package gradereport_overview
* @copyright 2010 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -44,4 +43,4 @@ class gradereport_overview_renderer extends plugin_renderer_base {
return $output;
}
}
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,7 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// Add settings for this module to the $settings object (it's already defined)
/**
* Defines site settings for the overview gradebook report
*
* @package gradereport_overview
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;

View File

@ -15,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
* Version details for the overview gradebook report
*
* @package gradereport
* @subpackage overview
* @package gradereport_overview
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Defines capabilities for the user report
*
* @package gradereport_user
* @copyright 2007 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$capabilities = array(
'gradereport/user:view' => array(

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,6 +14,14 @@
// 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 user report
*
* @package gradereport_user
* @copyright 2007 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../../../config.php';
require_once $CFG->libdir.'/gradelib.php';
require_once $CFG->dirroot.'/grade/lib.php';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'gradereport_user', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'gradereport_user', language 'en'
*
* @package gradereport_user
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,8 +15,11 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File in which the user_report class is defined.
* @package gradebook
* Definition of the grade_user_report class is defined
*
* @package gradereport_user
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . '/grade/report/lib.php');
@ -31,7 +33,7 @@ define("GRADE_REPORT_USER_SHOW_HIDDEN", 2);
/**
* Class providing an API for the user report building and displaying.
* @uses grade_report
* @package gradebook
* @package gradereport_user
*/
class grade_report_user extends grade_report {

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,7 +17,7 @@
/**
* Renderer for the grade user report
*
* @package moodlecore
* @package gradereport_user
* @copyright 2010 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -44,4 +43,4 @@ class gradereport_user_renderer extends plugin_renderer_base {
return $output;
}
}
}

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -15,7 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/// Add settings for this module to the $settings object (it's already defined)
/**
* Defines site settings for the user gradebook report
*
* @package gradereport_user
* @copyright 2007 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;

View File

@ -15,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details
* Version details for the user gradebook report
*
* @package gradereport
* @subpackage user
* @package gradereport_user
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,76 +13,253 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of constants for gradebook
*
* @package core
* @subpackage grade
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// category aggregation types
// Category aggregation types
/**
* GRADE_AGGREGATE_MEAN - Use the category mean for grade aggregation.
*/
define('GRADE_AGGREGATE_MEAN', 0);
/**
* GRADE_AGGREGATE_MEDIAN - Use the category median for grade aggregation.
*/
define('GRADE_AGGREGATE_MEDIAN', 2);
/**
* GRADE_AGGREGATE_MIN - Use the category minimum grade for grade aggregation.
*/
define('GRADE_AGGREGATE_MIN', 4);
/**
* GRADE_AGGREGATE_MAX - Use the category maximum grade for grade aggregation.
*/
define('GRADE_AGGREGATE_MAX', 6);
/**
* GRADE_AGGREGATE_MEDIAN - Use the category mode for grade aggregation.
*/
define('GRADE_AGGREGATE_MODE', 8);
/**
* GRADE_AGGREGATE_WEIGHTED_MEAN - Use a weighted mean of grades in the category for grade aggregation. Weights can be manually set.
*/
define('GRADE_AGGREGATE_WEIGHTED_MEAN', 10);
/**
* GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use a simple weighted mean of grades in the category for grade aggregation.
*/
define('GRADE_AGGREGATE_WEIGHTED_MEAN2', 11);
/**
* GRADE_AGGREGATE_EXTRACREDIT_MEAN - Use the category mean for grade aggregation and include support for extra credit.
*/
define('GRADE_AGGREGATE_EXTRACREDIT_MEAN', 12);
/**
* GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use the sum of grades in the category for grade aggregation.
*/
define('GRADE_AGGREGATE_SUM', 13);
// grade types
// Grade types
/**
* GRADE_TYPE_NONE - Ungraded.
*/
define('GRADE_TYPE_NONE', 0);
/**
* GRADE_TYPE_NONE - The grade is a numeric value
*/
define('GRADE_TYPE_VALUE', 1);
/**
* GRADE_TYPE_NONE - The grade is a value from the set of values available in a grade scale.
*/
define('GRADE_TYPE_SCALE', 2);
/**
* GRADE_TYPE_NONE - Feedback only.
*/
define('GRADE_TYPE_TEXT', 3);
// grade_update() return status
/**
* GRADE_UPDATE_OK - Grade updated completed successfully.
*/
define('GRADE_UPDATE_OK', 0);
/**
* GRADE_UPDATE_FAILED - Grade updated failed.
*/
define('GRADE_UPDATE_FAILED', 1);
/**
* GRADE_UPDATE_MULTIPLE - Grade update failed because there are multiple grade items with the same itemnumber for this activity.
*/
define('GRADE_UPDATE_MULTIPLE', 2);
/**
* GRADE_UPDATE_DELETED - Grade item deleted (MDL-31362)
*/
define('GRADE_UPDATE_ITEM_DELETED', 3);
/**
* GRADE_UPDATE_DELETED - Grade item cannot be updated as it is locked
*/
define('GRADE_UPDATE_ITEM_LOCKED', 4);
// Grade tables history tracking actions
/**
* GRADE_HISTORY_INSERT - A grade item was inserted
*/
define('GRADE_HISTORY_INSERT', 1);
/**
* GRADE_HISTORY_UPDATE - A grade item was updated
*/
define('GRADE_HISTORY_UPDATE', 2);
/**
* GRADE_HISTORY_INSERT - A grade item was deleted
*/
define('GRADE_HISTORY_DELETE', 3);
// Display style constants
/**
* GRADE_DISPLAY_TYPE_DEFAULT - Grade display type can be set at 3 levels: grade_item, course setting and site. Use the display type from the higher level.
*/
define('GRADE_DISPLAY_TYPE_DEFAULT', 0);
/**
* GRADE_DISPLAY_TYPE_REAL - Display the grade as a decimal number.
*/
define('GRADE_DISPLAY_TYPE_REAL', 1);
/**
* GRADE_DISPLAY_TYPE_PERCENTAGE - Display the grade as a percentage.
*/
define('GRADE_DISPLAY_TYPE_PERCENTAGE', 2);
/**
* GRADE_DISPLAY_TYPE_LETTER - Display the grade as a letter grade. For example, A, B, C, D or F.
*/
define('GRADE_DISPLAY_TYPE_LETTER', 3);
/**
* GRADE_DISPLAY_TYPE_REAL_PERCENTAGE - Display the grade as a decimal number and a percentage.
*/
define('GRADE_DISPLAY_TYPE_REAL_PERCENTAGE', 12);
/**
* GRADE_DISPLAY_TYPE_REAL_LETTER - Display the grade as a decimal number and a letter grade.
*/
define('GRADE_DISPLAY_TYPE_REAL_LETTER', 13);
/**
* GRADE_DISPLAY_TYPE_LETTER_REAL - Display the grade as a letter grade and a decimal number.
*/
define('GRADE_DISPLAY_TYPE_LETTER_REAL', 31);
/**
* GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE - Display the grade as a letter grade and a percentage.
*/
define('GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE', 32);
/**
* GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER - Display the grade as a percentage and a letter grade.
*/
define('GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER', 23);
/**
* GRADE_DISPLAY_TYPE_PERCENTAGE_REAL - Display the grade as a percentage and a decimal number.
*/
define('GRADE_DISPLAY_TYPE_PERCENTAGE_REAL', 21);
/**
* GRADE_REPORT_AGGREGATION_POSITION_FIRST - Display the course totals before the individual activity grades
*/
define('GRADE_REPORT_AGGREGATION_POSITION_FIRST', 0);
/**
* GRADE_REPORT_AGGREGATION_POSITION_LAST - Display the course totals after the individual activity grades
*/
define('GRADE_REPORT_AGGREGATION_POSITION_LAST', 1);
// These constants dont seem to be in use (MDL-31363)
define('GRADE_REPORT_AGGREGATION_VIEW_FULL', 0);
define('GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY', 1);
define('GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY', 2);
//What to do if category or course total contains a hidden item
define('GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN', 0);//hide the total from students
define('GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN', 1);//show the total to students minus grades from the hidden items
define('GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN', 2);//show students the real total including marks from hidden items
// What to do if category or course total contains a hidden item
define('GRADE_REPORT_PREFERENCE_DEFAULT', 'default'); // means use setting from site preferences
/**
* GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item hide the total from students.
*/
define('GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN', 0);
/**
* GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show the total to students minus grades from the hidden items.
*/
define('GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN', 1);
/**
* GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show students the real total including marks from hidden items.
*/
define('GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN', 2);
/**
* GRADE_REPORT_PREFERENCE_DEFAULT - Use the setting from site preferences.
*/
define('GRADE_REPORT_PREFERENCE_DEFAULT', 'default');
/**
* GRADE_REPORT_PREFERENCE_INHERIT - Inherit the setting value from the parent.
*/
define('GRADE_REPORT_PREFERENCE_INHERIT', 'inherit'); // means inherit from parent
/**
* GRADE_REPORT_PREFERENCE_UNUSED - Unused constant.
*/
define('GRADE_REPORT_PREFERENCE_UNUSED', -1);
/**
* GRADE_REPORT_MEAN_ALL - Include all grade items including those where the student hasn't received a grade when calculating the mean.
*/
define('GRADE_REPORT_MEAN_ALL', 0);
/**
* GRADE_REPORT_MEAN_GRADED - Only include grade items where the student has a grade when calculating the mean.
*/
define('GRADE_REPORT_MEAN_GRADED', 1);
/**
* GRADE_NAVMETHOD_DROPDOWN - Display a drop down box to allow navigation within the gradebook
*/
define('GRADE_NAVMETHOD_DROPDOWN', 0);
/**
* GRADE_NAVMETHOD_TABS - Display tabs to allow navigation within the gradebook
*/
define('GRADE_NAVMETHOD_TABS', 1);
/**
* GRADE_NAVMETHOD_TABS - Display both a drop down and tabs to allow navigation within the gradebook
*/
define('GRADE_NAVMETHOD_COMBO', 2);

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,13 +13,13 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of constants for gradebook
* Definition of a class to represent a grade category
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
@ -28,12 +27,12 @@ defined('MOODLE_INTERNAL') || die();
require_once('grade_object.php');
/**
* Grade_Category is an object mapped to DB table {prefix}grade_categories
* grade_category is an object mapped to DB table {prefix}grade_categories
*
* @package moodlecore
* @subpackage grade
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_category extends grade_object {
/**
@ -64,7 +63,7 @@ class grade_category extends grade_object {
/**
* The grade_category object referenced by $this->parent (PK).
* @var object $parent_category
* @var grade_category $parent_category
*/
public $parent_category;
@ -139,22 +138,25 @@ class grade_category extends grade_object {
/**
* An associated grade_item object, with itemtype=category, used to calculate and cache a set of grade values
* for this category.
* @var object $grade_item
* @var grade_item $grade_item
*/
public $grade_item;
/**
* Temporary sortorder for speedup of children resorting
* @var int $sortorder
*/
public $sortorder;
/**
* List of options which can be "forced" from site settings.
* @var array $forceable
*/
public $forceable = array('aggregation', 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes', 'aggregatesubcats');
/**
* String representing the aggregation coefficient. Variable is used as cache.
* @var string $coefstring
*/
public $coefstring = null;
@ -164,9 +166,8 @@ class grade_category extends grade_object {
* or when a new parent is added or changed. It is a recursive function: once the calling
* object no longer has a parent, the path is complete.
*
* @param object $grade_category A Grade_Category object
* @return int The depth of this category (2 means there is one parent)
* @static
* @param grade_category $grade_category A Grade_Category object
* @return string The category's path string
*/
public static function build_path($grade_category) {
global $DB;
@ -182,10 +183,9 @@ class grade_category extends grade_object {
/**
* Finds and returns a grade_category instance based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return object grade_category instance or false if none found.
* @return grade_category The retrieved grade_category instance or false if none found.
*/
public static function fetch($params) {
return grade_object::fetch_helper('grade_categories', 'grade_category', $params);
@ -193,7 +193,6 @@ class grade_category extends grade_object {
/**
* Finds and returns all grade_category instances based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return array array of grade_category insatnces or false if none found.
@ -204,8 +203,9 @@ class grade_category extends grade_object {
/**
* In addition to update() as defined in grade_object, call force_regrading of parent categories, if applicable.
*
* @param string $source from where was the object updated (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function update($source=null) {
// load the grade item or create a new one
@ -258,8 +258,9 @@ class grade_category extends grade_object {
/**
* If parent::delete() is successful, send force_regrading message to parent category.
*
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function delete($source=null) {
$grade_item = $this->load_grade_item();
@ -316,10 +317,12 @@ class grade_category extends grade_object {
/**
* In addition to the normal insert() defined in grade_object, this method sets the depth
* and path for this object, and update the record accordingly. The reason why this must
* be done here instead of in the constructor, is that they both need to know the record's
* id number, which only gets created at insertion time.
* and path for this object, and update the record accordingly.
*
* We do this here instead of in the constructor as they both need to know the record's
* ID number, which only gets created at insertion time.
* This method also creates an associated grade_item if this wasn't done during construction.
*
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*/
@ -356,8 +359,7 @@ class grade_category extends grade_object {
* Normal insert() can not be used for course category
*
* @param int $courseid The course ID
*
* @return bool success
* @return int The ID of the new course category
*/
public function insert_course_category($courseid) {
$this->courseid = $courseid;
@ -385,8 +387,9 @@ class grade_category extends grade_object {
/**
* Compares the values held by this object with those of the matching record in DB, and returns
* whether or not these differences are sufficient to justify an update of all parent objects.
* This assumes that this object has an id number and a matching record in DB. If not, it will return false.
* @return boolean
* This assumes that this object has an ID number and a matching record in DB. If not, it will return false.
*
* @return bool
*/
public function qualifies_for_regrading() {
if (empty($this->id)) {
@ -407,8 +410,7 @@ class grade_category extends grade_object {
}
/**
* Marks the category and course item as needing update - categories are always regraded.
* @return void
* Marks this grade categories' associated grade item as needing regrading
*/
public function force_regrading() {
$grade_item = $this->load_grade_item();
@ -420,7 +422,7 @@ class grade_category extends grade_object {
* These immediate children must already have their own final grades.
* The category's aggregation method is used to generate final grades.
*
* Please note that category grade is either calculated or aggregated - not both at the same time.
* Please note that category grade is either calculated or aggregated, not both at the same time.
*
* This method must be used ONLY from grade_item::regrade_final_grades(),
* because the calculation must be done in correct order!
@ -430,8 +432,7 @@ class grade_category extends grade_object {
* 3. Aggregate these grades
* 4. Save them in final grades of associated category grade item
*
* @param int $userid The user ID
*
* @param int $userid The user ID if final grade generation should be limited to a single user
* @return bool
*/
public function generate_grades($userid=null) {
@ -515,16 +516,13 @@ class grade_category extends grade_object {
}
/**
* internal function for category grades aggregation
* Internal function for grade category grade aggregation
*
* @param int $userid The User ID
* @param array $items Grade items
* @param array $grade_values Array of grade values
* @param object $oldgrade Old grade
* @param array $excluded Excluded
*
* @return boolean (just plain return;)
* @todo Document correctly
*/
private function aggregate_grades($userid, $items, $grade_values, $oldgrade, $excluded) {
global $CFG;
@ -630,13 +628,13 @@ class grade_category extends grade_object {
}
/**
* Internal function - aggregation maths.
* Must be public: used by grade_grade::get_hiding_affected()
* Internal function that calculates the aggregated grade for this grade category
*
* @param array $grade_values The values being aggregated
* Must be public as it is used by grade_grade::get_hiding_affected()
*
* @param array $grade_values An array of values to be aggregated
* @param array $items The array of grade_items
*
* @return float
* @return float The aggregate grade for this grade category
*/
public function aggregate_values($grade_values, $items) {
switch ($this->aggregation) {
@ -766,9 +764,9 @@ class grade_category extends grade_object {
}
/**
* Some aggregation types may update max grade
* Some aggregation types may automatically update max grade
*
* @param array $items sub items
* @return void
*/
private function auto_update_max($items) {
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
@ -818,15 +816,13 @@ class grade_category extends grade_object {
}
/**
* internal function for category grades summing
* Internal function for category grades summing
*
* @param grade_grade &$grade The grade item
* @param float $oldfinalgrade Old Final grade?
* @param array $items Grade items
* @param array $grade_values Grade values
* @param array $excluded Excluded
*
* @return boolean (just plain return;)
* @param grade_grade $grade The grade item
* @param float $oldfinalgrade Old Final grade
* @param array $items Grade items
* @param array $grade_values Grade values
* @param array $excluded Excluded
*/
private function sum_grades(&$grade, $oldfinalgrade, $items, $grade_values, $excluded) {
if (empty($items)) {
@ -869,12 +865,10 @@ class grade_category extends grade_object {
}
/**
* Given an array of grade values (numerical indices), applies droplow or keephigh
* rules to limit the final array.
* Given an array of grade values (numerical indices) applies droplow or keephigh rules to limit the final array.
*
* @param array &$grade_values itemid=>$grade_value float
* @param array $grade_values itemid=>$grade_value float
* @param array $items grade item objects
*
* @return array Limited grades.
*/
public function apply_limit_rules(&$grade_values, $items) {
@ -924,7 +918,7 @@ class grade_category extends grade_object {
/**
* Returns true if category uses extra credit of any kind
*
* @return boolean true if extra credit used
* @return bool True if extra credit used
*/
function is_extracredit_used() {
return ($this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2
@ -935,7 +929,7 @@ class grade_category extends grade_object {
/**
* Returns true if category uses special aggregation coefficient
*
* @return boolean true if coefficient used
* @return bool True if an aggregation coefficient is being used
*/
public function is_aggregationcoef_used() {
return ($this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN
@ -946,11 +940,11 @@ class grade_category extends grade_object {
}
/**
* Recursive function to find which weight/extra credit field to use in the grade item form. Inherits from a parent category
* if that category has aggregatesubcats set to true.
* Recursive function to find which weight/extra credit field to use in the grade item form.
*
* Inherits from a parent category if that category has aggregatesubcats set to true.
*
* @param string $first Whether or not this is the first item in the recursion
*
* @return string
*/
public function get_coefstring($first=true) {
@ -1008,10 +1002,8 @@ class grade_category extends grade_object {
* Returns tree with all grade_items and categories as elements
*
* @param int $courseid The course ID
* @param boolean $include_category_items as category children
*
* @param bool $include_category_items as category children
* @return array
* @static
*/
public static function fetch_course_tree($courseid, $include_category_items=false) {
$course_category = grade_category::fetch_course_category($courseid);
@ -1023,14 +1015,11 @@ class grade_category extends grade_object {
}
/**
* Needs documenting
* An internal function that recursively sorts grade categories within a course
*
* @param array $category_array The seed of the recursion
* @param int &$sortorder The current sortorder
*
* @return array
* @static
* @todo Document
* @param int $sortorder The current sortorder
* @return array An array containing 'object', 'type', 'depth' and optionally 'children'
*/
static private function _fetch_course_tree_recursion($category_array, &$sortorder) {
// update the sortorder in db if needed
@ -1087,7 +1076,6 @@ class grade_category extends grade_object {
* as well as all levels (0). The elements are indexed by sort order.
*
* @param bool $include_category_items Whether or not to include category grade_items in the children array
*
* @return array Array of child objects (grade_category and grade_item).
*/
public function get_children($include_category_items=false) {
@ -1194,8 +1182,7 @@ class grade_category extends grade_object {
* Private method used to retrieve all children of this category recursively
*
* @param grade_category $category Source of current recursion
*
* @return array
* @return array An array of child grade categories
*/
private static function _get_children_recursion($category) {
@ -1233,8 +1220,9 @@ class grade_category extends grade_object {
}
/**
* Uses get_grade_item to load or create a grade_item, then saves it as $this->grade_item.
* @return object Grade_item
* Uses {@see get_grade_item()} to load or create a grade_item, then saves it as $this->grade_item.
*
* @return grade_item
*/
public function load_grade_item() {
if (empty($this->grade_item)) {
@ -1244,9 +1232,11 @@ class grade_category extends grade_object {
}
/**
* Retrieves from DB and instantiates the associated grade_item object.
* If no grade_item exists yet, create one.
* @return object Grade_item
* Retrieves this grade categories' associated grade_item from the database
*
* If no grade_item exists yet, creates one.
*
* @return grade_item
*/
public function get_grade_item() {
if (empty($this->id)) {
@ -1281,9 +1271,9 @@ class grade_category extends grade_object {
}
/**
* Uses $this->parent to instantiate $this->parent_category based on the
* referenced record in the DB.
* @return object Parent_category
* Uses $this->parent to instantiate $this->parent_category based on the referenced record in the DB
*
* @return grade_category The parent category
*/
public function load_parent_category() {
if (empty($this->parent_category) && !empty($this->parent)) {
@ -1293,8 +1283,9 @@ class grade_category extends grade_object {
}
/**
* Uses $this->parent to instantiate and return a grade_category object.
* @return object Parent_category
* Uses $this->parent to instantiate and return a grade_category object
*
* @return grade_category Returns the parent category or null if this category has no parent
*/
public function get_parent_category() {
if (!empty($this->parent)) {
@ -1306,8 +1297,7 @@ class grade_category extends grade_object {
}
/**
* Returns the most descriptive field for this object. This is a standard method used
* when we do not know the exact type of an object.
* Returns the most descriptive field for this grade category
*
* @return string name
*/
@ -1324,12 +1314,11 @@ class grade_category extends grade_object {
}
/**
* Sets this category's parent id. A generic method shared by objects that have a parent id of some kind.
* Sets this category's parent id
*
* @param int $parentid The ID of the category parent to $this
* @param grade_category $source An optional grade_category to use as the source for the parent
*
* @return boolean success
* @param int $parentid The ID of the category that is the new parent to $this
* @param string $source From where was the object updated (mod/forum, manual, etc.)
* @return bool success
*/
public function set_parent($parentid, $source=null) {
if ($this->parent == $parentid) {
@ -1362,10 +1351,9 @@ class grade_category extends grade_object {
}
/**
* Returns the final values for this grade category.
*
* @param int $userid Optional: to retrieve a single final grade
* Returns the final grade values for this grade category.
*
* @param int $userid Optional user ID to retrieve a single user's final grade
* @return mixed An array of all final_grades (stdClass objects) for this grade_item, or a single final_grade.
*/
public function get_final($userid=null) {
@ -1374,8 +1362,9 @@ class grade_category extends grade_object {
}
/**
* Returns the sortorder of the associated grade_item. This method is also available in
* grade_item, for cases where the object type is not known.
* Returns the sortorder of the grade categories' associated grade_item
*
* This method is also available in grade_item for cases where the object type is not known.
*
* @return int Sort order
*/
@ -1385,8 +1374,9 @@ class grade_category extends grade_object {
}
/**
* Returns the idnumber of the associated grade_item. This method is also available in
* grade_item, for cases where the object type is not known.
* Returns the idnumber of the grade categories' associated grade_item.
*
* This method is also available in grade_item for cases where the object type is not known.
*
* @return string idnumber
*/
@ -1396,12 +1386,11 @@ class grade_category extends grade_object {
}
/**
* Sets sortorder variable for this category.
* Sets the sortorder variable for this category.
*
* This method is also available in grade_item, for cases where the object type is not know.
*
* @param int $sortorder The sortorder to assign to this category
*
* @return void
*/
public function set_sortorder($sortorder) {
$this->load_grade_item();
@ -1409,10 +1398,11 @@ class grade_category extends grade_object {
}
/**
* Move this category after the given sortorder - does not change the parent
* Move this category after the given sortorder
*
* Does not change the parent
*
* @param int $sortorder to place after.
*
* @return void
*/
public function move_after_sortorder($sortorder) {
@ -1423,7 +1413,7 @@ class grade_category extends grade_object {
/**
* Return true if this is the top most category that represents the total course grade.
*
* @return boolean
* @return bool
*/
public function is_course_category() {
$this->load_grade_item();
@ -1431,12 +1421,10 @@ class grade_category extends grade_object {
}
/**
* Return the top most course category.
* Return the course level grade_category object
*
* @param int $courseid The Course ID
*
* @return object grade_category instance for course grade
* @static
* @return grade_category Returns the course level grade_category instance
*/
public static function fetch_course_category($courseid) {
if (empty($courseid)) {
@ -1459,16 +1447,18 @@ class grade_category extends grade_object {
/**
* Is grading object editable?
*
* @return boolean
* @return bool
*/
public function is_editable() {
return true;
}
/**
* Returns the locked state/date of the associated grade_item. This method is also available in
* grade_item, for cases where the object type is not known.
* @return boolean
* Returns the locked state/date of the grade categories' associated grade_item.
*
* This method is also available in grade_item, for cases where the object type is not known.
*
* @return bool
*/
public function is_locked() {
$this->load_grade_item();
@ -1477,13 +1467,13 @@ class grade_category extends grade_object {
/**
* Sets the grade_item's locked variable and updates the grade_item.
* Method named after grade_item::set_locked().
*
* Calls set_locked() on the categories' grade_item
*
* @param int $lockedstate 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param bool $cascade lock/unlock child objects too
* @param bool $refresh refresh grades when unlocking
*
* @return boolean success if category locked (not all children mayb be locked though)
* @return bool success if category locked (not all children mayb be locked though)
*/
public function set_locked($lockedstate, $cascade=false, $refresh=true) {
$this->load_grade_item();
@ -1515,6 +1505,12 @@ class grade_category extends grade_object {
return $result;
}
/**
* Overrides grade_object::set_properties() to add special handling for changes to category aggregation types
*
* @param stdClass $instance the object to set the properties on
* @param array|stdClass $params Either an associative array or an object containing property name, property value pairs
*/
public static function set_properties(&$instance, $params) {
global $DB;
@ -1550,10 +1546,11 @@ class grade_category extends grade_object {
/**
* Sets the grade_item's hidden variable and updates the grade_item.
* Method named after grade_item::set_hidden().
* @param int $hidden 0, 1 or a timestamp int(10) after which date the item will be hidden.
* @param boolean $cascade apply to child objects too
* @return void
*
* Overrides grade_item::set_hidden() to add cascading of the hidden value to grade items in this grade category
*
* @param int $hidden 0 mean always visible, 1 means always hidden and a number > 1 is a timestamp to hide until
* @param bool $cascade apply to child objects too
*/
public function set_hidden($hidden, $cascade=false) {
$this->load_grade_item();
@ -1594,7 +1591,8 @@ class grade_category extends grade_object {
/**
* Applies default settings on this category
* @return bool true if anything changed
*
* @return bool True if anything changed
*/
public function apply_default_settings() {
global $CFG;
@ -1613,7 +1611,8 @@ class grade_category extends grade_object {
/**
* Applies forced settings on this category
* @return bool true if anything changed
*
* @return bool True if anything changed
*/
public function apply_forced_settings() {
global $CFG;
@ -1639,8 +1638,7 @@ class grade_category extends grade_object {
/**
* Notification of change in forced category settings.
*
* @return void
* @static
* Causes all course and category grade items to be marked as needing to be updated
*/
public static function updated_forced_settings() {
global $CFG, $DB;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,19 +13,28 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of grade grade class
* Definition of a class to represent an individual user's grade
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once('grade_object.php');
/**
* grade_grades is an object mapped to DB table {prefix}grade_grades
*
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_grade extends grade_object {
/**
@ -57,7 +65,7 @@ class grade_grade extends grade_object {
/**
* The grade_item object referenced by $this->itemid.
* @var object $grade_item
* @var grade_item $grade_item
*/
public $grade_item;
@ -123,38 +131,39 @@ class grade_grade extends grade_object {
/**
* Exported flag
* @var boolean $exported
* @var bool $exported
*/
public $exported = 0;
/**
* Overridden flag
* @var boolean $overridden
* @var bool $overridden
*/
public $overridden = 0;
/**
* Grade excluded from aggregation functions
* @var boolean $excluded
* @var bool $excluded
*/
public $excluded = 0;
/**
* TODO: HACK: create a new field datesubmitted - the date of submission if any
* @var boolean $timecreated
* TODO: HACK: create a new field datesubmitted - the date of submission if any (MDL-31377)
* @var bool $timecreated
*/
public $timecreated = null;
/**
* TODO: HACK: create a new field dategraded - the date of grading
* @var boolean $timemodified
* TODO: HACK: create a new field dategraded - the date of grading (MDL-31378)
* @var bool $timemodified
*/
public $timemodified = null;
/**
* Returns array of grades for given grade_item+users.
* @param object $grade_item
* Returns array of grades for given grade_item+users
*
* @param grade_item $grade_item
* @param array $userids
* @param bool $include_missing include grades that do not exist yet
* @return array userid=>grade_grade array
@ -196,8 +205,9 @@ class grade_grade extends grade_object {
}
/**
* Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access.
* @return object grade_item.
* Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access
*
* @return grade_item The grade_item instance referenced by $this->itemid
*/
public function load_grade_item() {
if (empty($this->itemid)) {
@ -219,7 +229,8 @@ class grade_grade extends grade_object {
/**
* Is grading object editable?
* @return boolean
*
* @return bool
*/
public function is_editable() {
if ($this->is_locked()) {
@ -240,7 +251,7 @@ class grade_grade extends grade_object {
* Internally any date in locked field (including future ones) means locked,
* the date is stored for logging purposes only.
*
* @return boolean true if locked, false if not
* @return bool True if locked, false if not
*/
public function is_locked() {
$this->load_grade_item();
@ -253,29 +264,30 @@ class grade_grade extends grade_object {
/**
* Checks if grade overridden
* @return boolean
*
* @return bool True if grade is overriden
*/
public function is_overridden() {
return !empty($this->overridden);
}
/**
* Returns timestamp of submission related to this grade,
* might be null if not submitted.
* @return int
* Returns timestamp of submission related to this grade, null if not submitted.
*
* @return int Timestamp
*/
public function get_datesubmitted() {
//TODO: HACK - create new fields in 2.0
//TODO: HACK - create new fields (MDL-31379)
return $this->timecreated;
}
/**
* Returns timestamp when last graded,
* might be null if no grade present.
* Returns timestamp when last graded, null if no grade present
*
* @return int
*/
public function get_dategraded() {
//TODO: HACK - create new fields in 2.0
//TODO: HACK - create new fields (MDL-31379)
if (is_null($this->finalgrade) and is_null($this->feedback)) {
return null; // no grade == no date
} else if ($this->overridden) {
@ -287,9 +299,10 @@ class grade_grade extends grade_object {
/**
* Set the overridden status of grade
* @param boolean $state requested overridden state
* @param boolean $refresh refresh grades from external activities if needed
* @return boolean true is db state changed
*
* @param bool $state requested overridden state
* @param bool $refresh refresh grades from external activities if needed
* @return bool true is db state changed
*/
public function set_overridden($state, $refresh = true) {
if (empty($this->overridden) and $state) {
@ -313,7 +326,8 @@ class grade_grade extends grade_object {
/**
* Checks if grade excluded from aggregation functions
* @return boolean
*
* @return bool True if grade is excluded from aggregation
*/
public function is_excluded() {
return !empty($this->excluded);
@ -321,8 +335,9 @@ class grade_grade extends grade_object {
/**
* Set the excluded status of grade
* @param boolean $state requested excluded state
* @return boolean true is db state changed
*
* @param bool $state requested excluded state
* @return bool True is database state changed
*/
public function set_excluded($state) {
if (empty($this->excluded) and $state) {
@ -341,10 +356,10 @@ class grade_grade extends grade_object {
/**
* Lock/unlock this grade.
*
* @param int $locked 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param boolean $cascade ignored param
* @param boolean $refresh refresh grades when unlocking
* @return boolean true if successful, false if can not set new lock state for grade
* @param int $lockedstate 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param bool $cascade Ignored param
* @param bool $refresh Refresh grades when unlocking
* @return bool True if successful, false if can not set new lock state for grade
*/
public function set_locked($lockedstate, $cascade=false, $refresh=true) {
$this->load_grade_item();
@ -380,7 +395,8 @@ class grade_grade extends grade_object {
}
/**
* Lock the grade if needed - make sure this is called only when final grades are valid
* Lock the grade if needed. Make sure this is called only when final grades are valid
*
* @param array $items array of all grade item ids
* @return void
*/
@ -411,7 +427,7 @@ class grade_grade extends grade_object {
}
/**
* Set the locktime for this grade.
* Get the locktime for this grade.
*
* @return int $locktime timestamp for lock to activate
*/
@ -430,7 +446,8 @@ class grade_grade extends grade_object {
/**
* Check grade hidden status. Uses data from both grade item and grade.
* @return boolean true if hidden, false if not
*
* @return bool true if hidden, false if not
*/
public function is_hidden() {
$this->load_grade_item();
@ -443,7 +460,8 @@ class grade_grade extends grade_object {
/**
* Check grade hidden status. Uses data from both grade item and grade.
* @return boolean true if hiddenuntil, false if not
*
* @return bool true if hiddenuntil, false if not
*/
public function is_hiddenuntil() {
$this->load_grade_item();
@ -461,6 +479,7 @@ class grade_grade extends grade_object {
/**
* Check grade hidden status. Uses data from both grade item and grade.
*
* @return int 0 means visible, 1 hidden always, timestamp hidden until
*/
public function get_hidden() {
@ -489,8 +508,9 @@ class grade_grade extends grade_object {
/**
* Set the hidden status of grade, 0 mean visible, 1 always hidden, number means date to hide until.
* @param boolean $cascade ignored
*
* @param int $hidden new hidden status
* @param bool $cascade ignored
*/
public function set_hidden($hidden, $cascade=false) {
$this->hidden = $hidden;
@ -499,10 +519,9 @@ class grade_grade extends grade_object {
/**
* Finds and returns a grade_grade instance based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return object grade_grade instance or false if none found.
* @return grade_grade Returns a grade_grade instance or false if none found
*/
public static function fetch($params) {
return grade_object::fetch_helper('grade_grades', 'grade_grade', $params);
@ -510,7 +529,6 @@ class grade_grade extends grade_object {
/**
* Finds and returns all grade_grade instances based on params.
* @static
*
* @param array $params associative arrays varname=>value
* @return array array of grade_grade instances or false if none found.
@ -524,7 +542,6 @@ class grade_grade extends grade_object {
* corresponding value situated between a target minimum and a target maximum. Thanks to Darlene
* for the formula :-)
*
* @static
* @param float $rawgrade
* @param float $source_min
* @param float $source_max
@ -553,9 +570,8 @@ class grade_grade extends grade_object {
* on hidden grades, excluded grades are not returned.
* THIS IS A REALLY BIG HACK! to be replaced by conditional aggregation of hidden grades in 2.0
*
* @static
* @param array $grades all course grades of one user, & used for better internal caching
* @param array $items $grade_items array of grade items, & used for better internal caching
* @param array $grade_grades all course grades of one user, & used for better internal caching
* @param array $grade_items array of grade items, & used for better internal caching
* @return array
*/
public static function get_hiding_affected(&$grade_grades, &$grade_items) {
@ -695,8 +711,9 @@ class grade_grade extends grade_object {
/**
* Returns true if the grade's value is superior or equal to the grade item's gradepass value, false otherwise.
* @param object $grade_item An optional grade_item of which gradepass value we can use, saves having to load the grade_grade's grade_item
* @return boolean
*
* @param grade_item $grade_item An optional grade_item of which gradepass value we can use, saves having to load the grade_grade's grade_item
* @return bool
*/
public function is_passed($grade_item = null) {
if (empty($grade_item)) {
@ -721,8 +738,14 @@ class grade_grade extends grade_object {
return $this->finalgrade >= $this->grade_item->gradepass;
}
/**
* Insert the grade_grade instance into the database.
*
* @param string $source From where was the object inserted (mod/forum, manual, etc.)
* @return int The new grade_grade ID if successful, false otherwise
*/
public function insert($source=null) {
// TODO: dategraded hack - do not update times, they are used for submission and grading
// TODO: dategraded hack - do not update times, they are used for submission and grading (MDL-31379)
//$this->timecreated = $this->timemodified = time();
return parent::insert($source);
}
@ -730,8 +753,9 @@ class grade_grade extends grade_object {
/**
* In addition to update() as defined in grade_object rounds the float numbers using php function,
* the reason is we need to compare the db value with computed number to skip updates if possible.
*
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function update($source=null) {
$this->rawgrade = grade_floatval($this->rawgrade);
@ -744,7 +768,8 @@ class grade_grade extends grade_object {
/**
* Used to notify the completion system (if necessary) that a user's grade
* has changed, and clear up a possible score cache.
* @param bool deleted True if grade was actually deleted
*
* @param bool $deleted True if grade was actually deleted
*/
function notify_changed($deleted) {
global $USER, $SESSION, $CFG,$COURSE, $DB;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,21 +13,28 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of grade item class
* Definition of a class to represent a grade item
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once('grade_object.php');
/**
* Class representing a grade item. It is responsible for handling its DB representation,
* modifying and returning its metadata.
* Class representing a grade item.
*
* It is responsible for handling its DB representation, modifying and returning its metadata.
*
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_item extends grade_object {
/**
@ -60,14 +66,14 @@ class grade_item extends grade_object {
public $categoryid;
/**
* The grade_category object referenced $this->iteminstance (itemtype must be == 'category' or == 'course' in that case).
* @var object $item_category
* The grade_category object referenced $this->iteminstance if itemtype == 'category' or == 'course'.
* @var grade_category $item_category
*/
public $item_category;
/**
* The grade_category object referenced by $this->categoryid.
* @var object $parent_category
* @var grade_category $parent_category
*/
public $parent_category;
@ -123,11 +129,12 @@ class grade_item extends grade_object {
/**
* Indicates if we already tried to normalize the grade calculation formula.
* This flag helps to minimize db access when broken formulas used in calculation.
* @var boolean
* @var bool
*/
public $calculation_normalized;
/**
* Math evaluation object
* @var calc_formula A formula object
*/
public $formula;
@ -156,8 +163,8 @@ class grade_item extends grade_object {
public $scaleid;
/**
* A grade_scale object (referenced by $this->scaleid).
* @var object $scale
* The grade_scale object referenced by $this->scaleid.
* @var grade_scale $scale
*/
public $scale;
@ -169,7 +176,7 @@ class grade_item extends grade_object {
/**
* The grade_outcome this grade is associated with, if applicable.
* @var object $outcome
* @var grade_outcome $outcome
*/
public $outcome;
@ -229,12 +236,13 @@ class grade_item extends grade_object {
/**
* If set, the whole column will be recalculated, then this flag will be switched off.
* @var boolean $needsupdate
* @var bool $needsupdate
*/
public $needsupdate = 1;
/**
* Cached dependson array
* @var array An array of cached grade item dependencies.
*/
public $dependson_cache = null;
@ -242,8 +250,9 @@ class grade_item extends grade_object {
* In addition to update() as defined in grade_object, handle the grade_outcome and grade_scale objects.
* Force regrading if necessary, rounds the float numbers using php function,
* the reason is we need to compare the db value with computed number to skip regrading if possible.
*
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function update($source=null) {
// reset caches
@ -276,7 +285,8 @@ class grade_item extends grade_object {
* Compares the values held by this object with those of the matching record in DB, and returns
* whether or not these differences are sufficient to justify an update of all parent objects.
* This assumes that this object has an id number and a matching record in DB. If not, it will return false.
* @return boolean
*
* @return bool
*/
public function qualifies_for_regrading() {
if (empty($this->id)) {
@ -307,10 +317,10 @@ class grade_item extends grade_object {
/**
* Finds and returns a grade_item instance based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return object grade_item instance or false if none found.
* @return grade_item|bool Returns a grade_item instance or false if none found
*/
public static function fetch($params) {
return grade_object::fetch_helper('grade_items', 'grade_item', $params);
@ -318,8 +328,8 @@ class grade_item extends grade_object {
/**
* Finds and returns all grade_item instances based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return array array of grade_item instances or false if none found.
*/
@ -329,8 +339,9 @@ class grade_item extends grade_object {
/**
* Delete all grades and force_regrading of parent category.
*
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function delete($source=null) {
$this->delete_all_grades($source);
@ -339,8 +350,9 @@ class grade_item extends grade_object {
/**
* Delete all grades
*
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
* @return bool
*/
public function delete_all_grades($source=null) {
if (!$this->is_course_item()) {
@ -358,7 +370,8 @@ class grade_item extends grade_object {
/**
* In addition to perform parent::insert(), calls force_regrading() method too.
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
*
* @param string $source From where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*/
public function insert($source=null) {
@ -413,8 +426,9 @@ class grade_item extends grade_object {
/**
* Set idnumber of grade item, updates also course_modules table
*
* @param string $idnumber (without magic quotes)
* @return boolean success
* @return bool success
*/
public function add_idnumber($idnumber) {
global $DB;
@ -450,8 +464,8 @@ class grade_item extends grade_object {
* $userid is given) or the locked state of a specific grade within this item if a specific
* $userid is given and the grade_item is unlocked.
*
* @param int $userid
* @return boolean Locked state
* @param int $userid The user's ID
* @return bool Locked state
*/
public function is_locked($userid=NULL) {
if (!empty($this->locked)) {
@ -470,10 +484,11 @@ class grade_item extends grade_object {
/**
* Locks or unlocks this grade_item and (optionally) all its associated final grades.
* @param int $locked 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param boolean $cascade lock/unlock child objects too
* @param boolean $refresh refresh grades when unlocking
* @return boolean true if grade_item all grades updated, false if at least one update fails
*
* @param int $lockedstate 0, 1 or a timestamp int(10) after which date the item will be locked.
* @param bool $cascade Lock/unlock child objects too
* @param bool $refresh Refresh grades when unlocking
* @return bool True if grade_item all grades updated, false if at least one update fails
*/
public function set_locked($lockedstate, $cascade=false, $refresh=true) {
if ($lockedstate) {
@ -525,7 +540,7 @@ class grade_item extends grade_object {
}
/**
* Lock the grade if needed - make sure this is called only when final grades are valid
* Lock the grade if needed. Make sure this is called only when final grades are valid
*/
public function check_locktime() {
if (!empty($this->locked)) {
@ -559,10 +574,12 @@ class grade_item extends grade_object {
}
/**
* Set the hidden status of grade_item and all grades, 0 mean visible, 1 always hidden, number means date to hide until.
* Set the hidden status of grade_item and all grades.
*
* 0 mean always visible, 1 means always hidden and a number > 1 is a timestamp to hide until
*
* @param int $hidden new hidden status
* @param boolean $cascade apply to child objects too
* @return void
* @param bool $cascade apply to child objects too
*/
public function set_hidden($hidden, $cascade=false) {
parent::set_hidden($hidden, $cascade);
@ -590,11 +607,12 @@ class grade_item extends grade_object {
}
/**
* Returns the number of grades that are hidden.
* @param string $groupsql
* @param array $params sql params in $groupsql
* @param string $groupsqlwhere
* @return int Number of hidden grades
* Returns the number of grades that are hidden
*
* @param string $groupsql SQL to limit the query by group
* @param array $params SQL params for $groupsql
* @param string $groupwheresql Where conditions for $groupsql
* @return int The number of hidden grades
*/
public function has_hidden_grades($groupsql="", array $params=null, $groupwheresql="") {
global $DB;
@ -622,7 +640,8 @@ class grade_item extends grade_object {
* This function must be used ONLY from lib/gradeslib.php/grade_regrade_final_grades(),
* because the regrading must be done in correct order!!
*
* @return boolean true if ok, error string otherwise
* @param int $userid Supply a user ID to limit the regrading to a single user
* @return bool true if ok, error string otherwise
*/
public function regrade_final_grades($userid=null) {
global $CFG, $DB;
@ -700,7 +719,8 @@ class grade_item extends grade_object {
/**
* Given a float grade value or integer grade scale, applies a number of adjustment based on
* grade_item variables and returns the result.
* @param float $rawgrade The raw grade value.
*
* @param float $rawgrade The raw grade value
* @param float $rawmin original rawmin
* @param float $rawmax original rawmax
* @return mixed
@ -766,6 +786,7 @@ class grade_item extends grade_object {
/**
* Sets this grade_item's needsupdate to true. Also marks the course item as needing update.
*
* @return void
*/
public function force_regrading() {
@ -778,9 +799,9 @@ class grade_item extends grade_object {
}
/**
* Instantiates a grade_scale object whose data is retrieved from the DB,
* if this item's scaleid variable is set.
* @return object grade_scale or null if no scale used
* Instantiates a grade_scale object from the DB if this item's scaleid variable is set
*
* @return grade_scale Returns a grade_scale object or null if no scale used
*/
public function load_scale() {
if ($this->gradetype != GRADE_TYPE_SCALE) {
@ -812,9 +833,9 @@ class grade_item extends grade_object {
}
/**
* Instantiates a grade_outcome object whose data is retrieved from the DB,
* if this item's outcomeid variable is set.
* @return object grade_outcome
* Instantiates a grade_outcome object from the DB if this item's outcomeid variable is set
*
* @return grade_outcome This grade item's associated grade_outcome or null
*/
public function load_outcome() {
if (!empty($this->outcomeid)) {
@ -824,11 +845,11 @@ class grade_item extends grade_object {
}
/**
* Returns the grade_category object this grade_item belongs to (referenced by categoryid)
* or category attached to category item.
*
* @return mixed grade_category object if applicable, false if course item
*/
* Returns the grade_category object this grade_item belongs to (referenced by categoryid)
* or category attached to category item.
*
* @return grade_category|bool Returns a grade_category object if applicable or false if this is a course item
*/
public function get_parent_category() {
if ($this->is_category_item() or $this->is_course_item()) {
return $this->get_item_category();
@ -841,7 +862,8 @@ class grade_item extends grade_object {
/**
* Calls upon the get_parent_category method to retrieve the grade_category object
* from the DB and assigns it to $this->parent_category. It also returns the object.
* @return object Grade_category
*
* @return grade_category This grade item's parent grade_category.
*/
public function load_parent_category() {
if (empty($this->parent_category->id)) {
@ -851,10 +873,10 @@ class grade_item extends grade_object {
}
/**
* Returns the grade_category for category item
*
* @return mixed grade_category object if applicable, false otherwise
*/
* Returns the grade_category for a grade category grade item
*
* @return grade_category|bool Returns a grade_category instance if applicable or false otherwise
*/
public function get_item_category() {
if (!$this->is_course_item() and !$this->is_category_item()) {
return false;
@ -865,7 +887,8 @@ class grade_item extends grade_object {
/**
* Calls upon the get_item_category method to retrieve the grade_category object
* from the DB and assigns it to $this->item_category. It also returns the object.
* @return object Grade_category
*
* @return grade_category
*/
public function load_item_category() {
if (empty($this->item_category->id)) {
@ -876,7 +899,8 @@ class grade_item extends grade_object {
/**
* Is the grade item associated with category?
* @return boolean
*
* @return bool
*/
public function is_category_item() {
return ($this->itemtype == 'category');
@ -884,7 +908,8 @@ class grade_item extends grade_object {
/**
* Is the grade item associated with course?
* @return boolean
*
* @return bool
*/
public function is_course_item() {
return ($this->itemtype == 'course');
@ -892,7 +917,8 @@ class grade_item extends grade_object {
/**
* Is this a manually graded item?
* @return boolean
*
* @return bool
*/
public function is_manual_item() {
return ($this->itemtype == 'manual');
@ -900,7 +926,8 @@ class grade_item extends grade_object {
/**
* Is this an outcome item?
* @return boolean
*
* @return bool
*/
public function is_outcome_item() {
return !empty($this->outcomeid);
@ -908,7 +935,8 @@ class grade_item extends grade_object {
/**
* Is the grade item external - associated with module, plugin or something else?
* @return boolean
*
* @return bool
*/
public function is_external_item() {
return ($this->itemtype == 'mod');
@ -916,7 +944,8 @@ class grade_item extends grade_object {
/**
* Is the grade item overridable
* @return boolean
*
* @return bool
*/
public function is_overridable_item() {
return !$this->is_outcome_item() and ($this->is_external_item() or $this->is_calculated() or $this->is_course_item() or $this->is_category_item());
@ -924,7 +953,8 @@ class grade_item extends grade_object {
/**
* Is the grade item feedback overridable
* @return boolean
*
* @return bool
*/
public function is_overridable_item_feedback() {
return !$this->is_outcome_item() and $this->is_external_item();
@ -932,16 +962,18 @@ class grade_item extends grade_object {
/**
* Returns true if grade items uses raw grades
* @return boolean
*
* @return bool
*/
public function is_raw_used() {
return ($this->is_external_item() and !$this->is_calculated() and !$this->is_outcome_item());
}
/**
* Returns grade item associated with the course
* Returns the grade item associated with the course
*
* @param int $courseid
* @return course item object
* @return grade_item Course level grade item object
*/
public static function fetch_course_item($courseid) {
if ($course_item = grade_item::fetch(array('courseid'=>$courseid, 'itemtype'=>'course'))) {
@ -955,7 +987,8 @@ class grade_item extends grade_object {
/**
* Is grading object editable?
* @return boolean
*
* @return bool
*/
public function is_editable() {
return true;
@ -963,7 +996,8 @@ class grade_item extends grade_object {
/**
* Checks if grade calculated. Returns this object's calculation.
* @return boolean true if grade item calculated.
*
* @return bool true if grade item calculated.
*/
public function is_calculated() {
if (empty($this->calculation)) {
@ -986,7 +1020,8 @@ class grade_item extends grade_object {
/**
* Returns calculation string if grade calculated.
* @return mixed string if calculation used, null if not
*
* @return string Returns the grade item's calculation if calculation is used, null if not
*/
public function get_calculation() {
if ($this->is_calculated()) {
@ -1001,8 +1036,9 @@ class grade_item extends grade_object {
* Sets this item's calculation (creates it) if not yet set, or
* updates it if already set (in the DB). If no calculation is given,
* the calculation is removed.
*
* @param string $formula string representation of formula used for calculation
* @return boolean success
* @return bool success
*/
public function set_calculation($formula) {
$this->calculation = grade_item::normalize_formula($formula, $this->courseid);
@ -1012,9 +1048,10 @@ class grade_item extends grade_object {
/**
* Denormalizes the calculation formula to [idnumber] form
* @static
* @param string $formula
* @return string denormalized string
*
* @param string $formula A string representation of the formula
* @param int $courseid The course ID
* @return string The denormalized formula as a string
*/
public static function denormalize_formula($formula, $courseid) {
if (empty($formula)) {
@ -1038,9 +1075,10 @@ class grade_item extends grade_object {
/**
* Normalizes the calculation formula to [#giXX#] form
* @static
* @param string $formula
* @return string normalized string
*
* @param string $formula The formula
* @param int $courseid The course ID
* @return string The normalized formula as a string
*/
public static function normalize_formula($formula, $courseid) {
$formula = trim($formula);
@ -1062,8 +1100,9 @@ class grade_item extends grade_object {
/**
* Returns the final values for this grade item (as imported by module or other source).
* @param int $userid Optional: to retrieve a single final grade
* @return mixed An array of all final_grades (stdClass objects) for this grade_item, or a single final_grade.
*
* @param int $userid Optional: to retrieve a single user's final grade
* @return array|grade_grade An array of all grade_grade instances for this grade_item, or a single grade_grade instance.
*/
public function get_final($userid=NULL) {
global $DB;
@ -1074,7 +1113,7 @@ class grade_item extends grade_object {
} else {
if ($grades = $DB->get_records('grade_grades', array('itemid' => $this->id))) {
//TODO: speed up with better SQL
//TODO: speed up with better SQL (MDL-31380)
$result = array();
foreach ($grades as $grade) {
$result[$grade->userid] = $grade;
@ -1088,8 +1127,10 @@ class grade_item extends grade_object {
/**
* Get (or create if not exist yet) grade for this user
* @param int $userid
* @return object grade_grade object instance
*
* @param int $userid The user ID
* @param bool $create If true and the user has no grade for this grade item a new grade_grade instance will be inserted
* @return grade_grade The grade_grade instance for the user for this grade item
*/
public function get_grade($userid, $create=true) {
if (empty($this->id)) {
@ -1108,6 +1149,7 @@ class grade_item extends grade_object {
/**
* Returns the sortorder of this grade_item. This method is also available in
* grade_category, for cases where the object type is not know.
*
* @return int Sort order
*/
public function get_sortorder() {
@ -1117,7 +1159,8 @@ class grade_item extends grade_object {
/**
* Returns the idnumber of this grade_item. This method is also available in
* grade_category, for cases where the object type is not know.
* @return string idnumber
*
* @return string The grade item idnumber
*/
public function get_idnumber() {
return $this->idnumber;
@ -1126,7 +1169,8 @@ class grade_item extends grade_object {
/**
* Returns this grade_item. This method is also available in
* grade_category, for cases where the object type is not know.
* @return string idnumber
*
* @return grade_item
*/
public function get_grade_item() {
return $this;
@ -1135,8 +1179,8 @@ class grade_item extends grade_object {
/**
* Sets the sortorder of this grade_item. This method is also available in
* grade_category, for cases where the object type is not know.
*
* @param int $sortorder
* @return void
*/
public function set_sortorder($sortorder) {
if ($this->sortorder == $sortorder) {
@ -1146,6 +1190,11 @@ class grade_item extends grade_object {
$this->update();
}
/**
* Update this grade item's sortorder so that it will appear after $sortorder
*
* @param int $sortorder The sort order to place this grade item after
*/
public function move_after_sortorder($sortorder) {
global $CFG, $DB;
@ -1160,9 +1209,11 @@ class grade_item extends grade_object {
}
/**
* Returns the most descriptive field for this object. This is a standard method used
* when we do not know the exact type of an object.
* @param boolean $fulltotal: if the item is a category total, returns $categoryname."total" instead of "Category total" or "Course total"
* Returns the most descriptive field for this object.
*
* Determines what type of grade item it is then returns the appropriate string
*
* @param bool $fulltotal If the item is a category total, returns $categoryname."total" instead of "Category total" or "Course total"
* @return string name
*/
public function get_name($fulltotal=false) {
@ -1190,8 +1241,9 @@ class grade_item extends grade_object {
/**
* Sets this item's categoryid. A generic method shared by objects that have a parent id of some kind.
* @param int $parentid
* @return boolean success;
*
* @param int $parentid The ID of the new parent
* @return bool True if success
*/
public function set_parent($parentid) {
if ($this->is_course_item() or $this->is_category_item()) {
@ -1225,6 +1277,7 @@ class grade_item extends grade_object {
/**
* Makes sure value is a valid grade value.
*
* @param float $gradevalue
* @return mixed float or int fixed grade value
*/
@ -1262,8 +1315,9 @@ class grade_item extends grade_object {
/**
* Finds out on which other items does this depend directly when doing calculation or category aggregation
*
* @param bool $reset_cache
* @return array of grade_item ids this one depends on
* @return array of grade_item IDs this one depends on
*/
public function depends_on($reset_cache=false) {
global $CFG, $DB;
@ -1366,7 +1420,8 @@ class grade_item extends grade_object {
/**
* Refetch grades from modules, plugins.
* @param int $userid optional, one user only
*
* @param int $userid optional, limit the refetch to a single user
*/
public function refresh_grades($userid=0) {
global $DB;
@ -1399,13 +1454,13 @@ class grade_item extends grade_object {
* and deals with overridden flag. This flag is set to prevent later overriding
* from raw grades submitted from modules.
*
* @param int $userid the graded user
* @param mixed $finalgrade float value of final grade - false means do not change
* @param string $howmodified modification source
* @param string $note optional note
* @param mixed $feedback teachers feedback as string - false means do not change
* @param int $feedbackformat
* @return boolean success
* @param int $userid The graded user
* @param float|false $finalgrade The float value of final grade, false means do not change
* @param string $source The modification source
* @param string $feedback Optional teacher feedback
* @param int $feedbackformat A format like FORMAT_PLAIN or FORMAT_HTML
* @param int $usermodified The ID of the user making the modification
* @return bool success
*/
public function update_final_grade($userid, $finalgrade=false, $source=NULL, $feedback=false, $feedbackformat=FORMAT_MOODLE, $usermodified=null) {
global $USER, $CFG;
@ -1467,7 +1522,7 @@ class grade_item extends grade_object {
if (empty($grade->id)) {
$grade->timecreated = null; // hack alert - date submitted - no submission yet
$grade->timemodified = time(); // hack alert - date graded
$result = (boolean)$grade->insert($source);
$result = (bool)$grade->insert($source);
} else if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)
or $grade->feedback !== $oldgrade->feedback
@ -1511,15 +1566,14 @@ class grade_item extends grade_object {
*
* @param int $userid the graded user
* @param mixed $rawgrade float value of raw grade - false means do not change
* @param string $howmodified modification source
* @param string $note optional note
* @param mixed $feedback teachers feedback as string - false means do not change
* @param int $feedbackformat
* @param int $usermodified - user which did the grading
* @param int $dategraded
* @param int $datesubmitted
* @param object $grade object - useful for bulk upgrades
* @return boolean success
* @param string $source modification source
* @param string $feedback optional teacher feedback
* @param int $feedbackformat A format like FORMAT_PLAIN or FORMAT_HTML
* @param int $usermodified the ID of the user who did the grading
* @param int $dategraded A timestamp of when the student's work was graded
* @param int $datesubmitted A timestamp of when the student's work was submitted
* @param grade_grade $grade A grade object, useful for bulk upgrades
* @return bool success
*/
public function update_raw_grade($userid, $rawgrade=false, $source=NULL, $feedback=false, $feedbackformat=FORMAT_MOODLE, $usermodified=null, $dategraded=null, $datesubmitted=null, $grade=null) {
global $USER;
@ -1619,7 +1673,7 @@ class grade_item extends grade_object {
// end of hack alert
if (empty($grade->id)) {
$result = (boolean)$grade->insert($source);
$result = (bool)$grade->insert($source);
} else if (grade_floats_different($grade->finalgrade, $oldgrade->finalgrade)
or grade_floats_different($grade->rawgrade, $oldgrade->rawgrade)
@ -1653,9 +1707,11 @@ class grade_item extends grade_object {
}
/**
* Calculates final grade values using the formula in calculation property.
* Calculates final grade values using the formula in the calculation property.
* The parameters are taken from final grades of grade items in current course only.
* @return boolean false if error
*
* @param int $userid Supply a user ID to limit the calculations to the grades of a single user
* @return bool false if error
*/
public function compute($userid=null) {
global $CFG, $DB;
@ -1751,7 +1807,13 @@ class grade_item extends grade_object {
}
/**
* internal function - does the final grade calculation
* Internal function that does the final grade calculation
*
* @param int $userid The user ID
* @param array $params An array of grade items of the form {'gi'.$itemid]} => $finalgrade
* @param array $useditems An array of grade item IDs that this grade item depends on plus its own ID
* @param grade_grade $oldgrade A grade_grade instance containing the old values from the database
* @return bool False if an error occurred
*/
public function use_formula($userid, $params, $useditems, $oldgrade) {
if (empty($userid)) {
@ -1833,8 +1895,9 @@ class grade_item extends grade_object {
/**
* Validate the formula.
* @param string $formula
* @return boolean true if calculation possible, false otherwise
*
* @param string $formulastr
* @return bool true if calculation possible, false otherwise
*/
public function validate_formula($formulastr) {
global $CFG, $DB;
@ -1910,7 +1973,10 @@ class grade_item extends grade_object {
}
/**
* Returns the value of the display type. It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
* Returns the value of the display type
*
* It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
*
* @return int Display type
*/
public function get_displaytype() {
@ -1925,7 +1991,10 @@ class grade_item extends grade_object {
}
/**
* Returns the value of the decimals field. It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
* Returns the value of the decimals field
*
* It can be set at 3 levels: grade_item, course setting and site. The lowest level overrides the higher ones.
*
* @return int Decimals (0 - 5)
*/
public function get_decimals() {
@ -1941,6 +2010,7 @@ class grade_item extends grade_object {
/**
* Returns a string representing the range of grademin - grademax for this grade item.
*
* @param int $rangesdisplaytype
* @param int $rangesdecimalpoints
* @return string
@ -1981,8 +2051,9 @@ class grade_item extends grade_object {
}
/**
* Queries parent categories recursively to find the aggregationcoef type that applies to this
* grade item.
* Queries parent categories recursively to find the aggregationcoef type that applies to this grade item.
*
* @return string|false Returns the coefficient string of false is no coefficient is being used
*/
public function get_coefstring() {
$parent_category = $this->load_parent_category();

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,21 +13,31 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of grade object class
* Definition of a grade object class for grade item, grade category etc to inherit from
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* An abstract object that holds methods and attributes common to all grade_* objects defined here.
* @abstract
*
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class grade_object {
/**
* The database table this grade object is stored in
* @var string $table
*/
public $table;
/**
@ -69,9 +78,10 @@ abstract class grade_object {
var $hidden = 0;
/**
* Constructor. Optionally (and by default) attempts to fetch corresponding row from DB.
* @param array $params an array with required parameters for this grade object.
* @param boolean $fetch Whether to fetch corresponding row from DB or not,
* Constructor. Optionally (and by default) attempts to fetch corresponding row from the database
*
* @param array $params An array with required parameters for this grade object.
* @param bool $fetch Whether to fetch corresponding row from the database or not,
* optional fields might not be defined if false used
*/
public function __construct($params=NULL, $fetch=true) {
@ -95,7 +105,8 @@ abstract class grade_object {
/**
* Makes sure all the optional fields are loaded.
* If id present (==instance exists in db) fetches data from db.
*
* If id present, meaning the instance exists in the database, then data will be fetched from the database.
* Defaults are used for new instances.
*/
public function load_optional_fields() {
@ -114,8 +125,9 @@ abstract class grade_object {
/**
* Finds and returns a grade_object instance based on params.
* @static abstract
*
* @static
* @abstract
* @param array $params associative arrays varname=>value
* @return object grade_object instance or false if none found.
*/
@ -124,20 +136,25 @@ abstract class grade_object {
}
/**
* Finds and returns all grade_object instances based on params.
* @static abstract
* Finds and returns all grade_object instances based on $params.
*
* @param array $params associative arrays varname=>value
* @return array array of grade_object instances or false if none found.
* @static
* @abstract
* @throws coding_exception Throws a coding exception if fetch_all() has not been overriden by the grade object subclass
* @param array $params Associative arrays varname=>value
* @return array|bool Array of grade_object instances or false if none found.
*/
public static function fetch_all($params) {
throw new coding_exception('fetch_all() method needs to be overridden in each subclass of grade_object');
}
/**
* Factory method - uses the parameters to retrieve matching instance from the DB.
* @static final protected
* @return mixed object instance or false if not found
* Factory method which uses the parameters to retrieve matching instances from the database
*
* @param string $table The table to retrieve from
* @param string $classname The name of the class to instantiate
* @param array $params An array of conditions like $fieldname => $fieldvalue
* @return mixed An object instance or false if not found
*/
protected static function fetch_helper($table, $classname, $params) {
if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) {
@ -152,9 +169,12 @@ abstract class grade_object {
}
/**
* Factory method - uses the parameters to retrieve all matching instances from the DB.
* @static final protected
* @return mixed array of object instances or false if not found
* Factory method which uses the parameters to retrieve all matching instances from the database
*
* @param string $table The table to retrieve from
* @param string $classname The name of the class to instantiate
* @param array $params An array of conditions like $fieldname => $fieldvalue
* @return array|bool Array of object instances or false if not found
*/
public static function fetch_all_helper($table, $classname, $params) {
$instance = new $classname();
@ -204,8 +224,9 @@ abstract class grade_object {
/**
* Updates this object in the Database, based on its object variables. ID must be set.
*
* @param string $source from where was the object updated (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function update($source=null) {
global $USER, $CFG, $DB;
@ -235,8 +256,9 @@ abstract class grade_object {
/**
* Deletes this object from the database.
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
*
* @param string $source From where was the object deleted (mod/forum, manual, etc.)
* @return bool success
*/
public function delete($source=null) {
global $USER, $CFG, $DB;
@ -269,6 +291,8 @@ abstract class grade_object {
/**
* Returns object with fields and values that are defined in database
*
* @return stdClass
*/
public function get_record_data() {
$data = new stdClass();
@ -289,8 +313,9 @@ abstract class grade_object {
* Records this object in the Database, sets its id to the returned value, and returns that value.
* If successful this function also fetches the new object data from database and stores it
* in object properties.
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*
* @param string $source From where was the object inserted (mod/forum, manual, etc.)
* @return int The new grade object ID if successful, false otherwise
*/
public function insert($source=null) {
global $USER, $CFG, $DB;
@ -328,6 +353,8 @@ abstract class grade_object {
* each variable in turn. If the DB has different data, the db's data is used to update
* the object. This is different from the update() function, which acts on the DB record
* based on the object.
*
* @return bool True if successful
*/
public function update_from_db() {
if (empty($this->id)) {
@ -348,7 +375,10 @@ abstract class grade_object {
/**
* Given an associated array or object, cycles through each key/variable
* and assigns the value to the corresponding variable in this object.
* @static final
*
* @param stdClass $instance The object to set the properties on
* @param array $params An array of properties to set like $propertyname => $propertyvalue
* @return array|stdClass Either an associative array or an object containing property name, property value pairs
*/
public static function set_properties(&$instance, $params) {
$params = (array) $params;
@ -370,29 +400,40 @@ abstract class grade_object {
}
/**
* Returns the hidden state of this grade_item
* @return boolean hidden state
* Returns the current hidden state of this grade_item
*
* This depends on the grade object hidden setting and the current time if hidden is set to a "hidden until" timestamp
*
* @return bool Current hidden state
*/
function is_hidden() {
return ($this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()));
}
/**
* Check grade hidden status. Uses data from both grade item and grade.
* @return boolean true if hiddenuntil, false if not
* Check grade object hidden status
*
* @return bool True if a "hidden until" timestamp is set, false if grade object is set to always visible or always hidden.
*/
function is_hiddenuntil() {
return $this->hidden > 1;
}
/**
* Check grade item hidden status.
* @return int 0 means visible, 1 hidden always, timestamp hidden until
* Check a grade item hidden status.
*
* @return int 0 means visible, 1 hidden always, a timestamp means "hidden until"
*/
function get_hidden() {
return $this->hidden;
}
/**
* Set a grade object hidden status
*
* @param int $hidden 0 means visiable, 1 means hidden always, a timestamp means "hidden until"
* @param bool $cascade Ignored
*/
function set_hidden($hidden, $cascade=false) {
$this->hidden = $hidden;
$this->update();

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,13 +13,14 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of grade outcome class
* Definition of grade outcome class
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
@ -28,8 +28,14 @@ defined('MOODLE_INTERNAL') || die();
require_once('grade_object.php');
/**
* Class representing a grade outcome. It is responsible for handling its DB representation,
* modifying and returning its metadata.
* Class representing a grade outcome.
*
* It is responsible for handling its DB representation, modifying and returning its metadata.
*
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_outcome extends grade_object {
/**
@ -83,14 +89,16 @@ class grade_outcome extends grade_object {
/**
* The userid of the person who last modified this outcome.
*
* @var int $usermodified
*/
public $usermodified;
/**
* Deletes this outcome from the database.
*
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function delete($source=null) {
global $DB;
@ -113,6 +121,7 @@ class grade_outcome extends grade_object {
* Records this object in the Database, sets its id to the returned value, and returns that value.
* If successful this function also fetches the new object data from database and stores it
* in object properties.
*
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*/
@ -134,8 +143,9 @@ class grade_outcome extends grade_object {
/**
* In addition to update() it also updates grade_outcomes_courses if needed
*
* @param string $source from where was the object inserted
* @return boolean success
* @return bool success
*/
public function update($source=null) {
$this->timemodified = time();
@ -149,9 +159,10 @@ class grade_outcome extends grade_object {
}
/**
* Mark outcome as used in course
* Mark outcome as used in a course
*
* @param int $courseid
* @return succes - false if incorrect courseid requested
* @return False if invalid courseid requested
*/
public function use_in($courseid) {
global $DB;
@ -170,8 +181,8 @@ class grade_outcome extends grade_object {
/**
* Finds and returns a grade_outcome instance based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return object grade_outcome instance or false if none found.
*/
@ -181,8 +192,8 @@ class grade_outcome extends grade_object {
/**
* Finds and returns all grade_outcome instances based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return array array of grade_outcome insatnces or false if none found.
*/
@ -191,8 +202,9 @@ class grade_outcome extends grade_object {
}
/**
* Instantiates a grade_scale object whose data is retrieved from the
* @return object grade_scale
* Instantiates a grade_scale object whose data is retrieved from the database
*
* @return grade_scale
*/
public function load_scale() {
if (empty($this->scale->id) or $this->scale->id != $this->scaleid) {
@ -204,8 +216,9 @@ class grade_outcome extends grade_object {
/**
* Static function returning all global outcomes
*
* @static
* @return object
* @return array
*/
public static function fetch_all_global() {
if (!$outcomes = grade_outcome::fetch_all(array('courseid'=>null))) {
@ -216,9 +229,10 @@ class grade_outcome extends grade_object {
/**
* Static function returning all local course outcomes
*
* @static
* @param int $courseid
* @return object
* @return array
*/
public static function fetch_all_local($courseid) {
if (!$outcomes =grade_outcome::fetch_all(array('courseid'=>$courseid))) {
@ -228,7 +242,8 @@ class grade_outcome extends grade_object {
}
/**
* Static method - returns all outcomes available in course
* Static method that returns all outcomes available in course
*
* @static
* @param int $courseid
* @return array
@ -257,6 +272,7 @@ class grade_outcome extends grade_object {
/**
* Returns the most descriptive field for this object. This is a standard method used
* when we do not know the exact type of an object.
*
* @return string name
*/
public function get_name() {
@ -265,6 +281,7 @@ class grade_outcome extends grade_object {
/**
* Returns unique outcome short name.
*
* @return string name
*/
public function get_shortname() {
@ -273,6 +290,7 @@ class grade_outcome extends grade_object {
/**
* Returns the formatted grade description with URLs converted
*
* @return string
*/
public function get_description() {
@ -288,7 +306,8 @@ class grade_outcome extends grade_object {
/**
* Checks if outcome can be deleted.
* @return boolean
*
* @return bool
*/
public function can_delete() {
if ($this->get_item_uses_count()) {
@ -304,6 +323,7 @@ class grade_outcome extends grade_object {
/**
* Returns the number of places where outcome is used.
*
* @return int
*/
public function get_course_uses_count() {
@ -317,7 +337,8 @@ class grade_outcome extends grade_object {
}
/**
* Returns the number of places where outcome is used.
* Returns the number of grade items that use this grade outcome
*
* @return int
*/
public function get_item_uses_count() {
@ -332,6 +353,7 @@ class grade_outcome extends grade_object {
* is also requested, then a single array is returned, which contains the grade_items AND the average grade
* if such is still requested (array('items' => array(...), 'avg' => 2.30)). This combining of two
* methods into one is to save on DB queries, since both queries are similar and can be performed together.
*
* @param int $courseid An optional courseid to narrow down the average to 1 course only
* @param bool $average Whether or not to return the average grade for this outcome
* @param bool $items Whether or not to return the list of items using this outcome

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -14,13 +13,14 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Definitions of grade scale class
* Definition of grade scale class
*
* @package core
* @subpackage grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
@ -28,8 +28,14 @@ defined('MOODLE_INTERNAL') || die();
require_once('grade_object.php');
/**
* Class representing a grade scale. It is responsible for handling its DB representation,
* modifying and returning its metadata.
* Class representing a grade scale.
*
* It is responsible for handling its DB representation, modifying and returning its metadata.
*
* @package core_grades
* @category grade
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grade_scale extends grade_object {
/**
@ -50,6 +56,10 @@ class grade_scale extends grade_object {
*/
public $courseid;
/**
* The ID of the user who created the scale
* @var int $userid
*/
public $userid;
/**
@ -78,8 +88,8 @@ class grade_scale extends grade_object {
/**
* Finds and returns a grade_scale instance based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return object grade_scale instance or false if none found.
*/
@ -89,8 +99,8 @@ class grade_scale extends grade_object {
/**
* Finds and returns all grade_scale instances based on params.
* @static
*
* @static
* @param array $params associative arrays varname=>value
* @return array array of grade_scale instances or false if none found.
*/
@ -102,6 +112,7 @@ class grade_scale extends grade_object {
* Records this object in the Database, sets its id to the returned value, and returns that value.
* If successful this function also fetches the new object data from database and stores it
* in object properties.
*
* @param string $source from where was the object inserted (mod/forum, manual, etc.)
* @return int PK ID if successful, false otherwise
*/
@ -113,8 +124,9 @@ class grade_scale extends grade_object {
/**
* In addition to update() it also updates grade_outcomes_courses if needed
*
* @param string $source from where was the object inserted
* @return boolean success
* @return bool success
*/
public function update($source=null) {
$this->timemodified = time();
@ -123,8 +135,9 @@ class grade_scale extends grade_object {
/**
* Deletes this outcome from the database.
*
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
* @return bool success
*/
public function delete($source=null) {
global $DB;
@ -143,6 +156,7 @@ class grade_scale extends grade_object {
/**
* Returns the most descriptive field for this object. This is a standard method used
* when we do not know the exact type of an object.
*
* @return string name
*/
public function get_name() {
@ -206,6 +220,7 @@ class grade_scale extends grade_object {
* the grademin and grademax, this method returns the scale item that falls closest to the
* float given (which is usually an average of several grades on a scale). If the float falls
* below 1 but above 0, it will be rounded up to 1.
*
* @param float $grade
* @return string
*/
@ -226,6 +241,7 @@ class grade_scale extends grade_object {
/**
* Static function returning all global scales
*
* @return object
*/
public function fetch_all_global() {
@ -234,7 +250,9 @@ class grade_scale extends grade_object {
/**
* Static function returning all local course scales
* @return object
*
* @param int $courseid The course ID
* @return array Returns an array of grade_scale instances
*/
public static function fetch_all_local($courseid) {
return grade_scale::fetch_all(array('courseid'=>$courseid));
@ -242,7 +260,8 @@ class grade_scale extends grade_object {
/**
* Checks if scale can be deleted.
* @return boolean
*
* @return bool
*/
public function can_delete() {
return !$this->is_used();
@ -250,6 +269,7 @@ class grade_scale extends grade_object {
/**
* Returns if scale used anywhere - activities, grade items, outcomes, etc.
*
* @return bool
*/
public function is_used() {
@ -310,6 +330,7 @@ class grade_scale extends grade_object {
/**
* Returns the formatted grade description with URLs converted
*
* @return string
*/
public function get_description() {

View File

@ -1,34 +1,25 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Unit tests for grade_category object.
* Unit tests for grade_category class
*
* @author nicolas@moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {

View File

@ -1,34 +1,25 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Unit tests for grade_raw object.
* Unit tests for grade_grade class
*
* @author nicolas@moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {

View File

@ -1,34 +1,25 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Unit tests for grade_item object.
* Unit tests for grade_item class
*
* @author nicolas@moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {

View File

@ -1,34 +1,25 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Unit tests for grade_outcome object.
* Unit tests for grade_outcome class
*
* @author nicolas@moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {

View File

@ -1,34 +1,25 @@
<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
// 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/>.
/**
* Unit tests for grade_scale object.
* Unit tests for grade_scale class
*
* @author nicolas@moodle.com
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
* @package core_grades
* @copyright 2006 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!defined('MOODLE_INTERNAL')) {

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -18,10 +17,9 @@
/**
* Library of functions for gradebook - both public and internal
*
* @package core
* @subpackage grade
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package core_grades
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
@ -41,25 +39,24 @@ require_once($CFG->libdir . '/grade/grade_outcome.php');
/**
* Submit new or update grade; update/create grade_item definition. Grade must have userid specified,
* rawgrade and feedback with format are optional. rawgrade NULL means 'Not graded', missing property
* or key means do not change existing.
* rawgrade and feedback with format are optional. rawgrade NULL means 'Not graded'.
* Missing property or key means does not change the existing value.
*
* Only following grade item properties can be changed 'itemname', 'idnumber', 'gradetype', 'grademax',
* 'grademin', 'scaleid', 'multfactor', 'plusfactor', 'deleted' and 'hidden'. 'reset' means delete all current grades including locked ones.
*
* Manual, course or category items can not be updated by this function.
* @access public
* @global object
* @global object
* @global object
* @param string $source source of the grade such as 'mod/assignment'
* @param int $courseid id of course
* @param string $itemtype type of grade item - mod, block
* @param string $itemmodule more specific then $itemtype - assignment, forum, etc.; maybe NULL for some item types
* @param int $iteminstance instance it of graded subject
* @param int $itemnumber most probably 0, modules can use other numbers when having more than one grades for each user
* @param mixed $grades grade (object, array) or several grades (arrays of arrays or objects), NULL if updating grade_item definition only
* @param mixed $itemdetails object or array describing the grading item, NULL if no change
*
* @category grade
* @param string $source Source of the grade such as 'mod/assignment'
* @param int $courseid ID of course
* @param string $itemtype Type of grade item. For example, mod or block
* @param string $itemmodule More specific then $itemtype. For example, assignment or forum. May be NULL for some item types
* @param int $iteminstance Instance ID of graded item
* @param int $itemnumber Most probably 0. Modules can use other numbers when having more than one grade for each user
* @param mixed $grades Grade (object, array) or several grades (arrays of arrays or objects), NULL if updating grade_item definition only
* @param mixed $itemdetails Object or array describing the grading item, NULL if no change
* @return int Returns GRADE_UPDATE_OK, GRADE_UPDATE_FAILED, GRADE_UPDATE_MULTIPLE, GRADE_UPDATE_ITEM_DELETED (MDL-31362) or GRADE_UPDATE_ITEM_LOCKED
*/
function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance, $itemnumber, $grades=NULL, $itemdetails=NULL) {
global $USER, $CFG, $DB;
@ -301,18 +298,17 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance,
}
/**
* Updates outcomes of user
* Manual outcomes can not be updated.
* Updates a user's outcomes. Manual outcomes can not be updated.
*
* @access public
* @param string $source source of the grade such as 'mod/assignment'
* @param int $courseid id of course
* @param string $itemtype 'mod', 'block'
* @param string $itemmodule 'forum, 'quiz', etc.
* @param int $iteminstance id of the item module
* @param int $userid ID of the graded user
* @param array $data array itemnumber=>outcomegrade
* @return boolean returns true if grade items were found and updated successfully
* @category grade
* @param string $source Source of the grade such as 'mod/assignment'
* @param int $courseid ID of course
* @param string $itemtype Type of grade item. For example, 'mod' or 'block'
* @param string $itemmodule More specific then $itemtype. For example, 'forum' or 'quiz'. May be NULL for some item types
* @param int $iteminstance Instance ID of graded item. For example the forum ID.
* @param int $userid ID of the graded user
* @param array $data Array consisting of grade item itemnumber ({@see grade_update()}) => outcomegrade
* @return bool returns true if grade items were found and updated successfully
*/
function grade_update_outcomes($source, $courseid, $itemtype, $itemmodule, $iteminstance, $userid, $data) {
if ($items = grade_item::fetch_all(array('itemtype'=>$itemtype, 'itemmodule'=>$itemmodule, 'iteminstance'=>$iteminstance, 'courseid'=>$courseid))) {
@ -330,16 +326,15 @@ function grade_update_outcomes($source, $courseid, $itemtype, $itemmodule, $item
}
/**
* Returns grading information for given activity - optionally with users grades
* Returns grading information for given activity, optionally with user grades
* Manual, course or category items can not be queried.
*
* @access public
* @global object
* @param int $courseid id of course
* @param string $itemtype 'mod', 'block'
* @param string $itemmodule 'forum, 'quiz', etc.
* @param int $iteminstance id of the item module
* @param array|int $userid_or_ids optional id of the graded user or array of ids; if userid not used, returns only information about grade_item
* @category grade
* @param int $courseid ID of course
* @param string $itemtype Type of grade item. For example, 'mod' or 'block'
* @param string $itemmodule More specific then $itemtype. For example, 'forum' or 'quiz'. May be NULL for some item types
* @param int $iteminstance ID of the item module
* @param mixed $userid_or_ids Either a single user ID, an array of user IDs or null. If user ID or IDs are not supplied returns information about grade_item
* @return array Array of grade information objects (scaleid, name, grade and locked status, etc.) indexed with itemnumbers
*/
function grade_get_grades($courseid, $itemtype, $itemmodule, $iteminstance, $userid_or_ids=null) {
@ -552,14 +547,13 @@ function grade_get_grades($courseid, $itemtype, $itemmodule, $iteminstance, $use
///////////////////////////////////////////////////////////////////
/**
* Returns course gradebook setting
* Returns a course gradebook setting
*
* @global object
* @param int $courseid
* @param string $name of setting, maybe null if reset only
* @param string $default
* @param string $default value to return if setting is not found
* @param bool $resetcache force reset of internal static cache
* @return string value, NULL if no setting
* @return string value of the setting, $default if setting not found, NULL if supplied $name is null
*/
function grade_get_setting($courseid, $name, $default=null, $resetcache=false) {
global $DB;
@ -593,7 +587,6 @@ function grade_get_setting($courseid, $name, $default=null, $resetcache=false) {
/**
* Returns all course gradebook settings as object properties
*
* @global object
* @param int $courseid
* @return object
*/
@ -613,13 +606,11 @@ function grade_get_settings($courseid) {
}
/**
* Add/update course gradebook setting
* Add, update or delete a course gradebook setting
*
* @global object
* @param int $courseid
* @param string $name of setting
* @param string value, NULL means no setting==remove
* @return void
* @param int $courseid The course ID
* @param string $name Name of the setting
* @param string $value Value of the setting. NULL means delete the setting.
*/
function grade_set_setting($courseid, $name, $value) {
global $DB;
@ -647,11 +638,11 @@ function grade_set_setting($courseid, $name, $value) {
/**
* Returns string representation of grade value
*
* @param float $value grade value
* @param object $grade_item - by reference to prevent scale reloading
* @param float $value The grade value
* @param object $grade_item Grade item object passed by reference to prevent scale reloading
* @param bool $localized use localised decimal separator
* @param int $displaytype type of display - GRADE_DISPLAY_TYPE_REAL, GRADE_DISPLAY_TYPE_PERCENTAGE, GRADE_DISPLAY_TYPE_LETTER
* @param int $decimals number of decimal places when displaying float values
* @param int $displaytype type of display. For example GRADE_DISPLAY_TYPE_REAL, GRADE_DISPLAY_TYPE_PERCENTAGE, GRADE_DISPLAY_TYPE_LETTER
* @param int $decimals The number of decimal places when displaying float values
* @return string
*/
function grade_format_gradevalue($value, &$grade_item, $localized=true, $displaytype=null, $decimals=null) {
@ -716,7 +707,13 @@ function grade_format_gradevalue($value, &$grade_item, $localized=true, $display
}
/**
* @todo Document this function
* Returns a float representation of a grade value
*
* @param float $value The grade value
* @param object $grade_item Grade item object
* @param int $decimals The number of decimal places
* @param bool $localized use localised decimal separator
* @return string
*/
function grade_format_gradevalue_real($value, $grade_item, $decimals, $localized) {
if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
@ -731,8 +728,15 @@ function grade_format_gradevalue_real($value, $grade_item, $decimals, $localized
return format_float($value, $decimals, $localized);
}
}
/**
* @todo Document this function
* Returns a percentage representation of a grade value
*
* @param float $value The grade value
* @param object $grade_item Grade item object
* @param int $decimals The number of decimal places
* @param bool $localized use localised decimal separator
* @return string
*/
function grade_format_gradevalue_percentage($value, $grade_item, $decimals, $localized) {
$min = $grade_item->grademin;
@ -744,8 +748,14 @@ function grade_format_gradevalue_percentage($value, $grade_item, $decimals, $loc
$percentage = (($value-$min)*100)/($max-$min);
return format_float($percentage, $decimals, $localized).' %';
}
/**
* @todo Document this function
* Returns a letter grade representation of a grade value
* The array of grade letters used is produced by {@see grade_get_letters()} using the course context
*
* @param float $value The grade value
* @param object $grade_item Grade item object
* @return string
*/
function grade_format_gradevalue_letter($value, $grade_item) {
$context = get_context_instance(CONTEXT_COURSE, $grade_item->courseid);
@ -769,10 +779,10 @@ function grade_format_gradevalue_letter($value, $grade_item) {
/**
* Returns grade options for gradebook category menu
* Returns grade options for gradebook grade category menu
*
* @param int $courseid
* @param bool $includenew include option for new category (-1)
* @param int $courseid The course ID
* @param bool $includenew Include option for new category at array index -1
* @return array of grade categories in course
*/
function grade_get_categories_menu($courseid, $includenew=false) {
@ -804,10 +814,10 @@ function grade_get_categories_menu($courseid, $includenew=false) {
}
/**
* Returns grade letters array used in context
* Returns the array of grade letters to be used in the supplied context
*
* @param object $context object or null for defaults
* @return array of grade_boundary=>letter_string
* @param object $context Context object or null for defaults
* @return array of grade_boundary (minimum) => letter_string
*/
function grade_get_letters($context=null) {
global $DB;
@ -852,14 +862,13 @@ function grade_get_letters($context=null) {
/**
* Verify new value of idnumber - checks for uniqueness of new idnumbers, old are kept intact
* Verify new value of grade item idnumber. Checks for uniqueness of new ID numbers. Old ID numbers are kept intact.
*
* @global object
* @param string idnumber string (with magic quotes)
* @param int $courseid id numbers are course unique only
* @param object $grade_item is item idnumber
* @param object $cm used for course module idnumbers and items attached to modules
* @return boolean true means idnumber ok
* @param string $idnumber string (with magic quotes)
* @param int $courseid ID numbers are course unique only
* @param grade_item $grade_item The grade item this idnumber is associated with
* @param stdClass $cm used for course module idnumbers and items attached to modules
* @return bool true means idnumber ok
*/
function grade_verify_idnumber($idnumber, $courseid, $grade_item=null, $cm=null) {
global $DB;
@ -895,8 +904,7 @@ function grade_verify_idnumber($idnumber, $courseid, $grade_item=null, $cm=null)
/**
* Force final grade recalculation in all course items
*
* @global object
* @param int $courseid
* @param int $courseid The course ID to recalculate
*/
function grade_force_full_regrading($courseid) {
global $DB;
@ -904,9 +912,7 @@ function grade_force_full_regrading($courseid) {
}
/**
* Forces regrading of all site grades - usualy when chanign site setings
* @global object
* @global object
* Forces regrading of all site grades. Used when changing site setings
*/
function grade_force_site_regrading() {
global $CFG, $DB;
@ -994,10 +1000,10 @@ function grade_recover_history_grades($userid, $courseid) {
/**
* Updates all final grades in course.
*
* @param int $courseid
* @param int $userid if specified, try to do a quick regrading of grades of this user only
* @param object $updated_item the item in which
* @return boolean true if ok, array of errors if problems found (item id is used as key)
* @param int $courseid The course ID
* @param int $userid If specified try to do a quick regrading of the grades of this user only
* @param object $updated_item Optional grade item to be marked for regrading
* @return bool true if ok, array of errors if problems found. Grade item id => error message
*/
function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null) {
@ -1109,11 +1115,11 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null)
}
/**
* Refetches data from all course activities
* @param int $courseid the course ID
* @param string $modname limit the grade fetch to a single module type
* Refetches grade data from course activities
*
* @param int $courseid The course ID
* @param string $modname Limit the grade fetch to a single module type. For example 'forum'
* @param int $userid limit the grade fetch to a single user
* @return void
*/
function grade_grab_course_grades($courseid, $modname=null, $userid=0) {
global $CFG, $DB;
@ -1161,11 +1167,9 @@ function grade_grab_course_grades($courseid, $modname=null, $userid=0) {
/**
* Force full update of module grades in central gradebook
*
* @global object
* @global object
* @param object $modinstance object with extra cmidnumber and modname property
* @param int $userid
* @return boolean success
* @param object $modinstance Module object with extra cmidnumber and modname property
* @param int $userid Optional user ID if limiting the update to a single user
* @return bool True if success
*/
function grade_update_mod_grades($modinstance, $userid=0) {
global $CFG, $DB;
@ -1177,8 +1181,8 @@ function grade_update_mod_grades($modinstance, $userid=0) {
}
include_once($fullmod.'/lib.php');
$updategradesfunc = $modinstance->modname.'_update_grades';
$updateitemfunc = $modinstance->modname.'_grade_item_update';
$updategradesfunc = $modinstance->modname.'_update_grades';
if (function_exists($updategradesfunc) and function_exists($updateitemfunc)) {
//new grading supported, force updating of grades
@ -1195,8 +1199,8 @@ function grade_update_mod_grades($modinstance, $userid=0) {
/**
* Remove grade letters for given context
*
* @param context $context
* @param bool $showfeedback
* @param context $context The context
* @param bool $showfeedback If true a success notification will be displayed
*/
function remove_grade_letters($context, $showfeedback) {
global $DB, $OUTPUT;
@ -1210,10 +1214,11 @@ function remove_grade_letters($context, $showfeedback) {
}
/**
* Remove all grade related course data - history is kept
* Remove all grade related course data
* Grade history is kept
*
* @param int $courseid
* @param bool $showfeedback print feedback
* @param int $courseid The course ID
* @param bool $showfeedback If true success notifications will be displayed
*/
function remove_course_grades($courseid, $showfeedback) {
global $DB, $OUTPUT;
@ -1254,11 +1259,11 @@ function remove_course_grades($courseid, $showfeedback) {
}
/**
* Called when course category deleted - cleanup gradebook
* Called when course category is deleted
* Cleans the gradebook of associated data
*
* @global object
* @param int $categoryid course category id
* @param int $newparentid empty means everything deleted, otherwise id of category where content moved
* @param int $categoryid The course category id
* @param int $newparentid If empty everything is deleted. Otherwise the ID of the category where content moved
* @param bool $showfeedback print feedback
*/
function grade_course_category_delete($categoryid, $newparentid, $showfeedback) {
@ -1269,11 +1274,10 @@ function grade_course_category_delete($categoryid, $newparentid, $showfeedback)
}
/**
* Does gradebook cleanup when module uninstalled.
* Does gradebook cleanup when a module is uninstalled
* Deletes all associated grade items
*
* @global object
* @global object
* @param string $modname
* @param string $modname The grade item module name to remove. For example 'forum'
*/
function grade_uninstalled_module($modname) {
global $CFG, $DB;
@ -1292,8 +1296,9 @@ function grade_uninstalled_module($modname) {
}
/**
* Deletes all user data from gradebook.
* @param $userid
* Deletes all of a user's grade data from gradebook
*
* @param int $userid The user whose grade data should be deleted
*/
function grade_user_delete($userid) {
if ($grades = grade_grade::fetch_all(array('userid'=>$userid))) {
@ -1304,8 +1309,10 @@ function grade_user_delete($userid) {
}
/**
* Purge course data when user unenrolled.
* @param $userid
* Purge course data when user unenrolls from a course
*
* @param int $courseid The ID of the course the user has unenrolled from
* @param int $userid The ID of the user unenrolling
*/
function grade_user_unenrol($courseid, $userid) {
if ($items = grade_item::fetch_all(array('courseid'=>$courseid))) {
@ -1320,10 +1327,7 @@ function grade_user_unenrol($courseid, $userid) {
}
/**
* Grading cron job
*
* @global object
* @global object
* Grading cron job. Performs background clean up on the gradebook
*/
function grade_cron() {
global $CFG, $DB;
@ -1375,9 +1379,9 @@ function grade_cron() {
}
/**
* Resel all course grades
* Reset all course grades, refetch from the activities and recalculate
*
* @param int $courseid
* @param int $courseid The course to reset
* @return bool success
*/
function grade_course_reset($courseid) {
@ -1399,10 +1403,10 @@ function grade_course_reset($courseid) {
}
/**
* Convert number to 5 decimalfloat, empty string or null db compatible format
* Convert a number to 5 decimal point float, an empty string or a null db compatible format
* (we need this to decide if db value changed)
*
* @param mixed $number
* @param mixed $number The number to convert
* @return mixed float or null
*/
function grade_floatval($number) {
@ -1415,12 +1419,12 @@ function grade_floatval($number) {
}
/**
* Compare two float numbers safely. Uses 5 decimals php precision. Nulls accepted too.
* Used for skipping of db updates
* Compare two float numbers safely. Uses 5 decimals php precision using {@see grade_floatval()}. Nulls accepted too.
* Used for determining if a database update is required
*
* @param float $f1
* @param float $f2
* @return bool true if different
* @param float $f1 Float one to compare
* @param float $f2 Float two to compare
* @return bool True if the supplied values are different
*/
function grade_floats_different($f1, $f2) {
// note: db rounding for 10,5 is different from php round() function
@ -1428,15 +1432,15 @@ function grade_floats_different($f1, $f2) {
}
/**
* Compare two float numbers safely. Uses 5 decimals php precision.
* Compare two float numbers safely. Uses 5 decimals php precision using {@see grade_floatval()}
*
* Do not use rounding for 10,5 at the database level as the results may be
* different from php round() function.
*
* @since 2.0
* @param float $f1
* @param float $f2
* @return bool true if the values should be considered as the same grades
* @param float $f1 Float one to compare
* @param float $f2 Float two to compare
* @return bool True if the values should be considered as the same grades
*/
function grade_floats_equal($f1, $f2) {
return (grade_floatval($f1) === grade_floatval($f2));

View File

@ -1,4 +1,30 @@
<?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/>.
/**
* Redirect the user to the appropriate submission related page within /mod/assignment
*
* Based on the supplied parameters and the user's capabilities the user will be redirected
* to either their own submission, a particular student's submission or a summary of all submissions
*
* @package mod_assignment
* @category grade
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
@ -29,4 +55,4 @@ if (has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE,
} else {
// user will view his own submission, parameter $userid is ignored
redirect('view.php?id='.$cm->id);
}
}

View File

@ -593,6 +593,8 @@ class assignment_base {
/**
* Update grade item for this submission.
*
* @param stdClass $submission The submission instance
*/
function update_grade($submission) {
assignment_update_grades($this->assignment, $submission->userid);
@ -2433,6 +2435,9 @@ class mod_assignment_grading_form extends moodleform {
return $this->advancegradinginstance;
}
/**
* Add the grades configuration section to the assignment configuration form
*/
function add_grades_section() {
global $CFG;
$mform =& $this->_form;
@ -2853,9 +2858,9 @@ function assignment_cron () {
/**
* Return grade for given user or all users.
*
* @param int $assignmentid id of assignment
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
* @param stdClass $assignment An assignment instance
* @param int $userid Optional user id, 0 means all users
* @return array An array of grades, false if none
*/
function assignment_get_user_grades($assignment, $userid=0) {
global $CFG, $DB;
@ -2880,8 +2885,10 @@ function assignment_get_user_grades($assignment, $userid=0) {
/**
* Update activity grades
*
* @param object $assignment
* @category grade
* @param stdClass $assignment Assignment instance
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone Not used
*/
function assignment_update_grades($assignment, $userid=0, $nullifnone=true) {
global $CFG, $DB;
@ -2936,8 +2943,9 @@ function assignment_upgrade_grades() {
/**
* Create grade item for given assignment
*
* @param object $assignment object with extra cmidnumber
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
* @category grade
* @param stdClass $assignment An assignment instance with extra cmidnumber property
* @param mixed $grades Optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok, error code otherwise
*/
function assignment_grade_item_update($assignment, $grades=NULL) {
@ -2974,6 +2982,7 @@ function assignment_grade_item_update($assignment, $grades=NULL) {
/**
* Delete grade item for given assignment
*
* @category grade
* @param object $assignment object
* @return object assignment
*/
@ -3777,8 +3786,9 @@ function assignment_get_types() {
/**
* Removes all grades from gradebook
* @param int $courseid
* @param string optional type
*
* @param int $courseid The ID of the course to reset
* @param string $type Optional type of assignment to limit the reset to a particular assignment type
*/
function assignment_reset_gradebook($courseid, $type='') {
global $CFG, $DB;

View File

@ -1036,8 +1036,7 @@ function data_get_user_grades($data, $userid=0) {
/**
* Update activity grades
*
* @global object
* @global object
* @category grade
* @param object $data
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone
@ -1097,9 +1096,9 @@ function data_upgrade_grades() {
/**
* Update/create grade item for given data
*
* @global object
* @param object $data object with extra cmidnumber
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
* @category grade
* @param stdClass $data A database instance with extra cmidnumber property
* @param mixed $grades Optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return object grade_item
*/
function data_grade_item_update($data, $grades=NULL) {
@ -1132,7 +1131,7 @@ function data_grade_item_update($data, $grades=NULL) {
/**
* Delete grade item for given data
*
* @global object
* @category grade
* @param object $data object
* @return object grade_item
*/

View File

@ -1479,8 +1479,7 @@ function forum_get_user_grades($forum, $userid = 0) {
/**
* Update activity grades
*
* @global object
* @global object
* @category grade
* @param object $forum
* @param int $userid specific user only, 0 means all
* @param boolean $nullifnone return null if grade does not exist
@ -1539,12 +1538,12 @@ function forum_upgrade_grades() {
/**
* Create/update grade item for given forum
*
* @global object
* @category grade
* @uses GRADE_TYPE_NONE
* @uses GRADE_TYPE_VALUE
* @uses GRADE_TYPE_SCALE
* @param object $forum object with extra cmidnumber
* @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @param stdClass $forum Forum object with extra cmidnumber
* @param mixed $grades Optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok
*/
function forum_grade_item_update($forum, $grades=NULL) {
@ -1579,9 +1578,9 @@ function forum_grade_item_update($forum, $grades=NULL) {
/**
* Delete grade item for given forum
*
* @global object
* @param object $forum object
* @return object grade_item
* @category grade
* @param stdClass $forum Forum object
* @return grade_item
*/
function forum_grade_item_delete($forum) {
global $CFG;

View File

@ -435,10 +435,9 @@ function glossary_cron () {
/**
* Return grade for given user or all users.
*
* @global object
* @param int $glossaryid id of glossary
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
* @param stdClass $glossary A glossary instance
* @param int $userid Optional user id, 0 means all users
* @return array An array of grades, false if none
*/
function glossary_get_user_grades($glossary, $userid=0) {
global $CFG;
@ -583,10 +582,10 @@ function glossary_rating_validate($params) {
/**
* Update activity grades
*
* @global object
* @global object
* @param object $glossary null means all glossaries (with extra cmidnumber property)
* @category grade
* @param stdClass $glossary Null means all glossaries (with extra cmidnumber property)
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone If true and the user has no grade then a grade item with rawgrade == null will be inserted
*/
function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
global $CFG, $DB;
@ -642,9 +641,9 @@ function glossary_upgrade_grades() {
/**
* Create/update grade item for given glossary
*
* @global object
* @param object $glossary object with extra cmidnumber
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
* @category grade
* @param stdClass $glossary object with extra cmidnumber
* @param mixed $grades Optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int, 0 if ok, error code otherwise
*/
function glossary_grade_item_update($glossary, $grades=NULL) {
@ -677,7 +676,7 @@ function glossary_grade_item_update($glossary, $grades=NULL) {
/**
* Delete grade item for given glossary
*
* @global object
* @category grade
* @param object $glossary object
*/
function glossary_grade_item_delete($glossary) {
@ -2443,9 +2442,8 @@ function glossary_reset_course_form_defaults($course) {
/**
* Removes all grades from gradebook
*
* @global object
* @param int $courseid
* @param string optional type
* @param int $courseid The ID of the course to reset
* @param string $type The optional type of glossary. 'main', 'secondary' or ''
*/
function glossary_reset_gradebook($courseid, $type='') {
global $DB;

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,12 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Grade.php
* Redirects the user to either a lesson or to the lesson statistics
*
* @package mod
* @subpackage lesson
* @package mod_lesson
* @category grade
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
/**
@ -44,4 +43,4 @@ if (has_capability('mod/lesson:edit', get_context_instance(CONTEXT_MODULE, $cm->
redirect('report.php?id='.$cm->id);
} else {
redirect('view.php?id='.$cm->id);
}
}

View File

@ -393,8 +393,7 @@ function lesson_get_user_grades($lesson, $userid=0) {
/**
* Update grades in central gradebook
*
* @global stdclass
* @global object
* @category grade
* @param object $lesson
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone
@ -453,7 +452,7 @@ function lesson_upgrade_grades() {
/**
* Create grade item for given lesson
*
* @global stdClass
* @category grade
* @uses GRADE_TYPE_VALUE
* @uses GRADE_TYPE_NONE
* @param object $lesson object with extra cmidnumber
@ -513,7 +512,7 @@ function lesson_grade_item_update($lesson, $grades=NULL) {
/**
* Delete grade item for given lesson
*
* @global stdClass
* @category grade
* @param object $lesson object
* @return object lesson
*/

View File

@ -361,6 +361,7 @@ function lti_get_lti_types() {
/**
* Create grade item for given basiclti
*
* @category grade
* @param object $basiclti object with extra cmidnumber
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok, error code otherwise
@ -395,6 +396,7 @@ function lti_grade_item_update($basiclti, $grades=null) {
/**
* Delete grade item for given basiclti
*
* @category grade
* @param object $basiclti object
* @return object basiclti
*/

View File

@ -18,10 +18,10 @@
* This page is the entry page into the quiz UI. Displays information about the
* quiz to students and teachers, and lets students see their previous attempts.
*
* @package mod
* @subpackage quiz
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package mod_quiz
* @category grade
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -537,8 +537,10 @@ function quiz_format_question_grade($quiz, $grade) {
/**
* Update grades in central gradebook
*
* @category grade
* @param object $quiz the quiz settings.
* @param int $userid specific user only, 0 means all users.
* @param bool $nullifnone If a single user is specified and $nullifnone is true a grade item with a null rawgrade will be inserted
*/
function quiz_update_grades($quiz, $userid = 0, $nullifnone = true) {
global $CFG, $DB;
@ -590,8 +592,9 @@ function quiz_upgrade_grades() {
}
/**
* Create grade item for given quiz
* Create or update the grade item for given quiz
*
* @category grade
* @param object $quiz object with extra cmidnumber
* @param mixed $grades optional array/object of grade(s); 'reset' means reset grades in gradebook
* @return int 0 if ok, error code otherwise
@ -680,6 +683,7 @@ function quiz_grade_item_update($quiz, $grades = null) {
/**
* Delete grade item for given quiz
*
* @category grade
* @param object $quiz object
* @return object quiz
*/

View File

@ -14,6 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Redirect the user based on their capabilities to either a scorm activity or to scorm reports
*
* @package mod_scorm
* @category grade
* @copyright 2010 onwards Dan Marsden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once("../../config.php");
$id = required_param('id', PARAM_INT); // Course module ID

View File

@ -560,8 +560,7 @@ function scorm_get_user_grades($scorm, $userid=0) {
/**
* Update grades in central gradebook
*
* @global stdClass
* @global object
* @category grade
* @param object $scorm
* @param int $userid specific user only, 0 mean all
* @param bool $nullifnone
@ -617,8 +616,7 @@ function scorm_upgrade_grades() {
/**
* Update/create grade item for given scorm
*
* @global stdClass
* @global object
* @category grade
* @uses GRADE_TYPE_VALUE
* @uses GRADE_TYPE_NONE
* @param object $scorm object with extra cmidnumber
@ -662,7 +660,7 @@ function scorm_grade_item_update($scorm, $grades=null) {
/**
* Delete grade item for given scorm
*
* @global stdClass
* @category grade
* @param object $scorm object
* @return object grade_item
*/

View File

@ -1054,6 +1054,7 @@ function workshop_grade_item_update(stdclass $workshop, $submissiongrades=null,
*
* Needed by grade_update_mod_grades() in lib/gradelib.php
*
* @category grade
* @param stdClass $workshop instance object with extra cmidnumber and modname property
* @param int $userid update grade of specific user only, 0 means all participants
* @return void