So what is your question about - calculating the stars, displaying them?
Record the number of correct answers. (correct/total)*100 gives you the percentage of correct answers. Then you can decide how many stars to give, say 3 stars for 100%, 2 stars for ≥50% or 1 star if <50%