My question is inspired by this question. Say a student wants to publish on GitHub some code that they've written as assignments for a programming class. The student may be motivated by a desire to show off their programming skills and advance their career this way, or by a wish to provide a useful resource on the internet that others might useful (say, people who are teaching themselves to program, or programmers who may be able to use the code to save themselves some work in connection with a project they're working on), or some combination.
The student publishes the code, but is then contacted by their department who ask him to take down the code, citing concerns that the code might be used to commit plagiarism by students taking the same class in following years.
First question: is it appropriate and ethical for the department to make such a request of the student? Are they not putting their own selfish interests ahead of the student's own interests and the interests of the community of people who might benefit from having the student's code be made available online?
Second question: Is the student obliged to comply with such a request, or can they simply say they have a right to put their work online in a publicly hosted website if they so desire and be entitled not to suffer any retaliation from the department for this refusal?
Note that even if the student is not obliged to comply with the request, it may still arguably be inappropriate of the department to make it, since the department has authority over the student and under such circumstances it is not clear that the student can make a decision to refuse that is free of duress.