]> git.mjollnir.org Git - moodle.git/commitdiff
Now hidden sections are hidden completely from student view if
authorstronk7 <stronk7>
Tue, 16 Nov 2004 17:30:45 +0000 (17:30 +0000)
committerstronk7 <stronk7>
Tue, 16 Nov 2004 17:30:45 +0000 (17:30 +0000)
"invisible sections" are configured in course settings.
Patch sent by Geoff Wilbert. Thanks!
See Bug 2185
(http://moodle.org/bugs/bug.php?op=show&bugid=2185)

Merged from MOODLE_14_STABLE

course/user.php

index 0a08005905317a1433684dd8764471eaa6fbf670..dcc222b230e7ae488bde21f5f9aa53a521b1aa1d 100644 (file)
                 if (isset($sections[$i])) {   // should always be true
 
                     $section = $sections[$i];
-        
-                    if ($section->sequence) {
-                        echo "<hr />";
-                        echo "<h2>";
-                        switch ($course->format) {
-                            case "weeks": print_string("week"); break;
-                            case "topics": print_string("topic"); break;
-                            default: print_string("section"); break;
-                        }
-                        echo " $i</h2>";
-
-                        echo "<ul>";
+                    $showsection = (isteacher($course->id) or $section->visible or !$course->hiddensections);
 
-                        if ($mode == "outline") {
-                            echo "<table cellpadding=\"4\" cellspacing=\"0\">";
-                        }
+                    if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert!
 
-                        $sectionmods = explode(",", $section->sequence);
-                        foreach ($sectionmods as $sectionmod) {
-                            if (empty($mods[$sectionmod])) {
-                                continue;
+                        if ($section->sequence) {
+                            echo "<hr />";
+                            echo "<h2>";
+                            switch ($course->format) {
+                                case "weeks": print_string("week"); break;
+                                case "topics": print_string("topic"); break;
+                                default: print_string("section"); break;
                             }
-                            $mod = $mods[$sectionmod];
+                            echo " $i</h2>";
+    
+                            echo "<ul>";
 
-                            if (empty($mod->visible)) {
-                                continue;
+                            if ($mode == "outline") {
+                                echo "<table cellpadding=\"4\" cellspacing=\"0\">";
                             }
 
-                            $instance = get_record("$mod->modname", "id", "$mod->instance");
-                            $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
-
-                            if (file_exists($libfile)) {
-                                require_once($libfile);
+                            $sectionmods = explode(",", $section->sequence);
+                            foreach ($sectionmods as $sectionmod) {
+                                if (empty($mods[$sectionmod])) {
+                                    continue;
+                                }
+                                $mod = $mods[$sectionmod];
+    
+                                if (empty($mod->visible)) {
+                                    continue;
+                                }
 
-                                switch ($mode) {
-                                    case "outline":
-                                        $user_outline = $mod->modname."_user_outline";
-                                        if (function_exists($user_outline)) {
-                                            $output = $user_outline($course, $user, $mod, $instance);
-                                            print_outline_row($mod, $instance, $output);
-                                        }
-                                        break;
-                                    case "complete":
-                                        $user_complete = $mod->modname."_user_complete";
-                                        if (function_exists($user_complete)) {
-                                            $image = "<img src=\"../mod/$mod->modname/icon.gif\" ".
-                                                     "height=\"16\" width=\"16\" alt=\"$mod->modfullname\" />";
-                                            echo "<h4>$image $mod->modfullname: ".
-                                                 "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
-                                                 "$instance->name</a></h4>";
-                                            echo "<ul>";
-                                            $user_complete($course, $user, $mod, $instance);
-                                            echo "</ul>";
+                                $instance = get_record("$mod->modname", "id", "$mod->instance");
+                                $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
+
+                                if (file_exists($libfile)) {
+                                    require_once($libfile);
+
+                                    switch ($mode) {
+                                        case "outline":
+                                            $user_outline = $mod->modname."_user_outline";
+                                            if (function_exists($user_outline)) {
+                                                $output = $user_outline($course, $user, $mod, $instance);
+                                                print_outline_row($mod, $instance, $output);
+                                            }
+                                            break;
+                                        case "complete":
+                                            $user_complete = $mod->modname."_user_complete";
+                                            if (function_exists($user_complete)) {
+                                                $image = "<img src=\"../mod/$mod->modname/icon.gif\" ".
+                                                         "height=\"16\" width=\"16\" alt=\"$mod->modfullname\" />";
+                                                echo "<h4>$image $mod->modfullname: ".
+                                                     "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">".
+                                                     "$instance->name</a></h4>";
+                                                echo "<ul>";
+                                                $user_complete($course, $user, $mod, $instance);
+                                                echo "</ul>";
+                                            }
+                                            break;
                                         }
-                                        break;
+                                    }
                                 }
+    
+                            if ($mode == "outline") {
+                                echo "</table>";
+                                print_simple_box_end();
                             }
+                            echo "</ul>";
                         }
-
-                        if ($mode == "outline") {
-                            echo "</table>";
-                            print_simple_box_end();
-                        }
-                        echo "</ul>";
-
-                    
                     }
                 }
             }