A quick search of the Moodle plugins directory gives me this. https://moodle.org/plugins/view.php?plugin=mod_attendanceregister. I've never used it but it may be what you are looking for.
As mentioned by George this will never be very accurate as you can't be sure of someone has just opened the course page and then gone off to do something else.