mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
New feature: hide/show topics!
This commit is contained in:
parent
81ed361792
commit
7d99d6959e
8 changed files with 105 additions and 44 deletions
|
@ -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 />";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -110,6 +113,7 @@
|
|||
|
||||
echo "</td>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top align=center width=10> ";
|
||||
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>";
|
||||
|
@ -129,9 +133,26 @@
|
|||
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 {
|
||||
|
@ -143,53 +164,60 @@
|
|||
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 " ";
|
||||
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!");
|
||||
echo "<td valign=top $colormain width=\"100%\">";
|
||||
|
||||
if (isediting($course->id)) {
|
||||
$thissection->summary .= " <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&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 (isediting($course->id)) {
|
||||
$thissection->summary .= " <a href=editsection.php?id=$thissection->id><img src=\"$pixpath/t/edit.gif\" border=0 height=11 width=11 alt=\"$streditsummary\"></a>";
|
||||
}
|
||||
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>";
|
||||
}
|
||||
|
||||
echo text_to_html($thissection->summary);
|
||||
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>";
|
||||
}
|
||||
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</div>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
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 "<tr><td colspan=3><img src=\"../pix/spacer.gif\" width=1 height=1></td></tr>";
|
||||
|
||||
$section++;
|
||||
|
|
|
@ -44,6 +44,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
# --------------------------------------------------------
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue