Beispiel #1
0
        static void ReceivedQuestionsEvent(object sender, QuestionsFetchedEventArgs e)
        {
            QuizParameters questions = e.Parameters;
            QuizAnswers answers = new QuizAnswers();
            answers.answers = new List<string>();
            foreach(QuizQuestionRaw question in questions.questions) {
                answers.answers.Add("test");
            }
            answers.hintsUsed = 0;

            MarkReceiver markReceiver = new MarkReceiver(serverAddr, port, username, answers);
            markReceiver.ClientLog += LogEvent;
            markReceiver.MarkReceived += MarkReceivedEvent;
            markReceiver.SendAnswersReceiveMark();
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the submission form
        /// </summary>
        /// <param name="answers">User's quiz answers</param>
        /// <param name="server">IP address of the server</param>
        /// <param name="port">Port number on the server</param>
        public frmSubmit(QuizAnswers answers, IPAddress server, int port)
        {
            //Set up the needed components
            InitializeComponent();
            this.answers = answers;

            //Initialise the answer-sending and mark-receiving component
            MarkReceiver answerSender = new MarkReceiver(server, port, Environment.UserName, answers);

            //Set up the events to log connection progress and get back the
            //quiz result when the operation is complete
            answerSender.ClientLog += LogEvent;
            answerSender.MarkReceived += DisplayMark;

            //Start the submission process
            answerSender.SendAnswersReceiveMark();

            Show();
        }
Beispiel #3
0
        public MarkReceiver(IPAddress serverAddress, int serverPort, string username, QuizAnswers quizAnswers)
        {
            //Store the connection parameters
            this.serverAddress = serverAddress;
            this.serverPort = serverPort;
            this.username = username;
            this.answers = quizAnswers;

            //Set up the background thread
            clientThread = new BackgroundWorker();
            clientThread.WorkerReportsProgress = true;
            clientThread.WorkerSupportsCancellation = true;
            clientThread.DoWork += DoSubmitAnswers;
            clientThread.RunWorkerCompleted += FinishSubmitAnswers;
            clientThread.ProgressChanged += LogEvent;
        }
Beispiel #4
0
 public QuizCompletedEventArgs(QuizAnswers quizAnswers)
 {
     this.quizAnswers = quizAnswers;
 }