Example #1
0
 /**
  * Get the next row of data from the csv file (only the columns we care about)
  *
  * @return stdClass or false The stdClass is an object containing user, grade and lastmodified
  */
 public function next()
 {
     global $DB;
     $result = new stdClass();
     while ($record = $this->csvreader->next()) {
         $idstr = $record[$this->idindex];
         // Strip the integer from the end of the participant string.
         $id = substr($idstr, strlen(get_string('hiddenuser', 'assign')));
         if ($userid = $this->assignment->get_user_id_for_uniqueid($id)) {
             if (array_key_exists($userid, $this->validusers)) {
                 $result->grade = $record[$this->gradeindex];
                 $result->modified = strtotime($record[$this->modifiedindex]);
                 $result->user = $this->validusers[$userid];
                 $result->feedback = array();
                 foreach ($this->feedbackcolumnindexes as $description => $details) {
                     if (!empty($details['index'])) {
                         $details['value'] = $record[$details['index']];
                         $result->feedback[] = $details;
                     }
                 }
                 return $result;
             }
         }
     }
     // If we got here the csvreader had no more rows.
     return false;
 }