-
Notifications
You must be signed in to change notification settings - Fork 21
Allow General Section to be Numbered #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f6dd322
e6be39b
4239b96
f32eb3a
61d88b7
3132427
17ef39a
b6f00cf
527de25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,15 +164,83 @@ public function get_content() { | |
$title = $format->get_section_name($section); | ||
} | ||
|
||
// Check if we want to display a course link. Checked forced status from global config first, | ||
// then check block instance settings. | ||
if ($globalconfig->display_course_link === 'forced_off') { | ||
$displaycourselink = false; | ||
|
||
} else if ($globalconfig->display_course_link === 'forced_on') { | ||
$displaycourselink = true; | ||
|
||
} else if (empty($this->config) or !isset($this->config->display_course_link)) { | ||
// Instance not configured, use the globally defined default value. | ||
if ($globalconfig->display_course_link === 'optional_on') { | ||
$displaycourselink = true; | ||
} else { | ||
$displaycourselink = false; | ||
} | ||
} else if (!empty($this->config->display_course_link)) { | ||
$displaycourselink = true; | ||
|
||
} else { | ||
$displaycourselink = false; | ||
|
||
} | ||
|
||
if (($i == 0) && ($displaycourselink)) { | ||
$sectionclass = 'section-item'; | ||
|
||
if ((!isset($selected)) && (empty($selected)) ) { | ||
$sectionclass .= ' current ' . $selected; | ||
} | ||
$text .= html_writer::start_tag('li', array('class' => $sectionclass)); | ||
|
||
$text .= html_writer::span('>', 'section-number'); | ||
if (!empty($this->config->display_course_link_text)) { | ||
$anchortext = $this->config->display_course_link_text; | ||
} else if (!empty($globalconfig->display_course_link_text)) { | ||
$anchortext = $globalconfig->display_course_link_text; | ||
} else { | ||
$anchortext = $course->shortname; | ||
} | ||
|
||
if ((!isset($selected)) && (empty($selected)) ) { | ||
$text .= ' ' . $anchortext; | ||
} else { | ||
$text .= ' ' . html_writer::link(course_get_url($course), $anchortext); | ||
} | ||
|
||
$text .= html_writer::end_tag('li'); | ||
} | ||
|
||
$odd = $r % 2; | ||
if ($format->is_section_current($section)) { | ||
$text .= html_writer::start_tag('li', array('class' => 'section-item current r'.$odd)); | ||
if (isset($selected) && $i == $selected) { | ||
$text .= html_writer::start_tag('li', array('class' => 'section-item current r.$odd')); | ||
} else { | ||
$text .= html_writer::start_tag('li', array('class' => 'section-item r'.$odd)); | ||
} | ||
|
||
if ($i == 0) { | ||
// Never enumerate the section number 0. | ||
// Check if we want to enumerate section 0. Checked forced status from global config first, | ||
// then check block instance settings. | ||
if ($globalconfig->enumerate_section_0 === 'forced_off') { | ||
$enumeratesection0 = false; | ||
} else if ($globalconfig->enumerate_section_0 === 'forced_on') { | ||
$enumeratesection0 = true; | ||
} else if (empty($this->config) or !isset($this->config->enumerate_section_0 )) { | ||
// Instance not configured, use the globally defined default value. | ||
if ($globalconfig->enumerate_section_0 === 'optional_on') { | ||
$enumeratesection0 = true; | ||
} else { | ||
$enumeratesection0 = false; | ||
} | ||
} else if (!empty($this->config->enumerate_section_0 )) { | ||
$enumeratesection0 = true; | ||
} else { | ||
$enumeratesection0 = false; | ||
} | ||
|
||
if ( ($i == 0) && ($enumeratesection0 == false) ) { | ||
// Never enumerate the section number 0 unless option has been set. | ||
$enumerate = false; | ||
|
||
} else if ($globalconfig->enumerate === 'forced_off') { | ||
|
@@ -196,8 +264,16 @@ public function get_content() { | |
$enumerate = false; | ||
} | ||
|
||
$sectionnumber = $i; | ||
|
||
// If enumerating and showing section 0, then increment section number. | ||
if ( ($enumerate == true) && ($enumeratesection0 == true)) { | ||
$sectionnumber++; | ||
} | ||
|
||
if ($enumerate) { | ||
$title = html_writer::span($i, 'section-number').' '.html_writer::span($title, 'section-title'); | ||
$title = html_writer::span($sectionnumber, 'section-number'). ' ' | ||
. html_writer::span(' ' . $title, 'section-title'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the point of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a little extra spacing between the number and section title. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am removing it and adding an extra space properly via CSS. |
||
|
||
} else { | ||
$title = html_writer::span($title, 'section-title not-enumerated'); | ||
|
@@ -258,4 +334,4 @@ private function node_plain_text($node) { | |
} | ||
return $t; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to remove the existing feature of highlighting the current section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From our testing it seems to highlight fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just re-checked and I believe there was some misunderstanding. Your has changed the meaning of the class "current" to match the section the user currently clicked to. But originally this was a section highlighted as the "current" one by the teacher of the course.
Anyway, I realized your intention and I agree that highlighting the currently selected section should be more prominent than highlighting the current one. I am adding an extra change that introduces a new CSS class "selected" which will use the original "current" styling. The "current" section will be still highlighted but not that much.
This is an example of the result of my fix: in the following example, the user is viewing the section "Topic 4" and the teacher has marked the "Topic 2" as the current one. Your patch did not highlight the "Topic 2" at all, my new version will show it in bold: