Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-41043

Trigger event on grade update

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 2.5.1
    • Events API, Gradebook
    • None

      In a complex synchronization scenario I had to push new grades from moodle to a web service...
      To achieve it I added some code to /lib/grade/grade_grade.php in the update function like this...

          public function update($source=null) {
              $this->rawgrade    = grade_floatval($this->rawgrade);
              $this->finalgrade  = grade_floatval($this->finalgrade);
              $this->rawgrademin = grade_floatval($this->rawgrademin);
              $this->rawgrademax = grade_floatval($this->rawgrademax);
       
              ////<grades_export event trigger
              $grade_to_update = new stdClass();
       
              $grade_to_update->courseid = $this->grade_item->courseid;
              $grade_to_update->userid = $this->userid;
              $grade_to_update->itemid = $this->grade_item->id;
              $grade_to_update->finalgrade = $this->finalgrade;
       
              events_trigger('grade_changed', $grade_to_update);
              ////>
              
      	return parent::update($source);
          }
      

      This few lines made my life easy (as I was able to add a local plugin to handle this event and call the web service), and I thought that it should be added to the common code-base...

            Unassigned Unassigned
            kepeter Peter Eliyahu Kornfeld
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.