function annotate($information, $informationformat=FORMAT_PLAIN, $feedback=NULL, $feedbackformat=FORMAT_PLAIN) {
$grade_text = new grade_grades_text();
- $grade_text->gradesid = $this->id;
+ $grade_text->itemid = $this->itemid;
+ $grade_text->userid = $this->userid;
$grade_text->information = $information;
$grade_text->informationformat = $informationformat;
$grade_text->feedback = $feedback;
// Update grade_grades_text if changed
if (!empty($this->text)) {
- $grade_text = grade_grades_text::fetch('gradesid', $this->id);
+ $grade_text = grade_grades_text::fetch('userid', $this->userid, 'itemid', $this->itemid);
if ($this->text != $grade_text && $this->text->id == $grade_text->id) {
$result = $result & $this->text->update();
}
var $nonfields = array('table', 'nonfields');
/**
- * A reference to the grade_grades_raw object this text belongs to.
- * @var int $gradesid
+ * The grade_item.id this text refers to.
+ * @var int $itemid
*/
- var $gradesid;
+ var $itemid;
+
+ /**
+ * The user.id this text refers to.
+ * @var int $userid
+ */
+ var $userid;
/**
* Further information like forum rating distribution 4/5/7/0/1
function test_grade_grades_text_construct() {
$params = new stdClass();
- $params->gradesid = $this->grade_grades_raw[0]->id;
+ $params->itemid = $this->grade_grades_raw[0]->itemid;
+ $params->userid = $this->grade_grades_raw[0]->userid;
$params->information = 'Thumbs down';
$params->informationformat = FORMAT_PLAIN;
$params->feedback = 'Good, but not good enough..';
$params->feedbackformat = FORMAT_PLAIN;
$grade_grades_text = new grade_grades_text($params, false);
- $this->assertEqual($params->gradesid, $grade_grades_text->gradesid);
+ $this->assertEqual($params->userid, $grade_grades_text->userid);
+ $this->assertEqual($params->itemid, $grade_grades_text->itemid);
$this->assertEqual($params->information, $grade_grades_text->information);
$this->assertEqual($params->informationformat, $grade_grades_text->informationformat);
$this->assertEqual($params->feedback, $grade_grades_text->feedback);
$grade_grades_text = new grade_grades_text();
$this->assertTrue(method_exists($grade_grades_text, 'insert'));
- $grade_grades_text->gradesid = $this->grade_grades_raw[0]->id;
+ $grade_grades_text->itemid = $this->grade_grades_raw[0]->itemid;
+ $grade_grades_text->userid = $this->grade_grades_raw[0]->userid;
$grade_grades_text->information = 'Thumbs down';
$grade_grades_text->informationformat = FORMAT_PLAIN;
$grade_grades_text->feedback = 'Good, but not good enough..';