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.
113 lines
3.4 KiB
C#
113 lines
3.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using ArabicSupport;
|
|
|
|
public class MiniQuizManager : MonoBehaviour
|
|
{
|
|
public Button[] answerButtons; // A, B, C, D
|
|
public TextMeshProUGUI[] answerLabels; // Corresponding TMP labels
|
|
public TextMeshProUGUI feedbackText;
|
|
|
|
private string[] answerTexts = new string[]
|
|
{
|
|
"Typos in the subject",
|
|
"Urgent language",
|
|
"Mismatched sender email",
|
|
"All of the above"
|
|
};
|
|
|
|
private string[] answerTextsAr = new string[]
|
|
{
|
|
"أخطاء مطبعية في العنوان",
|
|
"لغة مستعجلة",
|
|
"عنوان بريد مرسل غير متطابق",
|
|
"جميع ما سبق"
|
|
};
|
|
|
|
private int correctIndex = 3;
|
|
|
|
public void SubmitAnswer(int selectedIndex)
|
|
{
|
|
bool isArabic = LanguageManager.Instance != null &&
|
|
LanguageManager.Instance.currentLanguage == "Arabic";
|
|
|
|
string selectedAnswer = answerTexts[selectedIndex];
|
|
string selectedAnswerAr = answerTextsAr[selectedIndex];
|
|
|
|
// Log the selected answer
|
|
UserActionLogger.Instance?.LogQuizAnswer(selectedAnswer, selectedAnswerAr);
|
|
|
|
// Show feedback
|
|
if (selectedIndex == correctIndex)
|
|
{
|
|
feedbackText.text = isArabic
|
|
? ArabicFixer.Fix("✅ إجابة صحيحة! جميعها كانت إشارات خطر.")
|
|
: "✅ Correct! All of those were red flags.";
|
|
}
|
|
else
|
|
{
|
|
string correctAnswer = answerTexts[correctIndex];
|
|
string correctAnswerAr = answerTextsAr[correctIndex];
|
|
|
|
feedbackText.text = isArabic
|
|
? ArabicFixer.Fix($"❌ ليست الإجابة الصحيحة. الإجابة الصحيحة هي: {correctAnswerAr}")
|
|
: $"❌ Not quite. The correct answer was: {correctAnswer}";
|
|
}
|
|
|
|
// Disable all buttons
|
|
foreach (var btn in answerButtons)
|
|
btn.interactable = false;
|
|
|
|
// Prepend a ✅ to the selected label
|
|
answerLabels[selectedIndex].text = "✅ " + answerLabels[selectedIndex].text;
|
|
}
|
|
}
|
|
|
|
|
|
//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;
|
|
// }
|
|
//}
|