How is diamond quality determined?

How is diamond quality determined?