Trying to add a class to post links

A little bit of PHP can be used to determine if the current unit has been rendered or not.

In the solution below, the flag $current_unit_rendered is initially set to false. We check to see if we’re on the current unit. If so, we set the $unit_class variable to the appropriate string and update the flag. Using this information, we know if we’re before or after the current unit:

<?php
    $current_id            = get_the_ID();
    $current_unit_rendered = false;
    $unit_class="";
    $the_query = new WP_Query(array(
            'posts_per_page' => -1, // Ideally, an upper limit like 500 should be used.
            'post_type'      => 'course_unit',
            'orderby'        => 'menu_order'
    ) );
?>
<h4>Your Course Units</h4>
<ul>
    <?php if ( $the_query->have_posts() ): while ( $the_query->have_posts() ) : $the_query->the_post(); 
        if ( get_the_ID() === $current_id ) {
            $unit_class="current-unit";
            $current_unit_rendered  = true;
        } elseif ( true === $current_unit_rendered ) {
            $unit_class="future-unit";
        } elseif ( false === $current_unit_rendered ) {
            $unit_class="previous-unit";
        }
    ?>
    <li><a href="https://wordpress.stackexchange.com/questions/253724/<?php the_permalink(); ?>" class="list-link <?php echo esc_attr( $unit_class) ?>"><?php the_title(); ?></a></li>
    <?php endwhile; endif; ?>
</ul>
<?php wp_reset_query(); ?>