...
The Recently viewed block shows the last few items the active user has opened. This block is intended to be a quick way to get back to content the user recently discovered. The following content types are included:
Courses
Programs
Certifications
Resources
Surveys
Playlists
Workspaces
The Recommended for you block shows the content generated by the Recommendations engine. It has four different types to show different types of recommendations:
Trending: The top courses, programs, certifications, resources, surveys, playlists or workspaces based on user interaction over the last day
Micro-learning: Resources recommended to the active user with a time to read of less than five minutes
Courses: Courses recommended to the active user
Workspaces: Workspaces recommended to the active user
Both blocks can display results in either a compact list format or as larger tiles/cards.
...
The core of the blocks is handled by the recommender system, and then the block picks the results out and creates a collection of card objects, then feeding them into the renderers which use Mustache templates found in the Recently viewed block.
Class | Purpose |
---|---|
block_totara_recently_viewed | Main block class for the Recently viewed block. The get_content method will call the renderer to resolve the cards for the specific IDs. Controls when/how this block can be seen. |
block_totara_recommendations | Main block class for the Recommended for you block. The get_content method will call the renderer to resolve the cards for the specific IDs. Controls when/how this block can be seen. Provides the renderer with the specific mode helper that should be used. |
block_totara_recently_viewed\renderer | Queries the interaction repository for a collection of recently viewed cards, then transforms them and passes them through to the Mustache template. |
block_totara_recommendations\renderer | Queries the provided mode helper for a collection of cards, then transforms them and passes them through to the Mustache template. |
block_totara_recently_viewed\card | Each type of item rendered in either block must implement a class with this interface. Provides the content to the templates in a standard format. |
block_totara_recently_viewed\card_resolver | Helper that searches for all of the supported card types and returns them as cards. |
block_totara_recently_viewed\repository\interaction_repository | Repository class that returns a list of recently viewed items based on the view interaction in the |
block_totara_recommendations\block_mode_factory | Factory class to return the specific block mode (helper to provide the recommended content). Also does access checks and will not resolve block types that are not enabled (e.g. Recommended workspaces will not be available if the Workspaces advanced feature is disabled). |
block_totara_recommendations\mode\block_mode | Each type of recommended block must implement this interface. See |
block_totara_recommendations\observer\trending_observer | Watches for deleted components. When something (such as a resource) is deleted, the trending recommendations for that resource are also deleted. |
block_totara_recommendations\repository\recommendations_repository | Repository class that provides the different lookups in the recommendations tables. |
block_totara_recommendations\task\refresh_totara_trending_data_task | Scheduled task that will repopulate the content in the |
Each type of card has an individual Mustache template to render it out in both list and tile modes.
Template | Purpose |
---|---|
block_totara_recently_viewed\templates\main.mustache | Main template entry point for Recently viewed. Will loop through the provided card collection and render the appropriate template. |
block_totara_recommendations\templates\main.mustache | Main template entry for Recommended for you. Will loop through the provided card collection and render the appropriate templates from recently viewed. |
block_totara_recently_viewed\templates\card_container_course.mustache | Template for rendering a course. |
block_totara_recently_viewed\templates\card_container_workspace.mustache | Template for rendering a workspace. |
block_totara_recently_viewed\templates\card_engage_article.mustache | Template for rendering a resource. |
block_totara_recently_viewed\templates\card_engage_survey.mustache | Template for rendering a survey. |
block_totara_recently_viewed\templates\card_totara_playlist.mustache | Template for rendering a playlist. |
block_totara_recently_viewed\templates\card_totara_program.mustache | Template for rendering a program or certification. |
How to support of the new type of content
...
Edit both the blocks/totara_recently_viewed/templates/main.mustache
and blocks/totara_reccommendations/templates/main.mustache
files and make the same changes.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<!-- ... --> {{#is_totara_program}} {{>block_totara_recently_viewed/card_totara_program}} {{/is_totara_program}} <!-- Add a new component here --> {{#is_new_component}} {{>block_totara_recently_viewed/card_new_component}} {{/is_new_component}} <!-- ... --> |
...