original_string: protected function import_new_grade_item($header, $key, $value) {
          global $DB, $USER;
  
          // First check if header is already in temp database.
          if (empty($this->newgradeitems[$key])) {
  
              $newgradeitem = new stdClass();
              $newgradeitem->itemname = $header[$key];
              $newgradeitem->importcode = $this->importcode;
              $newgradeitem->importer = $USER->id;
  
              // Insert into new grade item buffer.
              $this->newgradeitems[$key] = $DB->insert_record('grade_import_newitem', $newgradeitem);
          }
          $newgrade = new stdClass();
          $newgrade->newgradeitem = $this->newgradeitems[$key];
  
          $trimmed = trim($value);
          if ($trimmed === '' or $trimmed == '-') {
              // Blank or dash grade means null, ie "no grade".
              $newgrade->finalgrade = null;
          } else {
              // We have an actual grade.
              $newgrade->finalgrade = $value;
          }
          $this->newgrades[] = $newgrade;
          return $newgrade;
      }
code: protected function import_new_grade_item($header, $key, $value) {
          global $DB, $USER;
  
          // First check if header is already in temp database.
          if (empty($this->newgradeitems[$key])) {
  
              $newgradeitem = new stdClass();
              $newgradeitem->itemname = $header[$key];
              $newgradeitem->importcode = $this->importcode;
              $newgradeitem->importer = $USER->id;
  
              // Insert into new grade item buffer.
              $this->newgradeitems[$key] = $DB->insert_record('grade_import_newitem', $newgradeitem);
          }
          $newgrade = new stdClass();
          $newgrade->newgradeitem = $this->newgradeitems[$key];
  
          $trimmed = trim($value);
          if ($trimmed === '' or $trimmed == '-') {
              // Blank or dash grade means null, ie "no grade".
              $newgrade->finalgrade = null;
          } else {
              // We have an actual grade.
              $newgrade->finalgrade = $value;
          }
          $this->newgrades[] = $newgrade;
          return $newgrade;
      }
code_tokens: protected function import_new_grade_item ( $ header , $ key , $ value ) { global $ DB , $ USER ; // First check if header is already in temp database. if ( empty ( $ this -> newgradeitems [ $ key ] ) ) { $ newgradeitem = new stdClass ( ) ; $ newgradeitem -> itemname = $ header [ $ key ] ; $ newgradeitem -> importcode = $ this -> importcode ; $ newgradeitem -> importer = $ USER -> id ; // Insert into new grade item buffer. $ this -> newgradeitems [ $ key ] = $ DB -> insert_record ( 'grade_import_newitem' , $ newgradeitem ) ; } $ newgrade = new stdClass ( ) ; $ newgrade -> newgradeitem = $ this -> newgradeitems [ $ key ] ; $ trimmed = trim ( $ value ) ; if ( $ trimmed === '' or $ trimmed == '-' ) { // Blank or dash grade means null, ie "no grade". $ newgrade -> finalgrade = null ; } else { // We have an actual grade. $ newgrade -> finalgrade = $ value ; } $ this -> newgrades [ ] = $ newgrade ; return $ newgrade ; }
docstring: Insert the new grade into the grade item buffer table.
  
  @param array $header The column headers from the CSV file.
  @param int $key Current row identifier.
  @param string $value The value for this row (final grade).
  @return stdClass new grade that is ready for commiting to the gradebook.
docstring_tokens: Insert the new grade into the grade item buffer table .