Teacher resigns after being revealed as author of soft porn book for teenagers set in school