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

Trigger event on grade update

    XMLWordPrintable

Details

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

    Description

      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...

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kepeter Peter Eliyahu Kornfeld
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: