Commit a65aadf

Richard Luby <richluby@gmail.com>
2016-11-17 07:51:57
status bar gives context sensistive status
user receives feedback on test while taking it
1 parent 2f2ec04
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))
 }