Hi @barron
I’ve written some code for you to show how you would compare the current ID to the loop ID:
<?php foreach( $posts as $post): ?>
<li class="lesson <?php if( get_the_ID() == $post->ID): ?>active<?php endif; ?>">
<h3><a href="<?php echo get_permalink( $post->ID ); ?>"><?php echo get_the_title( $post->ID ); ?></a></h3>
</li>
<?php endforeach; ?>
Please note I have removed the setup_postdata function as this will only cause you headaches if you are not careful with it