-
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
Conversation
…orrection to incorrect variable name
…course home page.
… home page highlighting.
Hi, I've just submitted a pull request now :) Thanks, M |
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.
Thanks for the pull request. Please see some first things I've noticed when looking at the patch. Also note, it is probably worth rebasing the branch and melting some commits together.
block_course_contents.php
Outdated
@@ -164,15 +164,41 @@ public function get_content() { | |||
$title = $format->get_section_name($section); | |||
} | |||
|
|||
if ( ($i == 0) && (!empty($globalconfig->display_course_link)) ) { |
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.
There seems to be some extra whitespace next to outer brackets.
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 added that for clarity, but I'm happy to correct in the next pull request.
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.
Yeah but Moodle has its coding style which we follow in plugins, too. Please see https://docs.moodle.org/dev/Coding_style
block_course_contents.php
Outdated
@@ -164,15 +164,41 @@ public function get_content() { | |||
$title = $format->get_section_name($section); | |||
} | |||
|
|||
if ( ($i == 0) && (!empty($globalconfig->display_course_link)) ) { |
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.
We should not check the globalconfig here. The global config should be used for setting the default values. Each block instance should have these settings available (via edit_form.php file).
$odd = $r % 2; | ||
if ($format->is_section_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.
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:
block_course_contents.php
Outdated
} else { | ||
$text .= html_writer::start_tag('li', array('class' => 'section-item r'.$odd)); | ||
} | ||
|
||
if ($i == 0) { | ||
// Never enumerate the section number 0. | ||
$enumeratesection0 = (!empty($globalconfig->enumerate_section_0) ? true : false); |
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.
Again, this should be instance-level setting. Also, I usually prefer explicit if/then block rather than this.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of the
here?
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.
For a little extra spacing between the number and section title.
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 am removing it and adding an extra space properly via CSS.
lang/en/block_course_contents.php
Outdated
$string['pluginname'] = 'Course contents'; | ||
$string['config_enumerate_section_0'] = 'Enumerate section 0'; |
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 could be reworded into more human language. Something like "Include the general section" or "Start enumerating with the general section" or so.
lang/en/block_course_contents.php
Outdated
$string['config_display_course_link'] = 'Display course page link'; | ||
$string['config_display_course_link_desc'] = 'Display course home page link before all sections at the top.'; | ||
$string['config_display_course_link_text'] = 'Display Course page link anchor text'; |
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.
Is there a use-case for not using the course name?
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.
Mainly because the course name might be too long.
settings.php
Outdated
@@ -41,6 +41,21 @@ | |||
$enumerate | |||
)); | |||
|
|||
// Enumerate section 0. | |||
$settings->add(new admin_setting_configcheckbox('block_course_contents/enumerate_section_0', | |||
get_string('config_enumerate_section_0', 'block_course_contents'), |
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.
These should be lang_string()
instances too.
… for enumerate general section 0 and display course page link in same manner as autotitle setting (allow overrides at instance level).
Hi David, I've submitted a pull request again so you should have another commit from today in there. Hope the changes are ok. I've made global and per-instance settings for the settings enumerate section 0 and display course link in the same way you did for auto title. Thanks, M |
Thanks for the contribution. I've melt your commits into a single one (9 were a bit too much for a change like this) and added some minor changes on top of it. I merged the final version into the master branch. I will appreciate if you can review the result and let me know you are happy with it so that I can release it as a new version of the plugin. Thanks in advance. |
Addresses issue #22.