questions havve id now

This commit is contained in:
Morgan - 6 Freedom 2024-01-28 11:46:24 +01:00
parent f254c044e8
commit 6e57cf8bfb
2 changed files with 7 additions and 8 deletions

View File

@ -6,6 +6,7 @@
[JsonObject]
public class Question
{
public string id;
public string promptId;
public Dictionary<string, Proposition> propositions;
public double creationDate;

View File

@ -43,11 +43,9 @@ public class RoomManager : MonoBehaviour
private float votingCurrentTime = 0;
/// <summary>
/// Contain the infos about the current displayed question (during votes)
/// Contain all the question for this game session
/// </summary>
private Question currentQuestion;
private List<Question> questions;
private Dictionary<string, Question> questions = new Dictionary<string, Question>();
/// <summary>
/// When this is equal to questions.Count, go to score page
@ -300,7 +298,7 @@ public void GeneratePrompts()
System.Random rnd = new();
List<Prompt> prompts = promptList.prompts.OrderBy(x => rnd.Next()).Take(myRoom.players.Count() * 2).ToList();
List<Player> fullPlayers = myRoom.players.Values.ToList().Concat(myRoom.players.Values.ToList()).OrderBy(x => rnd.Next()).ToList();
Dictionary<string, Question> questions = new();
questions.Clear();
foreach (Prompt prompt in prompts)
{
@ -331,15 +329,15 @@ public void GeneratePrompts()
break;
}
}
questions.Add(Guid.NewGuid().ToString(), new Question()
string newId = Guid.NewGuid().ToString();
questions.Add(newId, new Question()
{
id = newId,
promptId = prompt.id,
propositions = propositions,
creationDate = DateTime.Now.ToOADate(),
});
}
string JSON = JsonConvert.SerializeObject(questions);
realtimeDB.Child("rooms").Child(myRoom.code).Child("questions").SetRawJsonValueAsync(JSON);
}