if (!$viewsports && !$viewgrades) { error(get_string('no_permission', 'block_student_gradeviewer')); } // We want to make sure that the course preference block is installed // because we depend on those tables if (!get_field('block', 'id', 'name', 'courseprefs')) { error(get_string('install_cps', 'block_student_gradeviewer')); } // The user we're zoning in on $user = get_record('block_courseprefs_users', 'id', $id); // Wait a minute this cps user doesn't exist :( if (!$user) { error(get_string('bad_user', 'block_student_gradeviewer')); } // The courses for this student $courses = pull_courses($user); $blockname = get_string('blockname', 'block_student_gradeviewer'); $heading_main = get_string('view_grades', 'block_student_gradeviewer'); $navigation = array(array('name' => $blockname, 'link' => '', 'type' => 'title'), array('name' => $heading_main, 'link' => 'viewgrades.php', 'type' => 'title'), array('name' => fullname($user), 'link' => '', 'type' => 'title')); // Begin form output print_header_simple($heading_main, '', build_navigation($navigation)); // If they don't have any courses, then tell the user so and die if (empty($courses)) { print_heading(get_string('no_courses', 'block_student_gradeviewer')); print_footer(); die; } echo '<fieldset class="aligncenter"> <legend><strong>Grades Overview for ' . fullname($user) . '</strong></legend> <div class="student_courses"> <span>' . implode(' | ', pull_grades_courses($courses)) . '</span>
function pull_course_grades($user) { return array_map('get_course_grade', pull_courses($user)); }