Is a student with weak written examination skills also a weak candidate for PhD?
Let's map what you've written about your friend, onto the sort of things we might look for in a promising PhD candidate, to see why, although exams and PhD research are very different beasts, we might learn about one thing from another.


Meticulous? No.
Demonstrates good grasp of the substance and relevance of theory? No.
Can perform under pressure? No.
Can follow protocols? No.


As you can see, although you say the grade point average is only just below what is needed to convert to a PhD, there are a few warning signs that this student might not be appropriate PhD material; both the student and the decision-making body should pay heed.

I appreciate that this may not be easy for you to hear, as they are your friend. But really, PhDs aren't for everybody: there are lots of domain experts who are not PhD candidates; and there wil be lots of successful Computer Science PhDs who will never be such good programmers as your friend. A PhD is a measure of academic research skills, not of industrial skills or life skills.

Computer science and software engineering are two different disciplines, though they are related. Different institutions will teach them with varying degrees of overlap. But they are distinct. Maybe your friend is a talented software engineer who needs to specialise there, rather than in computer science.