示例#1
0
        //----------
        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();
        }
示例#2
0
        //----------
        private static string getPromptedInput(int row, string prompt)
        {
            string result = "";

            for (;;)
            {
                Useful.clearLines(row, 5);
                Console.Write(prompt);
                string        temp   = Console.ReadLine();
                StringBuilder tempsb = new StringBuilder();
                for (int ii = 0; ii < temp.Length; ii++)
                {
                    if (temp[ii] == ' ')
                    {
                        continue;
                    }
                    tempsb.Append(temp[ii]);
                }
                result = tempsb.ToString();
                Console.WriteLine();
                Console.WriteLine("    Here's what I got:  " + result);
                Console.WriteLine();
                Console.Write("        Is this correct (y|else)? ");
                temp = Console.ReadLine().ToLower();
                if (temp == "y")
                {
                    Useful.clearLines(row, 5);
                    Console.Write(prompt + result);
                    break;
                }
            }
            return(result);
        } // end method getPromptedInput()
示例#3
0
 //----------
 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();
 }
示例#4
0
 //----------
 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);
 }
示例#5
0
        } // end function Main()

        //----------
        private static void dumpScreenSizeInstructions()
        {
            Console.WriteLine("This program requires that the Console Window Size ");
            Console.WriteLine("must be at least (80 columns by 30 rows). ");

            Console.Write("\nPresently, it is (" + Console.WindowWidth + " by ");
            Console.WriteLine(Console.WindowHeight + ") which is too small. ");

            Console.Write("\nPlease resize this window, before attempting to ");
            Console.WriteLine("re-run this program.");
            Console.WriteLine();
            Useful.enterContinue();
        }
示例#6
0
        //----------
        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);
        }
示例#7
0
 //----------
 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();
 }
示例#8
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()
        }
示例#9
0
        //----------
        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"));
        }
示例#10
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()
示例#11
0
        //----------
        public string editResponseBox()
        {
            // clearRespbuf();
            respoff = 0;
            posresp();

            char inpkey;

            for (;;)
            {
                Char inpchr = Useful.getKeyPress(out inpkey);
                if ((inpchr >= ' ') && (inpchr <= '~'))
                {
                    Console.Write(inpchr);
                    respbuf[respoff++] = inpchr;
                    if (respoff >= maxoff)
                    {
                        Console.Beep();
                        respoff = respoff % maxoff;
                    }
                    posresp();
                    continue;
                }
                if ((inpchr == 8) || (inpkey == (int)ConsoleKey.Backspace))
                {
                    respoff--;
                    if (respoff < 0)
                    {
                        Console.Beep();
                        respoff = (respoff + maxoff) % maxoff;
                    }
                    posresp();

                    Console.Write(' ');
                    respbuf[respoff] = ' ';
                    posresp();
                    continue;
                }
                if ((inpchr == 9) && (inpkey == (int)ConsoleKey.Tab))
                {
                    break;
                }
                if (inpkey == (int)ConsoleKey.Enter)
                {
                    int scrrow   = respoff / maxcol;
                    int scrcol   = respoff - scrrow * maxcol;
                    int respoff2 = respoff;
                    respoff2 -= scrcol;
                    respoff2 += maxcol;
                    for (int ii = respoff; ii < respoff2; ii++)
                    {
                        Console.Write(' ');
                        respbuf[ii] = ' ';
                    }
                    respoff = respoff2;
                    if (respoff >= maxoff)
                    {
                        Console.Beep();
                        respoff = respoff % maxoff;
                    }
                    posresp();
                    continue;
                }

                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.RightArrow))
                {
                    respoff++;
                    if (respoff >= maxoff)
                    {
                        Console.Beep();
                        respoff = respoff % maxoff;
                    }
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.LeftArrow))
                {
                    respoff--;
                    if (respoff < 0)
                    {
                        Console.Beep();
                        respoff = (respoff + maxoff) % maxoff;
                    }
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.UpArrow))
                {
                    respoff -= maxcol;
                    if (respoff < 0)
                    {
                        Console.Beep();
                        respoff += maxoff;
                    }
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.DownArrow))
                {
                    respoff += maxcol;
                    if (respoff >= maxoff)
                    {
                        Console.Beep();
                        respoff -= maxoff;
                    }
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.Tab))
                {
                    Console.SetCursorPosition(10, 24);
                    Console.Write("tab<<<");
                    Console.Beep();
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.Insert))
                {
                    Console.SetCursorPosition(10, 24);
                    Console.Write("insert");
                    Console.Beep();
                    posresp();
                    continue;
                }
                if ((inpchr == 0) && (inpkey == (int)ConsoleKey.Delete))
                {
                    Console.SetCursorPosition(10, 24);
                    Console.Write("delete");
                    Console.Beep();
                    posresp();
                    continue;
                }
            } // end for()

            int offb = 0, offx = 0;

            for (int ii = 0; ii < respbuf.Length; ii++)
            {
                offb = ii;
                if (respbuf[ii] != ' ')
                {
                    break;
                }
            }

            for (int ii = respbuf.Length - 1; ii > 0; ii--)
            {
                offx = ii;
                if (respbuf[ii] != ' ')
                {
                    break;
                }
            }

            StringBuilder result = new StringBuilder();
            char          last   = ' ';

            for (int ii = offb; ii <= offx; ii++)
            {
                if ((last == ' ') && (respbuf[ii] == ' '))
                {
                    continue;
                }
                result.Append(respbuf[ii]);
                last = respbuf[ii];
            }
            return(result.ToString().ToLower());
        }
示例#12
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()