diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php
index 9fc6c50..4dbd120 100644
--- a/course/moodleform_mod.php
+++ b/course/moodleform_mod.php
@@ -48,7 +48,7 @@
 
     /** a flag indicating whether outcomes are being used*/
     protected $_outcomesused;
-
+    
     function moodleform_mod($current, $section, $cm, $course) {
         $this->current   = $current;
         $this->_instance = $current->instance;
@@ -59,7 +59,7 @@ function moodleform_mod($current, $section, $cm, $course) {
         } else {
             $this->context = get_context_instance(CONTEXT_COURSE, $course->id);
         }
-
+        
         // Guess module name
         $matches = array();
         if (!preg_match('/^mod_([^_]+)_mod_form$/', get_class($this), $matches)) {
@@ -106,6 +106,18 @@ function data_preprocessing(&$default_values){
             $default_values['ratingtime']=
                 ($default_values['assesstimestart'] && $default_values['assesstimefinish']) ? 1 : 0;
         }
+        
+        // gets the default value by checking any existing rating events 
+        // in the calendar for this forum.
+        if (!empty($this->_cm)) {
+            echo 'course='.$this->_cm->course.' forum='.$this->_cm->instance;
+            $rec = forum_get_rating_event($this->_cm->course, $this->_cm->instance);
+            if (!empty($rec)) {
+                $default_values['addduedateevent'] = 1;
+            } else {
+                $default_values['addduedateevent'] = 0;
+            }
+        }
     }
 
     /**
@@ -421,6 +433,11 @@ function standard_coursemodule_elements(){
             $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
             $mform->disabledIf('assesstimefinish', 'assessed', 'eq', 0);
             $mform->disabledIf('assesstimefinish', 'ratingtime');
+            
+            // facilitates to add an event in the calendar for rating end
+            $mform->addElement('checkbox', 'addduedateevent', get_string('duedateevent', 'rating'));
+            $mform->disabledIf('addduedateevent', 'ratingtime');
+            $mform->addHelpButton('addduedateevent', 'duedateevent', 'rating');
         }
 
         //doing this here means splitting up the grade related settings on the lesson settings page
diff --git a/lang/en/rating.php b/lang/en/rating.php
index 3ab441e..098015e 100644
--- a/lang/en/rating.php
+++ b/lang/en/rating.php
@@ -43,6 +43,10 @@
 $string['allratingsforitem'] = 'All submitted ratings';
 $string['capabilitychecknotavailable'] = 'Capability check not available until activity is saved';
 $string['couldnotdeleteratings'] = 'Sorry, that cannot be deleted as people have already rated it';
+$string['duedateevent'] = 'Add rating due date to calendar';
+$string['duedateevent_help'] = 'If this is checked, an event will be added to the calendar indicating due date of the rating.';
+$string['duedateeventname'] = 'Rating due date';
+$string['duedateeventtype'] = 'rating close';
 $string['norate'] = 'Rating of items not allowed!';
 $string['noratings'] = 'No ratings submitted';
 $string['noviewanyrate'] = 'You can only look at results for items that you made';
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index d16c1b4..16d5507 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -27,6 +27,7 @@
 require_once($CFG->libdir.'/filelib.php');
 require_once($CFG->libdir.'/eventslib.php');
 require_once($CFG->dirroot.'/user/selector/lib.php');
+require_once($CFG->dirroot.'/calendar/lib.php');
 
 /// CONSTANTS ///////////////////////////////////////////////////////////
 
@@ -72,6 +73,14 @@ function forum_add_instance($forum, $mform) {
     }
 
     $forum->id = $DB->insert_record('forum', $forum);
+
+    // adds a new due date rating event, if user is willing to.
+    if (!empty($forum->assessed) and !empty($forum->ratingtime)) {
+        if (!empty($forum->addduedateevent) and $forum->addduedateevent == 1) {
+            forum_add_rating_event($forum);
+        }
+    }
+    
     $modcontext = get_context_instance(CONTEXT_MODULE, $forum->coursemodule);
 
     if ($forum->type == 'single') {  // Create related discussion.
@@ -145,6 +154,18 @@ function forum_update_instance($forum, $mform) {
 
     $oldforum = $DB->get_record('forum', array('id'=>$forum->id));
 
+    // removes any old rating due date calendar events regarding this forum.
+    if (empty($forum->assessed) or empty($forum->ratingtime)) {
+        forum_delete_rating_event($forum);
+    } else {
+        // is user going to add a event
+        if (!empty($forum->addduedateevent) and $forum->addduedateevent == 1) {
+            forum_add_rating_event($forum);
+        } else {  // is user going to remove the event
+            forum_delete_rating_event($forum);
+        }
+    }
+    
     // MDL-3942 - if the aggregation type or scale (i.e. max grade) changes then recalculate the grades for the entire forum
     // if  scale changes - do we need to recheck the ratings, if ratings higher than scale how do we want to respond?
     // for count and sum aggregation types the grade we check to make sure they do not exceed the scale (i.e. max score) when calculating the grade
@@ -236,6 +257,9 @@ function forum_delete_instance($id) {
     if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
         return false;
     }
+    
+    // deletes any rating due date events from calendar.
+    forum_delete_rating_event($forum);
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -1705,6 +1729,21 @@ function forum_scale_used_anywhere($scaleid) {
 // SQL FUNCTIONS ///////////////////////////////////////////////////////////
 
 /**
+ * Get any corresponding rating event(s) for the given forum
+ * instance.
+ * 
+ * @param int $courseid course id of the forum
+ * @param int $forumid forum instance id
+ * @return event database record
+ */
+function forum_get_rating_event($courseid, $forumid) {
+    global $CFG, $DB;
+    
+    return $DB->get_record("event", array("courseid" => "$courseid", "modulename" => "forum",
+                                          "instance" => "$forumid", "eventtype" => get_string("duedateeventtype", "rating")));
+}
+
+/**
  * Gets a post with all info ready for forum_print_post
  * Most of these joins are just to get the forum id
  *
@@ -2914,6 +2953,54 @@ function forum_subscribed_users($course, $forum, $groupid=0, $context = null, $f
 
 // OTHER FUNCTIONS ///////////////////////////////////////////////////////////
 
+/**
+ * Deletes any rating related events from the calendar for
+ * the given forum instance.
+ * 
+ * @param object $forum forum instance
+ */
+function forum_delete_rating_event($forum) {
+    $rec = forum_get_rating_event($forum->course, $forum->id);
+    
+    if (!empty($rec)) {
+        $event = calendar_event::load($rec->id);
+        $event->delete();
+    }
+}
+
+/**
+ * Generates an event which can be included in the calendar.
+ * 
+ * @param object $forum forum instance
+ * @return an event instance
+ */
+function forum_add_rating_event($forum) {
+    $rec = forum_get_rating_event($forum->course, $forum->id);
+    
+    // event is already exist in the calendar, so don't add it
+    if (!empty($rec)) {
+        return null;
+    }
+    
+    $event = new stdClass;
+    
+    $event->name = get_string('duedateeventname', 'rating').' for '.$forum->name;
+    $event->description = $forum->intro;
+    $event->courseid = $forum->course;
+    $event->groupid = 0;
+    $event->userid = 0;
+    $event->modulename = 'forum';
+    $event->instance = $forum->id;
+    $event->eventtype = get_string("duedateeventtype", "rating");
+    $event->timestart = $forum->assesstimefinish;
+    $event->visible = instance_is_visible('forum', $forum);
+    $event->timeduration = 0;
+    
+    // add the event to calendar.
+    calendar_event::create($event);
+    
+    return $event;
+}
 
 /**
  * @global object