]> git.mjollnir.org Git - moodle.git/commitdiff
fix for MDL-7481, grade book student view should have table headers
authortoyomoyo <toyomoyo>
Fri, 1 Dec 2006 08:31:15 +0000 (08:31 +0000)
committertoyomoyo <toyomoyo>
Fri, 1 Dec 2006 08:31:15 +0000 (08:31 +0000)
grade/lib.php
lang/en_utf8/grades.php

index 0e4d5fe5c63b0013dc593ff2de2664bd6694d493..6c194fd88448f57f0637ae9d3583ce39db3a3bed 100644 (file)
@@ -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 ('<table align="center" class="grades"><tr><th>'.get_string('activity').'</th><th>'.get_string('yourgrade','grades').'</th><th>'.get_string('maxgrade','grades').'</th></tr>');
+    
     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 '<br />';
+                                  
+                                    $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 '<tr>';
                                     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 "<td><a href='$link'>$mod->modfullname: ".format_string($instance->name,true)."</a></td><td>$currentgrade</td><td>$maxgrade</td>";            } else {
+                                        echo "<td><a href='$link'>$mod->modfullname: ".format_string($instance->name,true)."</td><td>".get_string('nograde')."</a></td><td>$maxgrade</td>";                                        
                                     }
+                                    echo '</tr>';                       
                                 }
                             }
                         }
@@ -2994,7 +3008,8 @@ function print_student_grade($user, $course) {
                 }
             }
         }
-    } // a new Moodle nesting record? ;-) 
+    } // a new Moodle nesting record? ;-)
+    echo '</table>';
 }
 
 function grade_get_course_students($courseid) {
index a097022f4467023c352b8898fad860db15f03c58..c017017b822551362bd7778ca1e2b6fdf4d34039 100644 (file)
@@ -123,5 +123,6 @@ $string['weightedpct'] = 'weighted %%';
 $string['weightedpctcontribution'] = 'weighted %% contribution';
 $string['writinggradebookinfo'] = 'Writing Gradebook settings';
 $string['yes'] = 'Yes';
+$string['yourgrade'] = 'Your grade';
 
 ?>