Most of this function is written. All that is missing (look for
???
) are the indexes to use when comparing a studentโs answer to the key. Fill in those blanks with the correct counting variable - either
studentNumber
or
questionNumber
.
double questionDifficulty(
const ResponseSet& studentAnswers,
const Answers& key,
int questionNum
) {
---
// want to produce a decimal eventually
double numCorrect = 0;
---
size_t numStudents = studentAnswers.size();
for (size_t i = 0; i < numStudents; ++i) {
---
size_t numQuestions = key.size();
for (size_t i = 0; i < numQuestions; ++i) { #distractor
---
char answer = studentAnswers.at(i).at(questionNum);
char correctAnswer = key.at(questionNum);
---
char answer = studentAnswers.at(questionNum).at(i);
char correctAnswer = key.at(questionNum); #distractor
---
if (answer == correctAnswer) {
++numCorrect;
}
---
}
---
return numCorrect / numStudents;
}