using System.ComponentModel.DataAnnotations.Schema; namespace Quizzer.Models { /// /// This is the database model for the journal, which is used to store the quiz results and other related information. It is used to display the quiz results in the journal page and to store the quiz results in the database. /// public class Journal { public string PID { get; set; } public string QuizzID { get; set; } public string Category { get; set; } public int IsOpen { get; set; } public bool Anonymous { get; set; } public int Score { get; set; } public int ScoreAcc { get; set; } // This is the JSON string that contains the quiz results, which is used to display the quiz results in the journal page. It is also used to store the quiz results in the database. // The JSON string is in the following format: // { // "items": [ // { // "itemID": "1", // "isOpen": 1, // "score": 1, // "maxScore": 1, // "replyMC": [true, false, false, false] // }, // { // "itemID": "2", // "isOpen": 0, // "score": 0, // "maxScore": 1, // "replyMC": [false, false, false, false] // } // ] // } public string JournalJson { get; set; } } public class Item { public string ItemID { get; set; } public int IsOpen { get; set; } public int Score { get; set; } public int MaxScore { get; set; } public List ReplyMC { get; set; } } /// /// Used for web page building /// public class JournalHtml { public Journal2 Journal { get; set; } public string Text { get; set; } } /// /// Table for the journal. One is created for each test available to the PID. /// [Table("Journal2")] public class Journal2 { public string PID { get; set; } // VARCHAR 256 Primary key public string QuizzID { get; set; } // VARCHAR 50 Primary key public string Category { get; set; } // VARCHAR 50 public int IsOpen { get; set; } // INT 11 public bool Anonymous { get; set; } // INT 11 public int Score { get; set; } // INT 11 public int ScoreAcc { get; set; } // INT 11 public List Items { get; set; } // This field does not store in the DB, but is serialized to JSON and stored in the JournalJson field of the JournalHead table. The JSON string is in the following format: {"items": [{"itemID": "1", "isOpen": 1, "score": 1, "maxScore": 1, "replyMC": [true, false, false, false]}, {"itemID": "2", "isOpen": 0, "score": 0, "maxScore": 1, "replyMC": [false, false, false, false]}]} } /// /// One is created for each question in the test, and linked to the JournalHead by the QuizzID and PID. The ItemID is used to identify the question in the test, and the IsOpen, Score, MaxScore, and ReplyMCJson are used to store the quiz results for that question. /// [Table("Journal2Item")] public class Journal2Item { public string PID { get; set; } // VARCHAR 256, Foreign key to the JournalHead table. Primary key public string QuizzID { get; set; } // VARCHAR 50, Foreign key to the JournalHead table. Primary key public required string QuestionID { get; set; } // VARCHAR 50, used to identify the question in the test. Primary key public int IsOpen { get; set; } // INT 11, used to indicate whether the question is open or not. public int Score { get; set; } // INT 11, used to store the score for the question. public int MaxScore { get; set; } // INT 11, used to store the maximum score for the question. public List ReplyMC { get; set; } // This field does not store in the DB, but is serialized to JSON and stored in the JournalJson field of the JournalHead table. The JSON string is in the following format: [true, false, false, false] public string ReplyMCJson { get; set; } // VARCHAR 512, used to store the JSON string for the ReplyMC field. The JSON string is in the following format: [true, false, false, false] } }