Are you able to install plugins on your site? If so then there is a Restrict by password availability plugin that will do what you want: https://moodle.org/plugins/availability_password
Security and privacy
Folder Password in Moodle
This discussion has been locked so you can no longer reply to it.