Skip to content

Commit

Permalink
MDL-9506 Added grade_grades_text object to grade_grades_final and raw…
Browse files Browse the repository at this point in the history
… objects.
  • Loading branch information
nicolasconnault committed May 9, 2007
1 parent 95ec7c3 commit 70f9a14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
11 changes: 8 additions & 3 deletions lib/grade/grade_grades_final.php
Expand Up @@ -96,9 +96,14 @@ function grade_grades_final($params=NULL, $fetch=true) {
}

/**
*
function get_text() {
* Loads the grade_grades_text object linked to this grade (through the intersection of itemid and userid), and
* saves it as a class variable for this final object.
* @return object
*/
function load_text() {
if (empty($this->grade_grades_text)) {
return $this->grade_grades_text = grade_grades_text::fetch('itemid', $this->itemid, 'userid', $this->userid);
}
}

/**
Expand Down
16 changes: 8 additions & 8 deletions lib/grade/grade_grades_raw.php
Expand Up @@ -91,9 +91,9 @@ class grade_grades_raw extends grade_object {
* Additional textual information about this grade. It can be automatically generated
* from the module or entered manually by the teacher. This is kept in its own table
* for efficiency reasons, so it is encapsulated in its own object, and included in this raw grade object.
* @var object $text
* @var object $grade_grades_text
*/
var $text;
var $grade_grades_text;

/**
* Constructor. Extends the basic functionality defined in grade_object.
Expand All @@ -118,14 +118,14 @@ function load_scale() {
}

/**
* Loads the grade_grades_text object linked to this raw grade, into the $this->text variable, if
* such record exists. Otherwise returns null.
* Loads the grade_grades_text object linked to this grade (through the intersection of itemid and userid), and
* saves it as a class variable for this final object.
* @return object
*/
function load_text() {
if (!empty($this->id)) {
$this->text = grade_grades_text::fetch('gradesid', $this->id);
}
return $this->text;
if (empty($this->grade_grades_text)) {
return $this->grade_grades_text = grade_grades_text::fetch('itemid', $this->itemid, 'userid', $this->userid);
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion lib/grade/grade_grades_text.php
Expand Up @@ -94,7 +94,6 @@ class grade_grades_text extends grade_object {
function fetch($field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields="*") {
if ($grade_text = get_record('grade_grades_text', $field1, $value1, $field2, $value2, $field3, $value3, $fields)) {
if (isset($this) && get_class($this) == 'grade_grades_text') {
print_object($this);
foreach ($grade_text as $param => $value) {
$this->$param = $value;
}
Expand Down

0 comments on commit 70f9a14

Please sign in to comment.