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;
    }