MDL-33441 course/lib.php prevent fatal error when no visible categories