と先生に言われた

was told by the teacher that

→ と
phrase Rare #39,697
was told by the teacher that The と marks the content of what was said, and 言われた is the passive form of 言う, meaning that the speaker was told something. The subject of the quoted statement is usually understood from context.
JA: 宿題を忘れないようにと先生に言われた。
EN: I was told by the teacher not to forget my homework.

もっとじっくりスピーチの準備をすべきだったと先生に言われた

My teacher told me I should have taken more time to prepare my speech.

そうしろと先生に言われた

My teacher told me to do so.

— ダーク・プレイス (2015)

もっと水を飲んだ方がいいと先生に言われた

My teacher told me I should drink more water.

もっと時間をかけて発表準備すべきだったと先生に言われた

My teacher told me I should have spent more time preparing my presentation.