]> git.mjollnir.org Git - moodle.git/commitdiff
quizheader MDL-18896 Hides quiz closes and feedback if no quizzes use them
authorsamhemelryk <samhemelryk>
Tue, 9 Jun 2009 08:31:18 +0000 (08:31 +0000)
committersamhemelryk <samhemelryk>
Tue, 9 Jun 2009 08:31:18 +0000 (08:31 +0000)
Note: Feedback will be shown if there are any possible feedbacks that may one day be used

mod/quiz/index.php

index 18bfef3274c8afd67b68e728b8daaa9e72910211..f6f0647fcdc34e5f527bec164a80acb9359d619e 100644 (file)
         die;
     }
 
+// Check if we need the closing date header
+    $showclosingheader = false;
+    $showfeedback = false;
+    foreach ($quizzes as $quiz) {
+        if ($quiz->timeclose!=0) {
+            $showclosingheader=true;
+        }
+        if (quiz_has_feedback($quiz)) {
+            $showfeedback=true;
+        }
+    }
+
 // Configure table for displaying the list of instances.
-    $headings = array(get_string('name'), get_string('quizcloses', 'quiz'));
-    $align = array('left', 'left');
+    $headings = array(get_string('name'));
+    $align = array('left');
+
+    if ($showclosingheader) {
+        array_push($headings, get_string('quizcloses', 'quiz'));
+        array_push($align, 'left');
+    }
+
     if ($course->format == 'weeks' or $course->format == 'weekscss') {
         array_unshift($headings, get_string('week'));
     } else {
         array_push($align, 'left');
         $showing = 'stats';
     } else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $coursecontext)) {
-        array_push($headings, get_string('bestgrade', 'quiz'), get_string('feedback', 'quiz'));
-        array_push($align, 'left', 'left');
+        array_push($headings, get_string('bestgrade', 'quiz'));
+        array_push($align, 'left');
+        if ($showfeedback) {
+            array_push($headings, get_string('feedback', 'quiz'));
+            array_push($align, 'left');
+        }
         $showing = 'scores';  // default
     }
 
         // Close date.
         if ($quiz->timeclose) {
             $data[] = userdate($quiz->timeclose);
-        } else {
+        } else if ($showclosingheader) {
             $data[] = '';
         }
 
                 }
             }
             $data[] = $grade;
-            $data[] = $feedback;
+            if ($showfeedback) {
+                $data[] = $feedback;
+            }
         }
 
         $table->data[] = $data;