Totara allows users the choice to choose training:
- Via the training catalogue by searching for course/program
- Via the training calendar by date (i.e. looking for training in next few weeks)
This simple code provides a third option for users to find learning; i.e. choose their location to see if there are any upcoming seminar events to attend at their site/location (i.e. Room).
This is one of the 3 methods for users to find learning:
- Catalogue
- Calendar
- Workshops at location
Here is the process in detail:
There are 2 parts to this:
- Add a locations drop down to a dashboard with the values of the locations set to equivalent Room IDs. We will use scripts to redirect users to a report with roomid appended to the URL.
- Add code to a Seminar Room Assignments report. The roomid passed through the URL is used to filter and only show events happening at a particular location. In this report, include a column for Number of Attendees (linked to attendee page). The script uses this link and modifies it into a simple sign-up button.
More comments have been added to the code.
1. Trainers can choose a room (I have renamed Rooms to Locations via the Language pack).
Learn more how to Modify the correct language string easily in Totara LMS.
2. Each room has a unique ID which we can identify from the Manage Rooms Page /mod/facetoface/room/manage.php
Note: each location has been set to one of the site locations (rooms). Actual room name is added to the event description.
3. We use a simple Search By Location Dashboard /totara/dashboard/index.php?id=41
. It has a dropdown to choose location.
4. The SELECT Location (drop down) has its option values set to the Room Numbers. The first option value is set to โallโ
(1). Our code will redirect users to a report and append this value to the URL. When Virtual Session is selected, the &roomid=392
is appended to the report URL (2). When All upcoming sessions is selected, the &roomid=all
is appended to the report URL. When Melbourne is selected, the &roomid=393
is appended to the report URL.
Note: I was unable to add the select box to the Report itself since the HTML editor in report removes custom html.
Add the below code to create your custom location selector. Get your option values for your locations from /mod/facetoface/room/manage.php
<select id="location-selector">
<option value="all">Select Location</option>
<option value="392">Virtual Session</option>
<option value="393">Melbourne</option>
<option value="394">Sydney</option>
<option value="395">Adelaide</option>
<option value="396">Perth</option>
<option value="397">Box Hill</option>
<option value="398">External Location</option>
</select>
4. On the report page we generate sign-up buttons using the room ID.
The roomid filters and only shows events for that location.
Each event has an ‘Number of Attendees (linked to attendee page)’ column (1). This column has a link to facetoface/attendees/view.php?id=xxxx
screen.
We use our code to create a button (2) that redirect instead to the signup screen using that same event id. Notice the ?s=2088
in the code below.
Add the code
You can add the code below sitewide across LMS via /admin/settings.php?section=additionalhtml
to activate this filter on all seminar events or load it for an individual course via HTML block. Refer to my post on How to add code to enhance Totara LMS on LinkedIn More comments have been added to the code. Add this code to the Before Body is Closed section of Additional HTML screen.
<script>
$(document).ready(function () {
/*
Step 1: Create a signup via locations (Room ID) using a simple drop down on a dashboard page. When a location is selected, user is redirected to Seminar Room Assignments Reports with Sign-up buttons (see step 2 below)
*/
if ($('body').attr('id') == "page-totara-dashboard-41") { // only target the sign-up by location dashboard using Body ID
var locationSelector = document.getElementById("location-selector"); // get the dropdown
var locationLink = '/totara/reportbuilder/report.php?id=321&sid=1021&roomid='; // link to the report where users will sign-up. It is a saved search that does not show cancelled events and only shows upcoming events for next 1 year.
var allupcoming = "/totara/reportbuilder/report.php?id=321&sid=1021"; // remove the locations (roomid) filter to show all all upcoming training.
$('#location-selector').on("change", function () { // when the dropdown is changed
if (locationSelector.value === "") { // do nothing if location drop down is empty
} else if (locationSelector.value == "all") { // when all is chosen, redirect to the allupcoming link
window.location.href = allupcoming;
} else { // when any other location is chosen, redirect to the report but with roomid value extracted from the drop down and added to the end of the URL.
window.location.href = locationLink + locationSelector.value;
}
})
}
/*
Step 2: Add sign-up buttons to a Seminar Room Assignments report to allow users to sign-up by location. Users have been brought here from the dropdown they chose in step 1 above. Doing so creates a unique URL with the attribute &roomid=xxx appended to the report URL. This filters the report to just show only the events for that room ID (i.e. location).
*/
if ($('body').attr('id') == "page-totara-reportbuilder-report") { //target the specific report only using ID for body
$('#report_workshop_room_assignments td.session_numattendeeslink a').each(function () { // in the report look for all links in 'Number of Attendees (linked to attendee page)' column
var link = $(this).attr('href'); // get the link URL which looks like /mod/facetoface/attendees/view.php?s=xxxx
var newlink = link.replace('attendees/view.php?s=', 'signup.php?s='); // modify the URL to a sign-up link that looks like /mod/facetoface/signup.php?s=xxxx
$(this).append('<span class="sign-up-link" style="margin-left: 1em;"><a class="link-as-button" href="' + newlink + '">Sign-up</a></span>'); // Modify the new link to look like a button and display it next to the Number of attendees link.
});
}
});
</script>
That’s it!
I hope you found this useful!
Please comment and share your own thoughts on this technique…