Exemplo n.º 1
0
        public StudentController(UserManager <User> userManager, HSEContestDbContext db, TestingSystemConfig config, IHttpContextAccessor httpContextAccessor) : base(db, config)
        {
            curId = userManager.GetUserId(httpContextAccessor.HttpContext.User);
            var curUser = userManager.GetUserAsync(httpContextAccessor.HttpContext.User).Result;

            isProff = userManager.IsInRoleAsync(curUser, "professor").Result;
        }
Exemplo n.º 2
0
        public static TestResponse WriteToDb(HSEContestDbContext _db, TestingResult res, bool recheck)
        {
            bool ok = false;

            if (recheck)
            {
                var existing = _db.TestingResults.FirstOrDefault(r => r.SolutionId == res.SolutionId && r.TestId == res.TestId);

                if (existing != null)
                {
                    existing.Commentary = res.Commentary;
                    existing.ResultCode = res.ResultCode;
                    existing.Score      = res.Score;
                    existing.TestData   = res.TestData;

                    _db.SaveChanges();

                    ok = true;
                }
            }
            else
            {
                var x           = _db.TestingResults.Add(res);
                var beforeState = x.State;
                int r           = _db.SaveChanges();
                var afterState  = x.State;

                ok = beforeState == EntityState.Added && afterState == EntityState.Unchanged && r == 1;
            }

            TestResponse response;

            if (ok)
            {
                response = new TestResponse
                {
                    OK           = true,
                    Message      = "success",
                    Result       = res.ResultCode,
                    Score        = res.Score,
                    TestResultId = res.Id,
                    TestId       = res.TestId,
                };
            }
            else
            {
                response = new TestResponse
                {
                    OK      = false,
                    Message = "can't write result to db",
                    Result  = ResultCode.IE,
                    Score   = res.Score,
                    TestId  = res.TestId,
                };
            }

            return(response);
        }
Exemplo n.º 3
0
        public TestingSystemWorker()
        {
            string pathToConfig = "c:\\config\\config.json";
            _config = JsonConvert.DeserializeObject<TestingSystemConfig>(System.IO.File.ReadAllText(pathToConfig));

            DbContextOptionsBuilder<HSEContestDbContext> options = new DbContextOptionsBuilder<HSEContestDbContext>();
            options.UseNpgsql(_config.DatabaseInfo.GetConnectionStringFrom(_config.FrontEnd));
            _db = new HSEContestDbContext(options.Options);

            _busControl = RabbitHutch.CreateBus(_config.MessageQueueInfo, _config.TestingSystemWorker);
        }
Exemplo n.º 4
0
 public CompilerServicesOrchestrationController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _db     = db;
     _config = config;
 }
 public CodeStyleRulesController(HSEContestDbContext db)
 {
     _db = db;
 }
 public CodeStyleTesterController(HSEContestDbContext db)
 {
     _db = db;
 }
 public FunctionalTesterController(HSEContestDbContext db)
 {
     _db = db;
 }
 public FunctionalTestingOrchestratorController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _db     = db;
     _config = config;
 }
Exemplo n.º 9
0
 public CompilerController(HSEContestDbContext context)
 {
     _db = context;
 }
Exemplo n.º 10
0
 public TestingSystemController(HSEContestDbContext db, TestingSystemConfig config)
 {
     _pathToConfigDir = "c:\\config";
     _db     = db;
     _config = config;
 }
Exemplo n.º 11
0
 public ProfessorController(HSEContestDbContext db, TestingSystemConfig config) : base(db, config)
 {
 }
Exemplo n.º 12
0
 public GroupsController(UserManager <User> userManager, HSEContestDbContext db)
 {
     _db          = db;
     _userManager = userManager;
 }
Exemplo n.º 13
0
 public UsersController(UserManager <User> userManager, RoleManager <IdentityRole> roleManager, HSEContestDbContext db)
 {
     _userManager = userManager;
     _roleManager = roleManager;
     _db          = db;
 }
 public ReflectionTesterController(HSEContestDbContext db)
 {
     _db = db;
 }