original_string: public function move_item_left($id) {
          global $DB;
  
          $item = $this->find_item($id);
          if (!isset($item->parentlist->parentitem->parentlist)) {
              print_error('listcantmoveleft');
          } else {
              $newpeers = $this->get_items_peers($item->parentlist->parentitem->id);
              if (isset($item->parentlist->parentitem->parentlist->parentitem)) {
                  $newparent = $item->parentlist->parentitem->parentlist->parentitem->id;
              } else {
                  $newparent = $this->get_top_level_parent_id($item);
              }
              $DB->set_field($this->table, "parent", $newparent, array("id"=>$item->id));
              $oldparentkey = array_search($item->parentlist->parentitem->id, $newpeers);
              $neworder = array_merge(array_slice($newpeers, 0, $oldparentkey+1), array($item->id), array_slice($newpeers, $oldparentkey+1));
              $this->reorder_peers($neworder);
          }
          return $item->parentlist->parentitem;
      }
code: public function move_item_left($id) {
          global $DB;
  
          $item = $this->find_item($id);
          if (!isset($item->parentlist->parentitem->parentlist)) {
              print_error('listcantmoveleft');
          } else {
              $newpeers = $this->get_items_peers($item->parentlist->parentitem->id);
              if (isset($item->parentlist->parentitem->parentlist->parentitem)) {
                  $newparent = $item->parentlist->parentitem->parentlist->parentitem->id;
              } else {
                  $newparent = $this->get_top_level_parent_id($item);
              }
              $DB->set_field($this->table, "parent", $newparent, array("id"=>$item->id));
              $oldparentkey = array_search($item->parentlist->parentitem->id, $newpeers);
              $neworder = array_merge(array_slice($newpeers, 0, $oldparentkey+1), array($item->id), array_slice($newpeers, $oldparentkey+1));
              $this->reorder_peers($neworder);
          }
          return $item->parentlist->parentitem;
      }
code_tokens: public function move_item_left ( $ id ) { global $ DB ; $ item = $ this -> find_item ( $ id ) ; if ( ! isset ( $ item -> parentlist -> parentitem -> parentlist ) ) { print_error ( 'listcantmoveleft' ) ; } else { $ newpeers = $ this -> get_items_peers ( $ item -> parentlist -> parentitem -> id ) ; if ( isset ( $ item -> parentlist -> parentitem -> parentlist -> parentitem ) ) { $ newparent = $ item -> parentlist -> parentitem -> parentlist -> parentitem -> id ; } else { $ newparent = $ this -> get_top_level_parent_id ( $ item ) ; } $ DB -> set_field ( $ this -> table , "parent" , $ newparent , array ( "id" => $ item -> id ) ) ; $ oldparentkey = array_search ( $ item -> parentlist -> parentitem -> id , $ newpeers ) ; $ neworder = array_merge ( array_slice ( $ newpeers , 0 , $ oldparentkey + 1 ) , array ( $ item -> id ) , array_slice ( $ newpeers , $ oldparentkey + 1 ) ) ; $ this -> reorder_peers ( $ neworder ) ; } return $ item -> parentlist -> parentitem ; }
docstring: Moves the item one step up in the tree.
  
  @param int $id an item index.
  @return list_item the item that used to be the parent of the item moved.
docstring_tokens: Moves the item one step up in the tree .