as a teacher I might select one or several recent good questions from an on-topic Stack Exchange site and have students actually submit their answers on Stack Exchange
In the following, I will assume that you imagine this in a way that a teacher assigns a certain question to all students, and each student (or each of several teams of students) has to post an answer. As I will outline below, finding suitable questions could prove difficult, so using each question only for one student/team of students would probably be too uneconomical.
I would be opposed to this procedure:
- For a homework question, submitting what you think could be a valid answer, if you are not reasonably certain, is fine. After all, you're "entitled" to an attempt at solving the problem. Actually, if you do not have any idea how to respond to a question, even an almost random guess is OK as a response to a homework question, if you see a small chance it might be at least partially true. And likewise, a partial answer is totally fine for a homework question, as you have to use your chance to show even the partial solution that you have found, if you cannot solve the whole task.
- For a question on a Stack Exchange site, submitting any of the aforementioned "non-perfect" answers on purpose (especially on questions for which various more valid answers do exist) is unacceptable. Unless you are reasonably convinced that what you are posting is, in your opinion, a valid answer, you should not post it on a Stack Exchange site in a way that pretends to be an answer. Each posted answer takes time to read, and posting an answer that you know is quite likely wrong or incomplete (read: insufficient for the question) is simply disrespectful to all the people who take their time to read, evaluate, comment on, vote on and edit answers.
There are some further issues with your suggestion:
- Stack Exchange answers are public. As soon as one of the students has posted a good solution, nothing will stop other students from copying any information from that answer. You may still be testing your students' skills, but not the skills at solving the problem, but the skills at individually presenting a ready-made solution they found elsewhere.
- While votes on the Stack Exchange network indicate quality of the answers to some extent, there is no guarantee that this measurement works reliably for each answer. In particular, when there are many answers, my hunch is that most of the lower-ranked answers will never be read, while the top-ranked answers will be read repeatedly and receive ever more upvotes. To some extent, the same applies to comments, where the Nth answer is less likely to receive any helpful coments than the first one.
- Many Stack Exchange sites are not friendly towards duplicate answers. Exact reactions vary from site to site, but on various of the sites, the answer that proposes a certain solution for the 5th time might get harsh comments and even receive downvotes simply based on the fact that their answer does not contribute anything new.
Therefore, I do not unconditionally agree with the statement
It's sort of a free peer-review system.
It is a free peer-review system in the context of people voluntarily submitting posts for "peer-review" who want to submit something based on various preconditions (perceived good ideas, ...). The "peer-reviewers" spend their effort because they expect to read posts by exactly these people, people who thought they have good enough ideas to post.
If you remove those preconditions, you are, in a way, abusing the system. You are adding considerable workload for the peer-reviewers, who will have to dig through loads of submissions by people who did not think they have a good enough idea to post, but who posted primarily because it is their chance for completing the homework task. This, in turn, might reduce the willingness of those peer-reviewers to invest much effort for the respective Stack Exchange site in the first place and thereby worsen the experience for all users of the site.
After talking about the answers, I also have some thoughts about the questions. You wrote
as a teacher I might select one or several recent good questions
For more advanced students I might have them find good questions on their own.
Both of these can be problematic, as they are not guaranteed to yield good results. This is largely coupled to the fact that various Stack Exchange sites have strict policies against duplicate questions. These are fitting to build a consistent core of Q&A-shaped knowledge on each topic, but it also means that sooner or later, the less exotic (read: case-specific, or otherwise unusual or not too generalizeable) questions on any given topic will all have been asked. Asking new questions on the topic that are comparable without getting closed as duplicates can be come nearly impossible, whereas the task of finding interesting questions gradually gets reduced to checking a ready-made list of core questions on a given topic that gets circulated among students.
In summary, I think it is not a good idea to use any Stack Exchange site for "free peer-reviews" of student submissions. What is realistically feasible, though, is to use questions from a Stack Exchange site you deem appropriate and ask students to submit their own answer to you, and then check all the submissions. This will still preserve the real-world connection by the actual Stack Exchange question without burdening the users of the Stack Exchange site in any way.
As another note on this topic, from a privacy-related perspective, I am very skeptical of requiring any student to use a third-party service outside of the university's realm of control as a part of taking a class. Asking them to register somewhere (possibly, if they so choose, with a fake address, etc.) to retrieve software required for the class might still be OK, but I would never require a student to register with a third-party site (even one that I personally quite fully trust, like Stack Exchange) to upload anything that sheds a light on their performance as a student.