original_string: 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();
          }
      }
code: 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();
          }
      }
code_tokens: 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 ( ) ; } }
docstring: Set idnumber of grade item, updates also course_modules table
  
  @param string $idnumber (without magic quotes)
  @return bool success
docstring_tokens: Set idnumber of grade item updates also course_modules table