示例#1
0
        }     // 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()
        }
示例#2
0
        //----------
        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()
示例#3
0
        } // 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()