original_string: protected function getRoundsListAndSetDefault()
      {
          $model  = $this->getModel();
          $output = array();
          $select = $this->getRoundSelect();
  
          if ($select instanceof \Zend_Db_Select) {
              $rows = $this->db->fetchAll($select);
          } else {
              $rows = $select;
          }
  
          if ($rows) {
  
              // Initial values
              $maxAnswered      = 0;
              $maxGroupAnswered = 0;
              $minGroup         = -1;
  
              foreach ($rows as $row) {
                  $output[$row['round_order']] = $row['round_description'];
  
                  if ($row['has_group']) {
                      if (-1 === $minGroup) {
                          $minGroup = $row['round_order'];
                      }
                      if ($row['group_answered']) {
                          $maxGroupAnswered = $row['round_order'];
                      }
                  }
                  if ($row['any_answered']) {
                      $maxAnswered = $row['round_order'];
                  }
              }
              if ($maxGroupAnswered) {
                  $this->defaultRound = $maxGroupAnswered;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('The last round containing answers for surveys in the same user group is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } elseif ($maxAnswered) {
                  $this->defaultRound = $maxAnswered;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('The last round containing answers is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } elseif (-1 !== $minGroup) {
                  $this->defaultRound = $minGroup;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('No survey has been answered, the first round with surveys in the same user group is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } else {
                  reset($output);
                  $this->defaultRound = key($output);
                  $model->set('gto_round_order',
                          'description', $this->_('No surveys have answers, nor are any in the same user group.')
                          );
              }
  
          } else {
              $output[10] = $this->_('Added survey');
              $this->defaultRound = 10;
              $model->set('gto_round_order',
                      'description', $this->_('No current rounds available.')
                      );
          }
  
          return $output;
      }
code: protected function getRoundsListAndSetDefault()
      {
          $model  = $this->getModel();
          $output = array();
          $select = $this->getRoundSelect();
  
          if ($select instanceof \Zend_Db_Select) {
              $rows = $this->db->fetchAll($select);
          } else {
              $rows = $select;
          }
  
          if ($rows) {
  
              // Initial values
              $maxAnswered      = 0;
              $maxGroupAnswered = 0;
              $minGroup         = -1;
  
              foreach ($rows as $row) {
                  $output[$row['round_order']] = $row['round_description'];
  
                  if ($row['has_group']) {
                      if (-1 === $minGroup) {
                          $minGroup = $row['round_order'];
                      }
                      if ($row['group_answered']) {
                          $maxGroupAnswered = $row['round_order'];
                      }
                  }
                  if ($row['any_answered']) {
                      $maxAnswered = $row['round_order'];
                  }
              }
              if ($maxGroupAnswered) {
                  $this->defaultRound = $maxGroupAnswered;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('The last round containing answers for surveys in the same user group is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } elseif ($maxAnswered) {
                  $this->defaultRound = $maxAnswered;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('The last round containing answers is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } elseif (-1 !== $minGroup) {
                  $this->defaultRound = $minGroup;
                  $model->set('gto_round_order', 'description', sprintf(
                          $this->_('No survey has been answered, the first round with surveys in the same user group is "%s".'),
                          $output[$this->defaultRound]
                          ));
  
              } else {
                  reset($output);
                  $this->defaultRound = key($output);
                  $model->set('gto_round_order',
                          'description', $this->_('No surveys have answers, nor are any in the same user group.')
                          );
              }
  
          } else {
              $output[10] = $this->_('Added survey');
              $this->defaultRound = 10;
              $model->set('gto_round_order',
                      'description', $this->_('No current rounds available.')
                      );
          }
  
          return $output;
      }
code_tokens: protected function getRoundsListAndSetDefault ( ) { $ model = $ this -> getModel ( ) ; $ output = array ( ) ; $ select = $ this -> getRoundSelect ( ) ; if ( $ select instanceof \ Zend_Db_Select ) { $ rows = $ this -> db -> fetchAll ( $ select ) ; } else { $ rows = $ select ; } if ( $ rows ) { // Initial values $ maxAnswered = 0 ; $ maxGroupAnswered = 0 ; $ minGroup = - 1 ; foreach ( $ rows as $ row ) { $ output [ $ row [ 'round_order' ] ] = $ row [ 'round_description' ] ; if ( $ row [ 'has_group' ] ) { if ( - 1 === $ minGroup ) { $ minGroup = $ row [ 'round_order' ] ; } if ( $ row [ 'group_answered' ] ) { $ maxGroupAnswered = $ row [ 'round_order' ] ; } } if ( $ row [ 'any_answered' ] ) { $ maxAnswered = $ row [ 'round_order' ] ; } } if ( $ maxGroupAnswered ) { $ this -> defaultRound = $ maxGroupAnswered ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'The last round containing answers for surveys in the same user group is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } elseif ( $ maxAnswered ) { $ this -> defaultRound = $ maxAnswered ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'The last round containing answers is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } elseif ( - 1 !== $ minGroup ) { $ this -> defaultRound = $ minGroup ; $ model -> set ( 'gto_round_order' , 'description' , sprintf ( $ this -> _ ( 'No survey has been answered, the first round with surveys in the same user group is "%s".' ) , $ output [ $ this -> defaultRound ] ) ) ; } else { reset ( $ output ) ; $ this -> defaultRound = key ( $ output ) ; $ model -> set ( 'gto_round_order' , 'description' , $ this -> _ ( 'No surveys have answers, nor are any in the same user group.' ) ) ; } } else { $ output [ 10 ] = $ this -> _ ( 'Added survey' ) ; $ this -> defaultRound = 10 ; $ model -> set ( 'gto_round_order' , 'description' , $ this -> _ ( 'No current rounds available.' ) ) ; } return $ output ; }
docstring: Get the list of rounds and set the default
  
  @return array [roundInsertNr => RoundDescription
docstring_tokens: Get the list of rounds and set the default