For the first question you can simply replace the questionsSeen
variable with a reference to the number of questions in the List<QuestionSO>
from the Quiz
script. For that you’d need to tell ScoreKeeper the total number of questions, and since Quiz
already contains a reference to ScoreKeeper
it would be simplest to send the value by setting up a public method in Scorekeeper such as:
int questionCount;
public void SetQuestionCount(int count)
{
questionCount = count;
}
Then change the CalculateScore
method to use that value:
public int CalculateScore()
{
return Mathf.RoundToInt(correctAnswers / (float)questionCount * 100);
}
If you have ten questions, every correct answer will award 10%
In Quiz
you’ll have to make sure to send the value by using the public method, probably in Start:
void Start()
{
scoreKeeper.SetQuestionCount(questions.Count);
}