Skip to content

Commit

Permalink
MDL-68235 core_course: Add section ID attribute to sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed May 6, 2020
1 parent f570a79 commit 278d9d3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
43 changes: 32 additions & 11 deletions course/format/renderer.php
Expand Up @@ -198,9 +198,13 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
}
}

$o.= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
'class' => 'section main clearfix'.$sectionstyle, 'role'=>'region',
'aria-labelledby' => "sectionid-{$section->id}-title"));
$o .= html_writer::start_tag('li', [
'id' => 'section-'.$section->section,
'class' => 'section main clearfix'.$sectionstyle,
'role' => 'region',
'aria-labelledby' => "sectionid-{$section->id}-title",
'data-sectionid' => $section->section
]);

$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
$o.= html_writer::tag('div', $leftcontent, array('class' => 'left side'));
Expand Down Expand Up @@ -399,8 +403,13 @@ protected function section_summary($section, $course, $mods) {

$title = get_section_name($course, $section);
$o = '';
$o .= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
'class' => $classattr, 'role'=>'region', 'aria-label'=> $title));
$o .= html_writer::start_tag('li', [
'id' => 'section-'.$section->section,
'class' => $classattr,
'role' => 'region',
'aria-label' => $title,
'data-sectionid' => $section->section
]);

$o .= html_writer::tag('div', '', array('class' => 'left side'));
$o .= html_writer::tag('div', '', array('class' => 'right side'));
Expand Down Expand Up @@ -643,14 +652,22 @@ protected function get_nav_links($course, $sections, $sectionno) {
*/
protected function stealth_section_header($sectionno) {
$o = '';
$o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix orphaned hidden'));
$o.= html_writer::tag('div', '', array('class' => 'left side'));
$o .= html_writer::start_tag('li', [
'id' => 'section-'.$sectionno,
'class' => 'section main clearfix orphaned hidden',
'data-sectionid' => $sectionno
]);
$o .= html_writer::tag('div', '', array('class' => 'left side'));
$course = course_get_format($this->page->course)->get_course();
$section = course_get_format($this->page->course)->get_section($sectionno);
$rightcontent = $this->section_right_content($section, $course, false);
$o.= html_writer::tag('div', $rightcontent, array('class' => 'right side'));
$o.= html_writer::start_tag('div', array('class' => 'content'));
$o.= $this->output->heading(get_string('orphanedactivitiesinsectionno', '', $sectionno), 3, 'sectionname');
$o .= html_writer::tag('div', $rightcontent, array('class' => 'right side'));
$o .= html_writer::start_tag('div', array('class' => 'content'));
$o .= $this->output->heading(
get_string('orphanedactivitiesinsectionno', '', $sectionno),
3,
'sectionname'
);
return $o;
}

Expand Down Expand Up @@ -681,7 +698,11 @@ protected function section_hidden($sectionno, $courseorid = null) {
}

$o = '';
$o.= html_writer::start_tag('li', array('id' => 'section-'.$sectionno, 'class' => 'section main clearfix hidden'));
$o .= html_writer::start_tag('li', [
'id' => 'section-'.$sectionno,
'class' => 'section main clearfix hidden',
'data-sectionid' => $sectionno
]);
$o.= html_writer::tag('div', '', array('class' => 'left side'));
$o.= html_writer::tag('div', '', array('class' => 'right side'));
$o.= html_writer::start_tag('div', array('class' => 'content'));
Expand Down
Expand Up @@ -286,6 +286,8 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
// Update flag.
swapped = true;
}
sectionlist.item(index).setAttribute('data-sectionid',
Y.Moodle.core_course.util.section.getId(sectionlist.item(index)));
}
loopend = loopend - 1;
} while (swapped);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -282,6 +282,8 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
// Update flag.
swapped = true;
}
sectionlist.item(index).setAttribute('data-sectionid',
Y.Moodle.core_course.util.section.getId(sectionlist.item(index)));
}
loopend = loopend - 1;
} while (swapped);
Expand Down

0 comments on commit 278d9d3

Please sign in to comment.