diff -Nuar moodle/mod/journal/lib.php moodle_local/mod/journal/lib.php
--- moodle/mod/journal/lib.php	2008-07-25 02:18:59.000000000 +0200
+++ moodle_local/mod/journal/lib.php	2009-10-27 11:12:16.000000000 +0100
@@ -6,6 +6,151 @@
 } 
 
 
+/**
+ * Get journal grades for 1.9 gradebook
+ *
+ * @param   object  $journal   
+ * @param   int     $userid    if 0 return all journal grades
+ * @return  array grades if ok, false if error
+ */
+function journal_get_user_grades($journal, $userid=0) {
+
+    global $CFG;
+
+    if ($userid) {
+        $userstr = 'AND userid = '.$userid;
+    } else {
+        $userstr = '';
+    }
+
+    if (!$journal) {
+
+        return false;
+
+    } else {
+
+        $sql = "SELECT userid, modified as datesubmitted, format as feedbackformat, rating as rawgrade, entrycomment as feedback, teacher as usermodifier, timemarked as dategraded
+            FROM ".$CFG->prefix."journal_entries
+            WHERE journal = '$journal->id' ".$userstr;
+
+        $grades = get_records_sql($sql);
+
+        if ($grades) {
+            foreach ($grades as $key=>$grade) {
+                $grades[$key]->id = $grade->userid;
+            }
+        } else {
+            return false;
+        }
+ 
+        return $grades;
+    }
+
+}
+
+
+/**
+ * Update journal grades in 1.9 gradebook
+ *
+ * @param object   $journal      if is null, all journals
+ * @param int      $userid       if is false al users
+ * @param boolean  $nullifnone   return null if grade does not exist
+ */
+function journal_update_grades($journal=null, $userid=0, $nullifnone=true) {
+
+    global $CFG;
+
+    if (!function_exists('grade_update')) { //workaround for buggy PHP versions
+        require_once($CFG->libdir.'/gradelib.php');
+    }
+
+    if ($journal != null) {
+        if ($grades = journal_get_user_grades($journal, $userid)) {
+            journal_grade_item_update($journal, $grades);
+        } else if ($userid && $nullifnone) {
+            $grade = new object();
+            $grade->userid   = $userid;
+            $grade->rawgrade = NULL;
+            journal_grade_item_update($journal, $grade);
+        } else {
+            journal_grade_item_update($journal);
+        }
+    } else {
+        $sql = "SELECT j.*, cm.idnumber as cmidnumber 
+                FROM ".$CFG->prefix."course_modules cm 
+                JOIN ".$CFG->prefix."modules m ON m.id=cm.module 
+                JOIN ".$CFG->prefix."journal j ON cm.instance=j.id 
+                WHERE m.name='journal'";
+        if ($recordset = get_records_sql($sql)) {
+           foreach ($recordset as $journal) {
+                if ($journal->assessed != false) {
+                    journal_update_grades($journal);
+                } else {
+                    journal_grade_item_update($journal);
+                }
+            }
+        }
+    }
+}
+
+
+/**
+ * Create grade item for given journal
+ *
+ * @param object $journal object with extra cmidnumber
+ * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
+ * @return int 0 if ok, error code otherwise
+ */
+function journal_grade_item_update($journal, $grades=NULL) {
+    global $CFG;
+    if (!function_exists('grade_update')) { //workaround for buggy PHP versions
+        require_once($CFG->libdir.'/gradelib.php');
+    }
+
+    if (array_key_exists('cmidnumber', $journal)) {
+        $params = array('itemname'=>$journal->name, 'idnumber'=>$journal->cmidnumber);
+    } else {
+        $params = array('itemname'=>$journal->name);
+    }
+
+    if ($journal->assessed > 0) {
+        $params['gradetype']  = GRADE_TYPE_VALUE;
+        $params['grademax']   = $journal->assessed;
+        $params['grademin']   = 0;
+        $params['multfactor'] = 1.0;
+
+    } else if($journal->assessed < 0) {
+        $params['gradetype'] = GRADE_TYPE_SCALE;
+        $params['scaleid']   = -$journal->assessed;
+
+    } else {
+        $params['gradetype']  = GRADE_TYPE_NONE;
+        $params['multfactor'] = 1.0;
+    }
+
+    if ($grades  === 'reset') {
+        $params['reset'] = true;
+        $grades = NULL;
+    }
+
+    return grade_update('mod/journal', $journal->course, 'mod', 'journal', $journal->id, 0, $grades, $params);
+}
+
+
+/**
+ * Delete grade item for given journal
+ *
+ * @param   object   $journal
+ * @return  object   grade_item
+ */
+function journal_grade_item_delete($journal) {
+    global $CFG;
+
+    require_once($CFG->libdir.'/gradelib.php');
+
+    return grade_update('mod/journal', $journal->course, 'mod', 'journal', $journal->id, 0, NULL, array('deleted'=>1));
+}
+
 
 // STANDARD MODULE FUNCTIONS /////////////////////////////////////////////////////////
 
@@ -462,7 +607,11 @@
 
     $journal->timemodified = time();
 
-    return insert_record("journal", $journal);
+    $journal->id = insert_record("journal", $journal);
+
+    journal_grade_item_update(stripslashes_recursive($journal));
+
+    return $journal->id;
 }
 
 
@@ -474,7 +623,13 @@
     $journal->timemodified = time();
     $journal->id = $journal->instance;
 
-    return update_record("journal", $journal);
+    $result = update_record("journal", $journal);
+
+    journal_grade_item_update(stripslashes_recursive($journal));
+
+    journal_update_grades(stripslashes_recursive($journal), 0, false);
+
+    return $result;
 }
 
 
@@ -497,8 +652,9 @@
         $result = false;
     }
 
-    return $result;
+    journal_grade_item_delete($journal);
 
+    return $result;
 }
 
 
diff -Nuar moodle/mod/journal/report.php moodle_local/mod/journal/report.php
--- moodle/mod/journal/report.php	2007-10-22 19:26:47.000000000 +0200
+++ moodle_local/mod/journal/report.php	2009-10-27 09:27:43.000000000 +0100
@@ -81,6 +81,11 @@
                 $entrybyuser[$entry->userid]->entrycomment    = $vals['c'];
                 $entrybyuser[$entry->userid]->teacher    = $USER->id;
                 $entrybyuser[$entry->userid]->timemarked = $timenow;
+
+                $journal = get_record("journal", "id", $entrybyuser[$entry->userid]->journal);
+                $journal->cmidnumber = $cm->idnumber;
+
+                journal_update_grades($journal, $entry->userid);
             }
         }
         add_to_log($course->id, "journal", "update feedback", "report.php?id=$cm->id", "$count users", $cm->id);
