Universities do encourage close cooperation between students and faculty. However, how does one prevent close working or personal relationships from affecting grading, so that it can be carried out fairly and uniformly? Is there a method of avoiding "playing favorites" with students a faculty member has a "closer" relationship with than others?
I would suggest to design a rubric to assess the work of students. The design of a rubric is difficult and may require a lot of work for the teacher, but it will isolate the grading process from other factors. Here you can find a book about rubrics.
One of the advantages of using a rubric is that students can easily observe how their work is going to be evaluated. Another advantage is that teachers can easily apply the same criteria across all the work to be graded.
If at all possible, have all papers and/or exams graded by two people independently, for example, two teaching assistants / graduate students. Then the official examiner can browse through the results. Where the two agree, one can directly go along with it. Where they don't agree, the examiner can judge what is correct.
This protects not only against favouritism, but also against simple, honest mistakes in grading. Of course, it's possible that two or even three all make the same error, but that's why students have the opportunity to appeal, don't they?
Where possible, exams and courseworks should be anonymised before grading. But otherwise, we have to depend on the professionalism of academics, a strategy I think is sometimes undervalued. Academics are professionals, and one part of many professions is striving to be objective.
Of course, psychologically it is impossible not to be influenced by knowledge, but it shouldn't be assumed that academics can't compensate for this adequately to give fair marks. Some people may actually overcompensate and mark students they know harder, not easier, but hopefully the experience of learning from working with faculty makes up for this risk.
The ultimate academic "grade", a PhD, is entirely assessed by letters written by people who know the holder both personally and professionally. Again, the same is true in other industries.