public static (int totalMarks, int obtainedMarks) GradeSheet(AnswerKey answerKey, byte[][] observedOptions) { int totalMarks = 0, obtainedMarks = 0; int correctOptionValue = answerKey.GetPaper.GetCorrectOptionValue; int wrongOptionValue = answerKey.GetPaper.GetWrongOptionValue; int[][] keyOptions = answerKey.GetKey; int totalFields = keyOptions.Length; int totalOptions = keyOptions[0].Length; totalMarks = correctOptionValue * totalFields; for (int i = 0; i < totalFields; i++) { bool isCorrect = false; for (int j = 0; j < totalOptions; j++) { if (observedOptions[i][j] == 1 && observedOptions[i][j] == keyOptions[i][j]) { isCorrect = true; } } if (isCorrect) { obtainedMarks += correctOptionValue; } else { obtainedMarks -= wrongOptionValue; } } return(totalMarks, obtainedMarks); }
public static (int totalMarks, int obtainedMarks) GradeSheet(AnswerKey answerKey, byte[,] observedOptions, MultiMarkAction multiMarkAction) { int totalMarks = 0, obtainedMarks = 0; int correctOptionValue = answerKey.GetPaper.GetCorrectOptionValue; int wrongOptionValue = answerKey.GetPaper.GetWrongOptionValue; int[][] keyOptions = answerKey.GetKey; int totalFields = keyOptions.Length; int totalOptions = keyOptions[0].Length; totalMarks = correctOptionValue * totalFields; for (int i = 0; i < totalFields; i++) { bool isCorrect = false; for (int j = 0; j < totalOptions; j++) { if (observedOptions[i, j] == 1) { if (isCorrect) { if (multiMarkAction == MultiMarkAction.MarkAsManual || multiMarkAction == MultiMarkAction.Invalidate) { isCorrect = false; } else if (multiMarkAction == MultiMarkAction.ConsiderCorrect) { isCorrect = true; } else if (multiMarkAction == MultiMarkAction.ConsiderLast) { isCorrect = observedOptions[i, j] == keyOptions[i][j]? true : false; } } else { if (observedOptions[i, j] == keyOptions[i][j]) { isCorrect = true; } } } } if (isCorrect) { obtainedMarks += correctOptionValue; } else { obtainedMarks -= wrongOptionValue; } } return(totalMarks, obtainedMarks); }
public static AnswerKeyListItem Create(string configTitle, AnswerKey answerKey, OnControlButtonPressed OnControllButoonPressed) { AnswerKeyListItem keyListItem = new AnswerKeyListItem(answerKey.IsActive); keyListItem.KeyTitle = answerKey.Title; keyListItem.ConfigTitle = configTitle; keyListItem.OnControlButtonPressedEvent += OnControllButoonPressed; return(keyListItem); }
public Result <AddOrReplaceAnswerResult> AddOrReplaceAnswer(AnswerKey answerKey, Grade value) { var isAuthorised = IsVoterAuthorized(answerKey.Voter); if (!isAuthorised) { return(new Result <AddOrReplaceAnswerResult>( new AddOrReplaceAnswerResult(false, DictionaryExtensions.AddOrReplaceResultEnum.None), new[] { new Error(ErrorCode.VoterNotAuthorized) })); } var addOrReplaceResult = Answers.AddOrReplace(answerKey, value); return(new Result <AddOrReplaceAnswerResult>(new AddOrReplaceAnswerResult(true, addOrReplaceResult))); }
public void LoadScanFile(string[] lines, bool saveData) { try { if (lines.Count() > 0) { int cnt = 0; foreach (var line in lines) { if (cnt == 0) { AnswerKey = line.Replace(",BLANK", "").Split(',').ToList(); AnswerKey.RemoveAt(0); AnswerKey.RemoveAt(0); } else { StudentScannedTest test = new StudentScannedTest(); List <string> Answers = line.Replace("BLANK", "_").Split(',').ToList(); test.Id = Answers[0]; Answers.RemoveAt(0); Answers.RemoveAt(0); test.Answers = Answers; if (test.Answers.Count > AnswerKey.Count) { test.Answers.RemoveRange(AnswerKey.Count, test.Answers.Count - AnswerKey.Count); } test.Answers = test.Answers.Select(x => x.Length > 1 ? "*" : x).ToList(); Students.Add(test); } cnt++; } } } catch (Exception ex) { } }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { AnswerKey window = new AnswerKey(); window.Show(); this.Close(); }