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

grade_update_outcomes() never returns a value (+ fix)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.9
    • Fix Version/s: 1.9.10
    • Component/s: Gradebook
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      This makes it very difficult to develop extensions that save outcomes to the gradebook as it is impossible to know if the save has occurred properly.

      here's a working version:

      function grade_update_outcomes($source, $courseid, $itemtype, $itemmodule, $iteminstance, $userid, $data) {
          if ($items = grade_item::fetch_all(array('itemtype'=>$itemtype, 'itemmodule'=>$itemmodule, 'iteminstance'=>$iteminstance, 'courseid'=>$courseid))) {
              $errors = false;
              foreach ($items as $item) {
                  if (!array_key_exists($item->itemnumber, $data)) {
                      continue;
                  }
                  $grade = $data[$item->itemnumber] < 1 ? null : $data[$item->itemnumber];
                  $errors = ($item->update_final_grade($userid, $grade, $source)) ? $errors : true;
              }
              return $errors;
          }
          return false;
      }

        Attachments

          Activity

            People

            • Assignee:
              andyjdavis Andrew Davis
              Reporter:
              mattgibson Matt Gibson
              Tester:
              Nobody
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                25/Oct/10