Beispiel #1
0
 /**
  * Called from definition_after_data() in the completion mode
  *
  * This will add only items from a current page to the feedback and adjust the buttons
  */
 protected function definition_complete()
 {
     if (!$this->structure instanceof mod_feedback_completion) {
         // We should not really be here but just in case.
         return;
     }
     $pages = $this->structure->get_pages();
     $gopage = $this->gopage;
     $pageitems = $pages[$gopage];
     $hasnextpage = $gopage < count($pages) - 1;
     // Until we complete this page we can not trust get_next_page().
     $hasprevpage = $gopage && $this->structure->get_previous_page($gopage, false) !== null;
     // Add elements.
     foreach ($pageitems as $item) {
         $itemobj = feedback_get_item_class($item->typ);
         $itemobj->complete_form_element($item, $this);
     }
     // Remove invalid buttons (for example, no "previous page" if we are on the first page).
     if (!$hasprevpage) {
         $this->remove_button('gopreviouspage');
     }
     if (!$hasnextpage) {
         $this->remove_button('gonextpage');
     }
     if ($hasnextpage) {
         $this->remove_button('savevalues');
     }
 }