Commit a65aadf
Changed files (1)
command.go
@@ -184,6 +184,13 @@ func calculateScore(numCorrect int, numQuestions int) float32 {
return float32(numCorrect) / float32(numQuestions) * 100
}
+// setStatusBarForTest updates the status bar to match the
+// current progress on the test the user is taking
+func setStatusBarForTest(clientTest *ClientTest, currentIndex int) {
+ setStatusBar(fmt.Sprintf("\tScore: %3.2f%%\tProgress: %d/%d",
+ clientTest.Score, currentIndex+1, len(clientTest.Records)))
+}
+
// walks the user through the test questions
// this function updates the records with the user responses
func runTest(clientTest *ClientTest) {
@@ -218,7 +225,9 @@ func runTest(clientTest *ClientTest) {
"[X]"+COLOR_RESET))
clientTest.Records[i].ClientAnswer = input
}
+ clientTest.Score = calculateScore(numCorrect, len(clientTest.Records))
updateMainView()
+ setStatusBarForTest(clientTest, i)
}
clientTest.Score = calculateScore(numCorrect, len(clientTest.Records))
}