public ActionResult GetAllCritReviews(int assignmentId) { Assignment assignment = db.Assignments.Find(assignmentId); Stream submission = null; if (assignment.Type == AssignmentTypes.CriticalReview) { //Critical Review: We want all the reviews this team was set to do. ZipFile zipfile = new ZipFile(); //List of all the teams who the current team was set to review List <ReviewTeam> reviewTeams = (from rt in db.ReviewTeams where rt.AssignmentID == assignmentId select rt).ToList(); //Add each review into the zip Dictionary <string, dynamic> reviewStreams = new Dictionary <string, dynamic>(); foreach (ReviewTeam reviewTeam in reviewTeams) { string key = reviewTeam.AuthorTeam.Name; OSBLE.Models.FileSystem.FileCollection fc = Models.FileSystem.Directories.GetAssignment( ActiveCourseUser.AbstractCourseID, assignmentId) .Review(reviewTeam.AuthorTeam, reviewTeam.ReviewingTeam) .AllFiles(); //don't create a zip if we don't have have anything to zip. if (fc.Count > 0) { var bytes = fc.ToBytes(); reviewStreams[key] = bytes; } } Random rnd = new Random(); foreach (string author in reviewStreams.Keys) { foreach (string file in reviewStreams[author].Keys) { string location = string.Format("{0}/{1}", "Review of Anoymous " + rnd.Next(), file); zipfile.AddEntry(location, reviewStreams[author][file]); } } submission = new MemoryStream(); zipfile.Save(submission); submission.Position = 0; } string ZipName = assignment.AssignmentName + ".zip"; return(new FileStreamResult(submission, "application/octet-stream") { FileDownloadName = ZipName }); }
public ActionResult GetSubmissionZip(int assignmentId, int teamId, bool resubmission = false) { //basic assignments have the option of being annotatable. In this case, //send off to annotate rather than creating a zip file. Assignment assignment = db.Assignments.Find(assignmentId); Team team = db.Teams.Find(teamId); if (assignment.Type == AssignmentTypes.Basic && assignment.IsAnnotatable == true) { if (assignment.HasDeliverables && assignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { if (resubmission) { return(RedirectToRoute(new { controller = "PdfCriticalReviewHTTPS", action = "Grade", assignmentID = assignmentId, authorTeamID = teamId, resubmission = resubmission })); } else { return(RedirectToRoute(new { controller = "PdfCriticalReview", action = "Grade", assignmentID = assignmentId, authorTeamID = teamId, resubmission = resubmission })); } } } Stream submission = null; if (assignment.Type == AssignmentTypes.CriticalReview) { //Critical Review: We want all the reviews this team was set to do. ZipFile zipfile = new ZipFile(); //List of all the teams who the current team was set to review List <ReviewTeam> reviewTeams = (from rt in db.ReviewTeams where rt.AssignmentID == assignmentId && rt.ReviewTeamID == teamId select rt).ToList(); //Add each review into the zip Dictionary <string, dynamic> reviewStreams = new Dictionary <string, dynamic>(); foreach (ReviewTeam reviewTeam in reviewTeams) { string key = reviewTeam.AuthorTeam.Name; OSBLE.Models.FileSystem.FileCollection fc = Models.FileSystem.Directories.GetAssignment( ActiveCourseUser.AbstractCourseID, assignmentId) .Review(reviewTeam.AuthorTeam, reviewTeam.ReviewingTeam) .AllFiles(); //don't create a zip if we don't have have anything to zip. if (fc.Count > 0) { var bytes = fc.ToBytes(); reviewStreams[key] = bytes; } } foreach (string author in reviewStreams.Keys) { foreach (string file in reviewStreams[author].Keys) { string location = string.Format("{0}/{1}", "Review of " + author, file); zipfile.AddEntry(location, reviewStreams[author][file]); } } submission = new MemoryStream(); zipfile.Save(submission); submission.Position = 0; } else //Basic Assigment, only need to get submissions { submission = OSBLE.Models.FileSystem.Directories.GetAssignmentSubmission( ActiveCourseUser.AbstractCourseID, assignmentId, teamId) .AllFiles() .ToZipStream(); } string ZipName = assignment.AssignmentName + " by " + team.Name + ".zip"; return(new FileStreamResult(submission, "application/octet-stream") { FileDownloadName = ZipName }); }