original_string: public function repaginate_slots($nextslotnumber, $type) {
          global $DB;
          $this->slots = $DB->get_records('quiz_slots', array('quizid' => $this->quizid), 'slot');
          $nextslot = null;
          $newslots = array();
          foreach ($this->slots as $slot) {
              if ($slot->slot < $nextslotnumber) {
                  $newslots[$slot->id] = $slot;
              } else if ($slot->slot == $nextslotnumber) {
                  $nextslot = $this->repaginate_next_slot($nextslotnumber, $type);
  
                  // Update DB.
                  $DB->update_record('quiz_slots', $nextslot, true);
  
                  // Update returning object.
                  $newslots[$slot->id] = $nextslot;
              }
          }
          if ($nextslot) {
              $newslots = array_merge($newslots, $this->repaginate_the_rest($this->slots, $nextslotnumber, $type));
              $this->slots = $this->get_slots_by_slotid($newslots);
          }
      }
code: public function repaginate_slots($nextslotnumber, $type) {
          global $DB;
          $this->slots = $DB->get_records('quiz_slots', array('quizid' => $this->quizid), 'slot');
          $nextslot = null;
          $newslots = array();
          foreach ($this->slots as $slot) {
              if ($slot->slot < $nextslotnumber) {
                  $newslots[$slot->id] = $slot;
              } else if ($slot->slot == $nextslotnumber) {
                  $nextslot = $this->repaginate_next_slot($nextslotnumber, $type);
  
                  // Update DB.
                  $DB->update_record('quiz_slots', $nextslot, true);
  
                  // Update returning object.
                  $newslots[$slot->id] = $nextslot;
              }
          }
          if ($nextslot) {
              $newslots = array_merge($newslots, $this->repaginate_the_rest($this->slots, $nextslotnumber, $type));
              $this->slots = $this->get_slots_by_slotid($newslots);
          }
      }
code_tokens: public function repaginate_slots ( $ nextslotnumber , $ type ) { global $ DB ; $ this -> slots = $ DB -> get_records ( 'quiz_slots' , array ( 'quizid' => $ this -> quizid ) , 'slot' ) ; $ nextslot = null ; $ newslots = array ( ) ; foreach ( $ this -> slots as $ slot ) { if ( $ slot -> slot < $ nextslotnumber ) { $ newslots [ $ slot -> id ] = $ slot ; } else if ( $ slot -> slot == $ nextslotnumber ) { $ nextslot = $ this -> repaginate_next_slot ( $ nextslotnumber , $ type ) ; // Update DB. $ DB -> update_record ( 'quiz_slots' , $ nextslot , true ) ; // Update returning object. $ newslots [ $ slot -> id ] = $ nextslot ; } } if ( $ nextslot ) { $ newslots = array_merge ( $ newslots , $ this -> repaginate_the_rest ( $ this -> slots , $ nextslotnumber , $ type ) ) ; $ this -> slots = $ this -> get_slots_by_slotid ( $ newslots ) ; } }
docstring: Repaginate, update DB and slots object
  @param int $nextslotnumber
  @param int $type repaginate::LINK or repaginate::UNLINK.
docstring_tokens: Repaginate update DB and slots object