by Jake Dallimore.
Hi Akshay,
You're right in that Moodle is the limiting factor for you right now. You're also right in that you need to create a plugin, however, implementing the before_launch() callback in the plugin won't allow you to add new substitution vars for use in the Moodle form; it allows you to programatically set custom_xxxx values based on, well, whatever you like (you can fetch this data however you like during the before_launch callback), and include these in tool launches.
You'll likely also want to ensure that whatever custom_xxx properties you need are only being added to launches of your specific tool too - perhaps by inspection/comparison of the tool url in that callback function. The way that plugin callback is designed makes it a global callback that will be called before ALL tool launches. If the logic to fetch your leaderboard data is heavy, you really want to make sure you're only doing it when the appropriate tool URL is seen. The callback receives a few things:https://github.com/moodle/moodle/blob/master/mod/lti/locallib.php#L671
1. The tool type (a record from the PREFIX_enrol_lti_tools table)
You're right in that Moodle is the limiting factor for you right now. You're also right in that you need to create a plugin, however, implementing the before_launch() callback in the plugin won't allow you to add new substitution vars for use in the Moodle form; it allows you to programatically set custom_xxxx values based on, well, whatever you like (you can fetch this data however you like during the before_launch callback), and include these in tool launches.
You'll likely also want to ensure that whatever custom_xxx properties you need are only being added to launches of your specific tool too - perhaps by inspection/comparison of the tool url in that callback function. The way that plugin callback is designed makes it a global callback that will be called before ALL tool launches. If the logic to fetch your leaderboard data is heavy, you really want to make sure you're only doing it when the appropriate tool URL is seen. The callback receives a few things:https://github.com/moodle/moodle/blob/master/mod/lti/locallib.php#L671
1. The tool type (a record from the PREFIX_enrol_lti_tools table)
2. The tool URL
3. The request params
You should be able to make the relevant decision on whether to add leaderboard information based on the tool url here.
Hope that helps
Jake