You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class MiniQuizManager : MonoBehaviour
|
|
{
|
|
public Button[] answerButtons; // Assign in order: A, B, C, D
|
|
public TextMeshProUGUI[] answerLabels; // Same order as buttons
|
|
public TextMeshProUGUI feedbackText;
|
|
|
|
private string[] answerTexts = new string[]
|
|
{
|
|
"Typos in the subject",
|
|
"Urgent language",
|
|
"Mismatched sender email",
|
|
"All of the above"
|
|
};
|
|
|
|
private int correctIndex = 3;
|
|
|
|
public void SubmitAnswer(int selectedIndex)
|
|
{
|
|
string selectedAnswer = answerTexts[selectedIndex];
|
|
UserActionLogger.Instance?.LogQuizAnswer(selectedAnswer);
|
|
|
|
// Feedback
|
|
if (selectedIndex == correctIndex)
|
|
{
|
|
feedbackText.text = "✅ Correct! All of those were red flags.";
|
|
}
|
|
else
|
|
{
|
|
feedbackText.text = $"❌ Not quite. The correct answer was: {answerTexts[correctIndex]}";
|
|
}
|
|
|
|
// Lock all buttons
|
|
foreach (var btn in answerButtons)
|
|
{
|
|
btn.interactable = false;
|
|
}
|
|
|
|
// Mark selected
|
|
answerLabels[selectedIndex].text = "✅ " + answerLabels[selectedIndex].text;
|
|
}
|
|
}
|