コード例 #1
0
        /// <summary>
        /// Send exercises to client, depending on selected exam.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="filename"></param>
        private static void SendExercisesToClient(TcpClient client, object data)
        {
            _server.SetExamFileName(client, (string)data);
            _log.AppendToLog("Sending exercises to client: " +
                             ((IPEndPoint)client.Client.RemoteEndPoint).Address.ToString(), LogType.Info);
            _csv = new CsvImport(_exampath);
            var ex = _csv.GetExercises((string)data);

            _server.SendPacket(client, ex);
        }
コード例 #2
0
        /// <summary>
        /// Process received answers from client and sending the result back
        /// </summary>
        /// <param name="client"></param>
        /// <param name="data"></param>
        private static void ProcessAnswers(TcpClient client, object data)
        {
            _csv = new CsvImport(_exampath);
            var filename = _server.GetExamFileName(client);
            var list     = _csv.GetExercises(filename);
            var erh      = new ExerciseResultHelper();
            var result   = erh.ProcessResult((List <DefaultAnswer>)data, list);
            var examlog  = new ExamLog
            {
                ConsoleOutput = true
            };

            examlog.AppendToLog(_server.GetIpFromClient(client), erh.ExistingAnswers, erh.CorrectAnswers);
            _server.SendPacket(client, result);
        }