public void ApplyTemplate(Project other) { foreach (FlatAssignmentCollection assignmentcol in other.Assignments) { var fac = Assignments.First((c) => c.Flat == assignmentcol.Flat); foreach (FlatAssignment assignment in assignmentcol) { if (assignment.End == other.EndDate) { var fa = new FlatAssignment(this); fa.StartIntervalIndex = 0; fa.EndIntervalIndex = 23; fa.Lessee = assignment.Lessee; fac.Add(fa); } } } foreach (Cost cost in other.Costs) { var c = CreateCost(); c.AffectsVacancy = cost.AffectsVacancy; c.Mode = cost.Mode; c.Name = cost.Name; foreach (CostOptions options in cost.Options) { var co = c.Options.FirstOrDefault((o) => o.Lessee == options.Lessee); if (co != null) { co.Affected = options.Affected; co.Exempt = options.Exempt; } } } }
public async Task <IActionResult> OnGetAsync(string selected) { Selected = selected; var indices = selected.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); if (selected.Length < 2) { return(NotFound()); } var institutionalId = Context.Users.Single(u => u.Email.Equals(User.Identity.Name)).InstitutionId; var assignments = (await Context.GetAssignmentsAsync()).Where(a => a.InstitutionId.Equals(institutionalId)).ToList(); foreach (var index in indices) { if (index >= 0 && index < assignments.Count) { Assignments.Add(assignments[index]); } } if (assignments.Count < 2) { return(NotFound()); } Instructors = Assignments.First().Instructors.ToList().Select(a => a.Instructor.Id).ToList(); Chart = GetChart(); return(Page()); }
public async Task <FileStreamResult> OnPostDownloadAsync(string selected) { var indices = selected.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); if (selected.Length < 2) { return(null); } var institutionalId = Context.Users.Single(u => u.Email.Equals(User.Identity.Name)).InstitutionId; var assignments = (await Context.GetAssignmentsAsync()).Where(a => a.InstitutionId.Equals(institutionalId)).ToList(); foreach (var index in indices) { if (index >= 0 && index < assignments.Count) { Assignments.Add(assignments[index]); } } if (assignments.Count < 2) { return(null); } Instructors = Assignments.First().Instructors.ToList().Select(a => a.Instructor.Id).ToList(); var fileText = $"Assignment,Course,Alias Id,Line,Branch,Conditional,Redundant,# of Valid Feedback\n"; Assignments.ToList().ForEach(asg => { var submissions = GetSubmissions(Instructors, asg); var studentAverages = submissions.GroupBy( x => x.SubmitterId, x => x.Feedback, (key, g) => new { Id = key, Feedbacks = g.ToList() }).Select(x => new { x.Id, Averages = new List <double>() { CalculateAverageLineCoveragePercentage(x.Feedbacks), CalculateAverageBranchCoveragePercentage(x.Feedbacks), CalculateAverageConditionalCoveragePercentage(x.Feedbacks), CalculateAverageRedundantCoverage(x.Feedbacks), }, Amount = x.Feedbacks.Count, }) .ToList(); studentAverages.ForEach(sa => fileText += $"{asg.Name}," + $"{asg.Course.CourseName}," + $"S{sa.Id}," + $"{sa.Averages[0]}," + $"{sa.Averages[1]}," + $"{sa.Averages[2]}," + $"{sa.Averages[3]}," + $"{sa.Amount}\n" ); }); var bytes = Encoding.ASCII.GetBytes(fileText); return(new FileStreamResult(new MemoryStream(bytes), "text/csv") { FileDownloadName = "analysis.csv", }); }