Example #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');
     }
 }
Example #2
0
            if (!isset($SESSION->feedback->is_started) or !$SESSION->feedback->is_started == true) {
                print_error('error', '', $CFG->wwwroot . '/course/view.php?id=' . $course->id);
            }
            $feedbackcompletion->save_response_tmp($data);
            if (!empty($data->savevalues) || !empty($data->gonextpage)) {
                if (($nextpage = $feedbackcompletion->get_next_page($gopage)) !== null) {
                    redirect(new moodle_url($PAGE->url, array('gopage' => $nextpage)));
                } else {
                    $feedbackcompletion->save_response();
                    if (!$feedback->page_after_submit) {
                        \core\notification::success(get_string('entries_saved', 'feedback'));
                    }
                }
            } else {
                if (!empty($data->gopreviouspage)) {
                    $prevpage = $feedbackcompletion->get_previous_page($gopage);
                    redirect(new moodle_url($PAGE->url, array('gopage' => intval($prevpage))));
                }
            }
        }
    }
}
// Print the page header.
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
if ($feedbackcompletion->is_empty()) {
    \core\notification::error(get_string('no_items_available_yet', 'feedback'));
} else {
    if ($cansubmit) {