MDL-68235 core_course: Add section ID attribute to sections

This commit is contained in:
Mathew May 2020-04-14 13:55:45 +08:00
parent f570a79071
commit 278d9d30f7
5 changed files with 40 additions and 13 deletions

View File

@ -198,9 +198,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
}
}
$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'));
@ -399,8 +403,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$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'));
@ -643,14 +652,22 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
*/
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;
}
@ -681,7 +698,11 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
}
$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'));

View File

@ -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);

File diff suppressed because one or more lines are too long

View File

@ -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);

View File

@ -254,6 +254,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);