/** * Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and * (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions * in favour of the usual print_header(), print_header_simple(), print_heading() etc. * !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at * the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN). * * @param int $courseid Course id * @param string $active_type The type of the current page (report, settings, * import, export, scales, outcomes, letters) * @param string $active_plugin The plugin of the current page (grader, fullview etc...) * @param string $heading The heading of the page. Tries to guess if none is given * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function * @param string $bodytags Additional attributes that will be added to the <body> tag * @param string $buttons Additional buttons to display on the page * @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown? * @param string $headerhelpidentifier The help string identifier if required. * @param string $headerhelpcomponent The component for the help string. * @param stdClass $user The user object for use with the user context header. * * @return string HTML code or nothing if $return == false */ function print_grade_page_head($courseid, $active_type, $active_plugin=null, $heading = false, $return=false, $buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null, $user = null) { global $CFG, $OUTPUT, $PAGE; // Put a warning on all gradebook pages if the course has modules currently scheduled for background deletion. require_once($CFG->dirroot . '/course/lib.php'); if (course_modules_pending_deletion($courseid)) { \core\notification::add(get_string('gradesmoduledeletionpendingwarning', 'grades'), \core\output\notification::NOTIFY_WARNING); } if ($active_type === 'preferences') { // In Moodle 2.8 report preferences were moved under 'settings'. Allow backward compatibility for 3rd party grade reports. $active_type = 'settings'; } $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); // Determine the string of the active plugin $stractive_plugin = ($active_plugin) ? $plugin_info['strings']['active_plugin_str'] : $heading; $stractive_type = $plugin_info['strings'][$active_type]; if (empty($plugin_info[$active_type]->id) || !empty($plugin_info[$active_type]->parent)) { $title = $PAGE->course->fullname.': ' . $stractive_type . ': ' . $stractive_plugin; } else { $title = $PAGE->course->fullname.': ' . $stractive_plugin; } if ($active_type == 'report') { $PAGE->set_pagelayout('report'); } else { $PAGE->set_pagelayout('admin'); } $PAGE->set_title(get_string('grades') . ': ' . $stractive_type); $PAGE->set_heading($title); if ($buttons instanceof single_button) { $buttons = $OUTPUT->render($buttons); } $PAGE->set_button($buttons); if ($courseid != SITEID) { grade_extend_settings($plugin_info, $courseid); } // Set the current report as active in the breadcrumbs. if ($active_plugin !== null && $reportnav = $PAGE->settingsnav->find($active_plugin, navigation_node::TYPE_SETTING)) { $reportnav->make_active(); } $returnval = $OUTPUT->header(); if (!$return) { echo $returnval; } // Guess heading if not given explicitly if (!$heading) { $heading = $stractive_plugin; } if ($shownavigation) { $navselector = null; if ($courseid != SITEID && ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) { // It's absolutely essential that this grade plugin selector is shown after the user header. Just ask Fred. $navselector = print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, true); if ($return) { $returnval .= $navselector; } else if (!isset($user)) { echo $navselector; } } $output = ''; // Add a help dialogue box if provided. if (isset($headerhelpidentifier)) { $output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent); } else { if (isset($user)) { $output = $OUTPUT->context_header( array( 'heading' => html_writer::link(new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $courseid)), fullname($user)), 'user' => $user, 'usercontext' => context_user::instance($user->id) ), 2 ) . $navselector; } else { $output = $OUTPUT->heading($heading); } } if ($return) { $returnval .= $output; } else { echo $output; } if ($courseid != SITEID && ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS)) { $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return); } } $returnval .= print_natural_aggregation_upgrade_notice($courseid, context_course::instance($courseid), $PAGE->url, $return); if ($return) { return $returnval; } }
/** * Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and * (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions * in favour of the usual print_header(), print_header_simple(), print_heading() etc. * !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at * the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN). * * @param int $courseid Course id * @param string $active_type The type of the current page (report, settings, * import, export, scales, outcomes, letters) * @param string $active_plugin The plugin of the current page (grader, fullview etc...) * @param string $heading The heading of the page. Tries to guess if none is given * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function * @param string $bodytags Additional attributes that will be added to the <body> tag * @param string $buttons Additional buttons to display on the page * @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown? * @param string $headerhelpidentifier The help string identifier if required. * @param string $headerhelpcomponent The component for the help string. * * @return string HTML code or nothing if $return == false */ function print_grade_page_head($courseid, $active_type, $active_plugin = null, $heading = false, $return = false, $buttons = false, $shownavigation = true, $headerhelpidentifier = null, $headerhelpcomponent = null) { global $CFG, $OUTPUT, $PAGE; if ($active_type === 'preferences') { // In Moodle 2.8 report preferences were moved under 'settings'. Allow backward compatibility for 3rd party grade reports. $active_type = 'settings'; } $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin); // Determine the string of the active plugin $stractive_plugin = $active_plugin ? $plugin_info['strings']['active_plugin_str'] : $heading; $stractive_type = $plugin_info['strings'][$active_type]; if (empty($plugin_info[$active_type]->id) || !empty($plugin_info[$active_type]->parent)) { $title = $PAGE->course->fullname . ': ' . $stractive_type . ': ' . $stractive_plugin; } else { $title = $PAGE->course->fullname . ': ' . $stractive_plugin; } if ($active_type == 'report') { $PAGE->set_pagelayout('report'); } else { $PAGE->set_pagelayout('admin'); } $PAGE->set_title(get_string('grades') . ': ' . $stractive_type); $PAGE->set_heading($title); if ($buttons instanceof single_button) { $buttons = $OUTPUT->render($buttons); } $PAGE->set_button($buttons); if ($courseid != SITEID) { grade_extend_settings($plugin_info, $courseid); } $returnval = $OUTPUT->header(); if (!$return) { echo $returnval; } // Guess heading if not given explicitly if (!$heading) { $heading = $stractive_plugin; } if ($shownavigation) { if ($courseid != SITEID && ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) { $returnval .= print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return); } $output = ''; // Add a help dialogue box if provided. if (isset($headerhelpidentifier)) { $output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent); } else { $output = $OUTPUT->heading($heading); } if ($return) { $returnval .= $output; } else { echo $output; } if ($courseid != SITEID && ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS)) { $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return); } } $returnval .= print_natural_aggregation_upgrade_notice($courseid, context_course::instance($courseid), $PAGE->url, $return); if ($return) { return $returnval; } }
} //first make sure we have proper final grades - this must be done before constructing of the grade tree grade_regrade_final_grades($courseid); // Perform actions if (!empty($target) && !empty($action) && confirm_sesskey()) { grade_report_grader::do_process_action($target, $action, $courseid); } $reportname = get_string('pluginname', 'gradereport_grader'); // Print header print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons); // Hide the following warning if the user told it to go away. if (optional_param('seensumofgradesupgradedgrades', false, PARAM_BOOL) && confirm_sesskey()) { hide_natural_aggregation_upgrade_notice($courseid); } // This shows a notice about the upgrade to Natural aggregation. print_natural_aggregation_upgrade_notice($COURSE->id, $context); //Initialise the grader report object that produces the table //the class grade_report_grader_ajax was removed as part of MDL-21562 $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid); $numusers = $report->get_numusers(true, true); // make sure separate group does not prevent view if ($report->currentgroup == -2) { echo $OUTPUT->heading(get_string("notingroup")); echo $OUTPUT->footer(); exit; } // processing posted grades & feedback here if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) { $warnings = $report->process_data($data); } else { $warnings = array();