A-levels and GCSEs: How did the exam algorithm work?

The government has made a U-turn on A-level results in England, but what sparked such controversy?