First, students who work part-time in their spare time are not regarded as employment, because they have not established labor relations and do not need to sign labor contracts. According to Opinions on Several Issues Concerning the Implementation of the Labor Law of People's Republic of China (PRC) (12). If you don't graduate, you're not a laborer. Not signing a labor contract is legal and well documented. Your relationship is a contractual relationship rather than a labor relationship, so it should be protected by the contract law rather than the labor contract law.
Second, according to the contract law, the deposit you agreed is legal and effective. If you break the contract, the deposit will naturally not be recovered.