apluslms / a-plus

A+ frontend portal - A+ LMS documentation:
https://apluslms.github.io/
Other
68 stars 73 forks source link

Cache entries are loaded multiple times and unnecessarily #1232

Open lainets opened 1 year ago

lainets commented 1 year ago

Each access to a course loads CachedContent once and CachedPoints four times. CachedPoints includes CachedContent, so it should only be needed to load CachedPoints once (though this might be a bit difficult to implement). At the very least the duplicated CachedPoints loads should be removed.

ExerciseView also loads them, and seems to only really need the points for the exercise.

One reason for these is that the different mixins load things every time even if they aren't needed. I would suggest putting expensive attributes behind cached_properties, so that they are only loaded if they are needed. They would need to be passed to the templates using something like operator.attrgetter, so that they are only evaluated if the template needs them.