apluslms / a-plus

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

Fix ModuleRevealState crashing if it contains no exercises #1274

Closed Mikael-Lenander closed 11 months ago

Mikael-Lenander commented 11 months ago

Description

What?

ModuleRevealState stores the exercises of the module. If the module has none, an empty list is passed to max function, which throws an exception.

Why?

It is unlikely that any chapter should be hidden before a module with no exercises is "completed". However, if a teacher does set a model solution to this kind of module, the site will crash.

How?

Check if the list is empty before feeding it to the max function.

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

The site does not crash anymore if a module with no exercises has a model solution.

Did you test the changes in

Translation

Programming style

Have you updated the README or other relevant documentation?

Is it Done?

Clean up your git commit history before submitting the pull request!