One problem with releasing source as a teaching tool is that people will want to use parts of it (if it's any good, that is). A long time ago, I saw a good Macintosh framework in MacTech (or maybe it was MacTutor then), couldn't find license information, and wound up annoyed. I didn't want to reimplement it myself, particularly since I couldn't be sure to avoid copyright violations. It wasn't clear that I could use it.
No Open Source license (as defined by the Open Source Initiative, which is the standard in this area) will restrict redistribution or building a product on it. Such licenses can include some restrictions: the Gnu General Public License, for example, will prevent some possible uses, and will prevent somebody from producing a closed-source competing product.
You might want to look at some proprietary licenses for guidance, if that is definitely what you don't want. Microsoft has some, for example. You could look at the Free Software Foundation's license list and look through the ones that don't qualify as Free Licenses by FSF criteria. Some of these licenses are called "shared source" or "source available".
Or, you could roll your own. You might want to check with a lawyer, or not.
You do need to consider the following things:
- Exactly what do you want to permit? Is this going to impede its desired use? Will it annoy your users too much?
- Exactly what are you trying to protect? You're pretty close-mouthed about what this thing actually is.
- What will you actually lose if somebody violates the license?
- How do you intend to enforce the license? (It won't do much good to go into excessive details if you don't intend to enforce them.)
- What do you want from the user community?