protected void Application_BeginRequest() { if (!SubmissionTester.IsInitialized) { SubmissionTester.Init(Request.Url, HttpRuntime.AppDomainAppVirtualPath); } }
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); }