//---------- private static void dumpAdmissionInstructions() { Console.Clear(); // Console.ResetColor(); Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); Console.Write("\nfile not found: "); Console.WriteLine(si.getCourse() + "_" + si.getExamination() + "_questions.txt"); Console.WriteLine("\nThis program requires that a text data file containing "); Console.WriteLine("the test questions be placed in the local directory from "); Console.WriteLine("whence this program is executed. You can download this "); Console.WriteLine("data file from the Exam Assignment in our Moodle course "); Console.WriteLine("shell."); Console.WriteLine("\nThe information that you just provided "); Console.WriteLine("(YourName, the course name, and the exam type) "); Console.WriteLine("are all used to locate the files used by the program. "); Console.WriteLine("If you did not copy the data file into the directory, "); Console.WriteLine("or if you entered an invalid course name, or an invalid "); Console.WriteLine("exam type (which are parts of the text data file name), "); Console.WriteLine("you will see this error message and be given an "); Console.WriteLine("opportunity to restart the program."); Console.WriteLine("\nAlso be aware that this program produces a text file "); Console.WriteLine("(which includes YourName) containing your responses to "); Console.WriteLine("the test questions. Theoretically, your responses "); Console.WriteLine("should be preserved across multiple runs of the program. "); Console.WriteLine("Still you need to check your work, and maybe even re-enter "); Console.WriteLine("some of your responses, because.... No guarantees! "); Console.WriteLine(); Useful.enterContinue(); }
//---------- private static void dumpIterativeDevelopmentMessage() { Console.Clear(); // Console.ResetColor(); Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); for (int ii = 0; ii < iterativeDevelopmentMessage.Length; ii++) { Console.WriteLine(iterativeDevelopmentMessage[ii]); } Console.WriteLine(); Useful.enterContinue(); }
//---------- public void drawQuestionBox() { Useful.setColors(ConsoleColor.Yellow, ConsoleColor.Black); for (int ii = 0; ii < 12; ii++) { Console.SetCursorPosition(xoff, yoff + ii); for (int jj = 0; jj < maxcol; jj++) { Console.Write(questbuf[ii * maxcol + jj]); } } Console.SetCursorPosition(xoff, yoff); }
//---------- public void drawResponseBox() { // Useful.dbg("drawResponseBox(): xoff="+xoff+" yoff="+yoff); Useful.setColors(ConsoleColor.Black, ConsoleColor.White); for (int ii = 0; ii < 12; ii++) { Console.SetCursorPosition(xoff, yoff + ii); for (int jj = 0; jj < maxcol; jj++) { Console.Write(respbuf[ii * maxcol + jj]); } } Console.SetCursorPosition(xoff, yoff); }
//---------- private static void dumpReleaseInstructions() { // Useful.clearLine(5); Console.Clear(); // Console.ResetColor(); Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); Console.WriteLine("You will need to upload your responses file "); Console.WriteLine("(" + si.getCourse() + "_" + si.getExamination() + "_" + si.getStudentName() + ".txt)"); Console.WriteLine("into the final exam dropbox in the Moodle shell for our course."); Console.WriteLine(); Console.WriteLine("It would also be a very good idea for you to keep "); Console.WriteLine("a backup copy of that file, just in case I encounter "); Console.WriteLine("problems in processing it. "); Console.WriteLine(); Useful.enterContinue(); }
} // end method takeTest() //---------- private static string navbar(out int qnum) { for (;;) { Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); Useful.clearLine(0); Console.Write("Navigate? ___ Specify QUESTION # or one of these one-letter commands: "); Useful.clearLine(1); Console.Write(" A)nswer_current N)ext P)rev S)can_next_unanswered D)one"); Console.SetCursorPosition(10, 0); string option = Console.ReadLine().Trim(); int optnum = 0; if (Int32.TryParse(option, out optnum)) { if ((optnum >= 1) && (optnum <= maxq)) { Useful.clearLine(3); qnum = optnum; return(""); } Console.SetCursorPosition(0, 3); Console.Write("Invalid input.... QUESTION # must be "); Console.WriteLine("between 1 and " + maxq + ". Try again."); continue; } if ((option == "") || (option.ToLower() == "a") || (option.ToLower() == "n") || (option.ToLower() == "p") || (option.ToLower() == "s") || (option.ToLower() == "d")) { Useful.clearLine(3); qnum = 0; return(option.ToLower()); } Useful.clearLine(3); Console.Beep(); Console.WriteLine("invalid command entered: " + option); } // end for() }
//---------- public void drawQuestionHdr(int curq, int maxq, int unanswered, DateTime starttime, int weight) { Console.SetCursorPosition(0, 5); Useful.setColors(ConsoleColor.White, ConsoleColor.Black); Console.Write("QUESTION #: " + (curq + 1).ToString("D3") + " "); Console.Write("ANSWERED: " + (maxq - unanswered).ToString("D3") + " of " + maxq.ToString("D3") + " "); DateTime currtime = DateTime.Now; TimeSpan elapsed = DateTime.Now.Subtract(starttime); long totseconds = (long)elapsed.TotalSeconds; Console.Write("ELAPSED TIME: "); Console.Write(elapsed.Hours.ToString("D2")); Console.Write(":" + elapsed.Minutes.ToString("D2")); Console.Write(":" + elapsed.Seconds.ToString("D2")); Console.Write(" WEIGHT: " + weight.ToString("D2")); }
//---------- public StudentInfo() { Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); Console.Clear(); Useful.clearLine(0); Console.WriteLine("Greetings! Before we get started..."); Console.WriteLine(" I need to get a couple of pieces of information from you,"); Console.WriteLine(" in order to process your examination."); studentname = getPromptedInput(4, "What is your name (FirstLast, no spaces)? "); course = getPromptedInput(6, "What course are you taking (csc999, no spaces)? "); examination = getPromptedInput(8, "What examination are you taking (midterm or final)? "); Console.WriteLine(); Useful.enterContinue(); } // end constructor StudentInfo()
} // end constructor TestAdministrator //---------- public static void takeTest(string examname, string studentname, DateTime starttime) { initta(); readQuestions(examname + "_questions.txt"); ReadResponses(examname + "_" + studentname + ".txt"); Console.Clear(); Question qst = new Question(Console.WindowWidth - 4, 12, 2, 6); Response rsp = new Response(Console.WindowWidth - 4, 12, 2, 18); for (int curq = 0;;) { displayQuestion(curq, starttime, qst, rsp); int optnum; string option = navbar(out optnum); if ((option == "") && ((optnum >= 1) && (optnum <= maxq))) { curq = optnum - 1; displayQuestion(curq, starttime, qst, rsp); continue; } if ((option == "") || (option.ToLower() == "a")) { if (answerQuestion(curq, starttime, rsp)) { // response was changed // write changes out to disk WriteResponses(examname + "_" + studentname + ".txt"); } continue; } if (option.ToLower() == "n") { curq++; if (curq >= maxq) { curq = 0; } displayQuestion(curq, starttime, qst, rsp); continue; } if (option.ToLower() == "p") { curq--; if (curq < 0) { curq = maxq - 1; } displayQuestion(curq, starttime, qst, rsp); continue; } if (option.ToLower() == "s") { if (unanswered == 0) { Console.WriteLine("all questions have been answered."); } else { int end_search = curq; for (;;) { curq++; if (curq >= maxq) { curq = 0; } if (curq == end_search) { Console.WriteLine("all questions appear to have been answered."); break; } if (responses[curq] == "") { break; } } displayQuestion(curq, starttime, qst, rsp); } continue; } if (option.ToLower() == "d") { Console.Clear(); Useful.setColors(ConsoleColor.Green, ConsoleColor.Black); Useful.clearLine(0); Console.Write("All done? "); Useful.clearLine(1); unanswered = 0; for (int ii = 0; ii < maxq; ii++) { if (responses[ii].Trim() == "") { unanswered++; } } if (unanswered == 0) { Console.Write("All questions appear to have some kind of an answer."); } else { Console.Write(" UNANSWERED=" + unanswered); } Useful.clearLine(2); Console.Write("Are you sure your want to leave "); Console.Write("this program at this time (YES|else)? "); if (Console.ReadLine() == "YES") { break; } continue; } } // end for() } // end method takeTest()