if (empty($gi->idnumber) and !$gi->add_idnumber(stripslashes($idnumbers[$gi->id]))) {
                $errors[$giid] = get_string('error');
                continue;
            }
        } else {
            $errors[$giid] = 'Could not fetch the grade_item with id=' . $giid;
        }
    }
}
$gtree = new grade_tree($course->id, false, false);
$strgrades = get_string('grades');
$strgraderreport = get_string('graderreport', 'grades');
$strcalculationedit = get_string('editcalculation', 'grades');
$navigation = grade_build_nav(__FILE__, $strcalculationedit, array('courseid' => $courseid));
print_header_simple($strgrades . ': ' . $strgraderreport, ': ' . $strcalculationedit, $navigation, '', '', true, '', navmenu($course));
$mform->display();
// Now show the gradetree with the idnumbers add/edit form
echo '
<form class="mform" id="mform2" method="post" action="' . $CFG->wwwroot . '/grade/edit/tree/calculation.php?courseid=' . $courseid . '&amp;id=' . $id . '">
    <div style="display: none;">
        <input type="hidden" value="' . $id . '" name="id"/>
        <input type="hidden" value="' . $courseid . '" name="courseid"/>
        <input type="hidden" value="' . $gpr->type . '" name="gpr_type"/>
        <input type="hidden" value="' . $gpr->plugin . '" name="gpr_plugin"/>
        <input type="hidden" value="' . $gpr->courseid . '" name="gpr_courseid"/>
        <input type="hidden" value="' . sesskey() . '" name="sesskey"/>
        <input type="hidden" value="idnumbers" name="section"/>
    </div>

    <fieldset id="idnumbers" class="clearfix">
        <legend class="ftoggler">' . get_string('idnumbers', 'grades') . '</legend>