Skip to content

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

Closed
wants to merge 9 commits into from

Conversation

5882wolverine
Copy link

Addresses issue #22.

@5882wolverine
Copy link
Author

Hi,

I've just submitted a pull request now :)

Thanks,

M

Copy link
Owner

@mudrd8mz mudrd8mz left a 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.

@@ -164,15 +164,41 @@ public function get_content() {
$title = $format->get_section_name($section);
}

if ( ($i == 0) && (!empty($globalconfig->display_course_link)) ) {
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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

@@ -164,15 +164,41 @@ public function get_content() {
$title = $format->get_section_name($section);
}

if ( ($i == 0) && (!empty($globalconfig->display_course_link)) ) {
Copy link
Owner

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)) {
Copy link
Owner

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?

Copy link
Author

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?

Copy link
Owner

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:

image

} 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);
Copy link
Owner

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');
Copy link
Owner

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?

Copy link
Author

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.

Copy link
Owner

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.

$string['pluginname'] = 'Course contents';
$string['config_enumerate_section_0'] = 'Enumerate section 0';
Copy link
Owner

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.

$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';
Copy link
Owner

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?

Copy link
Author

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'),
Copy link
Owner

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.

Manoj Solanki added 2 commits November 20, 2017 11:36
… for enumerate general section 0 and display course page link in same manner as autotitle setting (allow overrides at instance level).
@5882wolverine
Copy link
Author

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

@mudrd8mz
Copy link
Owner

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.

@mudrd8mz mudrd8mz closed this Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants