I have a vague recollection about a children's book I read a while ago, hopefully I'm not mixing things up with something else. Here's what I think I remember, though some of it might be wrong:
Set in a middle school on Earth, probably in the United States (if it's even mentioned)
There's a robot built by the students to interact with people that is being tested in the school
The robot's facial recognition system gets overloaded, so they turn it off
There's a computer system running the school, monitoring bad behavior, and announcing punishments. At some point, it goes rogue, so the students overload it with foul language, public displays of affection (PDA), etc.
Towards the end, the robot is about to unplug the computer system, but decides not to because it would be equivalent to death
At the end, one of the robots gets chosen to be sent on a mission to Mars, but they end up deciding to use the other one because its personality for resilience and forcefulness aligns better with surviving in space
There might be something about the robot reading books?
Any ideas or guesses, even if you're not really sure, would be much appreciated! I should hopefully be able to recognize the title or especially the cover.
Is this Fuzzy (2016) by Tom Angleberger and Paul Dellinger...?
The plot summary provided by this review matches your general description of the premise.
Max (short for Maxine, but she just likes Max and that's all) is a student at Vanguard Middle School. The school has been selected to pilot a Robot Integration Program, having an actual robot as a student. When she is chosen to act as a native guide for the robotic student, Fuzzy, Max is thrilled. But not everyone is happy about this development, including the computer program Barbara that acts as the vice-principal for the school. Barbara's lines of code and logic see Fuzzy as a disruption to learning, and students like Max fall into the same category. To get rid of these distractions, how far can and will a computerized school principal go?
I also searched the Google Books preview using terms such as "mars" and "public display of affection," and got hits for both.