]> git.mjollnir.org Git - moodle.git/commitdiff
New feature: hide/show topics!
authormoodler <moodler>
Sun, 4 May 2003 07:59:46 +0000 (07:59 +0000)
committermoodler <moodler>
Sun, 4 May 2003 07:59:46 +0000 (07:59 +0000)
course/lib.php
course/topics.php
course/view.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
version.php

index 6ec9a6d2bbcaa4a5e4fb138e4de989e9339b9fa1..17e211ad17331e13b53c2e049a83b3a3179a96ca 100644 (file)
@@ -504,7 +504,7 @@ function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modname
 function get_all_sections($courseid) {
     
     return get_records("course_sections", "course", "$courseid", "section", 
-                       "section, id, course, summary, sequence");
+                       "section, id, course, summary, sequence, visible");
 }
 
 function course_set_display($courseid, $display=0) {
@@ -546,6 +546,20 @@ function course_section_visible($courseid, $section) {
     return $USER->display[$courseid] == $section;
 }
 
+function set_section_visible($courseid, $sectionnumber, $visibility) {
+/// For a given course section, markes it visible or hidden,
+/// and does the same for every activity in that section
+
+    if ($section = get_record("course_sections", "course", $courseid, "section", $sectionnumber)) {
+        set_field("course_sections", "visible", "$visibility", "id", $section->id);
+        if (!empty($section->sequence)) {
+            $modules = explode(",", $section->sequence);
+            foreach ($modules as $moduleid) {
+                set_field("course_modules", "visible", "$visibility", "id", $moduleid);
+            }
+        }
+    }
+}
 
 function print_section_block($heading, $course, $section, $mods, $modnames, $modnamesused, 
                              $absolute=true, $width="100%", $isediting=false) {
@@ -688,7 +702,7 @@ function print_side_block_start($heading="", $width=180, $class="sideblockmain")
 
 function print_side_block_end() {
     echo "</td></tr>";
-    echo "</table><br \>";
+    echo "</table><br />";
 }
 
 
index 77fd7e8477f4ffd7861ea6a2804d74dc516e729d..558058c07579893e199bd689efa01f4add988273 100644 (file)
@@ -32,6 +32,9 @@
     $streditsummary = get_string("editsummary");
     $stradd         = get_string("add");
     $stractivities  = get_string("activities");
+    $strshowalltopics = get_string("showalltopics");
+    $strtopichide = get_string("topichide");
+    $strtopicshow = get_string("topicshow");
 
 
 /// Layout the whole page as three big columns.
     
         echo "</td>";
         echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top align=center width=10>&nbsp;";
+        echo "<a href=\"view.php?id=$course->id&topic=all\" title=\"$strshowalltopics\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br><br>";
         echo "</td>";
         echo "</tr>";
         echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
             continue;
         }
 
+        if (!empty($sections[$section])) {
+            $thissection = $sections[$section];
+
+        } else {
+            unset($thissection);
+            $thissection->course = $course->id;   // Create a new section structure
+            $thissection->section = $section;
+            $thissection->summary = "";
+            $thissection->visible = 1;
+            if (!$thissection->id = insert_record("course_sections", $thissection)) {
+                notify("Error inserting new topic!");
+            }
+        }
+
         $currenttopic = ($course->marker == $section);
 
-        if ($currenttopic) {
+        if (!$thissection->visible) {
+            $colorsides = "bgcolor=\"$THEME->hidden\" class=\"topicsoutlinesidehidden\"";
+            $colormain  = "bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontenthidden\"";
+        } else if ($currenttopic) {
             $colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"topicsoutlinesidehighlight\"";
             $colormain  = "bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontenthighlight\"";
         } else {
         echo "<td nowrap $colorsides valign=top width=20>";
         echo "<p align=center><font size=3><b>$section</b></font></p>";
         echo "</td>";
-
-        echo "<td valign=top $colormain width=\"100%\">";
-
-        if (!empty($sections[$section])) {
-            $thissection = $sections[$section];
+    
+        if (!isteacher($course->id) and !$thissection->visible) {   // Hidden for students
+            echo "<td valign=top align=center $colormain width=\"100%\">";
+            echo get_string("notavailable");
+            echo "</td><td $colorsides width=20>";
+            echo "&nbsp;";
+            echo "</td></tr>";
 
         } else {
-            unset($thissection);
-            $thissection->course = $course->id;   // Create a new section structure
-            $thissection->section = $section;
-            $thissection->summary = "";
-            if (!$thissection->id = insert_record("course_sections", $thissection)) {
-                notify("Error inserting new topic!");
-            }
-        }
-
-        if (isediting($course->id)) {
-            $thissection->summary .= "&nbsp;<a href=editsection.php?id=$thissection->id><img src=\"$pixpath/t/edit.gif\" border=0 height=11 width=11 alt=\"$streditsummary\"></a>";
-        }
+            echo "<td valign=top $colormain width=\"100%\">";
 
-        echo text_to_html($thissection->summary);
+            if (isediting($course->id)) {
+                $thissection->summary .= "&nbsp;<a href=editsection.php?id=$thissection->id><img src=\"$pixpath/t/edit.gif\" border=0 height=11 width=11 alt=\"$streditsummary\"></a>";
+            }
+    
+            echo text_to_html($thissection->summary);
+    
+            print_section($course, $thissection, $mods, $modnamesused);
+    
+            if (isediting($course->id)) {
+                echo "<div align=right>";
+                popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&add=", 
+                            $modnames, "section$section", "", "$stradd...", "mods", $stractivities);
+                echo "</div>";
+            }
+    
+            echo "</td>";
+            echo "<td nowrap $colorsides valign=top align=center width=10>";
+            echo "<font size=1>";
+
+            if ($displaysection == $section) {      // Show the zoom box
+                echo "<a href=\"view.php?id=$course->id&topic=all\" title=\"$strshowalltopics\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br><br>";
+            } else {
+                $strshowonlytopic = get_string("showonlytopic", "", $section);
+                echo "<a href=\"view.php?id=$course->id&topic=$section\" title=\"$strshowonlytopic\"><img src=\"$pixpath/i/one.gif\" height=16 width=16 border=0></a><br><br>";
+            }
 
-        print_section($course, $thissection, $mods, $modnamesused);
+            if (isediting($course->id) and $course->marker != $section) {  // Show the "tick"
+                $strmarkthistopic = get_string("markthistopic");
+                echo "<a href=\"view.php?id=$course->id&marker=$section\" title=\"$strmarkthistopic\"><img src=\"$pixpath/i/marker.gif\" height=16 width=16 border=0></a><br><br>";
+            }
 
-        if (isediting($course->id)) {
-            echo "<div align=right>";
-            popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&amp;section=$section&add=", 
-                        $modnames, "section$section", "", "$stradd...", "mods", $stractivities);
-            echo "</div>";
-        }
+            if (isediting($course->id)) {      // Show the hide/show eye
+                if ($thissection->visible) {
+                    echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strtopichide\"><img src=\"$pixpath/i/hide.gif\" height=16 width=16 border=0></a><br><br>";
+                    
+                } else {
+                    echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strtopicshow\"><img src=\"$pixpath/i/show.gif\" height=16 width=16 border=0></a><br><br>";
+                }
+            }
 
-        echo "</td>";
-        echo "<td nowrap $colorsides valign=top align=center width=10>";
-        echo "<font size=1>";
-        if ($displaysection == $section) {
-            $strshowalltopics = get_string("showalltopics");
-            echo "<a href=\"view.php?id=$course->id&topic=all\" title=\"$strshowalltopics\"><img src=\"$pixpath/i/all.gif\" height=25 width=16 border=0></a><br><br>";
-        } else {
-            $strshowonlytopic = get_string("showonlytopic", "", $section);
-            echo "<a href=\"view.php?id=$course->id&topic=$section\" title=\"$strshowonlytopic\"><img src=\"$pixpath/i/one.gif\" height=16 width=16 border=0></a><br><br>";
-        }
-        if (isediting($course->id) and $course->marker != $section) {
-            $strmarkthistopic = get_string("markthistopic");
-            echo "<a href=\"view.php?id=$course->id&marker=$section\" title=\"$strmarkthistopic\"><img src=\"$pixpath/i/marker.gif\" height=16 width=16 border=0></a><br><br>";
+            echo "</td>";
+            echo "</tr>";
         }
-        echo "</td>";
-        echo "</tr>";
         echo "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
 
         $section++;
index 75808f865ee4620b85912528a86f7785740b6173..f8f6cfcf10b6195f82f008f38551263c23fb0323 100644 (file)
         } 
     }
 
+    if (isset($hide)) {
+        set_section_visible($course->id, $hide, "0");
+    }
+
+    if (isset($show)) {
+        set_section_visible($course->id, $show, "1");
+    }
+
     $SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
 
     if (! $course->category) {      // This course is not a real course.
@@ -76,6 +84,7 @@
         }
     }
 
+
     switch ($course->format) {
         case "weeks":
             include("weeks.php");
index c317b6011f5a0ab230555113a434a85d9b98ccac..97e8be11f124845348c07296fdfec0c57d50d4b3 100644 (file)
@@ -375,6 +375,10 @@ function main_upgrade($oldversion=0) {
                      ) TYPE=MyISAM COMMENT='Stores info about how to display the course'");
     }
 
+    if ($oldversion < 2003050400) {
+        table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
+    }
+
     return $result;
 
 }
index 748b0ce29feb0485750852ca82a18e0e12c9a23f..d32571f2ed5747efe0b7e00dfc3ab6fb2c5f3c9b 100644 (file)
@@ -110,6 +110,7 @@ CREATE TABLE `prefix_course_sections` (
   `section` int(10) unsigned NOT NULL default '0',
   `summary` text NOT NULL,
   `sequence` varchar(255) NOT NULL default '',
+  `visible` tinyint(1) NOT NULL default '1',
   PRIMARY KEY  (`id`)
 ) TYPE=MyISAM;
 # --------------------------------------------------------
index 11c5630e92ecd62818bdd3f7a129f024237d2ef7..62270300620e50e8e90a09f591d548e0e5345493 100644 (file)
@@ -137,6 +137,10 @@ function main_upgrade($oldversion=0) {
 
         execute_sql("CREATE INDEX {$CFG->prefix}course_display_courseuserid_idx ON {$CFG->prefix}course_display (course,userid)");
     }
+
+    if ($oldversion < 2003050400) {
+        table_column("course_sections", "", "visible", "integer", "1", "unsigned", "1", "", "");
+    }
                                                             
     return $result;
 }
index e62662975c5c685f9f72cf33c69e4fda0f53696f..8513496f4bd138a8ddad142725877e79e473916a 100644 (file)
@@ -58,7 +58,8 @@ CREATE TABLE prefix_course_sections (
    course integer NOT NULL default '0',
    section integer NOT NULL default '0',
    summary text NOT NULL default '',
-   sequence varchar(255) NOT NULL default ''
+   sequence varchar(255) NOT NULL default '',
+   visible integer NOT NULL default '1'
 );
 
 CREATE TABLE prefix_log (
index 4c7e7893e2d74cf44d637d17571730becdc8ce7d..06054e584a530bdc1da8dfa0e876bba903a64e8c 100644 (file)
@@ -5,7 +5,7 @@
 // database to determine whether upgrades should
 // be performed (see lib/db/*.php)
 
-$version = 2003042801;   // The current version is a date (YYYYMMDDXX)
+$version = 2003050400;   // The current version is a date (YYYYMMDDXX)
 
 $release = "1.0.9 development";  // User-friendly version number