예제 #1
0
        public SubmissionTester(StudentSubmission submission)
        {
            _submission = submission;
            _assignment = submission.StudentAssignment.Assignment;

            _repo = SubmissionRepository.Get(submission.StudentAssignment);
            _repo.Checkout(submission.CommitId);

            _validator = new W3CValidator(_repo.FileUri);

            var allDeviceIds = _assignment.AllScripts.Select(s => s.DeviceId).Distinct();

            foreach (var deviceId in allDeviceIds)
            {
                _allDevices.Add(Device.Parse(deviceId));
            }
            if (_allDevices.Count == 0)
            {
                _allDevices.Add(Device.Large);
            }

            _browser = BrowserFactory.GetDriver();
            if (_browser != null)
            {
                _browser.SetWindowSize(Device.Large.ViewportWidth, Device.Large.ViewportHeight);
            }
        }
예제 #2
0
        public static StudentSubmission Submit(Repository workRepository)
        {
            StudentSubmission submission = new StudentSubmission();

            try
            {
                using (var db = new AugerContext())
                {
                    var studentAssignment = db.StudentAssignments
                                            .Include(sa => sa.Assignment)
                                            .Include(sa => sa.Enrollment.User)
                                            .FirstOrDefault(sa => sa.AssignmentId == workRepository.RepositoryId && sa.Enrollment.UserName == workRepository.UserName);

                    if (studentAssignment == null)
                    {
                        var ex = new InvalidOperationException("Unable to retrieve the student assignment from the given repository.");
                        submission.Exception = ex.Message;
                        Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                    }
                    else
                    {
                        var repo = SubmissionRepository.Get(studentAssignment);

                        string commitId = repo.CommitFromRepository(workRepository);
                        if (commitId != null)
                        {
                            submission.StudentAssignment = studentAssignment;
                            //submission.StudentAssignment.AssignmentId = repo.RepositoryId;
                            submission.CommitId  = commitId;
                            submission.Succeeded = true;

                            db.StudentSubmissions.Add(submission);
                            studentAssignment.HasSubmission = true;

                            db.SaveChanges();

                            using (var t = new SubmissionTester(submission))
                            {
                                t.TestAll();
                            }

                            db.SaveChanges();
                        }
                        else
                        {
                            submission.Exception = "There were no changes detected. No new submission has been saved.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                submission.Exception = ex.Message;
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }

            return(submission);
        }
예제 #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _browser.Dispose();
                }

                _presubmissionResults = null;
                _fullResults          = null;
                _submission           = null;
                _assignment           = null;
                _repo       = null;
                _validator  = null;
                _allDevices = null;
                _browser    = null;

                disposedValue = true;
            }
        }
예제 #4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            TemplateManager.Init(GetPath("AugerTemplateDir"));
            SubmissionRepository.Init(GetPath("AugerSubmissionDir"));
            WorkRepository.Init(GetPath("AugerWorkDir"));
            PlaygroundRepository.Init(GetPath("AugerPlaygroundDir"));
            TempDir.Init(GetPath("AugerTempDir"));
            //TemplateManager.Init(Server.MapPath("~/app_data/templates/"));
            //SubmissionRepository.Init(Server.MapPath("~/app_data/repo/"));
            //WorkRepository.Init(Server.MapPath("~/app_data/work/"));
            //PlaygroundRepository.Init(Server.MapPath("~/app_data/play/"));
            //TempDir.Init(Server.MapPath("~/app_data/temp/"));

            //HostingEnvironment.RegisterVirtualPathProvider(new RepositoryVPP());

            HttpContext.Current.Server.ScriptTimeout = 2400;
        }