Hi,
The Dialogue System doesn't have built-in MySQL integration, so you will need to do at least a little bit of programming.
I recommend this approach:
1. Add a custom Boolean field named "Correct" to your dialogue database's dialogue entry template, and tick the Main checkbox:

- correctField.png (48.06 KiB) Viewed 1481 times
2. In your player response dialogue entries (the blue nodes), set the Correct field to true for the correct responses and false for the incorrect responses:

- correctAnswer.png (10.73 KiB) Viewed 1481 times
3. Add a script with an OnConversationLine(Subtitle) method to your Dialogue Manager GameObject. In this script, check if the line is a player line. If so, check its "Correct" field and record the value to your MySQL database. Example:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class RecordCorrectAnswers : MonoBehaviour
{
public string questionID;
void OnConversationLine(Subtitle subtitle)
{
if (string.IsNullOrEmpty(subtitle.formattedText.text)) return;
if (subtitle.speakerInfo.isNPC)
{
// If this is an NPC line (i.e., question, not answer), record a questionID to use when the player answers:
questionID = $"{subtitle.dialogueEntry.conversationID}:{subtitle.dialogueEntry.id}";
// Alternate: questionID = subtitle.dialogueEntry.Title;
}
else
{
// Otherwise this is a PC response line, so determine whether it's a correct or incorrect answer:
bool isCorrect = Field.LookupBool(subtitle.dialogueEntry.fields, "Correct");
// Then record it: (Here we just log it to the Console. In your case, log it to MySQL.)
Debug.Log($"Player answered {questionID} correctly? {isCorrect}");
}
}
}
In the example above, the question is identified by its conversation ID and entry ID. I also provided alternate code that could identify it by the question's Title field if you prefer.