From 59fd781a66a81b7b0e7ad1678227d9cbfa39646e Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Fri, 1 Dec 2006 08:31:15 +0000 Subject: [PATCH] fix for MDL-7481, grade book student view should have table headers --- grade/lib.php | 27 +++++++++++++++++++++------ lang/en_utf8/grades.php | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index 0e4d5fe5c6..6c194fd884 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -1684,8 +1684,9 @@ function grade_view_category_grades($view_by_student) { $context = get_context_instance(CONTEXT_COURSE, $course->id); + // if can't see course grades, print single grade view if (!has_capability('moodle/course:viewcoursegrades', $context)) { - $view_by_student = $USER->id; + return print_student_grade($USER, $course); } if ($preferences->use_advanced == 0) { @@ -1984,8 +1985,9 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a return false; } + // if can't see course grades, print single grade view if (!has_capability('moodle/course:viewcoursegrades', $context)) { - $view_by_student = $USER->id; + return print_student_grade($USER, $course); } list($grades_by_student, $all_categories) = grade_get_formatted_grades(); @@ -2933,6 +2935,7 @@ function grade_download_form($type='both') { /** * Simply prints all grade of one student from all modules from a given course + * used in the grade book for student view, and grade button under user profile * @param int $userid; * @param int $courseid; */ @@ -2952,12 +2955,18 @@ function print_student_grade($user, $course) { /// Search through all the modules, pulling out grade data $sections = get_all_sections($course->id); // Sort everything the same as the course + + // prints table + + echo (''); + for ($i=0; $i<=$course->numsections; $i++) { if (isset($sections[$i])) { // should always be true $section = $sections[$i]; if ($section->sequence) { $sectionmods = explode(",", $section->sequence); foreach ($sectionmods as $sectionmod) { + $mod = $mods[$sectionmod]; if (empty($mod->modname)) { continue; // Just in case, see MDL-7150 @@ -2981,12 +2990,17 @@ function print_student_grade($user, $course) { } if ($maxgrade) { - echo '
'; + + $link_id = grade_get_module_link($course->id, $mod->instance, $mod->module); + $link = $CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$link_id->id; + + echo ''; if (!empty($modgrades->grades[$user->id])) { $currentgrade = $modgrades->grades[$user->id]; - echo "$mod->modfullname: ".format_string($instance->name,true)." - $currentgrade/$maxgrade"; } else { - echo "$mod->modfullname: ".format_string($instance->name,true)." - ".get_string('nograde')."/$maxgrade"; + echo ""; } else { + echo ""; } + echo ''; } } } @@ -2994,7 +3008,8 @@ function print_student_grade($user, $course) { } } } - } // a new Moodle nesting record? ;-) + } // a new Moodle nesting record? ;-) + echo '
'.get_string('activity').''.get_string('yourgrade','grades').''.get_string('maxgrade','grades').'
$mod->modfullname: ".format_string($instance->name,true)."$currentgrade$maxgrade$mod->modfullname: ".format_string($instance->name,true)."".get_string('nograde')."$maxgrade
'; } function grade_get_course_students($courseid) { diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index a097022f44..c017017b82 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -123,5 +123,6 @@ $string['weightedpct'] = 'weighted %%'; $string['weightedpctcontribution'] = 'weighted %% contribution'; $string['writinggradebookinfo'] = 'Writing Gradebook settings'; $string['yes'] = 'Yes'; +$string['yourgrade'] = 'Your grade'; ?> -- 2.39.5