original_string: public function next_user() {
          if (!$this->users_rs) {
              return false; // no users present
          }
  
          if (!$this->users_rs->valid()) {
              if ($current = $this->_pop()) {
                  // this is not good - user or grades updated between the two reads above :-(
              }
  
              return false; // no more users
          } else {
              $user = $this->users_rs->current();
              $this->users_rs->next();
          }
  
          // find grades of this user
          $grade_records = array();
          while (true) {
              if (!$current = $this->_pop()) {
                  break; // no more grades
              }
  
              if (empty($current->userid)) {
                  break;
              }
  
              if ($current->userid != $user->id) {
                  // grade of the next user, we have all for this user
                  $this->_push($current);
                  break;
              }
  
              $grade_records[$current->itemid] = $current;
          }
  
          $grades = array();
          $feedbacks = array();
  
          if (!empty($this->grade_items)) {
              foreach ($this->grade_items as $grade_item) {
                  if (!isset($feedbacks[$grade_item->id])) {
                      $feedbacks[$grade_item->id] = new stdClass();
                  }
                  if (array_key_exists($grade_item->id, $grade_records)) {
                      $feedbacks[$grade_item->id]->feedback       = $grade_records[$grade_item->id]->feedback;
                      $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat;
                      unset($grade_records[$grade_item->id]->feedback);
                      unset($grade_records[$grade_item->id]->feedbackformat);
                      $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false);
                  } else {
                      $feedbacks[$grade_item->id]->feedback       = '';
                      $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE;
                      $grades[$grade_item->id] =
                          new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false);
                  }
                  $grades[$grade_item->id]->grade_item = $grade_item;
              }
          }
  
          // Set user suspended status.
          $user->suspendedenrolment = isset($this->suspendedusers[$user->id]);
          $result = new stdClass();
          $result->user      = $user;
          $result->grades    = $grades;
          $result->feedbacks = $feedbacks;
          return $result;
      }
code: public function next_user() {
          if (!$this->users_rs) {
              return false; // no users present
          }
  
          if (!$this->users_rs->valid()) {
              if ($current = $this->_pop()) {
                  // this is not good - user or grades updated between the two reads above :-(
              }
  
              return false; // no more users
          } else {
              $user = $this->users_rs->current();
              $this->users_rs->next();
          }
  
          // find grades of this user
          $grade_records = array();
          while (true) {
              if (!$current = $this->_pop()) {
                  break; // no more grades
              }
  
              if (empty($current->userid)) {
                  break;
              }
  
              if ($current->userid != $user->id) {
                  // grade of the next user, we have all for this user
                  $this->_push($current);
                  break;
              }
  
              $grade_records[$current->itemid] = $current;
          }
  
          $grades = array();
          $feedbacks = array();
  
          if (!empty($this->grade_items)) {
              foreach ($this->grade_items as $grade_item) {
                  if (!isset($feedbacks[$grade_item->id])) {
                      $feedbacks[$grade_item->id] = new stdClass();
                  }
                  if (array_key_exists($grade_item->id, $grade_records)) {
                      $feedbacks[$grade_item->id]->feedback       = $grade_records[$grade_item->id]->feedback;
                      $feedbacks[$grade_item->id]->feedbackformat = $grade_records[$grade_item->id]->feedbackformat;
                      unset($grade_records[$grade_item->id]->feedback);
                      unset($grade_records[$grade_item->id]->feedbackformat);
                      $grades[$grade_item->id] = new grade_grade($grade_records[$grade_item->id], false);
                  } else {
                      $feedbacks[$grade_item->id]->feedback       = '';
                      $feedbacks[$grade_item->id]->feedbackformat = FORMAT_MOODLE;
                      $grades[$grade_item->id] =
                          new grade_grade(array('userid'=>$user->id, 'itemid'=>$grade_item->id), false);
                  }
                  $grades[$grade_item->id]->grade_item = $grade_item;
              }
          }
  
          // Set user suspended status.
          $user->suspendedenrolment = isset($this->suspendedusers[$user->id]);
          $result = new stdClass();
          $result->user      = $user;
          $result->grades    = $grades;
          $result->feedbacks = $feedbacks;
          return $result;
      }
code_tokens: public function next_user ( ) { if ( ! $ this -> users_rs ) { return false ; // no users present } if ( ! $ this -> users_rs -> valid ( ) ) { if ( $ current = $ this -> _pop ( ) ) { // this is not good - user or grades updated between the two reads above :-( } return false ; // no more users } else { $ user = $ this -> users_rs -> current ( ) ; $ this -> users_rs -> next ( ) ; } // find grades of this user $ grade_records = array ( ) ; while ( true ) { if ( ! $ current = $ this -> _pop ( ) ) { break ; // no more grades } if ( empty ( $ current -> userid ) ) { break ; } if ( $ current -> userid != $ user -> id ) { // grade of the next user, we have all for this user $ this -> _push ( $ current ) ; break ; } $ grade_records [ $ current -> itemid ] = $ current ; } $ grades = array ( ) ; $ feedbacks = array ( ) ; if ( ! empty ( $ this -> grade_items ) ) { foreach ( $ this -> grade_items as $ grade_item ) { if ( ! isset ( $ feedbacks [ $ grade_item -> id ] ) ) { $ feedbacks [ $ grade_item -> id ] = new stdClass ( ) ; } if ( array_key_exists ( $ grade_item -> id , $ grade_records ) ) { $ feedbacks [ $ grade_item -> id ] -> feedback = $ grade_records [ $ grade_item -> id ] -> feedback ; $ feedbacks [ $ grade_item -> id ] -> feedbackformat = $ grade_records [ $ grade_item -> id ] -> feedbackformat ; unset ( $ grade_records [ $ grade_item -> id ] -> feedback ) ; unset ( $ grade_records [ $ grade_item -> id ] -> feedbackformat ) ; $ grades [ $ grade_item -> id ] = new grade_grade ( $ grade_records [ $ grade_item -> id ] , false ) ; } else { $ feedbacks [ $ grade_item -> id ] -> feedback = '' ; $ feedbacks [ $ grade_item -> id ] -> feedbackformat = FORMAT_MOODLE ; $ grades [ $ grade_item -> id ] = new grade_grade ( array ( 'userid' => $ user -> id , 'itemid' => $ grade_item -> id ) , false ) ; } $ grades [ $ grade_item -> id ] -> grade_item = $ grade_item ; } } // Set user suspended status. $ user -> suspendedenrolment = isset ( $ this -> suspendedusers [ $ user -> id ] ) ; $ result = new stdClass ( ) ; $ result -> user = $ user ; $ result -> grades = $ grades ; $ result -> feedbacks = $ feedbacks ; return $ result ; }
docstring: Returns information about the next user
  @return mixed array of user info, all grades and feedback or null when no more users found
docstring_tokens: Returns information about the next user