/** * Create an instance of this class representing the structure of a given offlinequiz. * @param \offlinequiz $offlinequizobj the offlinequiz. * @return structure */ public static function create_for_offlinequiz($offlinequizobj) { $structure = self::create(); $structure->offlinequizobj = $offlinequizobj; $structure->populate_structure($offlinequizobj->get_offlinequiz()); return $structure; }
/** * Render the edit grade page * * @param \offlinequiz $offlinequizobj object containing all the offlinequiz settings information. * @param structure $structure object containing the structure of the offlinequiz. * @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_grades_page(\offlinequiz $offlinequizobj, structure $structure, \question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars, array $groupletters) { $offlinequiz = $offlinequizobj->get_offlinequiz(); $output = ''; // Page title. $output .= $this->heading_with_help(get_string('gradingofflinequizx', 'offlinequiz', format_string($offlinequizobj->get_offlinequiz_name())) . ' (' . get_string('group', 'offlinequiz') . ' ' . $groupletters[$offlinequiz->groupnumber] . ') ', 'editingofflinequiz', 'offlinequiz', '', get_string('basicideasofofflinequiz', 'offlinequiz'), 2); ///echo $OUTPUT->heading(get_string('gradingofflinequiz', 'offlinequiz') . ': ' . $offlinequiz->name. ' (' . // get_string('group', 'offlinequiz') . ' ' . $groupletters[$offlinequiz->groupnumber] . ')'); // Information at the top. $output .= $this->offlinequiz_group_selector($offlinequiz, $pageurl); $output .= $this->offlinequiz_information($structure); $output .= html_writer::div('<br/>', 'clear'); $output .= $this->maximum_grade_input($offlinequiz, $this->page->url); $output .= $this->offlinequiz_state_warnings($structure); $output .= $this->total_marks($offlinequiz); $output .= $this->start_grading_form($offlinequiz, $pageurl); // Show the questions organised into sections and pages. $output .= $this->start_section_list(); // Show the questions in one form for single submit. $sections = $structure->get_offlinequiz_sections(); foreach ($sections as $section) { $output .= $this->start_section($section); $questionhtml = ''; foreach ($structure->get_questions_in_section($section->id) as $question) { $questionhtml .= $this->question_row_for_grading($structure, $question, $contexts, $pagevars, $pageurl); } $output .= html_writer::tag('ul', $questionhtml, array('class' => 'section img-text')); $output .= $this->end_section(); } $output .= $this->end_section_list(); $output .= $this->end_grading_form(); return $output; }