/** * Render the edit page * * @param \quiz $quizobj object containing all the quiz settings information. * @param structure $structure object containing the structure of the quiz. * @param \question_edit_contexts $contexts the relevant question bank contexts. * @param \moodle_url $pageurl the canonical URL of this page. * @param array $pagevars the variables from {@link question_edit_setup()}. * @return string HTML to output. */ public function edit_page(\quiz $quizobj, structure $structure, \question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) { $output = ''; // Page title. $output .= $this->heading_with_help(get_string('editingquizx', 'quiz', format_string($quizobj->get_quiz_name())), 'editingquiz', 'quiz', '', get_string('basicideasofquiz', 'quiz'), 2); // Information at the top. $output .= $this->quiz_state_warnings($structure); $output .= $this->quiz_information($structure); $output .= $this->maximum_grade_input($quizobj->get_quiz(), $this->page->url); $output .= $this->repaginate_button($structure, $pageurl); $output .= $this->total_marks($quizobj->get_quiz()); // Show the questions organised into sections and pages. $output .= $this->start_section_list(); $sections = $structure->get_quiz_sections(); $lastsection = end($sections); foreach ($sections as $section) { $output .= $this->start_section($section); $output .= $this->questions_in_section($structure, $section, $contexts, $pagevars, $pageurl); if ($section === $lastsection) { $output .= \html_writer::start_div('last-add-menu'); $output .= html_writer::tag('span', $this->add_menu_actions($structure, 0, $pageurl, $contexts, $pagevars), array('class' => 'add-menu-outer')); $output .= \html_writer::end_div(); } $output .= $this->end_section(); } $output .= $this->end_section_list(); // Inialise the JavaScript. $this->initialise_editing_javascript($quizobj->get_course(), $quizobj->get_quiz()); // Include the contents of any other popups required. if ($structure->can_be_edited()) { $popups = ''; $popups .= $this->question_bank_loading(); $this->page->requires->yui_module('moodle-mod_quiz-quizquestionbank', 'M.mod_quiz.quizquestionbank.init', array('class' => 'questionbank', 'cmid' => $structure->get_cmid())); $popups .= $this->random_question_form($pageurl, $contexts, $pagevars); $this->page->requires->yui_module('moodle-mod_quiz-randomquestion', 'M.mod_quiz.randomquestion.init'); $output .= html_writer::div($popups, 'mod_quiz_edit_forms'); // Include the question chooser. $output .= $this->question_chooser(); $this->page->requires->yui_module('moodle-mod_quiz-questionchooser', 'M.mod_quiz.init_questionchooser'); } return $output; }