Ejemplo n.º 1
0
        public KetQuaThiSinh ChamBai(int MaBai, String SourceCode, string NgonNgu)
        {
            Problem problem = db.Problems.FirstOrDefault(m => m.ID == MaBai);
            if (problem == null)
                throw new SPKTOnlineException("Ma bai khong ton tai");
            List<ITestCase> tescase = new List<ITestCase>();
            foreach (ITestCase t in problem.TestCases)
            {
                //TODO: config
                t.TimeOut = (int)(problem.TimeLimit <= 0? 1000 : problem.TimeLimit);
                tescase.Add(t);
            }
            IFileComparer ss = FileComparerFactory.GetComparer(problem.Comparer.DllPath, problem.Comparer.ClassName);
            ss.Init(problem.ComparerParameter);

            String executionDir = Server.MapPath(WebConfigurationManager.AppSettings["ExecutionDir"]);
            BienDichCPP.ApplicationFolder = Server.MapPath(WebConfigurationManager.AppSettings["VisualCCompilerDir"]);
            ChamBaiManager chamManager = new ChamBaiManager(NgonNgu,executionDir);
            KetQuaThiSinh ketQua = chamManager.ChamBai(SourceCode, tescase, ss);
            return ketQua;
            #region Bỏ

            //String exeFilePath = System.IO.Path.Combine(Server.MapPath(ExeDir), fileName);
            //KetQuaBienDich kqBienDich = bienDich.BienDich(SourceCode, exeFilePath);
            //ketQua.KetQuaBienDich = kqBienDich;

            //TODO: Luu ket qua bien dich vao DB
            //if (kqBienDich.BienDichThanhCong == false)
            //{
            //    ketQua.KetQuaCham = null;
            //    return ketQua;
            //}
            //Cham diem de lay ket qua cham

            //List<ITestCase> tescase = new List<ITestCase>();
            //ITestCase tc = problem.TestCases.First();
            //foreach (ITestCase t in problem.TestCases)
            //{
            //    t.TimeOut = (int)(problem.TimeLimit == null ? 1000 : problem.TimeLimit);
            //    tescase.Add(t);
            //}
            //IFileComparer ss = FileComparerFactory.GetComparer(problem.Comparer.DllPath, problem.Comparer.ClassName);
            //ss.Init(problem.ComparerParameter);

            // Cham
            //KetQuaCham kqCham = chamDiem.Cham(exeFilePath, tescase, ss);
            //ketQua.KetQuaCham = kqCham;
            //return ketQua;
            #endregion
        }
Ejemplo n.º 2
0
        //public KetQuaThiSinh ChamBai(int submitID,int MaBai, String SourceCode, string NgonNgu)
        //{
        //    KetQuaThiSinh kq = ChamBai(MaBai, SourceCode, NgonNgu);
        //    kq.SubmitID = submitID;
        //    return kq;
        //}
        public KetQuaThiSinh ChamBai(int MaBai, String SourceCode, string NgonNgu)
        {
            Problem problem = db.Problems.FirstOrDefault(m => m.ID == MaBai);
            if (problem == null)
                throw new SPKTOnlineException("Mã bài không tồn tại");
            List<ITestCase> tescase = new List<ITestCase>();
            foreach (ITestCase t in problem.TestCases)
            {
                //TODO: config
                t.TimeOut = (problem.TimeLimit <= 0? 1000 : problem.TimeLimit);
                tescase.Add(t);
            }
            IFileComparer ss = FileComparerFactory.GetComparer(problem.Comparer.DllPath, problem.Comparer.ClassName);
            ss.Init(problem.ComparerParameter);

            String executionDir =HttpContext.Current.Server.MapPath(WebConfigurationManager.AppSettings["ExecutionDir"]);
            BienDichCPP.ApplicationFolder = HttpContext.Current.Server.MapPath(WebConfigurationManager.AppSettings["VisualCCompilerDir"]);
            ChamBaiManager chamManager = new ChamBaiManager(NgonNgu, executionDir);
            KetQuaThiSinh ketQua = chamManager.ChamBai(SourceCode, tescase, ss);
            return ketQua;
        }