public function add_idnumber($idnumber) {
        global $DB;
        if (!empty($this->idnumber)) {
            return false;
        }

        if ($this->itemtype == 'mod' and !$this->is_outcome_item()) {
            if ($this->itemnumber == 0) {
                // for activity modules, itemnumber 0 is synced with the course_modules
                if (!$cm = get_coursemodule_from_instance($this->itemmodule, $this->iteminstance, $this->courseid)) {
                    return false;
                }
                if (!empty($cm->idnumber)) {
                    return false;
                }
                $DB->set_field('course_modules', 'idnumber', $idnumber, array('id' => $cm->id));
                $this->idnumber = $idnumber;
                return $this->update();
            } else {
                $this->idnumber = $idnumber;
                return $this->update();
            }

        } else {
            $this->idnumber = $idnumber;
            return $this->update();
        }
    }