diff --git a/backup/backuplib.php b/backup/backuplib.php
index a3d89ec8803..52fe33e5440 100644
--- a/backup/backuplib.php
+++ b/backup/backuplib.php
@@ -1408,7 +1408,6 @@
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);
}
@@ -1479,7 +1478,7 @@
// 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
@@ -1524,7 +1523,6 @@
// 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));
@@ -1627,6 +1625,10 @@
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));
@@ -1634,34 +1636,6 @@
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;
@@ -1724,6 +1698,10 @@
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,full_tag("FEEDBACK",7,false,$ch->feedback));
+ fwrite ($bf,full_tag("FEEDBACKFORMAT",7,false,$ch->feedbackformat));
+ 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_GRADES_HISTORIES",5,true));
@@ -1731,41 +1709,6 @@
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));
- }
- $status = fwrite ($bf,end_tag("GRADE_TEXT_HISTORIES",5,true));
- }
- return $status;
- }
-
function backup_gradebook_items_history_info($bf, $preferences) {
global $CFG;
diff --git a/backup/restorelib.php b/backup/restorelib.php
index 0bd2c9c39c6..140738eed4e 100644
--- a/backup/restorelib.php
+++ b/backup/restorelib.php
@@ -1198,7 +1198,6 @@
$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');
@@ -1470,7 +1469,7 @@
}
}
- // Process grade items (grade_raw, grade_final, and grade_text)
+ // Process grade items (grade_grade)
if ($itemscount && $continue) {
if (!defined('RESTORE_SILENTLY')) {
echo '
'.get_string('gradeitems','grades').'';
@@ -1599,7 +1598,7 @@
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
@@ -1607,7 +1606,7 @@
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++) {
@@ -1636,6 +1635,10 @@
$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);
@@ -1654,42 +1657,6 @@
}
}
}
-
-
-
- /// 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 "
";
- }
- }
- backup_flush(300);
- }
- }
- }
}
$counteritems++; // increment item count
}
@@ -1849,6 +1816,10 @@
$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']['#']);
+ $dbrec->feedback = backup_todb($info['GRADE_TEXT_HISTORY']['#']['FEEDBACK']['0']['#']);
+ $dbrec->feedbackformat = backup_todb($info['GRADE_TEXT_HISTORY']['#']['FEEDBACKFORMAT']['0']['#']);
+ $dbrec->information = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATION']['0']['#']);
+ $dbrec->informationformat = backup_todb($info['GRADE_TEXT_HISTORY']['#']['INFORMATIONFORMAT']['0']['#']);
insert_record('grade_grades_history', $dbrec);
unset($dbrec);
@@ -1873,80 +1844,6 @@
// process histories
- if ($ggthcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
- if (!defined('RESTORE_SILENTLY')) {
- echo ''.get_string('gradegradestexthistory','grades').'';
- }
- $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;
- }
-
- insert_record('grade_grades_text_history', $dbrec);
- unset($dbrec);
-
- }
- //Increment counters
- $counter++;
- //Do some output
- if ($counter % 1 == 0) {
- if (!defined('RESTORE_SILENTLY')) {
- echo ".";
- if ($counter % 20 == 0) {
- echo "
";
- }
- }
- backup_flush(300);
- }
- }
- }
- }
- }
-
- // process histories
if ($gihcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
if (!defined('RESTORE_SILENTLY')) {
echo ''.get_string('gradeitemshistory','grades').'';
@@ -5408,30 +5305,6 @@
unset($this->temp);
}
- if (($this->level == 5) and ($tagName == "GRADE_TEXT_HISTORY")) {
- //Prepend XML standard header to info gathered
- $xml_data = "\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()).""; //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 = "\n".$this->temp;
diff --git a/grade/edit/tree/grade.php b/grade/edit/tree/grade.php
index d7c2991df82..0f7dd025862 100644
--- a/grade/edit/tree/grade.php
+++ b/grade/edit/tree/grade.php
@@ -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);
diff --git a/grade/lib.php b/grade/lib.php
index 608aaf2e1d0..d12da72936c 100644
--- a/grade/lib.php
+++ b/grade/lib.php
@@ -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
diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php
index bee29f9153f..15775a7ebe4 100644
--- a/grade/report/grader/lib.php
+++ b/grade/report/grader/lib.php
@@ -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)) {
diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php
index a1485bb1d3e..384d6be50ab 100644
--- a/grade/report/user/lib.php
+++ b/grade/report/user/lib.php
@@ -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[] = ' ';
}
diff --git a/lib/db/install.xml b/lib/db/install.xml
index 20c726f40ff..3b44f552320 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -1359,7 +1359,7 @@
-
+
@@ -1375,8 +1375,12 @@
-
-
+
+
+
+
+
+
@@ -1390,25 +1394,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
@@ -1531,7 +1517,11 @@
-
+
+
+
+
+
@@ -1546,33 +1536,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 25bbd1b47d0..d7eed37dc94 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -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
diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php
index 048cacbbeb7..4b3159d4b94 100644
--- a/lib/grade/grade_category.php
+++ b/lib/grade/grade_category.php
@@ -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";
diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php
index ad75ae6e85b..e38fd78e848 100644
--- a/lib/grade/grade_grade.php
+++ b/lib/grade/grade_grade.php
@@ -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
index 0db4c2ed96d..00000000000
--- a/lib/grade/grade_grade_text.php
+++ /dev/null
@@ -1,104 +0,0 @@
-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);
- }
-
-}
-?>
diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php
index 51458308f7a..35486532fcc 100644
--- a/lib/grade/grade_item.php
+++ b/lib/grade/grade_item.php
@@ -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();
diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php
index 0881d2905e5..e7f8df28207 100644
--- a/lib/grade/grade_object.php
+++ b/lib/grade/grade_object.php
@@ -29,16 +29,17 @@
*/
class grade_object {
/**
- * Array of class variables that are not part of the DB table fields
- * @var array $nonfields
- */
- var $nonfields = array('nonfields', 'required_fields');
-
- /**
- * Array of required fields (keys) and their default values (values).
+ * Array of required table fields, must start with 'id'.
* @var array $required_fields
*/
- var $required_fields = array();
+ var $required_fields = array('id', 'timecreated', 'timemodified');
+
+ /**
+ * 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 $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;
}
}
diff --git a/lib/grade/grade_outcome.php b/lib/grade/grade_outcome.php
index 077fd629157..9db91adcd01 100644
--- a/lib/grade/grade_outcome.php
+++ b/lib/grade/grade_outcome.php
@@ -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.
diff --git a/lib/grade/grade_scale.php b/lib/grade/grade_scale.php
index 4f1b278b2cd..66f19434cf7 100644
--- a/lib/grade/grade_scale.php
+++ b/lib/grade/grade_scale.php
@@ -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.
diff --git a/lib/grade/simpletest/testgradegrades.php b/lib/grade/simpletest/testgradegrades.php
index f99bebc3b70..46a9ebdc2b2 100755
--- a/lib/grade/simpletest/testgradegrades.php
+++ b/lib/grade/simpletest/testgradegrades.php
@@ -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
index 2077a5ce478..00000000000
--- a/lib/grade/simpletest/testgradegradestext.php
+++ /dev/null
@@ -1,116 +0,0 @@
-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));
- }
-}
-?>
diff --git a/lib/gradelib.php b/lib/gradelib.php
index ac43d3cd3d5..7b551e32875 100644
--- a/lib/gradelib.php
+++ b/lib/gradelib.php
@@ -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;
diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php
index 0cb96eeceee..6da19327580 100644
--- a/lib/simpletest/fixtures/gradetest.php
+++ b/lib/simpletest/fixtures/gradetest.php
@@ -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.
*/
diff --git a/version.php b/version.php
index 1c20e51ac03..19137dc9e08 100644
--- a/version.php
+++ b/version.php
@@ -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