From 4115ff91e7dc5e09afc919b1fd99e4d1bce3ef56 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Thu, 3 Jul 2025 13:14:43 -0700 Subject: [PATCH] Update QuizView.swift Fixed a bug where a user could select another answer after an answer was previously selected. Removed the Back button. There's no going back now! ;3 --- .../HAM Operator Quiz iPhone/QuizView.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HAM Operator Quiz iPhone/HAM Operator Quiz iPhone/QuizView.swift b/HAM Operator Quiz iPhone/HAM Operator Quiz iPhone/QuizView.swift index 215291d..547d2a0 100644 --- a/HAM Operator Quiz iPhone/HAM Operator Quiz iPhone/QuizView.swift +++ b/HAM Operator Quiz iPhone/HAM Operator Quiz iPhone/QuizView.swift @@ -23,7 +23,7 @@ struct QuizView: View { var body: some View { VStack(alignment: .leading, spacing: 20) { if loadError { - Text("Could not load questions for \(testName). Make sure the .json file is included in the app bundle or Documents folder.") + Text("Could not load questions for \(testName).") .foregroundColor(.red) .padding() } else if questions.isEmpty { @@ -36,6 +36,7 @@ struct QuizView: View { ForEach(questions[currentIndex].answers, id: \.self) { answer in Button(action: { + guard selectedAnswer == nil else { return } selectedAnswer = answer checkAnswer() @@ -58,6 +59,7 @@ struct QuizView: View { .foregroundColor(.white) } .buttonStyle(PlainButtonStyle()) + .disabled(selectedAnswer != nil) } Text(feedbackText) @@ -92,6 +94,7 @@ struct QuizView: View { .padding() .onAppear(perform: syncAndLoadQuestions) .navigationTitle(testName + " Test") + .navigationBarBackButtonHidden(true) .alert(isPresented: $showSummaryAlert) { let percentage = currentIndex > 0 ? Int((Double(score) / Double(currentIndex + 1)) * 100) : 0 return Alert(