Issue with fetching mysql data and displaying results via shortcode in webpage

$wpdb->get_results() returns an array of rows from the queried table and not a mysqli_result object, so you can just use foreach like so:

$result = $wpdb->get_results( $sql );

foreach ( $result as $row ) {
    echo $row->correct_count;
    // ...
}

And by default, each row is an object with the columns (<column name> => <column value>) in the database table, but if you want the item be an associative array, then pass ARRAY_A as the second parameter for $wpdb->get_results().

$result = $wpdb->get_results( $sql, ARRAY_A );

foreach ( $result as $row ) {
    echo $row['correct_count'];
    // ...
}

Please refer to the reference for further information.