So I have had this happen twice. With current and former patients. I split my time teaching undergrads and engaging in clinical work, so I assumed this would happen at some point, just did not realize how early in my career I would be presented with it. I also teach a few classes within a small minor that require certain courses (including one that I teach) to be taken for their minor requirements. I am kind of SOL in terms of dictating whether they should take it or not. So lots of consulting with colleagues initially on how to best manage this, how to have this conversation with patients, etc.
The way I have worked around it is via TAs. I am NOT involved in grading basically anything in the course, for any students. That is a complete luxury, I recognize this. I will help with grading if needed, but since my students submit things via an online portal, I have the option to blind myself to the students names on assignments. Otherwise I am mostly just incorporating grades together for final grading / calculating attendance grades, which are objective and laid out in my syllabus. I have never had a student-patient challenge or appeal grades, but if they did it would be difficult to do so since everything is so cut and dry in terms of points and grading.
I have frank conversations about this with patients as well. In one case they were a current patient so could have that conversation ongoing. In the other case I knew in advance that a patient was enrolled in my course and discussed the dual role with them prior to the end of their therapy (unrelated to my course). This was really helpful and both had good questions/agreed to the process that I go by in my class with grading and evaluations. I have not run into any problems with this yet, but do try to avoid it when I can (e.g., I try not to take patients who are enrolled in the minor i teach for, but sometimes this is unavoidable given geography/what I specialize in). I have also made this more clear with the head of our minor in terms of my ethical standards.
With that all being said, it is not ideal and is uncomfortable at times. You have to set clear boundaries ("I will not discuss matters of the course in therapy and I will not discuss therapy if you come up to me after class or come into office hours") and be very frank about how grading works. I was also really clear to document in therapy notes when we discussed these concerns prior to class starting/that the patient agreed and understood, etc..
I am still learning on this too and am definitely curious to hear other perspectives/thoughts! The dual-role piece is a huge struggle in my location (small state, college town, basically 1/10 of the state population is in a 20-mile radius with little behavioral health outside of the area). It's always discussed with my patients in some capacity, just depends on the patient.