section links now preserve focused view, see http://moodle.org/mod/forum/discuss.php?d=7648#37555

This commit is contained in:
gustav_delius 2004-05-29 10:40:07 +00:00
parent e48550e0b8
commit f1020d0dd2

View file

@ -33,10 +33,12 @@ class CourseBlock_section_links extends MoodleBlock {
if ($this->course->format == 'weeks') { if ($this->course->format == 'weeks') {
$highlight = ceil((time()-$this->course->startdate)/604800); $highlight = ceil((time()-$this->course->startdate)/604800);
$linktext = get_string('jumptocurrentweek', 'block_section_links'); $linktext = get_string('jumptocurrentweek', 'block_section_links');
$sectionname = 'week';
} }
else if ($this->course->format == 'topics') { else if ($this->course->format == 'topics') {
$highlight = $this->course->marker; $highlight = $this->course->marker;
$linktext = get_string('jumptocurrenttopic', 'block_section_links'); $linktext = get_string('jumptocurrenttopic', 'block_section_links');
$sectionname = 'topic';
} }
$inc = 1; $inc = 1;
if ($this->course->numsections > 22) { if ($this->course->numsections > 22) {
@ -47,20 +49,20 @@ class CourseBlock_section_links extends MoodleBlock {
} }
$courseid = $this->course->id; $courseid = $this->course->id;
if ($display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id)) { if ($display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id)) {
$link = "$CFG->wwwroot/course/view.php?id=$courseid&topic=all"; $link = "$CFG->wwwroot/course/view.php?id=$courseid&$sectionname=";
} else { } else {
$link = ''; $link = '#';
} }
$text = '<font size=-1>'; $text = '<font size=-1>';
for ($i = $inc; $i <= $this->course->numsections; $i += $inc) { for ($i = $inc; $i <= $this->course->numsections; $i += $inc) {
if ($i == $highlight) { if ($i == $highlight) {
$text .= "<a href=\"$link#$i\"><b>$i</b></a> "; $text .= "<a href=\"$link$i\"><b>$i</b></a> ";
} else { } else {
$text .= "<a href=\"$link#$i\">$i</a> "; $text .= "<a href=\"$link$i\">$i</a> ";
} }
} }
if ($highlight) { if ($highlight) {
$text .= "<br><a href=\"$link#$highlight\">$linktext</a>"; $text .= "<br><a href=\"$link$highlight\">$linktext</a>";
} }
$this->content = New stdClass; $this->content = New stdClass;