Hi Petr,
although your solution is very elegant, I'm not really sure if it will scale fine with courses having a lot of
sections. Instead, the drop-down menu will scale fine.
Anyway, some type of paging will be necessary, because some sections can be too much individually. So I think that, the drop-down plus paging should be the solution.
But, taking a look to the code, I think that it's really difficult to make the paging, because every module_user_complete() function is being invoked independently, so it's impossible to control the number of "actions" showed for each of them.
The solution should involve passing some extra parameters (the number of actions printed and the size of the paging) to such functions and to make them return some value too (the number of actions printed by it. Only then, that view could include paging, I think! If anybody has another alternative....
About optimisation, I think that all that functions are executing queries based in the userid, and moduleid fields. If theory is being applied, used tables should have indexes in that fields (because they are foreign_keys). It should improve things a lot (more if done with all the fks in Moodle!!), although I think that, in this case, the problem can be the "render" time instead of the "DB query" time!!
Ciao