static void Main(string[] args) { //input RetrieveData.ReadFileData(); RetrieveData.DisplayData(false); // change to true to see red data from .txt ExamData ed = new ExamData(); string answers = ed.GetAnswerLine(); string[] studId = ed.GetStudntId(); string[] studAns = ed.GetStudntAnswers(); //logic Console.WriteLine(" ********* MCQ STUDENT EXAM REPORT ********* "); int[] score = CountCorrectAnswer(answers, studAns); //output #1 Print student id and their score ShowStudScore(studId, score); //output #2 Print total candidate number Console.WriteLine("The total amount of eximninations marked : " + ShowTotalCandidates(studId)); //output #3 Print the correct answer for each question ShowCorrectAnswerForQuestion(); Console.ReadKey(); }
//Split up all data into specific variables static private void SplitData(string[] lines) { int size = lines.Length; string[] splitData = { }; string answerLine; string[] studentID = new string[size]; string[] studentAnswers = new string[size]; answerLine = lines[0]; for (int i = 1; i < size - 1; i++) { splitData = lines[i].Split(); studentID[i] = splitData[0]; studentAnswers[i] = splitData[1]; } ExamData ed = new ExamData(); ed.SetAnswerLine(answerLine); ed.SetStudentId(studentID); ed.SetStudentAnswers(studentAnswers); }
/// <summary> /// 生成一组测试数据 /// </summary> public void GenerateExam(ExamSetting examSetting) { ExamData examData = new ExamData(); examData.SettingId = examSetting.id.ToInt32(); RoleManager.Instance._CurGameInfo.CurActionData.CurExamData = examData; for (int i = 0; i < 8; i++) { SingleExamEnemy enemy = new SingleExamEnemy(); enemy.Id = DataTable.FindTestEnemyNumerialByLevel(examSetting.level.ToInt32()).id.ToInt32(); enemy.Status = (int)SingleExamEnemyStatus.UnAccomplished; enemy.OnlyId = ConstantVal.SetId; InitExamProperty(enemy); RoleManager.Instance._CurGameInfo.CurActionData.CurExamData.EnemyList.Add(enemy); } //生成玩家的数据 int count = RoleManager.Instance.playerPeople.protoData.PropertyData.ExamPropertyIdList.Count; RoleManager.Instance.playerPeople.protoData.PropertyData.CurExamPropertyIdList.Clear(); RoleManager.Instance.playerPeople.protoData.PropertyData.CurExamPropertyDataList.Clear(); for (int i = 0; i < count; i++) { int theId = RoleManager.Instance.playerPeople.protoData.PropertyData.ExamPropertyIdList[i]; SinglePropertyData pro = RoleManager.Instance.playerPeople.protoData.PropertyData.ExamPropertyDataList[i]; SinglePropertyData newPro = pro.Clone(); RoleManager.Instance.playerPeople.protoData.PropertyData.CurExamPropertyIdList.Add(theId); RoleManager.Instance.playerPeople.protoData.PropertyData.CurExamPropertyDataList.Add(newPro); } //发消息给view显示数据 EventCenter.Broadcast(TheEventType.StartExam); }
protected virtual void RaiseResultFound(ExamData arg1, ExamResult arg2) { Action <ExamData, ExamResult> handler = ResultFound; if (handler != null) { handler(arg1, arg2); } }
protected virtual void RaiseExceptionalResultFound(ExamData arg1, ExamResult arg2) { var handler = ExceptionalResultFound; if (handler != null) { handler(arg1, arg2); } }
public void GetQuestions() { if (Session["ExamData"] != null) { ExamData.DataSource = (DataTable)Session["ExamData"]; ExamData.DataBind(); CategoryID = Convert.ToInt16(((DataTable)Session["ExamData"]).Rows[0]["fkcategoryid"].ToString()); } else { Response.Redirect("~/User (Student)/UserExamInitPage.aspx"); } }
//long running task public void EvaluateAsync(ExamData data) { //some evaluation logic var result = new ExamResult { Grade = 100 - _rnd.Next(100) }; if (result.Grade > 95) { RaiseExceptionalResultFound(data, result); } RaiseResultFound(data, result); }
static public void ShowCorrectAnswerForQuestion() { Console.WriteLine("number of correct responses for each question:"); int[] corrAnsTimes = ExamData.GetCorrectCount(); FormatLines(0, 10, "question", " ", corrAnsTimes); FormatLines(0, 10, "#correct", " ", corrAnsTimes); Console.WriteLine(); FormatLines(10, 20, "question", " ", corrAnsTimes); FormatLines(10, 20, "#correct", " ", corrAnsTimes); }
static public void DisplayData(bool showThis) { ExamData ed = new ExamData(); string[] studentID = ed.GetStudntId(); string[] studentAnswers = ed.GetStudntAnswers(); string answerLine = ed.GetAnswerLine(); int size = studentID.Length; if (showThis == true) { Console.WriteLine("\n>>>Answer line: " + answerLine + " "); for (int i = 1; i < size - 1; i++) { Console.WriteLine(i + ") \n" + "Student id: " + studentID[i] + "\nAnswers: " + studentAnswers[i]); } } }
void ExamInfo() { if (!string.IsNullOrEmpty(tempMessageString)) { TempStruct tempStruct = JsonUtility.FromJson <TempStruct>(tempMessageString); if (tempStruct.eventName == "RequestExamInfo") { ExamData examInfo = JsonUtility.FromJson <ExamData>(tempMessageString); if (examInfo.status == true) { // var data = examInfo.message.Split(','); List <string> data = new List <string>(examInfo.message.Split(',')); } Debug.Log("success"); } else { Debug.Log("err"); } } tempMessageString = string.Empty; }
static public int[] CountCorrectAnswer(string ansSheet, string[] studAns) { int[] score = new int[studAns.Length]; char[] word; char[] ansLetter = ansSheet.ToCharArray(); int[] correctCountQuestion = new int[20]; // 20 for amount of questions int count = 0; // the correct question counter for (int i = 1; i < studAns.Length - 1; i++) { word = studAns[i].ToCharArray(); for (int j = 0; j < 20; j++) { // if the score is correct add 4 points if (word[j] == ansLetter[j]) { score[i] += 4; //count +1 when correct count++; correctCountQuestion[j] += count; count = 0; } else if (word[j] == 'X' || word[j] == 'x') { // no score } else { //Minus one point if answer was incorrect score[i] -= 1; } } count = 0; // reset counter once couted all 20 score for 1 question } ExamData.SetCorrectCount(correctCountQuestion); // save correct answers count return(score); }