]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9506 Replaces grade_grades_text.gradesid by composite key userid and itemid.
authornicolasconnault <nicolasconnault>
Wed, 9 May 2007 09:01:56 +0000 (09:01 +0000)
committernicolasconnault <nicolasconnault>
Wed, 9 May 2007 09:01:56 +0000 (09:01 +0000)
lib/grade/grade_grades_raw.php
lib/grade/grade_grades_text.php
lib/simpletest/grade/simpletest/testgradetext.php

index 3b8754c5607b547394b0038ddb43624a25d483df..4de893e3d24773336afc04d7b33048c08a86c8ff 100644 (file)
@@ -171,7 +171,8 @@ class grade_grades_raw extends grade_object {
     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;
@@ -215,7 +216,7 @@ class grade_grades_raw extends grade_object {
        
         // 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();
             }
index 9a28bd5bc156d144550586def74235697b2bdf9e..c28941b2c2a06eb0b403d545bce5a1e20936babe 100644 (file)
@@ -43,10 +43,16 @@ class grade_grades_text extends grade_object {
     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
index e4b0d02f64c0d8c8e3cdf945ec0bfc996c3a505c..e09e30c097c884db0d52742bb5b5cae3df2a7ad7 100755 (executable)
@@ -39,14 +39,16 @@ class grade_text_test extends gradelib_test {
     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);
@@ -57,7 +59,8 @@ class grade_text_test extends gradelib_test {
         $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..';