protected override void LoadQuestion(System.IO.Stream stream) { this.a = (int)QuestionData.ReadValue(stream); this.b = (int)QuestionData.ReadValue(stream); this.op = (Operator)QuestionData.ReadValue(stream); this.c = (int)QuestionData.ReadValue(stream); string resultText = QuestionData.ReadText(stream); if (resultText == "{NULL}") { this.result = null; } else { this.result = Convert.ToInt32(resultText); } string isCorrectText = QuestionData.ReadText(stream); if (isCorrectText == "{NULL}") { this.IsCorrect = null; } else { this.IsCorrect = Convert.ToBoolean(isCorrectText); } }
internal QuestionData GetQuestionData() { if (this.CreateQuestionData != null) { this.currentQuestionData = this.CreateQuestionData(); this.questionDataCollection.Add(this.currentQuestionData); } return(this.currentQuestionData); }
public static Question Load(Stream stream) { Question question = null; int type = (int)QuestionData.ReadValue(stream); if (type == Question_a_b_c.type) { question = new Question_a_b_c(); } question.LoadQuestion(stream); return(question); }
public static QuestionData Load(string file) { QuestionData data = null; FileStream fs = null; try { fs = File.OpenRead(file); // Read Header; byte[] headerData = new byte[38]; fs.Read(headerData, 0, 38); string header = Encoding.ASCII.GetString(headerData); if (header == MathSetting.Instance.CurrentQuestionHeader) { data = MathSetting.Instance.GetQuestionData(); } data.id = ReadText(fs); data.createTime = DateTime.Parse(ReadText(fs)); data.maxNumber = (int)ReadValue(fs); data.examTime = (int)ReadValue(fs); data.questionCount = (int)ReadValue(fs); data.leftTime = (int)ReadValue(fs); data.pointPerQuestion = (float)ReadValue(fs); data.passQuizCorrectCount = (int)ReadValue(fs); int questionCount = (int)ReadValue(fs); for (int i = 0; i < questionCount; i++) { data.questionCollection.Add(Question.Load(fs)); } } catch { } finally { if (fs != null) { fs.Close(); } } return(data); }
public override void Save(System.IO.Stream stream) { QuestionData.WriteValue(stream, type); QuestionData.WriteValue(stream, this.a); QuestionData.WriteValue(stream, this.b); QuestionData.WriteValue(stream, (double)this.op); QuestionData.WriteValue(stream, this.c); if (this.result == null) { QuestionData.WriteText(stream, "{NULL}"); } else { QuestionData.WriteText(stream, this.Result.Value.ToString()); } if (this.IsCorrect == null) { QuestionData.WriteText(stream, "{NULL}"); } else { QuestionData.WriteText(stream, this.IsCorrect.Value.ToString()); } }