Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Linq;
- using UnityEngine;
- using System.Collections.Generic;
- using System.Runtime.Serialization.Formatters.Binary;
- using System;
- [System.Serializable]
- public class Enfant
- {
- public Enfant()
- {
- EvaluationsApp1 = new List<EvaluationApp1>();
- EvaluationsApp2 = new List<EvaluationApp2>();
- EvaluationsApp3 = new List<EvaluationApp3>();
- EvaluationsApp4 = new List<EvaluationApp4>();
- }
- public int EnfantID;
- public string NumeroDossier;
- public string Nom;
- public string Prenom;
- public string Genre;
- public string DateDeNaissance;
- public string ct1;
- public string ct2;
- public string NiveauScolaire;
- public string MoyenneAnneePrecedente;
- public string NivSocioEco;
- public string DiagnostiqueDSMV;
- public string CPM;
- public string TestComprehension;
- public string TestDeFluenceVerbaleSemantique;
- public string NomReferant;
- public string PrenomReferant;
- public string StatusReferant;
- public string situationMatrimoniale;
- public string NombreEnfants;
- public string MaladieAuLongCours;
- public string AntecedentsPsychiatriques;
- public List<EvaluationApp1> EvaluationsApp1;
- public List<EvaluationApp2> EvaluationsApp2;
- public List<EvaluationApp3> EvaluationsApp3;
- public List<EvaluationApp4> EvaluationsApp4;
- }
- [System.Serializable]
- public class EvaluationApp1
- {
- public EvaluationApp1()
- {
- Sessions = new List<Session>();
- }
- public string EvaluationID;
- public List<Session> Sessions;
- public int GetGlobalScore()
- {
- int result = 0;
- foreach (var session in Sessions)
- {
- result += session.ScoreSession;
- }
- return result;
- }
- }
- [System.Serializable]
- public class EvaluationApp2
- {
- public string EvaluationID;
- public int Score;
- public int Duree;
- public string NomExaminateur;
- public string DateExamination;
- public string LieuExamination;
- public List<TagApp2> Tags = new List<TagApp2>() {
- new TagApp2 () { ID = TagID2.EmpathieAffective, Label = "Empathie Affective", Value = 0 },
- new TagApp2 () { ID = TagID2.EmpathieCognitive, Label = "Empathie Cognitive", Value = 0 },
- new TagApp2 () { ID = TagID2.EmpathieSomatique, Label = "Empathie Somatique", Value = 0 },
- new TagApp2 () { ID = TagID2.ComporetementsEmpathiques, Label = "Comporetements Empathiques", Value = 0 }
- };
- }
- [System.Serializable]
- public class EvaluationApp3
- {
- public string EvaluationID;
- public int Score;
- public int NonReponse;
- public int Duree;
- public int DureeMoyenne;
- public bool isVideo;
- public string nomExaimnateur;
- public string LieuExamination;
- public string DateExamination;
- public List<TagApp3> Tags = new List<TagApp3>() {
- new TagApp3 () { EmotionID = EmotionTagID.Colère, Label = "Colère", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Dégoût, Label = "Dégoût", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Joie, Label = "Joie", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Peur, Label = "Peur", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Surprise, Label = "Surprise", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Tristesse, Label = "Tristesse", Value = 0, Correct = 0 },
- new TagApp3 () { EmotionID = EmotionTagID.Neutre, Label = "Neutre", Value = 0, Correct = 0 },
- new TagApp3 () { GenderID = GenderTagID.Masculin, Label = "Masculin", Value = 0, Correct = 0 },
- new TagApp3 () { GenderID = GenderTagID.Féminin, Label = "Féminin", Value = 0, Correct = 0 },
- new TagApp3 () { AgeTagID = AgeTagID.Adolescent, Label = "Adolescent", Value = 0, Correct = 0 },
- new TagApp3 () { AgeTagID = AgeTagID.Enfant, Label = "Enfant", Value = 0, Correct = 0 },
- new TagApp3 () { AgeTagID = AgeTagID.Adulte, Label = "Adulte", Value = 0, Correct = 0 },
- new TagApp3 () { IntensityTagId = IntensityId.Faible, Label = "Faible", Value = 0, Correct = 0 },
- new TagApp3 () { IntensityTagId = IntensityId.Moyenne, Label = "Moyenne", Value = 0, Correct = 0 },
- new TagApp3 () { IntensityTagId = IntensityId.Forte, Label = "Forte", Value = 0, Correct = 0 }
- };
- }
- [System.Serializable]
- public class EvaluationApp4
- {
- public string EvaluationID;
- public int Score;
- public int Duree;
- public int DureeMoyenne;
- public string nomExaimnateur;
- public string LieuExamination;
- public string DateExamination;
- public List<TagApp4> Tags2 = new List<TagApp4>() {
- new TagApp4 () { logicID = LogicTagId.attributionEmpathique, Label = "attributionEmpathique", Value = 0, Correct = 0 },
- new TagApp4 () { logicID = LogicTagId.EMaffectif, Label = "EMaffectif", Value = 0, Correct = 0 },
- new TagApp4 () { logicID = LogicTagId.EMcognitif, Label = "EMcognitif", Value = 0, Correct = 0 },
- new TagApp4 () { logicID = LogicTagId.comportementales, Label = "comportementales", Value = 0, Correct = 0 },
- new TagApp4 () { logicID = LogicTagId.intentionelle, Label = "intentionelle", Value = 0, Correct = 0 },
- new TagApp4 () { logicID = LogicTagId.logiquePhysique, Label = "logiquePhysique", Value = 0, Correct = 0 },
- };
- }
- [System.Serializable]
- public class Session
- {
- public Session()
- {
- SituationsDone = new List<int>();
- }
- public string SessionID;
- public string NomExaminateur;
- public string DateExamination;
- public string LieuExamination;
- public int ScoreSession;
- public int Duree;
- public bool Synced;
- public List<TagApp1> Tags = new List<TagApp1>() {
- new TagApp1 () { ID = TagID.Epistémique, Label = "Epistémique", Value = 0 },
- new TagApp1 () { ID = TagID.EpistémiqueNiveau2, Label = "Epistémique Niveau 2", Value = 0 },
- new TagApp1 () { ID = TagID.Affectif, Label = "Affectif", Value = 0 },
- new TagApp1 () { ID = TagID.Intention, Label = "Intention", Value = 0 },
- new TagApp1 () { ID = TagID.MaladresseSociale, Label = "Maladresse Sociale", Value = 0 },
- new TagApp1 () { ID = TagID.CompréhensionSimple, Label = "Compréhension Simple", Value = 0 },
- new TagApp1 () { ID = TagID.Contrôle, Label = "Contrôle", Value = 0 }
- };
- // List of stories which are done in this session
- public List<int> SituationsDone;
- }
- [System.Serializable]
- public class DB
- {
- public DB()
- {
- Enfants = new List<Enfant>();
- }
- public List<Enfant> Enfants;
- }
- public static class Persistence
- {
- #if UNITY_EDITOR
- public static string DataPath = Application.persistentDataPath + "/sessions.data";
- #else
- public static string DataPath = "/storage/sdcard0/Android/data/com.nextgen.therapieform/files/sessions.data";
- #endif
- public static DB ReadDB()
- {
- BinaryFormatter bf = new BinaryFormatter();
- FileStream readFileStream = new FileStream(DataPath, FileMode.OpenOrCreate, FileAccess.Read);
- DB db;
- if (readFileStream.Length == 0)
- {
- db = new DB();
- }
- else
- {
- db = (DB)bf.Deserialize(readFileStream);
- }
- readFileStream.Close();
- return db;
- }
- public static void WriteDB(DB db)
- {
- BinaryFormatter bf = new BinaryFormatter();
- FileStream writeFileStream = new FileStream(DataPath, FileMode.OpenOrCreate, FileAccess.Write);
- bf.Serialize(writeFileStream, db);
- writeFileStream.Close();
- }
- public static List<Enfant> GetAllEnfants()
- {
- return ReadDB().Enfants;
- }
- public static Enfant GetEnfantByID(int id)
- {
- return ReadDB().Enfants.First(enf => enf.EnfantID == id);
- }
- public static Enfant GetEnfantByNumDossier(string numDossier)
- {
- return ReadDB().Enfants.FirstOrDefault(enfant => enfant.NumeroDossier == numDossier);
- }
- public static List<EvaluationApp3> GetEvaluationsApp3ByEnfantID(int EnfantID)
- {
- return ReadDB().Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp3;
- }
- public static List<EvaluationApp4> GetEvaluationsApp4ByEnfantID(int EnfantID)
- {
- return ReadDB().Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp4;
- }
- public static List<EvaluationApp2> GetEvaluationsApp2ByEnfantID(int EnfantID)
- {
- return ReadDB().Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp2;
- }
- public static string TimeStampID()
- {
- return (Int32)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds + "";
- }
- public static void AddEvaluationApp3ForEnfant(int EnfantID, int score, int duree, int dureeMoyenne, int nonReponses, bool isVideo, int[] tags, int[] tagsCorrect)
- {
- DB db = ReadDB();
- EvaluationApp3 eval = new EvaluationApp3();
- eval.EvaluationID = TimeStampID();
- eval.Score = score;
- eval.Duree = duree;
- eval.NonReponse = nonReponses;
- eval.DureeMoyenne = dureeMoyenne;
- eval.isVideo = isVideo;
- eval.Tags[0].Value = tags[0];
- eval.Tags[1].Value = tags[1];
- eval.Tags[2].Value = tags[2];
- eval.Tags[3].Value = tags[3];
- eval.Tags[4].Value = tags[4];
- eval.Tags[5].Value = tags[5];
- eval.Tags[6].Value = tags[6];
- eval.Tags[7].Value = tags[7];
- eval.Tags[8].Value = tags[8];
- eval.Tags[9].Value = tags[9];
- eval.Tags[10].Value = tags[10];
- eval.Tags[11].Value = tags[11];
- eval.Tags[12].Value = tags[12];
- eval.Tags[13].Value = tags[13];
- eval.Tags[14].Value = tags[14];
- eval.Tags[0].Correct = tagsCorrect[0];
- eval.Tags[1].Correct = tagsCorrect[1];
- eval.Tags[2].Correct = tagsCorrect[2];
- eval.Tags[3].Correct = tagsCorrect[3];
- eval.Tags[4].Correct = tagsCorrect[4];
- eval.Tags[5].Correct = tagsCorrect[5];
- eval.Tags[6].Correct = tagsCorrect[6];
- eval.Tags[7].Correct = tagsCorrect[7];
- eval.Tags[8].Correct = tagsCorrect[8];
- eval.Tags[9].Correct = tagsCorrect[9];
- eval.Tags[10].Correct = tagsCorrect[10];
- eval.Tags[11].Correct = tagsCorrect[11];
- eval.Tags[12].Correct = tagsCorrect[12];
- eval.Tags[13].Correct = tagsCorrect[13];
- eval.Tags[14].Correct = tagsCorrect[14];
- db.Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp3.Add(eval);
- WriteDB(db);
- }
- public static void AddEvaluationApp4ForEnfant(int EnfantID, int score, int duree, int dureeMoyenne, int[] tags, int[] tagsCorrect)
- {
- DB db = ReadDB();
- EvaluationApp4 eval = new EvaluationApp4();
- eval.EvaluationID = TimeStampID();
- eval.Score = score;
- eval.Duree = duree;
- eval.DureeMoyenne = dureeMoyenne;
- eval.Tags2[0].Value = tags[0];
- eval.Tags2[1].Value = tags[1];
- eval.Tags2[2].Value = tags[2];
- eval.Tags2[3].Value = tags[3];
- eval.Tags2[4].Value = tags[4];
- eval.Tags2[5].Value = tags[5];
- eval.Tags2[0].Correct = tagsCorrect[0];
- eval.Tags2[1].Correct = tagsCorrect[1];
- eval.Tags2[2].Correct = tagsCorrect[2];
- eval.Tags2[3].Correct = tagsCorrect[3];
- eval.Tags2[4].Correct = tagsCorrect[4];
- eval.Tags2[5].Correct = tagsCorrect[5];
- db.Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp4.Add(eval);
- WriteDB(db);
- }
- public static void AddEvaluationApp2ForEnfant(int EnfantID, int score, int duree, params int[] tags)
- {
- DB db = ReadDB();
- EvaluationApp2 eval = new EvaluationApp2();
- eval.EvaluationID = TimeStampID();
- eval.Score = score;
- eval.Duree = duree;
- eval.Tags[0].Value = tags[0];
- eval.Tags[1].Value = tags[1];
- eval.Tags[2].Value = tags[2];
- eval.Tags[3].Value = tags[3];
- db.Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp2.Add(eval);
- WriteDB(db);
- }
- public static void UpdateEvaluationApp3WithScoreAndDurationAndTags(int EnfantID, string EvaluationID, int score, int duree, int dureeMoyenne, int nonReponses, bool isVideo, int[] tags, int[] tagsCorrect)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp3 evaluation = enfant.EvaluationsApp3.First(eval => eval.EvaluationID == EvaluationID);
- evaluation.Score = score;
- evaluation.Duree = duree;
- evaluation.NonReponse = nonReponses;
- evaluation.DureeMoyenne = dureeMoyenne;
- evaluation.isVideo = isVideo;
- evaluation.Tags[0].Value = tags[0];
- evaluation.Tags[1].Value = tags[1];
- evaluation.Tags[2].Value = tags[2];
- evaluation.Tags[3].Value = tags[3];
- evaluation.Tags[4].Value = tags[4];
- evaluation.Tags[5].Value = tags[5];
- evaluation.Tags[6].Value = tags[6];
- evaluation.Tags[7].Value = tags[7];
- evaluation.Tags[8].Value = tags[8];
- evaluation.Tags[9].Value = tags[9];
- evaluation.Tags[10].Value = tags[10];
- evaluation.Tags[11].Value = tags[11];
- evaluation.Tags[12].Value = tags[12];
- evaluation.Tags[13].Value = tags[13];
- evaluation.Tags[14].Value = tags[14];
- evaluation.Tags[0].Correct = tagsCorrect[0];
- evaluation.Tags[1].Correct = tagsCorrect[1];
- evaluation.Tags[2].Correct = tagsCorrect[2];
- evaluation.Tags[3].Correct = tagsCorrect[3];
- evaluation.Tags[4].Correct = tagsCorrect[4];
- evaluation.Tags[5].Correct = tagsCorrect[5];
- evaluation.Tags[6].Correct = tagsCorrect[6];
- evaluation.Tags[7].Correct = tagsCorrect[7];
- evaluation.Tags[8].Correct = tagsCorrect[8];
- evaluation.Tags[9].Correct = tagsCorrect[9];
- evaluation.Tags[10].Correct = tagsCorrect[10];
- evaluation.Tags[11].Correct = tagsCorrect[11];
- evaluation.Tags[12].Correct = tagsCorrect[12];
- evaluation.Tags[13].Correct = tagsCorrect[13];
- evaluation.Tags[14].Correct = tagsCorrect[14];
- WriteDB(db);
- }
- public static void UpdateEvaluationApp4WithScoreAndDurationAndTags(int EnfantID, string EvaluationID, int score, int duree, int dureeMoyenne, int[] tags, int[] tagsCorrect)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp4 evaluation = enfant.EvaluationsApp4.First(eval => eval.EvaluationID == EvaluationID);
- evaluation.Score = score;
- evaluation.Duree = duree;
- evaluation.DureeMoyenne = dureeMoyenne;
- evaluation.Tags2[0].Value = tags[0];
- evaluation.Tags2[1].Value = tags[1];
- evaluation.Tags2[2].Value = tags[2];
- evaluation.Tags2[3].Value = tags[3];
- evaluation.Tags2[4].Value = tags[4];
- evaluation.Tags2[5].Value = tags[5];
- evaluation.Tags2[0].Correct = tagsCorrect[0];
- evaluation.Tags2[1].Correct = tagsCorrect[1];
- evaluation.Tags2[2].Correct = tagsCorrect[2];
- evaluation.Tags2[3].Correct = tagsCorrect[3];
- evaluation.Tags2[4].Correct = tagsCorrect[4];
- evaluation.Tags2[5].Correct = tagsCorrect[5];
- WriteDB(db);
- }
- public static void UpdateEvaluationApp2WithScoreAndDurationAndTags(int EnfantID, string EvaluationID, int Score, int Duration, params int[] tags)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp2 evaluation = enfant.EvaluationsApp2.First(eval => eval.EvaluationID == EvaluationID);
- evaluation.Score = Score;
- evaluation.Duree = Duration;
- for (int i = 0; i < tags.Length; i++)
- {
- evaluation.Tags[i].Value += tags[i];
- }
- WriteDB(db);
- }
- public static List<EvaluationApp3> GetAllEvaluationApp3ForEnfant(int ID)
- {
- if (ReadDB().Enfants.Any((Enfant arg1) => arg1.EnfantID == ID))
- {
- return ReadDB().Enfants.First(el => el.EnfantID == ID).EvaluationsApp3;
- }
- else
- {
- return new List<EvaluationApp3>();
- }
- }
- public static List<EvaluationApp4> GetAllEvaluationApp4ForEnfant(int ID)
- {
- if (ReadDB().Enfants.Any((Enfant arg1) => arg1.EnfantID == ID))
- {
- return ReadDB().Enfants.First(el => el.EnfantID == ID).EvaluationsApp4;
- }
- else
- {
- return new List<EvaluationApp4>();
- }
- }
- public static List<EvaluationApp2> GetAllEvaluationApp2ForEnfant(int ID)
- {
- if (ReadDB().Enfants.Any((Enfant arg1) => arg1.EnfantID == ID))
- {
- return ReadDB().Enfants.First(el => el.EnfantID == ID).EvaluationsApp2;
- }
- else
- {
- return new List<EvaluationApp2>();
- }
- }
- public static string CreateNewEvalutionApp3(int EnfantID)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp3 newEvaluation = new EvaluationApp3
- {
- EvaluationID = TimeStampID()
- };
- enfant.EvaluationsApp3.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static string CreateNewEvalutionApp3(int EnfantID, string NomExaminateur, string LieuExamination, string DateExamination)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp3 newEvaluation = new EvaluationApp3
- {
- EvaluationID = TimeStampID(),
- nomExaimnateur = NomExaminateur,
- LieuExamination = LieuExamination,
- DateExamination = DateExamination
- };
- enfant.EvaluationsApp3.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static string CreateNewEvalutionApp4(int EnfantID)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp4 newEvaluation = new EvaluationApp4
- {
- EvaluationID = TimeStampID()
- };
- enfant.EvaluationsApp4.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static string CreateNewEvalutionApp4(int EnfantID, string NomExaminateur, string LieuExamination, string DateExamination)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp4 newEvaluation = new EvaluationApp4
- {
- EvaluationID = TimeStampID(),
- nomExaimnateur = NomExaminateur,
- LieuExamination = LieuExamination,
- DateExamination = DateExamination
- };
- enfant.EvaluationsApp4.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static string CreateNewEvalutionApp2(int EnfantID)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp2 newEvaluation = new EvaluationApp2
- {
- EvaluationID = TimeStampID()
- };
- enfant.EvaluationsApp2.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static List<Session> GetSessionsByEvaluationIDAndEnfantID(int EnfantID, string EvalutionID)
- {
- return ReadDB().Enfants.First(enfant => enfant.EnfantID == EnfantID).EvaluationsApp1.First(evaluation => evaluation.EvaluationID == EvalutionID).Sessions;
- }
- public static int CreateEnfant(
- string NumeroDossier,
- string Nom,
- string Prenom,
- string Genre,
- string DateDeNaissance,
- string ct1,
- string ct2,
- string NiveauScolaire,
- string MoyenneAnneePrecedente,
- string NivSocioEco,
- string DiagnostiqueDSMV,
- string CPM,
- string TestComprehension,
- string TestDeFluenceVerbaleSemantique,
- string NomRéférant,
- string PrénomRéférant,
- string StatusRéférant,
- string situationMatrimoniale,
- string NombreEnfants,
- string MaladieAuLongCours,
- string AntecedentsPsychiatriques
- )
- {
- DB db = ReadDB();
- Enfant newEnfant = new Enfant
- {
- EnfantID = db.Enfants.Count,
- NumeroDossier = NumeroDossier,
- Nom = Nom,
- Prenom = Prenom,
- Genre = Genre,
- DateDeNaissance = DateDeNaissance,
- ct1 = ct1,
- ct2 = ct2,
- NiveauScolaire = NiveauScolaire,
- MoyenneAnneePrecedente = MoyenneAnneePrecedente,
- NivSocioEco = NivSocioEco,
- DiagnostiqueDSMV = DiagnostiqueDSMV,
- CPM = CPM,
- TestComprehension = TestComprehension,
- TestDeFluenceVerbaleSemantique = TestDeFluenceVerbaleSemantique,
- NomReferant = NomRéférant,
- PrenomReferant = PrénomRéférant,
- StatusReferant = StatusRéférant,
- situationMatrimoniale = situationMatrimoniale,
- NombreEnfants = NombreEnfants,
- MaladieAuLongCours = MaladieAuLongCours,
- AntecedentsPsychiatriques = AntecedentsPsychiatriques
- };
- db.Enfants.Add(newEnfant);
- WriteDB(db);
- return newEnfant.EnfantID;
- }
- public static string CreateNewEvalutionApp1(int EnfantID)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- EvaluationApp1 newEvaluation = new EvaluationApp1
- {
- EvaluationID = TimeStampID()
- };
- enfant.EvaluationsApp1.Add(newEvaluation);
- WriteDB(db);
- return newEvaluation.EvaluationID;
- }
- public static string CreateNewSession(int EnfantID, int EvaluationID, string nomexa, string dateexa, string lieuexa)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- Session newSession = new Session
- {
- SessionID = TimeStampID(),
- NomExaminateur = nomexa,
- DateExamination = dateexa,
- LieuExamination = lieuexa,
- Duree = 0,
- ScoreSession = 0,
- Synced = false
- };
- enfant.EvaluationsApp1[EvaluationID].Sessions.Add(newSession);
- WriteDB(db);
- return newSession.SessionID;
- }
- public static void UpdateSessionWithScoreAndDurationAndTags(int EnfantID, int EvaluationID, int SessionID, int Score, int Duration, int StoryDoneID, List<TagApp1> tags)
- {
- DB db = ReadDB();
- Enfant enfant = db.Enfants.First(el => el.EnfantID == EnfantID);
- enfant.EvaluationsApp1[EvaluationID].Sessions[SessionID].ScoreSession = Score;
- enfant.EvaluationsApp1[EvaluationID].Sessions[SessionID].Duree = Duration;
- enfant.EvaluationsApp1[EvaluationID].Sessions[SessionID].SituationsDone.Add(StoryDoneID);
- for (int i = 0; i < tags.Count; i++)
- {
- if (tags[i].ID == enfant.EvaluationsApp1[EvaluationID].Sessions[SessionID].Tags[i].ID)
- {
- enfant.EvaluationsApp1[EvaluationID].Sessions[SessionID].Tags[i].Value += tags[i].Value;
- }
- }
- // enfant.Evaluations [EvaluationID].Sessions [SessionID].Tags.Clear ();
- // if (tags != null)
- //enfant.Evaluations [EvaluationID].Sessions [SessionID].Tags.AddRange (tags);
- WriteDB(db);
- }
- public static int GetScoreForEnfantIDAndEvaluationIDAndSessionID(int EnfantID, string EvaluationID, string SessionID)
- {
- return ReadDB().Enfants.First(e => e.EnfantID == EnfantID).EvaluationsApp1
- .First(e => e.EvaluationID == EvaluationID).Sessions
- .First(s => s.SessionID == SessionID).ScoreSession;
- }
- public static List<EvaluationApp1> GetAllEvaluationsApp1ForEnfant(int EnfantID)
- {
- return ReadDB().Enfants.First(el => el.EnfantID == EnfantID).EvaluationsApp1;
- }
- public static List<EvaluationApp3> GetAllEvaluationsApp3ForEnfant(int EnfantID)
- {
- return ReadDB().Enfants.First(el => el.EnfantID == EnfantID).EvaluationsApp3;
- }
- public static List<EvaluationApp4> GetAllEvaluationsApp4ForEnfant(int EnfantID)
- {
- return ReadDB().Enfants.First(el => el.EnfantID == EnfantID).EvaluationsApp4;
- }
- public static List<string> GetAllExaminateursNames()
- {
- List<string> result = new List<string>();
- List<Enfant> all = GetAllEnfants();
- foreach (var enfant in all)
- {
- foreach (var evaluation in enfant.EvaluationsApp1)
- {
- foreach (var session in evaluation.Sessions)
- {
- if (!result.Exists(v => v == session.NomExaminateur))
- {
- result.Add(session.NomExaminateur);
- }
- }
- }
- }
- return result;
- }
- public static List<string> GetAllLocations()
- {
- List<string> result = new List<string>();
- List<Enfant> all = GetAllEnfants();
- foreach (var enfant in all)
- {
- foreach (var evaluation in enfant.EvaluationsApp1)
- {
- foreach (var session in evaluation.Sessions)
- {
- if (!result.Exists(v => v == session.LieuExamination))
- {
- result.Add(session.LieuExamination);
- }
- }
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement