2007-05-03 08:51:48 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.com //
|
|
|
|
// //
|
|
|
|
// Copyright (C) 2001-2003 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 //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
require_once('grade_object.php');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing a grade outcome. It is responsible for handling its DB representation,
|
|
|
|
* modifying and returning its metadata.
|
|
|
|
*/
|
|
|
|
class grade_outcome extends grade_object {
|
|
|
|
/**
|
|
|
|
* DB Table (used by grade_object).
|
|
|
|
* @var string $table
|
|
|
|
*/
|
|
|
|
var $table = 'grade_outcomes';
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-03 08:51:48 +00:00
|
|
|
/**
|
|
|
|
* Array of class variables that are not part of the DB table fields
|
|
|
|
* @var array $nonfields
|
|
|
|
*/
|
2007-07-06 12:49:28 +00:00
|
|
|
var $nonfields = array('table', 'nonfields', 'required_fields', 'scale');
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-03 08:51:48 +00:00
|
|
|
/**
|
|
|
|
* The course this outcome belongs to.
|
|
|
|
* @var int $courseid
|
|
|
|
*/
|
|
|
|
var $courseid;
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-03 08:51:48 +00:00
|
|
|
/**
|
|
|
|
* The shortname of the outcome.
|
|
|
|
* @var string $shortname
|
|
|
|
*/
|
|
|
|
var $shortname;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The fullname of the outcome.
|
|
|
|
* @var string $fullname
|
|
|
|
*/
|
|
|
|
var $fullname;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A full grade_scale object referenced by $this->scaleid.
|
|
|
|
* @var object $scale
|
|
|
|
*/
|
|
|
|
var $scale;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The id of the scale referenced by this outcome.
|
|
|
|
* @var int $scaleid
|
|
|
|
*/
|
|
|
|
var $scaleid;
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-03 08:51:48 +00:00
|
|
|
/**
|
|
|
|
* The userid of the person who last modified this outcome.
|
|
|
|
* @var int $usermodified
|
|
|
|
*/
|
|
|
|
var $usermodified;
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-03 08:51:48 +00:00
|
|
|
/**
|
2007-06-24 22:26:33 +00:00
|
|
|
* Finds and returns a grade_outcome instance based on params.
|
|
|
|
* @static
|
|
|
|
*
|
|
|
|
* @param array $params associative arrays varname=>value
|
|
|
|
* @return object grade_outcome instance or false if none found.
|
2007-05-03 08:51:48 +00:00
|
|
|
*/
|
2007-06-24 22:26:33 +00:00
|
|
|
function fetch($params) {
|
|
|
|
if ($outcome = grade_object::fetch_helper('grade_outcomes', 'grade_outcome', $params)) {
|
|
|
|
if (!empty($outcome->scaleid)) {
|
|
|
|
$outcome->scale = new grade_scale(array('id'=>$outcome->scaleid));
|
|
|
|
$outcome->scale->load_items();
|
|
|
|
}
|
|
|
|
return $outcome;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return false;
|
2007-05-03 08:51:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-23 16:51:09 +00:00
|
|
|
|
2007-05-04 07:40:51 +00:00
|
|
|
/**
|
2007-06-24 22:26:33 +00:00
|
|
|
* Finds and returns all grade_outcome instances based on params.
|
2007-06-23 16:33:17 +00:00
|
|
|
* @static
|
2007-05-04 07:40:51 +00:00
|
|
|
*
|
2007-06-24 22:26:33 +00:00
|
|
|
* @param array $params associative arrays varname=>value
|
|
|
|
* @return array array of grade_outcome insatnces or false if none found.
|
2007-05-04 07:40:51 +00:00
|
|
|
*/
|
2007-06-24 22:26:33 +00:00
|
|
|
function fetch_all($params) {
|
|
|
|
if ($outcomes = grade_object::fetch_all_helper('grade_outcomes', 'grade_outcome', $params)) {
|
|
|
|
foreach ($outcomes as $key=>$value) {
|
|
|
|
if (!empty($outcomes[$key]->scaleid)) {
|
|
|
|
$outcomes[$key]->scale = new grade_scale(array('id'=>$outcomes[$key]->scaleid));
|
|
|
|
$outcomes[$key]->scale->load_items();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $outcomes;
|
2007-06-23 16:33:17 +00:00
|
|
|
|
2007-05-04 07:40:51 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2007-05-24 08:50:01 +00:00
|
|
|
|
|
|
|
/**
|
2007-06-23 16:51:09 +00:00
|
|
|
* Returns the most descriptive field for this object. This is a standard method used
|
2007-05-24 08:50:01 +00:00
|
|
|
* when we do not know the exact type of an object.
|
|
|
|
* @return string name
|
|
|
|
*/
|
|
|
|
function get_name() {
|
|
|
|
return $this->shortname;
|
2007-06-23 16:51:09 +00:00
|
|
|
}
|
2007-05-03 08:51:48 +00:00
|
|
|
}
|
|
|
|
?>
|