This is a really, really difficult question. It’s something that classroom / course process tactics can mitigate, but not something they can solve. You really have to go deep into psychology: what students think education is for, how they imagine their own learning, what pressures they’re experiencing, what kinds of resilience they have.
There are some advantages I have going for me in my situation that an instructor can’t control:
- liberal arts college → students already likely to be invested in the idea that the •experience• of school is what’s valuable, as opposed to just the credential you acquire at the end
- unusually human-centered and anti-conformist campus culture
- strong cooperative (I’d even say anti-competitive) academic culture among the students
There are also things that •are• under instructor control:
- CS curriculum that’s •extremely• heavy on active learning: in-class time spent working hands on with code instead of just lecture (especially in intro classes)
- lots of projects and smaller assignments with a creative element that create pride of ownership, sense of agency, emotional investment in results
- flexible grading policies that help reduce the sorts of panic that lead to shortcutting and cheating
- positive student/instructor relationships, as much as I can manage
- normalizing struggle as a common and a •desirable• part of learning
…and then in that context, I talk a lot about •why• we’re doing what we’re doing, how learning works, how time and struggle are essential (“If you go to the gym and have a robot lift weights, do you expect to get stronger?”), and how grades are just a transient and essentially meaningless incentive structure and the •only• real thing of value they take away from the class will be the experience.