]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11363 merged tables grade_grades with grade_grades_text - it is now possible...
authorskodak <skodak>
Sat, 22 Sep 2007 11:39:59 +0000 (11:39 +0000)
committerskodak <skodak>
Sat, 22 Sep 2007 11:39:59 +0000 (11:39 +0000)
finally fixed formula validation in calculation edit form

20 files changed:
backup/backuplib.php
backup/restorelib.php
grade/edit/tree/grade.php
grade/lib.php
grade/report/grader/lib.php
grade/report/user/lib.php
lib/db/install.xml
lib/db/upgrade.php
lib/grade/grade_category.php
lib/grade/grade_grade.php
lib/grade/grade_grade_text.php [deleted file]
lib/grade/grade_item.php
lib/grade/grade_object.php
lib/grade/grade_outcome.php
lib/grade/grade_scale.php
lib/grade/simpletest/testgradegrades.php
lib/grade/simpletest/testgradegradestext.php [deleted file]
lib/gradelib.php
lib/simpletest/fixtures/gradetest.php
version.php

index a3d89ec8803bf306d0b2d8c9cf51f486818c8c0c..52fe33e544070875322b4caad0ce8a81f3d9205a 100644 (file)
         if ($preferences->backup_gradebook_history) {
             $status = backup_gradebook_categories_history_info($bf, $preferences);
             $status = backup_gradebook_grades_history_info($bf, $preferences);
-            $status = backup_gradebook_grades_text_history_info($bf, $preferences);
             $status = backup_gradebook_items_history_info($bf, $preferences);
             $status = backup_gradebook_outcomes_history($bf, $preferences);
         }
 
                 // do not restore if this grade_item is a mod, and
                 if ($grade_item->itemtype == 'mod') {
-                    // this still needs to be included, though grades and grades_text can be ignored
+                    // this still needs to be included, though grades can be ignored
                 } else if ($grade_item->itemtype == 'category') {
                     // if not all grade items are being backed up
                     // we ignore this type of grade_item and grades associated
                     // but userdata is not selected
                 } else {
                     $status = backup_gradebook_grades_info($bf,$preferences,$grade_item->id);
-                    $status = backup_gradebook_grades_text_info($bf,$preferences,$grade_item->id);
                 }
                 //End grade_item
                 fwrite ($bf,end_tag("GRADE_ITEM",4,true));
                 fwrite ($bf,full_tag("EXPORTED",7,false,$grade->exported));
                 fwrite ($bf,full_tag("OVERRIDDEN",7,false,$grade->overridden));
                 fwrite ($bf,full_tag("EXCLUDED",7,false,$grade->excluded));
+                fwrite ($bf,full_tag("FEEDBACK",7,false,$grade->feedback));
+                fwrite ($bf,full_tag("FEEDBACKFORMAT",7,false,$grade->feedbackformat));
+                fwrite ($bf,full_tag("INFORMATION",7,false,$grade->information));
+                fwrite ($bf,full_tag("INFORMATIONFORMAT",7,false,$grade->informationformat));
                 fwrite ($bf,end_tag("GRADE",6,true));
             }
             $status = fwrite ($bf,end_tag("GRADE_GRADES",5,true));
         return $status;
     }
 
-    function backup_gradebook_grades_text_info($bf, $preferences, $itemid) {
-
-        global $CFG;
-
-        $status = true;
-
-        // find all grade texts belonging to this item
-        if ($grades = get_records('grade_grades', 'itemid', $itemid)) {
-            fwrite ($bf,start_tag("GRADE_GRADES_TEXT",5,true));
-            foreach ($grades as $grade) {
-                if ($texts = get_records('grade_grades_text', 'gradeid', $grade->id)) {
-                    foreach ($texts as $text) {
-                        fwrite ($bf,start_tag("GRADE_TEXT",6,true));
-                        fwrite ($bf,full_tag("ID",7,false,$text->id));
-                        fwrite ($bf,full_tag("GRADEID",7,false,$text->gradeid));
-                        fwrite ($bf,full_tag("INFORMATION",7,false,$text->information));
-                        fwrite ($bf,full_tag("INFORMATIONFORMAT",7,false,$text->informationformat));
-                        fwrite ($bf,full_tag("FEEDBACK",7,false,$text->feedback));
-                        fwrite ($bf,full_tag("FEEDBACKFORMAT",7,false,$text->feedbackformat));
-                        fwrite ($bf,end_tag("GRADE_TEXT",6,true));
-                    }
-                }
-            }
-            $status = fwrite ($bf,end_tag("GRADE_GRADES_TEXT",5,true));
-        }
-        return $status;
-    }
-
     function backup_gradebook_categories_history_info($bf, $preferences) {
 
         global $CFG;
                 fwrite ($bf,full_tag("EXPORTED",7,false,$ch->exported));
                 fwrite ($bf,full_tag("OVERRIDDEN",7,false,$ch->overridden));
                 fwrite ($bf,full_tag("EXCLUDED",7,false,$ch->excluded));
-                fwrite ($bf,end_tag("GRADE_GRADES_HISTORY",6,true));
-            }
-            $status = fwrite ($bf,end_tag("GRADE_GRADES_HISTORIES",5,true));
-        }
-        return $status;
-    }
-
-    function backup_gradebook_grades_text_history_info($bf, $preferences) {
-
-        global $CFG;
-        $status = true;
-
-        // find all grade categories history
-        if ($chs = get_records_sql("SELECT ggth.* FROM {$CFG->prefix}grade_grades_text_history ggth,
-                                                  {$CFG->prefix}grade_grades gg,
-                                                  {$CFG->prefix}grade_items gi
-                                             WHERE gi.courseid = $preferences->backup_course
-                                             AND ggth.gradeid = gg.id
-                                             AND gg.itemid = gi.id")) {
-
-            fwrite ($bf,start_tag("GRADE_TEXT_HISTORIES",5,true));
-            foreach ($chs as $ch) {
-                fwrite ($bf,start_tag("GRADE_TEXT_HISTORY",6,true));
-                fwrite ($bf,full_tag("ID",7,false,$ch->id));
-                fwrite ($bf,full_tag("OLDID",7,false,$ch->oldid));
-                fwrite ($bf,full_tag("ACTION",7,false,$ch->action));
-                fwrite ($bf,full_tag("SOURCE",7,false,$ch->source));
-                fwrite ($bf,full_tag("TIMEMODIFIED",7,false,$ch->timemodified));
-                fwrite ($bf,full_tag("LOGGEDUSER",7,false,$ch->loggeduser));
-                fwrite ($bf,full_tag("GRADEID",7,false,$ch->gradeid));
-                fwrite ($bf,full_tag("INFORMATION",7,false,$ch->information));
-                fwrite ($bf,full_tag("INFORMATIONFORMAT",7,false,$ch->informationformat));
                 fwrite ($bf,full_tag("FEEDBACK",7,false,$ch->feedback));
                 fwrite ($bf,full_tag("FEEDBACKFORMAT",7,false,$ch->feedbackformat));
-                fwrite ($bf,full_tag("USERMODIFIED",7,false,$ch->usermodified));
-                fwrite ($bf,end_tag("GRADE_TEXT_HISTORY",6,true));
+                fwrite ($bf,full_tag("INFORMATION",7,false,$ch->information));
+                fwrite ($bf,full_tag("INFORMATIONFORMAT",7,false,$ch->informationformat));
+                fwrite ($bf,end_tag("GRADE_GRADES_HISTORY",6,true));
             }
-            $status = fwrite ($bf,end_tag("GRADE_TEXT_HISTORIES",5,true));
+            $status = fwrite ($bf,end_tag("GRADE_GRADES_HISTORIES",5,true));
         }
         return $status;
     }
index 0bd2c9c39c6221841042ab780e62853f022ac032..140738eed4ea68ea7bdd673ff81d7f836b4a3c03 100644 (file)
         $outcomescoursescount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_outcomes_courses');
         $gchcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_categories_history');
         $gghcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_grades_history');
-        $ggthcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_grades_text_history');
         $gihcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_items_history');
         $gohcount = count_records ('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_outcomes_history');
 
             }
         }
 
-        // Process grade items (grade_raw, grade_final, and grade_text)
+        // Process grade items (grade_grade)
         if ($itemscount && $continue) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradeitems','grades').'</li>';
                                 backup_putid($restore->backup_unique_code,'grade_items', backup_todb($info['GRADE_ITEM']['#']['ID']['0']['#']), $itemid);
                             }
                             
-                            // no need to restore grades/grades_text if user data is not selected
+                            // no need to restore grades if user data is not selected
                             if ($dbrec->itemtype == 'mod' && !restore_userdata_selected($restore,  $dbrec->itemmodule, $iteminstance)) {
                                 // module instance not selected when restored using granular
                                 // skip this item
                                 continue;
                             }
                             
-                            /// now, restore grade_grades, grade_text
+                            /// now, restore grade_grades
                             if (!empty($info['GRADE_ITEM']['#']['GRADE_GRADES']['0']['#']) && ($grades = $info['GRADE_ITEM']['#']['GRADE_GRADES']['0']['#']['GRADE'])) {
                                 //Iterate over items
                                 for($i = 0; $i < sizeof($grades); $i++) {
                                     $grade->exported = backup_todb($ite_info['#']['EXPORTED']['0']['#']);
                                     $grade->overridden = backup_todb($ite_info['#']['OVERRIDDEN']['0']['#']);
                                     $grade->excluded = backup_todb($ite_info['#']['EXCLUDED']['0']['#']);
+                                    $grade->feedback = backup_todb($ite_info['#']['FEEDBACK']['0']['#']);
+                                    $grade->feedbackformat = backup_todb($ite_info['#']['FEEDBACKFORMAT']['0']['#']);
+                                    $grade->information = backup_todb($ite_info['#']['INFORMATION']['0']['#']);
+                                    $grade->informationformat = backup_todb($ite_info['#']['INFORMATIONFORMAT']['0']['#']);
 
                                     $newid = insert_record('grade_grades', $grade);
 
                                     }
                                 }
                             }
-
-
-
-                            /// processing grade_grades_text
-                            if (!empty($info['GRADE_ITEM']['#']['GRADE_GRADES_TEXT']['0']['#']) && ($texts = $info['GRADE_ITEM']['#']['GRADE_GRADES_TEXT']['0']['#']['GRADE_TEXT'])) {
-                                //Iterate over items
-                                for($i = 0; $i < sizeof($texts); $i++) {
-                                    $ite_info = $texts[$i];
-                                    //traverse_xmlize($ite_info);                                                                 //Debug
-                                    //print_object ($GLOBALS['traverse_array']);                                                  //Debug
-                                    //$GLOBALS['traverse_array']="";                                                              //Debug
-                                    $grade = backup_getid($restore->backup_unique_code,"grade_grades", backup_todb($ite_info['#']['GRADEID']['0']['#']));
-
-                                    $text = new object();
-                                    $text->gradeid = $grade->new_id;
-                                    $text->information = backup_todb($ite_info['#']['INFORMATION']['0']['#']);
-                                    $text->informationformat = backup_todb($ite_info['#']['INFORMATIONFORMAT']['0']['#']);
-                                    $text->feedback = backup_todb($ite_info['#']['FEEDBACK']['0']['#']);
-                                    $text->feedbackformat = backup_todb($ite_info['#']['FEEDBACKFORMAT']['0']['#']);
-
-                                    $newid = insert_record('grade_grades_text', $text);
-                                    if ($newid) {
-                                        backup_putid($restore->backup_unique_code,'grade_grades_text', backup_todb($ite_info['#']['ID']['0']['#']), $newid);
-                                    }
-                                    $counter++;
-                                    if ($counter % 20 == 0) {
-                                        if (!defined('RESTORE_SILENTLY')) {
-                                            echo ".";
-                                            if ($counter % 400 == 0) {
-                                                echo "<br />";
-                                            }
-                                        }
-                                        backup_flush(300);
-                                    }
-                                }
-                            }
                         }
                     $counteritems++; // increment item count
                     }
                             $dbrec->exported = backup_todb($info['GRADE_GRADES_HISTORY']['#']['EXPORTED']['0']['#']);
                             $dbrec->overridden = backup_todb($info['GRADE_GRADES_HISTORY']['#']['OVERRIDDEN']['0']['#']);
                             $dbrec->excluded = backup_todb($info['GRADE_GRADES_HISTORY']['#']['EXCLUDED']['0']['#']);
-
-                            insert_record('grade_grades_history', $dbrec);
-                            unset($dbrec);
-
-                        }
-                        //Increment counters
-                        $counter++;
-                        //Do some output
-                        if ($counter % 1 == 0) {
-                            if (!defined('RESTORE_SILENTLY')) {
-                                echo ".";
-                                if ($counter % 20 == 0) {
-                                    echo "<br />";
-                                }
-                            }
-                            backup_flush(300);
-                        }
-                    }
-                }
-            }
-        }
-
-        // process histories
-
-        if ($ggthcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
-            if (!defined('RESTORE_SILENTLY')) {
-                echo '<li>'.get_string('gradegradestexthistory','grades').'</li>';
-            }
-            $counter = 0;
-            while ($counter < $ggthcount) {
-                //Fetch recordset_size records in each iteration
-                $recs = get_records_select("backup_ids","table_name = 'grade_grades_text_history' AND backup_code = '$restore->backup_unique_code'",
-                                            "old_id",
-                                            "old_id",
-                                            $counter,
-                                            $recordset_size);
-
-                if ($recs) {
-                    foreach ($recs as $rec) {
-                        //Get the full record from backup_ids
-                        $data = backup_getid($restore->backup_unique_code,'grade_grades_text_history',$rec->old_id);
-                        if ($data) {
-                            //Now get completed xmlized object
-                            $info = $data->info;
-                            //traverse_xmlize($info);                            //Debug
-                            //print_object ($GLOBALS['traverse_array']);         //Debug
-                            //$GLOBALS['traverse_array']="";                     //Debug
-
-                            $oldobj = backup_getid($restore->backup_unique_code,"grade_grades_text", backup_todb($info['GRADE_TEXT_HISTORY']['#']['OLDID']['0']['#']));
-                            if (empty($oldobj->new_id)) {
-                                // if the old object is not being restored, can't restoring its history
-                                $counter++;
-                                continue;
-                            }
-                            $dbrec->oldid = $oldobj->new_id;
-                            $dbrec->action = backup_todb($info['GRADE_TEXT_HISTORY']['#']['ACTION']['0']['#']);
-                            $dbrec->source = backup_todb($info['GRADE_TEXT_HISTORY']['#']['SOURCE']['0']['#']);
-                            $dbrec->timemodified = backup_todb($info['GRADE_TEXT_HISTORY']['#']['TIMEMODIFIED']['0']['#']);
-                            if ($oldobj = backup_getid($restore->backup_unique_code,"user", backup_todb($info['GRADE_TEXT_HISTORY']['#']['LOGGEDUSER']['0']['#']))) {
-                                $dbrec->loggeduser = $oldobj->new_id;
-                            }
-                            $oldobj = backup_getid($restore->backup_unique_code,"grade_grades", backup_todb($info['GRADE_TEXT_HISTORY']['#']['GRADEID']['0']['#']));
-                            $dbrec->gradeid = $oldobj->new_id;
-                            if (empty($dbrec->gradeid)) {
-                                $counter++;
-                                continue; // grade not being restore, possibly because grade item is not restored
-                            }
-
-                            $dbrec->information = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATION']['0']['#']);
-                            $dbrec->informationformat = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATIONFORMAT']['0']['#']);
                             $dbrec->feedback = backup_todb($info['GRADE_TEXT_HISTORY']['#']['FEEDBACK']['0']['#']);
                             $dbrec->feedbackformat = backup_todb($info['GRADE_TEXT_HISTORY']['#']['FEEDBACKFORMAT']['0']['#']);
-                            if ($oldobj = backup_getid($restore->backup_unique_code,"user", backup_todb($info['GRADE_TEXT_HISTORY']['#']['USERMODIFIED']['0']['#']))) {
-                                $dbrec->usermodified = $oldobj->new_id;
-                            }
+                            $dbrec->information = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATION']['0']['#']);
+                            $dbrec->informationformat = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATIONFORMAT']['0']['#']);
 
-                            insert_record('grade_grades_text_history', $dbrec);
+                            insert_record('grade_grades_history', $dbrec);
                             unset($dbrec);
 
                         }
         }
 
         // process histories
+
         if ($gihcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradeitemshistory','grades').'</li>';
                     unset($this->temp);
                 }
 
-                if (($this->level == 5) and ($tagName == "GRADE_TEXT_HISTORY")) {
-                    //Prepend XML standard header to info gathered
-                    $xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".$this->temp;
-                    //Call to xmlize for this portion of xml data (one PREFERENCE)
-                    //echo "-XMLIZE: ".strftime ("%X",time()),"-";                                    //Debug
-                    $data = xmlize($xml_data,0);
-                    //echo strftime ("%X",time())."<p>";                                              //Debug
-                    //traverse_xmlize($data);                                                         //Debug
-                    //print_object ($GLOBALS['traverse_array']);                                      //Debug
-                    //$GLOBALS['traverse_array']="";                                                  //Debug
-                    //Now, save data to db. We'll use it later
-                    //Get id and status from data
-                    $id = $data["GRADE_TEXT_HISTORY"]["#"]["ID"]["0"]["#"];
-                    $this->counter++;
-                    //Save to db
-                    $status = backup_putid($this->preferences->backup_unique_code, 'grade_grades_text_history', $id,
-                                           null,$data);
-                    //Create returning info
-                    $this->info = $this->counter;
-                    //Reset temp
-
-                    unset($this->temp);
-                }
-
                 if (($this->level == 5) and ($tagName == "GRADE_ITEM_HISTORY")) {
                     //Prepend XML standard header to info gathered
                     $xml_data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".$this->temp;
index d7c2991df828d8e52c30631ce25183d178400a20..0f7dd0258621083f74ca54fb35afa91eed593351 100644 (file)
@@ -70,19 +70,17 @@ if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('
 $mform = new edit_grade_form(null, array('grade_item'=>$grade_item, 'gpr'=>$gpr));
 
 if ($grade = get_record('grade_grades', 'itemid', $grade_item->id, 'userid', $userid)) {
-    if ($grade_text = get_record('grade_grades_text', 'gradeid', $grade->id)) {
-        // always clean existing feedback - grading should not have XSS risk
-        if (can_use_html_editor()) {
-            $options = new object();
-            $options->smiley  = false;
-            $options->filter  = false;
-            $options->noclean = false;
-            $grade->feedback       = format_text($grade_text->feedback, $grade_text->feedbackformat, $options);
-            $grade->feedbackformat = FORMAT_HTML;
-        } else {
-            $grade->feedback       = clean_text($grade_text->feedback, $grade_text->feedbackformat);
-            $grade->feedbackformat = $grade_text->feedbackformat;
-        }
+
+    // always clean existing feedback - grading should not have XSS risk
+    if (can_use_html_editor()) {
+        $options = new object();
+        $options->smiley  = false;
+        $options->filter  = false;
+        $options->noclean = false;
+        $grade->feedback       = format_text($grade->feedback, $grade->feedbackformat, $options);
+        $grade->feedbackformat = FORMAT_HTML;
+    } else {
+        $grade->feedback       = clean_text($grade->feedback, $grade->feedbackformat);
     }
 
     $grade->locked      = $grade->locked     > 0 ? 1:0;
@@ -130,7 +128,6 @@ if ($mform->is_cancelled()) {
 // form processing
 } else if ($data = $mform->get_data(false)) {
     $old_grade_grade = new grade_grade(array('userid'=>$data->userid, 'itemid'=>$grade_item->id), true); //might not exist yet
-    $old_grade_text = new grade_grade_text(array('gradeid' => $old_grade_grade->id), true);
 
     // fix no grade for scales
     if (!isset($data->finalgrade) or $data->finalgrade == $data->oldgrade) {
@@ -144,8 +141,8 @@ if ($mform->is_cancelled()) {
     }
 
     if (!isset($data->feedback)) {
-        $data->feedback       = $old_grade_text->feedback;
-        $data->feedbackformat = $old_grade_text->feedbackformat;
+        $data->feedback       = $old_grade_grade->feedback;
+        $data->feedbackformat = $old_grade_grade->feedbackformat;
     }
     // update final grade or feedback
     $grade_item->update_final_grade($data->userid, $data->finalgrade, NULL, 'editgrade', $data->feedback, $data->feedbackformat);
index 608aaf2e1d05c49e0da699dbb5712f93aaf5d9aa..d12da72936cefcbba02ab17b4a95744a7723939c 100644 (file)
@@ -75,9 +75,8 @@ class graded_users_iterator {
             $itemids = array_keys($this->grade_items);
             $itemids = implode(',', $itemids);
 
-            $grades_sql = "SELECT g.*, gt.feedback, gt.feedbackformat
+            $grades_sql = "SELECT g.*
                              FROM {$CFG->prefix}grade_grades g
-                                  LEFT JOIN {$CFG->prefix}grade_grades_text gt ON gt.gradeid = g.id
                                   INNER JOIN {$CFG->prefix}user u ON g.userid = u.id
                                   INNER JOIN {$CFG->prefix}role_assignments ra ON u.id = ra.userid
                                   $groupsql
index bee29f9153ffdbc3af8d44b615c96c253ce157a1..15775a7ebe4b470375b366c07bbc1889925e743c 100644 (file)
@@ -312,10 +312,9 @@ class grade_report_grader extends grade_report {
         global $CFG;
 
         // please note that we must fetch all grade_grades fields if we want to contruct grade_grade object from it!
-        $sql = "SELECT g.*, gt.feedback, gt.feedbackformat, gi.grademin, gi.grademax
+        $sql = "SELECT g.*, gi.grademin, gi.grademax
                   FROM {$CFG->prefix}grade_items gi,
                        {$CFG->prefix}grade_grades g
-                       LEFT JOIN {$CFG->prefix}grade_grades_text gt ON g.id = gt.gradeid
                  WHERE g.itemid = gi.id AND gi.courseid = $this->courseid $this->userselect";
 
         if ($grades = get_records_sql($sql)) {
index a1485bb1d3e12d6ed4a97c8ba89925be26483b85..384d6be50ab03a7e74e302af362a84952bc45460 100644 (file)
@@ -115,7 +115,6 @@ class grade_report_user extends grade_report {
                 $data = array();
 
                 $grade_grade = new grade_grade(array('itemid'=>$grade_item->id, 'userid'=>$this->user->id));
-                $grade_text = $grade_grade->load_text();
 
                 // TODO: indicate items that "needsupdate" - missing final calculation
 
@@ -215,8 +214,8 @@ class grade_report_user extends grade_report {
                 }
 
                 /// prints notes
-                if (!empty($grade_text->feedback)) {
-                    $data[] = $grade_text->feedback;
+                if (!empty($grade_grade->feedback)) {
+                    $data[] = format_text($grade_grade->feedback, $grade_grade->feedbackformat);
                 } else {
                     $data[] = '&nbsp;';
                 }
index 20c726f40ff93186f37afe2a3a2d8ea5d4e3e0c2..3b44f552320dfce1b6bdba28a8c18da01c6385f0 100644 (file)
         <INDEX NAME="idnumber-courseid" UNIQUE="false" FIELDS="idnumber, courseid" COMMENT="non unique index (although programatically we are guarantying some sort of uniqueness both under this table and the course_modules one). TODO: We need a central store of module idnumbers in the future." PREVIOUS="gradetype"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="grade_grades" COMMENT="grade_grades  This table keeps individual grades for each user and each item, exactly as imported or submitted by modules. The rawgrademax/min and rawscaleid are stored here to record the values at the time the grade was stored, because teachers might change this for an activity! All the results are normalised/resampled for the final grade value." PREVIOUS="grade_items" NEXT="grade_grades_text">
+    <TABLE NAME="grade_grades" COMMENT="grade_grades  This table keeps individual grades for each user and each item, exactly as imported or submitted by modules. The rawgrademax/min and rawscaleid are stored here to record the values at the time the grade was stored, because teachers might change this for an activity! All the results are normalised/resampled for the final grade value." PREVIOUS="grade_items" NEXT="grade_outcomes_history">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemid"/>
         <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The item this grade belongs to" PREVIOUS="id" NEXT="userid"/>
         <FIELD NAME="locktime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="automatic locking of final grade, 0 means none, date otherwise" PREVIOUS="locked" NEXT="exported"/>
         <FIELD NAME="exported" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="date of last grade export, 0 if none" PREVIOUS="locktime" NEXT="overridden"/>
         <FIELD NAME="overridden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="indicates grade overridden from gradebook, 0 means none, date means overridden" PREVIOUS="exported" NEXT="excluded"/>
-        <FIELD NAME="excluded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="grade excluded from aggregation functions, date means when excluded" PREVIOUS="overridden" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time this grade was first created" PREVIOUS="excluded" NEXT="timemodified"/>
+        <FIELD NAME="excluded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="grade excluded from aggregation functions, date means when excluded" PREVIOUS="overridden" NEXT="feedback"/>
+        <FIELD NAME="feedback" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="grading feedback" PREVIOUS="excluded" NEXT="feedbackformat"/>
+        <FIELD NAME="feedbackformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="format of feedback text" PREVIOUS="feedback" NEXT="information"/>
+        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="optiona information" PREVIOUS="feedbackformat" NEXT="informationformat"/>
+        <FIELD NAME="informationformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="format of information text" PREVIOUS="information" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time this grade was first created" PREVIOUS="informationformat" NEXT="timemodified"/>
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time this grade was last modified" PREVIOUS="timecreated"/>
       </FIELDS>
       <KEYS>
         <INDEX NAME="locked-locktime" UNIQUE="false" FIELDS="locked, locktime" COMMENT="used in grading cron"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="grade_grades_text" COMMENT="This table keeps additional textual information about each individual grade, whether it be automatically generated from the module or entered manually by the teacher. It's here separate from the all-numeric grade_grades for database efficiency reasons." PREVIOUS="grade_grades" NEXT="grade_outcomes_history">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="gradeid"/>
-        <FIELD NAME="gradeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="information"/>
-        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Further information like forum rating distribution 4/5/7/0/1" PREVIOUS="gradeid" NEXT="informationformat"/>
-        <FIELD NAME="informationformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for information" PREVIOUS="information" NEXT="feedback"/>
-        <FIELD NAME="feedback" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Manual feedback from the teacher. Could be a code like 'mi'." PREVIOUS="informationformat" NEXT="feedbackformat"/>
-        <FIELD NAME="feedbackformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for feedback" PREVIOUS="feedback" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the time these entry was first created" PREVIOUS="feedbackformat" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="the time this entry was last updated" PREVIOUS="timecreated" NEXT="usermodified"/>
-        <FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" ENUM="false" COMMENT="the userid of the person who last modified this entry" PREVIOUS="timemodified"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="gradeid"/>
-        <KEY NAME="gradeid" TYPE="foreign" FIELDS="gradeid" REFTABLE="grade_grades" REFFIELDS="id" PREVIOUS="primary" NEXT="usermodified"/>
-        <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="gradeid"/>
-      </KEYS>
-    </TABLE>
-    <TABLE NAME="grade_outcomes_history" COMMENT="History table" PREVIOUS="grade_grades_text" NEXT="grade_categories_history">
+    <TABLE NAME="grade_outcomes_history" COMMENT="History table" PREVIOUS="grade_grades" NEXT="grade_categories_history">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="action"/>
         <FIELD NAME="action" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="created/modified/deleted constants" PREVIOUS="id" NEXT="oldid"/>
         <INDEX NAME="action" UNIQUE="false" FIELDS="action" COMMENT="insert/update/delete"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="grade_grades_history" COMMENT="History table" PREVIOUS="grade_items_history" NEXT="grade_grades_text_history">
+    <TABLE NAME="grade_grades_history" COMMENT="History table" PREVIOUS="grade_items_history" NEXT="grade_import_newitem">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="action"/>
         <FIELD NAME="action" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="created/modified/deleted constants" PREVIOUS="id" NEXT="oldid"/>
         <FIELD NAME="locktime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="automatic locking of final grade, 0 means none, date otherwise" PREVIOUS="locked" NEXT="exported"/>
         <FIELD NAME="exported" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="date of last grade export, 0 if none" PREVIOUS="locktime" NEXT="overridden"/>
         <FIELD NAME="overridden" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="indicates grade overridden from gradebook, 0 means none, date means overridden" PREVIOUS="exported" NEXT="excluded"/>
-        <FIELD NAME="excluded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="grade excluded from aggregation functions, date means when excluded" PREVIOUS="overridden"/>
+        <FIELD NAME="excluded" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="grade excluded from aggregation functions, date means when excluded" PREVIOUS="overridden" NEXT="feedback"/>
+        <FIELD NAME="feedback" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="grading feedback" PREVIOUS="excluded" NEXT="feedbackformat"/>
+        <FIELD NAME="feedbackformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="format of feedback text" PREVIOUS="feedback" NEXT="information"/>
+        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="optiona information" PREVIOUS="feedbackformat" NEXT="informationformat"/>
+        <FIELD NAME="informationformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="format of information text" PREVIOUS="information"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="oldid"/>
         <INDEX NAME="action" UNIQUE="false" FIELDS="action" COMMENT="insert/update/delete"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="grade_grades_text_history" COMMENT="History table" PREVIOUS="grade_grades_history" NEXT="grade_import_newitem">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="action"/>
-        <FIELD NAME="action" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="created/modified/deleted constants" PREVIOUS="id" NEXT="oldid"/>
-        <FIELD NAME="oldid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="id of the table, please edit me" PREVIOUS="action" NEXT="source"/>
-        <FIELD NAME="source" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="What caused the modification? manual/module/import/..." PREVIOUS="oldid" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The last time this grade_item was modified" PREVIOUS="source" NEXT="loggeduser"/>
-        <FIELD NAME="loggeduser" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the userid of the person who last modified this outcome" PREVIOUS="timemodified" NEXT="gradeid"/>
-        <FIELD NAME="gradeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="loggeduser" NEXT="information"/>
-        <FIELD NAME="information" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Further information like forum rating distribution 4/5/7/0/1" PREVIOUS="gradeid" NEXT="informationformat"/>
-        <FIELD NAME="informationformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for information" PREVIOUS="information" NEXT="feedback"/>
-        <FIELD NAME="feedback" TYPE="text" LENGTH="medium" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Manual feedback from the teacher. Could be a code like 'mi'." PREVIOUS="informationformat" NEXT="feedbackformat"/>
-        <FIELD NAME="feedbackformat" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Text format for feedback" PREVIOUS="feedback" NEXT="usermodified"/>
-        <FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="the userid of the person who last modified this grade" PREVIOUS="feedbackformat"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="oldid"/>
-        <KEY NAME="oldid" TYPE="foreign" FIELDS="oldid" REFTABLE="grade_grades_text" REFFIELDS="id" PREVIOUS="primary" NEXT="gradeid"/>
-        <KEY NAME="gradeid" TYPE="foreign" FIELDS="gradeid" REFTABLE="grade_grades" REFFIELDS="id" PREVIOUS="oldid" NEXT="usermodified"/>
-        <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="gradeid" NEXT="loggeduser"/>
-        <KEY NAME="loggeduser" TYPE="foreign" FIELDS="loggeduser" REFTABLE="user" REFFIELDS="id" PREVIOUS="usermodified"/>
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="action" UNIQUE="false" FIELDS="action" COMMENT="insert/update/delete"/>
-      </INDEXES>
-    </TABLE>
-    <TABLE NAME="grade_import_newitem" COMMENT="temporary table for storing new grade_item names from grade import" PREVIOUS="grade_grades_text_history" NEXT="grade_import_values">
+    <TABLE NAME="grade_import_newitem" COMMENT="temporary table for storing new grade_item names from grade import" PREVIOUS="grade_grades_history" NEXT="grade_import_values">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemname"/>
         <FIELD NAME="itemname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="new grade item name" PREVIOUS="id" NEXT="import_code"/>
index 25bbd1b47d0c79426e9be6e5e63eab96e26ded1d..d7eed37dc9465a291daca0b7a892500221bffd8e 100644 (file)
@@ -1123,6 +1123,10 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('excluded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
         $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
 
@@ -1140,29 +1144,6 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_grades_text to be created
-        $table = new XMLDBTable('grade_grades_text');
-
-    /// Adding fields to table grade_grades_text
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('gradeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-        $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-        $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
-        $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
-
-    /// Adding keys to table grade_grades_text
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('gradeid', XMLDB_KEY_FOREIGN, array('gradeid'), 'grade_grades', array('id'));
-        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-
-    /// Launch create table for grade_grades_text
-        $result = $result && create_table($table);
-
-
     /// Define table grade_outcomes_history to be created
         $table = new XMLDBTable('grade_outcomes_history');
 
@@ -1304,6 +1285,10 @@ function xmldb_main_upgrade($oldversion=0) {
         $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
         $table->addFieldInfo('excluded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+        $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+        $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
 
     /// Adding keys to table grade_grades_history
         $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
@@ -1321,37 +1306,6 @@ function xmldb_main_upgrade($oldversion=0) {
         $result = $result && create_table($table);
 
 
-    /// Define table grade_grades_text_history to be created
-        $table = new XMLDBTable('grade_grades_text_history');
-
-    /// Adding fields to table grade_grades_text_history
-        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-        $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-        $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-        $table->addFieldInfo('gradeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-        $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-        $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-        $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-        $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-
-    /// Adding keys to table grade_grades_text_history
-        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-        $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_grades_text', array('id'));
-        $table->addKeyInfo('gradeid', XMLDB_KEY_FOREIGN, array('gradeid'), 'grade_grades', array('id'));
-        $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-        $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
-
-    /// Adding indexes to table grade_grades_text_history
-        $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
-
-    /// Launch create table for grade_grades_text_history
-        $result = $result && create_table($table);
-
-
     /// Define table grade_import_newitem to be created
         $table = new XMLDBTable('grade_import_newitem');
 
@@ -1957,30 +1911,6 @@ function xmldb_main_upgrade($oldversion=0) {
     }
 
     if ($result && $oldversion < 2007090503) {
-/// Remove obsoleted unit tests tables - they will be recreated automatically
-        $tables = array('grade_categories',
-                        'scale',
-                        'grade_items',
-                        'grade_calculations',
-                        'grade_grades',
-                        'grade_grades_raw',
-                        'grade_grades_final',
-                        'grade_grades_text',
-                        'grade_outcomes',
-                        'grade_outcomes_courses');
-
-        foreach ($tables as $tablename) {
-            $table = new XMLDBTable('unittest_'.$tablename);
-            if (table_exists($table)) {
-                drop_table($table);
-            }
-            $table = new XMLDBTable('unittest_'.$tablename.'_history');
-            if (table_exists($table)) {
-                drop_table($table);
-            }
-        }
-
-
     /// Define field aggregatesubcats to be added to grade_categories
         $table = new XMLDBTable('grade_categories');
         $field = new XMLDBField('aggregatesubcats');
@@ -2117,6 +2047,149 @@ function xmldb_main_upgrade($oldversion=0) {
         load_all_capabilities();
     }
 
+    /**
+     * Merging of grade_grades_text back into grade_grades
+     */
+    if ($result && $oldversion < 2007092002) {
+
+/// Remove obsoleted unit tests tables - they will be recreated automatically
+        $tables = array('grade_categories',
+                        'scale',
+                        'grade_items',
+                        'grade_calculations',
+                        'grade_grades',
+                        'grade_grades_raw',
+                        'grade_grades_final',
+                        'grade_grades_text',
+                        'grade_outcomes',
+                        'grade_outcomes_courses');
+
+        foreach ($tables as $tablename) {
+            $table = new XMLDBTable('unittest_'.$tablename);
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+            $table = new XMLDBTable('unittest_'.$tablename.'_history');
+            if (table_exists($table)) {
+                drop_table($table);
+            }
+        }
+
+    /// Define field feedback to be added to grade_grades
+        $table = new XMLDBTable('grade_grades');
+        $field = new XMLDBField('feedback');
+        $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null, 'excluded');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field feedback
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field feedbackformat to be added to grade_grades
+        $table = new XMLDBTable('grade_grades');
+        $field = new XMLDBField('feedbackformat');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'feedback');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field feedbackformat
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field information to be added to grade_grades
+        $table = new XMLDBTable('grade_grades');
+        $field = new XMLDBField('information');
+        $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null, 'feedbackformat');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field information
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field informationformat to be added to grade_grades
+        $table = new XMLDBTable('grade_grades');
+        $field = new XMLDBField('informationformat');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'information');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field informationformat
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field feedback to be added to grade_grades_history
+        $table = new XMLDBTable('grade_grades_history');
+        $field = new XMLDBField('feedback');
+        $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null, 'excluded');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field feedback
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field feedbackformat to be added to grade_grades_history
+        $table = new XMLDBTable('grade_grades_history');
+        $field = new XMLDBField('feedbackformat');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'feedback');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field feedbackformat
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field information to be added to grade_grades_history
+        $table = new XMLDBTable('grade_grades_history');
+        $field = new XMLDBField('information');
+        $field->setAttributes(XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null, 'feedbackformat');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field information
+            $result = $result && add_field($table, $field);
+        }
+
+    /// Define field informationformat to be added to grade_grades_history
+        $table = new XMLDBTable('grade_grades_history');
+        $field = new XMLDBField('informationformat');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'information');
+
+        if (!field_exists($table, $field)) {
+        /// Launch add field informationformat
+            $result = $result && add_field($table, $field);
+        }
+
+        $table = new XMLDBTable('grade_grades_text');
+        if ($result and table_exists($table)) {
+            //migrade existing data into grade_grades table - this is slow but works for all dbs,
+            //it will be executed on development sites only
+            $fields = array('feedback', 'information');
+            foreach ($fields as $field) {
+                $sql = "UPDATE {$CFG->prefix}grade_grades
+                           SET $field = (
+                                SELECT $field
+                                  FROM {$CFG->prefix}grade_grades_text ggt
+                                 WHERE ggt.gradeid = {$CFG->prefix}grade_grades.id)";
+                $result = execute_sql($sql) && $result;
+            }
+            $fields = array('feedbackformat', 'informationformat');
+            foreach ($fields as $field) {
+                $sql = "UPDATE {$CFG->prefix}grade_grades
+                           SET $field = COALESCE((
+                                SELECT $field
+                                  FROM {$CFG->prefix}grade_grades_text ggt
+                                 WHERE ggt.gradeid = {$CFG->prefix}grade_grades.id), 0)";
+                $result = execute_sql($sql) && $result;
+            }
+
+            if ($result) {
+                $tables = array('grade_grades_text', 'grade_grades_text_history');
+    
+                foreach ($tables as $table) {
+                    $table = new XMLDBTable($table);
+                    if (table_exists($table)) {
+                        drop_table($table);
+                    }
+                }
+            }
+        }
+    }
 
 /*
     /// drop old gradebook tables
index 048cacbbeb73717919f89dddfd387205155f1fc9..4b3159d4b9430268f76f0af6698ea3f5cb476919 100644 (file)
@@ -33,10 +33,12 @@ class grade_category extends grade_object {
     var $table = 'grade_categories';
 
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('table', 'required_fields', 'nonfields', 'children', 'all_children', 'grade_item', 'parent_category', 'sortorder');
+    var $required_fields = array('id', 'courseid', 'parent', 'depth', 'path', 'fullname', 'aggregation',
+                                 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes',
+                                 'aggregatesubcats', 'timecreated', 'timemodified');
 
     /**
      * The course this category belongs to.
@@ -390,9 +392,12 @@ class grade_category extends grade_object {
             $usersql = "";
         }
 
+        $grade_inst = new grade_grade();
+        $fields = 'g.'.implode(',g.', $grade_inst->required_fields);
+
         // where to look for final grades - include grade of this item too, we will store the results there
         $gis = implode(',', array_merge($depends_on, array($this->grade_item->id)));
-        $sql = "SELECT g.*
+        $sql = "SELECT $fields
                   FROM {$CFG->prefix}grade_grades g, {$CFG->prefix}grade_items gi
                  WHERE gi.id = g.itemid AND gi.id IN ($gis) $usersql
               ORDER BY g.userid";
index ad75ae6e85b2402b44a8832957406d1ac9860fdc..e38fd78e848db64efa87c4f104b82e77dd32267a 100644 (file)
@@ -34,10 +34,18 @@ class grade_grade extends grade_object {
     var $table = 'grade_grades';
 
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('table', 'nonfields', 'required_fields', 'grade_grade_text', 'grade_item');
+    var $required_fields = array('id', 'itemid', 'userid', 'rawgrade', 'rawgrademax', 'rawgrademin',
+                                 'rawscaleid', 'usermodified', 'finalgrade', 'hidden', 'locked',
+                                 'locktime', 'exported', 'overridden', 'excluded', 'timecreated', 'timemodified');
+
+    /**
+     * Array of optional fields with default values (these should match db defaults)
+     * @var array $optional_fields
+     */
+    var $optional_fields = array('feedback'=>null, 'feedbackformat'=>0, 'information'=>null, 'informationformat'=>0);
 
     /**
      * The id of the grade_item this grade belongs to.
@@ -87,14 +95,6 @@ class grade_grade extends grade_object {
      */
     var $usermodified;
 
-    /**
-     * 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 grade object.
-     * @var object $grade_grade_text
-     */
-    var $grade_grade_text;
-
     /**
      * The final value of this grade.
      * @var float $finalgrade
@@ -137,23 +137,6 @@ class grade_grade extends grade_object {
      */
     var $excluded = 0;
 
-    /**
-     * Loads the grade_grade_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)) {
-            return false; // text can not be attached to non existing grade
-        }
-
-        if (empty($this->grade_grade_text->id)) {
-            $this->grade_grade_text = grade_grade_text::fetch(array('gradeid'=>$this->id));
-        }
-
-        return $this->grade_grade_text;
-    }
-
     /**
      * Loads the grade_item object referenced by $this->itemid and saves it as $this->grade_item for easy access.
      * @return object grade_item.
@@ -425,93 +408,6 @@ class grade_grade extends grade_object {
         return grade_object::fetch_all_helper('grade_grades', 'grade_grade', $params);
     }
 
-
-    /**
-     * Delete grade together with feedback.
-     * @param string $source from where was the object deleted (mod/forum, manual, etc.)
-     * @return boolean success
-     */
-    function delete($source=null) {
-        if ($text = $this->load_text()) {
-            $text->delete($source);
-        }
-        return parent::delete($source);
-    }
-
-    /**
-     * Updates this grade with the given textual information. This will create a new grade_grade_text entry
-     * if none was previously in DB for this raw grade, or will update the existing one.
-     * @param string $information Manual information from the teacher. Could be a code like 'mi'
-     * @param int $informationformat Text format for the information
-     * @return boolean Success or Failure
-     */
-    function update_information($information, $informationformat) {
-        $this->load_text();
-
-        if (empty($this->grade_grade_text->id)) {
-            $this->grade_grade_text = new grade_grade_text();
-
-            $this->grade_grade_text->gradeid           = $this->id;
-            $this->grade_grade_text->userid            = $this->userid;
-            $this->grade_grade_text->information       = $information;
-            $this->grade_grade_text->informationformat = $informationformat;
-
-            return $this->grade_grade_text->insert();
-
-        } else {
-            if ($this->grade_grade_text->information != $information
-              or $this->grade_grade_text->informationformat != $informationformat) {
-
-                $this->grade_grade_text->information       = $information;
-                $this->grade_grade_text->informationformat = $informationformat;
-                return  $this->grade_grade_text->update();
-            } else {
-                return true;
-            }
-        }
-    }
-
-    /**
-     * Updates this grade with the given textual information. This will create a new grade_grade_text entry
-     * if none was previously in DB for this raw grade, or will update the existing one.
-     * @param string $feedback Manual feedback from the teacher. Could be a code like 'mi'
-     * @param int $feedbackformat Text format for the feedback
-     * @return boolean Success or Failure
-     */
-    function update_feedback($feedback, $feedbackformat, $usermodified=null) {
-        global $USER;
-
-        $this->load_text();
-
-        if (empty($usermodified)) {
-            $usermodified = $USER->id;
-        }
-
-        if (empty($this->grade_grade_text->id)) {
-            $this->grade_grade_text = new grade_grade_text();
-
-            $this->grade_grade_text->gradeid        = $this->id;
-            $this->grade_grade_text->feedback       = $feedback;
-            $this->grade_grade_text->feedbackformat = $feedbackformat;
-            $this->grade_grade_text->usermodified   = $usermodified;
-
-            return $this->grade_grade_text->insert();
-
-        } else {
-            if ($this->grade_grade_text->feedback != $feedback
-              or $this->grade_grade_text->feedbackformat != $feedbackformat) {
-
-                $this->grade_grade_text->feedback       = $feedback;
-                $this->grade_grade_text->feedbackformat = $feedbackformat;
-                $this->grade_grade_text->usermodified   = $usermodified;
-
-                return  $this->grade_grade_text->update();
-            } else {
-                return true;
-            }
-        }
-    }
-
     /**
      * Given a float value situated between a source minimum and a source maximum, converts it to the
      * corresponding value situated between a target minimum and a target maximum. Thanks to Darlene
diff --git a/lib/grade/grade_grade_text.php b/lib/grade/grade_grade_text.php
deleted file mode 100644 (file)
index 0db4c2e..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-<?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');
-
-/**
- * A text string used to compute the value displayed by a grade_item.
- * There can be only one grade_text per grade_item (one-to-one).
- */
-class grade_grade_text extends grade_object {
-    /**
-     * DB Table (used by grade_object).
-     * @var string $table
-     */
-    var $table = 'grade_grades_text';
-
-    /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
-     */
-    var $nonfields = array('table', 'required_fields', 'nonfields');
-
-    /**
-     * The grade_grade.id this text refers to.
-     * @var int $itemid
-     */
-    var $gradeid;
-
-    /**
-     * Further information like forum rating distribution 4/5/7/0/1
-     * @var string $information
-     */
-    var $information;
-
-    /**
-     * Text format for information (FORMAT_PLAIN, FORMAT_HTML etc...).
-     * @var int $informationformat
-     */
-    var $informationformat = FORMAT_MOODLE;
-
-    /**
-     * Manual feedback from the teacher. This could be a code like 'mi'.
-     * @var string $feedback
-     */
-    var $feedback;
-
-    /**
-     * Text format for feedback (FORMAT_PLAIN, FORMAT_HTML etc...).
-     * @var int $feedbackformat
-     */
-    var $feedbackformat = FORMAT_MOODLE;
-
-    /**
-     * The userid of the person who last modified this text.
-     * @var int $usermodified
-     */
-    var $usermodified;
-
-    /**
-     * Finds and returns a grade_grade_text instance based on params.
-     * @static
-     *
-     * @param array $params associative arrays varname=>value
-     * @return object grade_grade_text instance or false if none found.
-     */
-    function fetch($params) {
-        return grade_object::fetch_helper('grade_grades_text', 'grade_grade_text', $params);
-    }
-
-    /**
-     * Finds and returns all grade_grade_text instances based on params.
-     * @static
-     *
-     * @param array $params associative arrays varname=>value
-     * @return array array of grade_grade_text insatnces or false if none found.
-     */
-    function fetch_all($params) {
-        return grade_object::fetch_all_helper('grade_grades_text', 'grade_grade_text', $params);
-    }
-
-}
-?>
index 51458308f7a3667b4d959f27eeb9b608e3cdee90..35486532fccc01de5f43323ae34219a278454917 100644 (file)
@@ -37,10 +37,14 @@ class grade_item extends grade_object {
     var $table = 'grade_items';
 
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('table', 'nonfields', 'required_fields', 'formula', 'calculation_normalized', 'scale', 'item_category', 'parent_category', 'outcome');
+    var $required_fields = array('id', 'courseid', 'categoryid', 'itemname', 'itemtype', 'itemmodule', 'iteminstance',
+                                 'itemnumber', 'iteminfo', 'idnumber', 'calculation', 'gradetype', 'grademax', 'grademin',
+                                 'scaleid', 'outcomeid', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef',
+                                 'sortorder', 'display', 'hidden', 'locked', 'locktime', 'needsupdate', 'timecreated',
+                                 'timemodified');
 
     /**
      * The course this grade_item belongs to.
@@ -615,10 +619,12 @@ class grade_item extends grade_object {
 
         // normal grade item - just new final grades
         $result = true;
+        $grade_inst = new grade_grade();
+        $fields = implode(',', $grade_inst->required_fields);
         if ($userid) {
-            $rs = get_recordset_select('grade_grades', "itemid={$this->id} AND userid=$userid");
+            $rs = get_recordset_select('grade_grades', "itemid={$this->id} AND userid=$userid", '', $fields);
         } else {
-            $rs = get_recordset('grade_grades', 'itemid', $this->id);
+            $rs = get_recordset('grade_grades', 'itemid', $this->id, '', $fields);
         }
         if ($rs) {
             if ($rs->RecordCount() > 0) {
@@ -1251,6 +1257,7 @@ class grade_item extends grade_object {
      */
     function update_final_grade($userid, $finalgrade=false, $source=NULL, $note=NULL, $feedback=false, $feedbackformat=FORMAT_MOODLE, $usermodified=null) {
         global $USER, $CFG;
+
         if (empty($usermodified)) {
             $usermodified = $USER->id;
         }
@@ -1280,8 +1287,10 @@ class grade_item extends grade_object {
         }
 
         $oldgrade = new object();
-        $oldgrade->finalgrade  = $grade->finalgrade;
-        $oldgrade->overridden  = $grade->overridden;
+        $oldgrade->finalgrade     = $grade->finalgrade;
+        $oldgrade->overridden     = $grade->overridden;
+        $oldgrade->feedback       = $grade->feedback;
+        $oldgrade->feedbackformat = $grade->feedbackformat;
 
         if ($finalgrade !== false or $feedback !== false) {
             if (($this->is_outcome_item() or $this->is_manual_item()) and !$this->is_calculated()) {
@@ -1304,18 +1313,22 @@ class grade_item extends grade_object {
             $grade->finalgrade = $finalgrade;
         }
 
+        // do we have comment from teacher?
+        if ($feedback !== false) {
+            $grade->feedback       = $feedback;
+            $grade->feedbackformat = $feedbackformat;
+        }
+
         if (empty($grade->id)) {
             $result = (boolean)$grade->insert($source);
 
-        } else if ($grade->finalgrade !== $oldgrade->finalgrade or $grade->overridden !== $oldgrade->overridden) {
+        } else if ($grade->finalgrade     !== $oldgrade->finalgrade
+                or $grade->overridden     !== $oldgrade->overridden
+                or $grade->feedback       !== $oldgrade->feedback
+                or $grade->feedbackformat !== $oldgrade->feedbackformat) {
             $result = $grade->update($source);
         }
 
-        // do we have comment from teacher?
-        if ($result and $feedback !== false) {
-            $result = $grade->update_feedback($feedback, $feedbackformat, $usermodified);
-        }
-
         if (!$result) {
             // something went wrong - better force final grade recalculation
             $this->force_regrading();
@@ -1360,6 +1373,8 @@ class grade_item extends grade_object {
             $usermodified = $USER->id;
         }
 
+        $result = true;
+
         // calculated grades can not be updated; course and category can not be updated  because they are aggregated
         if ($this->is_calculated() or $this->is_outcome_item() or !$this->is_normal_item()
          or $this->gradetype == GRADE_TYPE_NONE or $this->is_locked()) {
@@ -1384,42 +1399,49 @@ class grade_item extends grade_object {
         }
 
         $oldgrade = new object();
-        $oldgrade->finalgrade  = $grade->finalgrade;
-        $oldgrade->rawgrade    = $grade->rawgrade;
-        $oldgrade->rawgrademin = $grade->rawgrademin;
-        $oldgrade->rawgrademax = $grade->rawgrademax;
-        $oldgrade->rawscaleid  = $grade->rawscaleid;
+        $oldgrade->finalgrade     = $grade->finalgrade;
+        $oldgrade->rawgrade       = $grade->rawgrade;
+        $oldgrade->rawgrademin    = $grade->rawgrademin;
+        $oldgrade->rawgrademax    = $grade->rawgrademax;
+        $oldgrade->rawscaleid     = $grade->rawscaleid;
+        $oldgrade->feedback       = $grade->feedback;
+        $oldgrade->feedbackformat = $grade->feedbackformat;
 
         // fist copy current grademin/max and scale
         $grade->rawgrademin = $this->grademin;
         $grade->rawgrademax = $this->grademax;
         $grade->rawscaleid  = $this->scaleid;
 
+        // change raw grade?
         if ($rawgrade !== false) {
             $grade->rawgrade = $rawgrade;
         }
 
+        // do we have comment from teacher?
+        if ($feedback !== false) {
+            $grade->feedback       = $feedback;
+            $grade->feedbackformat = $feedbackformat;
+        }
+
         if (empty($grade->id)) {
             $result = (boolean)$grade->insert($source);
 
-        } else if ($grade->finalgrade  !== $oldgrade->finalgrade
-                or $grade->rawgrade    !== $oldgrade->rawgrade
-                or $grade->rawgrademin !== $oldgrade->rawgrademin
-                or $grade->rawgrademax !== $oldgrade->rawgrademax
-                or $grade->rawscaleid  !== $oldgrade->rawscaleid) {
+        } else if ($grade->finalgrade     !== $oldgrade->finalgrade
+                or $grade->rawgrade       !== $oldgrade->rawgrade
+                or $grade->rawgrademin    !== $oldgrade->rawgrademin
+                or $grade->rawgrademax    !== $oldgrade->rawgrademax
+                or $grade->rawscaleid     !== $oldgrade->rawscaleid
+                or $grade->feedback       !== $oldgrade->feedback
+                or $grade->feedbackformat !== $oldgrade->feedbackformat) {
 
             $result = $grade->update($source);
-
-        } else {
-            $result = true;
         }
 
-        // do we have comment from teacher?
-        if ($result and $feedback !== false) {
-            $result = $grade->update_feedback($feedback, $feedbackformat, $usermodified);
-        }
+        if (!$result) {
+            // something went wrong - better force final grade recalculation
+            $this->force_regrading();
 
-        if (!$this->needsupdate) {
+        } else if (!$this->needsupdate) {
             $course_item = grade_item::fetch_course_item($this->courseid);
             if (!$course_item->needsupdate) {
                 if (!grade_regrade_final_grades($this->courseid, $userid, $this)) {
@@ -1468,7 +1490,10 @@ class grade_item extends grade_object {
             $usersql = "";
         }
 
-        $sql = "SELECT g.*
+        $grade_inst = new grade_grade();
+        $fields = 'g.'.implode(',g.', $grade_inst->required_fields);
+
+        $sql = "SELECT $fields
                   FROM {$CFG->prefix}grade_grades g, {$CFG->prefix}grade_items gi
                  WHERE gi.id = g.itemid AND gi.courseid={$this->courseid} AND gi.id IN ($gis) $usersql
               ORDER BY g.userid";
@@ -1590,26 +1615,35 @@ class grade_item extends grade_object {
      * @param string $formula
      * @return boolean true if calculation possible, false otherwise
      */
-    function validate_formula($formula) {
+    function validate_formula($formulastr) {
         global $CFG;
         require_once($CFG->libdir.'/mathslib.php');
 
-        $formula = grade_item::normalize_formula($formula, $this->courseid);
+        $formulastr = grade_item::normalize_formula($formulastr, $this->courseid);
 
-        if (empty($formula)) {
+        if (empty($formulastr)) {
             return true;
         }
 
-        if (strpos($formula, '=') !== 0) {
+        if (strpos($formulastr, '=') !== 0) {
             return get_string('errorcalculationnoequal', 'grades');
         }
 
+        // get used items
+        if (preg_match_all('/##gi(\d+)##/', $formulastr, $matches)) {
+            $useditems = array_unique($matches[1]); // remove duplicates
+        } else {
+            $useditems = array();
+        }
+
+        if (!empty($this->id)) {
+            unset($useditems[$this->id]);
+        }
+
         // prepare formula and init maths library
-        $formula = preg_replace('/##(gi\d+)##/', '\1', $formula);
+        $formula = preg_replace('/##(gi\d+)##/', '\1', $formulastr);
         $formula = new calc_formula($formula);
 
-        // get used items
-        $useditems = $this->depends_on();
 
         if (empty($useditems)) {
             $grade_items = array();
index 0881d2905e5760048bce6c0bb4f1582a609a19f7..e7f8df282071c711a3bc25bb5c39332682e8cc94 100644 (file)
  */
 class grade_object {
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('nonfields', 'required_fields');
+    var $required_fields = array('id', 'timecreated', 'timemodified');
 
     /**
-     * Array of required fields (keys) and their default values (values).
-     * @var array $required_fields
+     * Array of optional fields with default values - usually long text information that is not always needed.
+     * If you want to create an instance without optional fields use: new grade_object($only_required_fields, false);
+     * @var array $optional_fields
      */
-    var $required_fields = array();
+    var $optional_fields = array();
 
     /**
      * The PK.
@@ -47,13 +48,13 @@ class grade_object {
     var $id;
 
     /**
-     * The first time this grade_calculation was created.
+     * The first time this grade_object was created.
      * @var int $timecreated
      */
     var $timecreated;
 
     /**
-     * The last time this grade_calculation was modified.
+     * The last time this grade_object was modified.
      * @var int $timemodified
      */
     var $timemodified;
@@ -63,7 +64,7 @@ class grade_object {
      * @param array $params an array with required parameters for this grade object.
      * @param boolean $fetch Whether to fetch corresponding row from DB or not.
      */
-    function grade_object($params=NULL, $fetch = true) {
+    function grade_object($params=NULL, $fetch=true) {
         if (!empty($params) and (is_array($params) or is_object($params))) {
             if ($fetch and $data = $this->fetch($params)) {
                 grade_object::set_properties($this, $data);
@@ -74,6 +75,24 @@ class grade_object {
         }
     }
 
+    /**
+     * Makes sure all the optional fields are loaded.
+     * If id present (==instance exists in db) fetches data from db.
+     * Defaults are used for new instances.
+     */
+    function load_optional_fields() {
+        foreach ($this->optional_fields as $field=>$default) {
+            if (array_key_exists($field, $this)) {
+                continue;
+            }
+            if (empty($this->id)) {
+                $this->$field = $default;
+            } else {
+                $this->$field = get_field($this->table, $field, 'id', $this->id);
+            }
+        }
+    }
+
     /**
      * Finds and returns a grade_object instance based on params.
      * @static abstract
@@ -130,10 +149,9 @@ class grade_object {
 
         $wheresql = array();
 
-        // remove incorrect params - warn developer if needed
+        // remove incorrect params
         foreach ($params as $var=>$value) {
-            if (!in_array($var, array_keys($classvars)) or in_array($var, $instance->nonfields)) {
-                debugging("Incorrect property name $var for class $classname");
+            if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) {
                 continue;
             }
             if (is_null($value)) {
@@ -177,7 +195,7 @@ class grade_object {
         // we need to do this to prevent infinite loops in addslashes_recursive - grade_item -> category ->grade_item
         $data = new object();
         foreach ($this as $var=>$value) {
-            if (!in_array($var, $this->nonfields)) {
+            if (in_array($var, $this->required_fields) or array_key_exists($var, $this->optional_fields)) {
                 if (is_object($value) or is_array($value)) {
                     debugging("Incorrect property '$var' found when updating grade object");
                 } else {
@@ -186,7 +204,7 @@ class grade_object {
             }
         }
 
-        if(!update_record($this->table, addslashes_recursive($data))) {
+        if (!update_record($this->table, addslashes_recursive($data))) {
             return false;
         }
 
@@ -253,7 +271,7 @@ class grade_object {
         // we need to do this to prevent infinite loops in addslashes_recursive - grade_item -> category ->grade_item
         $data = new object();
         foreach ($this as $var=>$value) {
-            if (!in_array($var, $this->nonfields)) {
+            if (in_array($var, $this->required_fields) or array_key_exists($var, $this->optional_fields)) {
                 if (is_object($value) or is_array($value)) {
                     debugging("Incorrect property '$var' found when inserting grade object");
                 } else {
@@ -310,9 +328,8 @@ class grade_object {
      * @static final
      */
     function set_properties(&$instance, $params) {
-        $classvars = (array)$instance;
         foreach ($params as $var => $value) {
-            if (in_array($var, array_keys($classvars))) {
+            if (in_array($var, $instance->required_fields) or array_key_exists($var, $instance->optional_fields)) {
                 $instance->$var = $value;
             }
         }
index 077fd62915739b92ac8a572d285a4696221e0c87..9db91adcd0158621e0d214c1f0dd76bb7db080f8 100644 (file)
@@ -37,10 +37,11 @@ class grade_outcome extends grade_object {
     var $table = 'grade_outcomes';
 
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('table', 'nonfields', 'required_fields', 'scale');
+    var $required_fields = array('id', 'courseid', 'shortname', 'fullname', 'scaleid',
+                                 'description', 'timecreated', 'timemodified', 'usermodified');
 
     /**
      * The course this outcome belongs to.
index 4f1b278b2cd4bd95c2864d61ab46b07e501aa5ee..66f19434cf7d815ee44e8f6e4611856b051ab192 100644 (file)
@@ -37,10 +37,10 @@ class grade_scale extends grade_object {
     var $table = 'scale';
 
     /**
-     * Array of class variables that are not part of the DB table fields
-     * @var array $nonfields
+     * Array of required table fields, must start with 'id'.
+     * @var array $required_fields
      */
-    var $nonfields = array('table', 'nonfields', 'required_fields', 'scale_items');
+    var $required_fields = array('id', 'courseid', 'userid', 'name', 'scale', 'description', 'timemodified');
 
     /**
      * The course this scale belongs to.
index f99bebc3b707acb0de54f3f932f8473464e86e56..46a9ebdc2b287aee3940a83d72ee3494b37b0d1e 100755 (executable)
@@ -98,23 +98,6 @@ class grade_grade_test extends grade_test {
         $this->assertEqual(count($this->grade_grades), count($grades));
     }
 
-    function test_grade_raw_update_feedback() {
-
-    }
-
-    function test_grade_raw_update_information() {
-
-    }
-
-    function test_grade_load_text() {
-        $grade_grade = new grade_grade($this->grade_grades[0]);
-        $this->assertTrue(method_exists($grade_grade, 'load_text'));
-        $this->assertNull($grade_grade->grade_grade_text);
-        $this->assertNotNull($grade_grade->load_text());
-        $this->assertNotNull($grade_grade->grade_grade_text);
-        $this->assertEqual($this->grade_grades_text[0]->id, $grade_grade->grade_grade_text->id);
-    }
-
     function test_grade_grade_load_grade_item() {
         $grade_grade = new grade_grade($this->grade_grades[0]);
         $this->assertTrue(method_exists($grade_grade, 'load_grade_item'));
diff --git a/lib/grade/simpletest/testgradegradestext.php b/lib/grade/simpletest/testgradegradestext.php
deleted file mode 100755 (executable)
index 2077a5c..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.org                                            //
-//                                                                       //
-// Copyright (C) 1999-2004  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                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-/**
- * Unit tests for grade_text object.
- *
- * @author nicolas@moodle.com
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
- */
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-}
-
-require_once($CFG->libdir.'/simpletest/fixtures/gradetest.php');
-
-class grade_text_test extends grade_test {
-
-    function test_grade_grade_text_construct() {
-        $params = new stdClass();
-
-        $params->gradeid = $this->grade_grades[0]->id;
-        $params->information = 'Thumbs down';
-        $params->informationformat = FORMAT_PLAIN;
-        $params->feedback = 'Good, but not good enough..';
-        $params->feedbackformat = FORMAT_PLAIN;
-
-        $grade_grade_text = new grade_grade_text($params, false);
-        $this->assertEqual($params->gradeid, $grade_grade_text->gradeid);
-        $this->assertEqual($params->information, $grade_grade_text->information);
-        $this->assertEqual($params->informationformat, $grade_grade_text->informationformat);
-        $this->assertEqual($params->feedback, $grade_grade_text->feedback);
-        $this->assertEqual($params->feedbackformat, $grade_grade_text->feedbackformat);
-    }
-
-    function test_grade_grade_text_insert() {
-        global $USER;
-
-        $grade_grade_text = new grade_grade_text();
-        $this->assertTrue(method_exists($grade_grade_text, 'insert'));
-
-        $grade_grade_text->gradeid = $this->grade_grades[0]->id;
-        $grade_grade_text->information = 'Thumbs down';
-        $grade_grade_text->informationformat = FORMAT_PLAIN;
-        $grade_grade_text->feedback = 'Good, but not good enough..';
-        $grade_grade_text->feedbackformat = FORMAT_PLAIN;
-        $grade_grade_text->usermodified = $USER->id;
-
-        $grade_grade_text->insert();
-
-        $last_grade_grade_text = end($this->grade_grades_text);
-
-        $this->assertEqual($grade_grade_text->id, $last_grade_grade_text->id + 1);
-        $this->assertFalse(empty($grade_grade_text->timecreated));
-        $this->assertFalse(empty($grade_grade_text->timemodified));
-        $this->assertEqual($USER->id, $grade_grade_text->usermodified);
-    }
-
-    function test_grade_grade_text_update() {
-        $grade_grade_text = new grade_grade_text($this->grade_grades_text[0]);
-        $this->assertTrue(method_exists($grade_grade_text, 'update'));
-
-        $this->assertTrue($grade_grade_text->update(89));
-        $information = get_field('grade_grades_text', 'information', 'id', $this->grade_grades_text[0]->id);
-        $this->assertEqual($grade_grade_text->information, $information);
-    }
-
-    function test_grade_grade_text_delete() {
-        $grade_grade_text = new grade_grade_text($this->grade_grades_text[0]);
-        $this->assertTrue(method_exists($grade_grade_text, 'delete'));
-
-        $this->assertTrue($grade_grade_text->delete());
-        $this->assertFalse(get_record('grade_grades_text', 'id', $grade_grade_text->id));
-    }
-
-    function test_grade_grade_text_fetch() {
-        $grade_grade_text = new grade_grade_text();
-        $this->assertTrue(method_exists($grade_grade_text, 'fetch'));
-
-        $grade_grade_text = grade_grade_text::fetch(array('id'=>$this->grade_grades_text[0]->id));
-        $this->assertEqual($this->grade_grades_text[0]->id, $grade_grade_text->id);
-        $this->assertEqual($this->grade_grades_text[0]->information, $grade_grade_text->information);
-    }
-
-    function test_grade_grade_text_fetch_all() {
-        $grade_grade_text = new grade_grade_text();
-        $this->assertTrue(method_exists($grade_grade_text, 'fetch_all'));
-
-        $grade_grade_texts = grade_grade_text::fetch_all(array());
-        $this->assertEqual(count($this->grade_grades_text[0]), count($grade_grade_texts));
-    }
-}
-?>
index ac43d3cd3d5bb230d3dc053b457eca136e4e03ea..7b551e32875d79484c4f9e3a47485069ab397802 100644 (file)
@@ -38,7 +38,6 @@ require_once($CFG->libdir . '/grade/grade_item.php');
 require_once($CFG->libdir . '/grade/grade_grade.php');
 require_once($CFG->libdir . '/grade/grade_scale.php');
 require_once($CFG->libdir . '/grade/grade_outcome.php');
-require_once($CFG->libdir . '/grade/grade_grade_text.php');
 
 /***** PUBLIC GRADE API - only these functions should be used in modules *****/
 
@@ -360,18 +359,12 @@ function grade_get_final_grades($courseid, $itemtype, $itemmodule, $iteminstance
                 //no user info
 
             } if ($grade = $item->get_grade($userid, false)) {
-                $o->grade      = $grade->finalgrade;
-                $o->locked     = $grade->is_locked();
-                $o->hidden     = $grade->is_hidden();
-                $o->overridden = $grade->overridden;
-
-                if ($text = $grade->load_text()) {
-                    $o->feedback       = $text->feedback;
-                    $o->feedbackformat = $text->feedbackformat;
-                } else {
-                    $o->feedback       = null;
-                    $o->feedbackformat = FORMAT_MOODLE;
-                }
+                $o->grade          = $grade->finalgrade;
+                $o->locked         = $grade->is_locked();
+                $o->hidden         = $grade->is_hidden();
+                $o->overridden     = $grade->overridden;
+                $o->feedback       = $text->feedback;
+                $o->feedbackformat = $text->feedbackformat;
 
             } else {
                 $o->grade          = null;
index 0cb96eeceee716db47b686e2afa03a72dbf3bebf..6da19327580abb02bcebb613b4a3729f9ab34dfc 100644 (file)
@@ -55,13 +55,11 @@ class grade_test extends UnitTestCase {
                         'scale',
                         'grade_items',
                         'grade_grades',
-                        'grade_grades_text',
                         'grade_outcomes');
 
     var $grade_items = array();
     var $grade_categories = array();
     var $grade_grades = array();
-    var $grade_grades_text = array();
     var $grade_outcomes = array();
     var $scale = array();
 
@@ -264,6 +262,10 @@ class grade_test extends UnitTestCase {
             $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
             $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
             $table->addFieldInfo('excluded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+            $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+            $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
             $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
             $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
 
@@ -281,34 +283,6 @@ class grade_test extends UnitTestCase {
         }
 
 
-        /// Define table grade_grades_text to be created
-        $table = new XMLDBTable('grade_grades_text');
-
-        if ($result && !table_exists($table)) {
-
-        /// Adding fields to table grade_grades_text
-            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-            $table->addFieldInfo('gradeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-            $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-            $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-            $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-            $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-            $table->addFieldInfo('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
-            $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null);
-
-        /// Adding keys to table grade_grades_text
-            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-            $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-
-        /// Launch create table for grade_grades_text
-            $result = $result && create_table($table, true, false);
-
-        } else {
-            delete_records($table->name);
-        }
-
-
         /// Define table grade_outcomes to be created
         $table = new XMLDBTable('grade_outcomes');
 
@@ -534,6 +508,10 @@ class grade_test extends UnitTestCase {
             $table->addFieldInfo('exported', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
             $table->addFieldInfo('overridden', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
             $table->addFieldInfo('excluded', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+            $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+            $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', XMLDB_UNSIGNED, null, null, null, null, null);
+            $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
 
         /// Adding keys to table grade_grades_history
             $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
@@ -555,43 +533,6 @@ class grade_test extends UnitTestCase {
         }
 
 
-        /// Define table grade_grades_text to be created
-        $table = new XMLDBTable('grade_grades_text_history');
-
-        if ($result && !table_exists($table)) {
-
-        /// Adding fields to table grade_grades_text_history
-            $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
-            $table->addFieldInfo('action', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-            $table->addFieldInfo('oldid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, null);
-            $table->addFieldInfo('source', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
-            $table->addFieldInfo('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-            $table->addFieldInfo('loggeduser', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-            $table->addFieldInfo('gradeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
-            $table->addFieldInfo('information', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-            $table->addFieldInfo('informationformat', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, null, '0');
-            $table->addFieldInfo('feedback', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
-            $table->addFieldInfo('feedbackformat', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
-            $table->addFieldInfo('usermodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null);
-
-        /// Adding keys to table grade_grades_text_history
-            $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
-            $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_grades_text', array('id'));
-            $table->addKeyInfo('gradeid', XMLDB_KEY_FOREIGN, array('gradeid'), 'grade_grades', array('id'));
-            $table->addKeyInfo('loggeduser', XMLDB_KEY_FOREIGN, array('loggeduser'), 'user', array('id'));
-            $table->addKeyInfo('usermodified', XMLDB_KEY_FOREIGN, array('usermodified'), 'user', array('id'));
-
-        /// Adding indexes to table grade_grades_text_history
-            $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action'));
-
-        /// Launch create table for grade_grades_text_history
-            $result = $result && create_table($table, true, false);
-
-        } else {
-            delete_records($table->name);
-        }
-
-
         /// Define table grade_outcomes to be created
         $table = new XMLDBTable('grade_outcomes_history');
 
@@ -1205,6 +1146,10 @@ class grade_test extends UnitTestCase {
         $grade->finalgrade = 30;
         $grade->timecreated = mktime();
         $grade->timemodified = mktime();
+        $grade->information = 'Thumbs down';
+        $grade->informationformat = FORMAT_PLAIN;
+        $grade->feedback = 'Good, but not good enough..';
+        $grade->feedbackformat = FORMAT_PLAIN;
 
         if ($grade->id = insert_record('grade_grades', $grade)) {
             $this->grade_grades[0] = $grade;
@@ -1415,23 +1360,6 @@ class grade_test extends UnitTestCase {
         }
     }
 
-    /**
-     * Load grade_grades_text data into the database, and adds the corresponding objects to this class' variable.
-     */
-    function load_grade_grades_text() {
-        $grade_grades_text = new stdClass();
-
-        $grade_grades_text->gradeid = $this->grade_grades[0]->id;
-        $grade_grades_text->information = 'Thumbs down';
-        $grade_grades_text->informationformat = FORMAT_PLAIN;
-        $grade_grades_text->feedback = 'Good, but not good enough..';
-        $grade_grades_text->feedbackformat = FORMAT_PLAIN;
-
-        if ($grade_grades_text->id = insert_record('grade_grades_text', $grade_grades_text)) {
-            $this->grade_grades_text[] = $grade_grades_text;
-        }
-    }
-
     /**
      * Load grade_outcome data into the database, and adds the corresponding objects to this class' variable.
      */
index 1c20e51ac030f13f21d0e57931ec86def0e42e2b..19137dc9e08b94be8d4ed10b7db0481078968863 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2007092001;  // YYYYMMDD = date
+    $version = 2007092002;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 Beta +';   // Human-friendly version name