original_string: public function get_items($hasvalueonly = false) {
          global $DB;
          if ($this->allitems === null) {
              if ($this->templateid) {
                  $this->allitems = $DB->get_records('feedback_item', ['template' => $this->templateid], 'position');
              } else {
                  $this->allitems = $DB->get_records('feedback_item', ['feedback' => $this->feedback->id], 'position');
              }
              $idx = 1;
              foreach ($this->allitems as $id => $item) {
                  $this->allitems[$id]->itemnr = $item->hasvalue ? ($idx++) : null;
              }
          }
          if ($hasvalueonly && $this->allitems) {
              return array_filter($this->allitems, function($item) {
                  return $item->hasvalue;
              });
          }
          return $this->allitems;
      }
code: public function get_items($hasvalueonly = false) {
          global $DB;
          if ($this->allitems === null) {
              if ($this->templateid) {
                  $this->allitems = $DB->get_records('feedback_item', ['template' => $this->templateid], 'position');
              } else {
                  $this->allitems = $DB->get_records('feedback_item', ['feedback' => $this->feedback->id], 'position');
              }
              $idx = 1;
              foreach ($this->allitems as $id => $item) {
                  $this->allitems[$id]->itemnr = $item->hasvalue ? ($idx++) : null;
              }
          }
          if ($hasvalueonly && $this->allitems) {
              return array_filter($this->allitems, function($item) {
                  return $item->hasvalue;
              });
          }
          return $this->allitems;
      }
code_tokens: public function get_items ( $ hasvalueonly = false ) { global $ DB ; if ( $ this -> allitems === null ) { if ( $ this -> templateid ) { $ this -> allitems = $ DB -> get_records ( 'feedback_item' , [ 'template' => $ this -> templateid ] , 'position' ) ; } else { $ this -> allitems = $ DB -> get_records ( 'feedback_item' , [ 'feedback' => $ this -> feedback -> id ] , 'position' ) ; } $ idx = 1 ; foreach ( $ this -> allitems as $ id => $ item ) { $ this -> allitems [ $ id ] -> itemnr = $ item -> hasvalue ? ( $ idx ++ ) : null ; } } if ( $ hasvalueonly && $ this -> allitems ) { return array_filter ( $ this -> allitems , function ( $ item ) { return $ item -> hasvalue ; } ) ; } return $ this -> allitems ; }
docstring: Get all items in this feedback or this template
  @param bool $hasvalueonly only count items with a value.
  @return array of objects from feedback_item with an additional attribute 'itemnr'
docstring_tokens: Get all items in this feedback or this template