original_string: public function refresh_page_numbers($slots = array()) {
          global $DB;
          // Get slots ordered by page then slot.
          if (!count($slots)) {
              $slots = $DB->get_records('quiz_slots', array('quizid' => $this->get_quizid()), 'slot, page');
          }
  
          // Loop slots. Start Page number at 1 and increment as required.
          $pagenumbers = array('new' => 0, 'old' => 0);
  
          foreach ($slots as $slot) {
              if ($slot->page !== $pagenumbers['old']) {
                  $pagenumbers['old'] = $slot->page;
                  ++$pagenumbers['new'];
              }
  
              if ($pagenumbers['new'] == $slot->page) {
                  continue;
              }
              $slot->page = $pagenumbers['new'];
          }
  
          return $slots;
      }
code: public function refresh_page_numbers($slots = array()) {
          global $DB;
          // Get slots ordered by page then slot.
          if (!count($slots)) {
              $slots = $DB->get_records('quiz_slots', array('quizid' => $this->get_quizid()), 'slot, page');
          }
  
          // Loop slots. Start Page number at 1 and increment as required.
          $pagenumbers = array('new' => 0, 'old' => 0);
  
          foreach ($slots as $slot) {
              if ($slot->page !== $pagenumbers['old']) {
                  $pagenumbers['old'] = $slot->page;
                  ++$pagenumbers['new'];
              }
  
              if ($pagenumbers['new'] == $slot->page) {
                  continue;
              }
              $slot->page = $pagenumbers['new'];
          }
  
          return $slots;
      }
code_tokens: public function refresh_page_numbers ( $ slots = array ( ) ) { global $ DB ; // Get slots ordered by page then slot. if ( ! count ( $ slots ) ) { $ slots = $ DB -> get_records ( 'quiz_slots' , array ( 'quizid' => $ this -> get_quizid ( ) ) , 'slot, page' ) ; } // Loop slots. Start Page number at 1 and increment as required. $ pagenumbers = array ( 'new' => 0 , 'old' => 0 ) ; foreach ( $ slots as $ slot ) { if ( $ slot -> page !== $ pagenumbers [ 'old' ] ) { $ pagenumbers [ 'old' ] = $ slot -> page ; ++ $ pagenumbers [ 'new' ] ; } if ( $ pagenumbers [ 'new' ] == $ slot -> page ) { continue ; } $ slot -> page = $ pagenumbers [ 'new' ] ; } return $ slots ; }
docstring: Refresh page numbering of quiz slots.
  @param \stdClass[] $slots (optional) array of slot objects.
  @return \stdClass[] array of slot objects.
docstring_tokens: Refresh page numbering of quiz slots .