]> git.mjollnir.org Git - moodle.git/commitdiff
Better use of mod/quiz:view to hide quiz information (they already have the
authormoodler <moodler>
Sun, 24 Sep 2006 13:54:22 +0000 (13:54 +0000)
committermoodler <moodler>
Sun, 24 Sep 2006 13:54:22 +0000 (13:54 +0000)
name from the course page etc)

mod/quiz/view.php

index 1912dc7b966333532df68a8c6a082305555c3516..fbabffb680010209992c8ea323cefd8a8a97e909 100644 (file)
@@ -39,7 +39,6 @@
     // Check login and get context.
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-    require_capability('mod/quiz:view', $context);
 
     // if no questions have been set up yet redirect to edit.php
     if (!$quiz->questions and has_capability('mod/quiz:manage', $context)) {
     $currenttab = 'info';
     include('tabs.php');
 
-    // Print quiz name and description.
+    // Print quiz name 
+
     print_heading(format_string($quiz->name));
 
-    if (trim(strip_tags($quiz->intro))) {
-        $formatoptions->noclean = true;
-        print_simple_box(format_text($quiz->intro, FORMAT_MOODLE, $formatoptions), "center");
-    }
+    if (has_capability('mod/quiz:view', $context)) {
 
-    // Print information about number of attempts and grading method.
-    if ($quiz->attempts > 1) {
-        echo "<p align=\"center\">".get_string("attemptsallowed", "quiz").": $quiz->attempts</p>";
-    }
-    if ($quiz->attempts != 1) {
-        echo "<p align=\"center\">".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."</p>";
-    }
+        // Print quiz description
+        if (trim(strip_tags($quiz->intro))) {
+            $formatoptions->noclean = true;
+            print_simple_box(format_text($quiz->intro, FORMAT_MOODLE, $formatoptions), "center");
+        }
 
-    // Print information about timings.
-    $timenow = time();
-    $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose));
-    if ($available) {
-        if ($quiz->timelimit) {
-            echo "<p align=\"center\">".get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."</p>";
+        // Print information about number of attempts and grading method.
+        if ($quiz->attempts > 1) {
+            echo "<p align=\"center\">".get_string("attemptsallowed", "quiz").": $quiz->attempts</p>";
+        }
+        if ($quiz->attempts != 1) {
+            echo "<p align=\"center\">".get_string("grademethod", "quiz").": ".$QUIZ_GRADE_METHOD[$quiz->grademethod]."</p>";
+        }
+
+        // Print information about timings.
+        $timenow = time();
+        $available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose));
+        if ($available) {
+            if ($quiz->timelimit) {
+                echo "<p align=\"center\">".get_string("quiztimelimit","quiz", format_time($quiz->timelimit * 60))."</p>";
+            }
+            quiz_view_dates($quiz);
+        } else if ($timenow < $quiz->timeopen) {
+            echo "<p align=\"center\">".get_string("quiznotavailable", "quiz", userdate($quiz->timeopen));
+        } else {
+            echo "<p align=\"center\">".get_string("quizclosed", "quiz", userdate($quiz->timeclose));
         }
-        quiz_view_dates($quiz);
-    } else if ($timenow < $quiz->timeopen) {
-        echo "<p align=\"center\">".get_string("quiznotavailable", "quiz", userdate($quiz->timeopen));
     } else {
-        echo "<p align=\"center\">".get_string("quizclosed", "quiz", userdate($quiz->timeclose));
+        $available = false;
     }
 
     // Show number of attempts summary to those who can view reports.