Skip to content

Commit

Permalink
Fix section onclick
Browse files Browse the repository at this point in the history
  • Loading branch information
emilevirus committed Feb 14, 2022
1 parent a0fe18a commit 32eeb3c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ protected function get_section($name, $options = array()){
if ($sectionname == $name || get_string('section') . strval($section->section) == $name) {// Used for atto plugin, if no name, sectionX

$sectionname = (empty($section->name) ? get_string('section') . ' ' . strval($section->section) : $section->name);
$title = $sectionname;
if (isset($options['title'])) {
$sectionname = $options['title'];
$title = $sectionname.' - '.$name;
}
$class = '';
if (isset($options['class'])) {
Expand All @@ -144,14 +146,10 @@ protected function get_section($name, $options = array()){
$class .= " disabled";
}

$tagattr = array('class' => 'autolink '.$class, 'title' => $sectionname.' - '.$name, 'target' => $options['target']);
$tagattr = array('class' => 'autolink '.$class, 'title' => $title, 'target' => $options['target'], 'onclick' => 'this.search == document.location.search && setTimeout(location.reload.bind(location), 50)');
$href = "#";
if (($this->context instanceof context_course) && ($this->page->course->format == 'treetopics') && ($options['target'] != '_blank') && !isset($options['popup'])){
$tagattr['onclick'] = "M.recit.course.format.TreeTopics.instance.goToSection(event)";
}
else{
$href = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'section' => $section->section), $anchor);
}
$href = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'section' => $section->section), $anchor);

$result = html_writer::link($href, $sectionname, $tagattr);

return "<span>$result$availableInfo</span>";
Expand Down

0 comments on commit 32eeb3c

Please sign in to comment.