Speed up gathering of information for each course section #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly, this checks section visibility at the start of the section processing, so that hidden sections are skipped immediately (rather than processing each activity in the section and then not adding them at the end).
Secondly, the cm_info functions 'get_url()' and 'get_icon_url()' are used, which both simplifies the code and removes a slow call to 'resource_get_coursemodule_info()' (which needs to access the DB to get the details of the file(s) included in the resource).
Also, the use of 'has_view()' allows for compatibility with any 3rd-party addons that, like the label module, do not have a 'view' link.