Merge branch 'MDL-32860_user_iterator' of git://github.com/andyjdavis/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 28 May 2012 06:56:48 +0000 (14:56 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 28 May 2012 06:56:48 +0000 (14:56 +0800)
1  2 
grade/lib.php

diff --cc grade/lib.php
@@@ -32,22 -32,57 +32,62 @@@ require_once $CFG->libdir.'/gradelib.ph
   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
   */
  class graded_users_iterator {
-     public $course;
-     public $grade_items;
-     public $groupid;
-     public $users_rs;
-     public $grades_rs;
-     public $gradestack;
-     public $sortfield1;
-     public $sortorder1;
-     public $sortfield2;
-     public $sortorder2;
+     /**
+      * The couse whose users we are interested in
+      */
+     protected $course;
+     /**
+      * An array of grade items or null if only user data was requested
+      */
+     protected $grade_items;
+     /**
+      * The group ID we are interested in. 0 means all groups.
+      */
+     protected $groupid;
+     /**
+      * A recordset of graded users
+      */
+     protected $users_rs;
+     /**
+      * A recordset of user grades (grade_grade instances)
+      */
+     protected $grades_rs;
+     /**
+      * Array used when moving to next user while iterating through the grades recordset
+      */
+     protected $gradestack;
+     /**
+      * The first field of the users table by which the array of users will be sorted
+      */
+     protected $sortfield1;
+     /**
+      * Should sortfield1 be ASC or DESC
+      */
+     protected $sortorder1;
+     /**
+      * The second field of the users table by which the array of users will be sorted
+      */
+     protected $sortfield2;
+     /**
+      * Should sortfield2 be ASC or DESC
+      */
+     protected $sortorder2;
  
 +    /**
 +     * Should users whose enrolment has been suspended be ignored?
 +     */
 +    protected $onlyactive = false;
 +
      /**
       * Constructor
       *
          $this->gradestack = array();
      }
  
 +    /**
 +     * Should all enrolled users be exported or just those with an active enrolment?
 +     *
 +     * @param bool $onlyactive True to limit the export to users with an active enrolment
 +     */
 +    public function require_active_enrolment($onlyactive = true) {
 +        if (!empty($this->users_rs)) {
 +            debugging('Calling require_active_enrolment() has no effect unless you call init() again', DEBUG_DEVELOPER);
 +        }
 +        $this->onlyactive  = $onlyactive;
 +    }
 +
  
      /**
-      * _push
+      * Add a grade_grade instance to the grade stack
       *
       * @param grade_grade $grade Grade object
       *