private static string getRealFileZipName(Assignment activity, AssignmentTeam team = null) { string s = "assignmentID = " + activity.ID.ToString(); if (team != null) { s += " TeamID = " + team.TeamID.ToString(); } return(s); }
public static FileStream FindZipFile(Course course, Assignment assignment, AssignmentTeam team = null) { string location = FindZipFileLocation(course, getRealFileZipName(assignment, team)); if (location != null) { return(GetDocumentForRead(location)); } return(null); }
public override DynamicDictionary BuildTableForTeam(IAssignmentTeam assignmentTeam) { dynamic data = Builder.BuildTableForTeam(assignmentTeam); data.TeacherCritical = new DynamicDictionary(); data.TeacherCritical.ReviewTeams = ReviewTeams; AssignmentTeam assignTeam = assignmentTeam as AssignmentTeam; Assignment assignment = assignTeam.Assignment; //get information to download all reviews that the team did List <ReviewTeam> authorTeams = new List <ReviewTeam>(); authorTeams = (from rt in assignment.ReviewTeams where rt.ReviewTeamID == assignTeam.TeamID select rt).ToList(); StringBuilder reviewedTeams = new StringBuilder(); DateTime lastSubmission = DateTime.MinValue; bool hasSubmission = false; int submittedCount = 0; foreach (ReviewTeam reviewTeam in authorTeams) { DateTime?thisSub = FileSystem.GetSubmissionTime(assignTeam, reviewTeam.AuthorTeam); if (thisSub != null) { reviewedTeams.Append(reviewTeam.AuthorTeam.Name).Append(", submitted on ").Append(thisSub).Append("\n"); hasSubmission = true; submittedCount++; } else { reviewedTeams.Append(reviewTeam.AuthorTeam.Name).Append("; no review submitted\n"); } } string altText = string.Format("Download {0}'s reviews of:\n{1}", assignmentTeam.Team.Name, reviewedTeams); if (assignment.PreceedingAssignment.HasDeliverables && assignment.PreceedingAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { data.TeacherCritical.IsPdfReviewAssignment = true; } else { data.TeacherCritical.IsPdfReviewAssignment = false; } data.TeacherCritical.fractionReviewed = string.Format("{0}/{1} submitted", submittedCount.ToString(), authorTeams.Count.ToString()); data.TeacherCritical.altText = altText; data.TeacherCritical.hasSubmission = hasSubmission; data.TeacherCritical.AssignmentTeam = assignmentTeam; return(data); }
public ActionResult GetReviewsOfAuthor(int assignmentId, int receiverId) { Assignment CRAssignment = db.Assignments.Find(assignmentId); CourseUser receiver = db.CourseUsers.Find(receiverId); AssignmentTeam AuthorTeam = GetAssignmentTeam(CRAssignment.PreceedingAssignment, receiver); if (ActiveCourseUser.AbstractRole.CanModify || (receiverId == ActiveCourseUser.ID)) { //No need to anonymize name AuthorTeam here as this function call is only made by Instructors and the author team. return(GetAllReviewedDocuments(CRAssignment, AuthorTeam.Team, "Critical Reviews for " + AuthorTeam.Team.Name + ".zip")); } return(RedirectToAction("Index", "Home")); }
public ActionResult getCurrentUsersZip(int assignmentID) { Assignment assignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(assignment, ActiveCourseUser); try { AssignmentTeam assignmentTeam = (from a in db.AssignmentTeams where a.TeamID == at.TeamID && a.AssignmentID == assignment.ID select a).FirstOrDefault();//db.AssignmentTeams.Find(teamID); if (assignment.CourseID == ActiveCourseUser.AbstractCourseID && assignment.AssignmentTeams.Contains(assignmentTeam)) { Stream stream = FileSystem.FindZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, assignmentTeam); string zipFileName = assignment.AssignmentName + " by " + assignmentTeam.Team.Name + ".zip"; if (stream != null) { return(new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = zipFileName }); } string submissionfolder = FileSystem.GetTeamUserSubmissionFolder(false, (ActiveCourseUser.AbstractCourse as Course), assignmentID, assignmentTeam); using (ZipFile zipfile = new ZipFile()) { if (new DirectoryInfo(submissionfolder).Exists) { zipfile.AddDirectory(submissionfolder); } FileSystem.CreateZipFolder(ActiveCourseUser.AbstractCourse as Course, zipfile, assignment, assignmentTeam); stream = FileSystem.GetDocumentForRead(zipfile.Name); return(new FileStreamResult(stream, "application/octet-stream") { FileDownloadName = zipFileName }); } } } catch (Exception e) { throw new Exception("Error in GetSubmissionZip", e); } return(RedirectToAction("Index", "Home")); }
public static void RemoveZipFile(Course course, Assignment assignment, AssignmentTeam team) { bool foundTeamUserZip = false, foundActivityZip = false; string pathTeamUser = FindZipFileLocation(course, getRealFileZipName(assignment, team)); if (pathTeamUser != null) { foundTeamUserZip = true; File.Delete(pathTeamUser); } string pathActivity = FindZipFileLocation(course, getRealFileZipName(assignment)); if (pathActivity != null) { foundActivityZip = true; File.Delete(pathActivity); } if (foundActivityZip || foundTeamUserZip) { //we deleted a file so we got to update the records string recordFile; using (StreamReader sr = new StreamReader(getZipFilesRecords(course))) { recordFile = sr.ReadToEnd(); } File.Delete(getZipFilesRecords(course)); string assignmentRealname = getRealFileZipName(assignment); string teamRealname = getRealFileZipName(assignment, team); using (StreamWriter sw = new StreamWriter(getZipFilesRecords(course))) { foreach (string line in recordFile.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) { if (line.Trim() != "") { string realName = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[1]; if (realName != assignmentRealname && realName != teamRealname) { sw.WriteLine(line); } } } } } }
/// <summary> /// Used in annotate to build a unique string for each document in OSBLE /// </summary> /// <param name="assignmentID">The assignment on which the submission took place (NOT THE CRITICAL REVIEW)</param> /// <param name="authorTeamID">The team that submitted the document</param> /// <returns></returns> public static string GetAnnotateDocumentName(int assignmentID, int authorTeamID) { using (OSBLEContext db = new OSBLEContext()) { Assignment assignment = db.Assignments.Find(assignmentID); AssignmentTeam assignmentTeam = new AssignmentTeam(); ReviewTeam reviewTeam = new ReviewTeam(); //needed for anchored discussion string fileName; if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { reviewTeam = (from rt in db.ReviewTeams where rt.AssignmentID == assignment.ID && rt.AuthorTeamID == authorTeamID select rt ).FirstOrDefault(); fileName = string.Format( "{0}-{1}-{2}-{3}", assignment.CourseID, assignment.ID, reviewTeam.ReviewTeamID, assignment.Deliverables[0].ToString() ); } else { assignmentTeam = (from at in db.AssignmentTeams where at.AssignmentID == assignment.ID && at.TeamID == authorTeamID select at ).FirstOrDefault(); fileName = string.Format( "{0}-{1}-{2}-{3}", assignment.CourseID, assignment.ID, assignmentTeam.TeamID, assignment.Deliverables[0].ToString() ); } return(fileName); } }
public ActionResult Grade(int assignmentID, int authorTeamID, bool resubmission = false) { WebClient client = new WebClient(); Assignment assignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(assignment, ActiveCourseUser); ReviewTeam reviewTeam = null; if (at != null) { reviewTeam = (from rt in assignment.ReviewTeams where rt.ReviewTeamID == at.TeamID && rt.AuthorTeamID == authorTeamID select rt).FirstOrDefault(); } //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (assignment.Deliverables.Count == 1 && assignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)assignment.ID, authorTeamID, resubmission); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = new CriticalReviewSettings(); settings.AnonymizeComments = false; api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } return(View("Review")); }
public override DynamicDictionary BuildHeader(Assignment assignment) { dynamic header = Builder.BuildHeader(assignment); header.AssignmentDetails = new DynamicDictionary(); RubricEvaluation rubricEvaluation = null; //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation //that they were the recipient of. AssignmentTeam at = OSBLEController.GetAssignmentTeam(assignment, Student); int teamId = 0; if (at != null) { teamId = at.TeamID; using (OSBLEContext db = new OSBLEContext()) { //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise //the rubric evaluation is a student rubric (not interested in them here) rubricEvaluation = (from re in db.RubricEvaluations where re.AssignmentID == assignment.ID && re.Evaluator.AbstractRole.CanGrade && re.RecipientID == teamId select re).FirstOrDefault(); } } //If the Rubric has been evaluated and is published, calculate the rubric grade % to display to the student if (rubricEvaluation != null && rubricEvaluation.IsPublished) { header.AssignmentDetails.hasGrade = true; header.AssignmentDetails.assignmentID = assignment.ID; header.AssignmentDetails.cuID = Student.ID; header.AssignmentDetails.DisplayValue = "View Graded Rubric " + RubricEvaluation.GetGradeAsPercent(rubricEvaluation.ID); } else { header.AssignmentDetails.DisplayValue = "Not Graded"; header.AssignmentDetails.hasGrade = false; } return(header); }
public static string GetDeliverable(Course course, int assignmentID, AssignmentTeam subbmitterTeam, string fileName, string[] possibleFileExtensions) { string path = GetTeamUserSubmissionFolder(false, course, assignmentID, subbmitterTeam) + "\\"; if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path); foreach (string extension in possibleFileExtensions) { if (files.Contains(path + fileName + extension)) { return(path + fileName + extension); } } } return(null); }
public ActionResult GetDocumentsForCriticalReview(int assignmentId, int authorTeamId) { Assignment CRAssignment = db.Assignments.Find(assignmentId); AssignmentTeam CurrentUsersTeam = GetAssignmentTeam(CRAssignment, ActiveCourseUser); Team authorTeam = db.Teams.Find(authorTeamId); //Getting a list of all the Team Ids for the current user to review. List <int> AllTeamsToReview = (from rt in CRAssignment.ReviewTeams where rt.ReviewTeamID == CurrentUsersTeam.TeamID select rt.AuthorTeamID).ToList(); //If authorTeamId is not in the list of author teams being reviewed by current user, then permission is denied. if (AllTeamsToReview.Contains(authorTeamId)) { //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (CRAssignment.PreceedingAssignment.Deliverables.Count == 1 && CRAssignment.PreceedingAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { return(RedirectToRoute(new { controller = "PdfCriticalReview", action = "Review", assignmentID = assignmentId, authorTeamID = authorTeamId })); } //Document not handled by Annotate, must collect author teams preceding assignment's submission OSBLE.Models.FileSystem.FileCollection AuthorTeamSubmission = Models.FileSystem.Directories.GetAssignment( ActiveCourseUser.AbstractCourseID, CRAssignment.PrecededingAssignmentID.Value) .Submission(authorTeamId) .AllFiles(); //Checking if author should be anonymized. string displayName = authorTeam.Name; if (AnonymizeAuthor(CRAssignment, authorTeam)) { displayName = "Anonymous " + authorTeamId; } string zipFileName = string.Format("{0}'s submission for {1}.zip", displayName, CRAssignment.PreceedingAssignment.AssignmentName); return(new FileStreamResult(AuthorTeamSubmission.ToZipStream(), "application/octet-stream") { FileDownloadName = zipFileName }); } return(RedirectToAction("Index", "Home")); }
public void SendFilesSubmittedNotification(Assignment assignment, AssignmentTeam team, string fileName) { //if (assignment.Category.CourseID == activeCourse.AbstractCourseID) //{ // var canGrade = (from c in db.CourseUsers // where c.AbstractCourseID == activeCourse.AbstractCourseID // && c.AbstractRole.CanGrade // select c).ToList(); // foreach (CourseUser user in canGrade) // { // Notification n = new Notification(); // n.ItemType = Notification.Types.FileSubmitted; // n.Data = assignment.ID.ToString() + ";" + team.TeamID.ToString() + ";" + assignment.AssignmentName + ";" + team.Team.Name + ";" + fileName + ";" + DateTime.UtcNow; // n.RecipientID = user.ID; // n.SenderID = activeCourse.ID; // addNotification(n); // } //} }
/// <summary> /// By design, all students must be part of their own individual assignment team. /// But, some assignments (I.e. Discussion type assignments, or team evaluations) should not be taken the TeamController to set up the asisngment teams. /// /// This will set the teams to the default individual assignment teams. /// If teams already exist, it does nothing. /// </summary> void SetUpDefaultAssignmentTeams() { bool assignmentTeamsExist = (from at in db.AssignmentTeams where at.AssignmentID == Assignment.ID select at).Count() > 0; //Only set up default teams if teams don't already exist if (Assignment.ID == 0 || !assignmentTeamsExist) { List <CourseUser> users = (from cu in db.CourseUsers where cu.AbstractCourseID == ActiveCourseUser.AbstractCourseID && cu.AbstractRole.CanSubmit orderby cu.UserProfile.LastName, cu.UserProfile.FirstName select cu).ToList(); //Creates an assignment team for each CourseUser who can submit documents (students) //The team name will be "FirstName LastName" foreach (CourseUser cu in users) { //Creating team Team team = new Team(); team.Name = cu.UserProfile.FirstName + " " + cu.UserProfile.LastName; //Creating Tm and adding them to team TeamMember tm = new TeamMember() { CourseUserID = cu.ID }; team.TeamMembers.Add(tm); //Creating the assignment team and adding it to the assignment AssignmentTeam at = new AssignmentTeam() { Team = team, Assignment = Assignment }; Assignment.AssignmentTeams.Add(at); } } }
public ActionResult GetAnnotateDocument(int assignmentID, int authorTeamID, string apiKey) { if (apiKey != ConfigurationManager.AppSettings["AnnotateApiKey"]) { return(RedirectToAction("Index", "Home")); } Assignment assignment = db.Assignments.Find(assignmentID); //add in some robustness. If we were passed in a critical review, //get the preceeding assignment. Otherwise, just use the current assignment. if (assignment.Type == AssignmentTypes.CriticalReview) { assignment = assignment.PreceedingAssignment; } AssignmentTeam assignmentTeam = (from at in db.AssignmentTeams where at.AssignmentID == assignment.ID && at.TeamID == authorTeamID select at ).FirstOrDefault(); string path = FileSystem.GetDeliverable( assignment.Course as Course, assignment.ID, assignmentTeam, assignment.Deliverables[0].ToString() ); string fileName = AnnotateApi.GetAnnotateDocumentName(assignment.ID, authorTeamID); return(new FileStreamResult(FileSystem.GetDocumentForRead(path), "application/octet-stream") { FileDownloadName = fileName }); }
private AssignmentDetailsViewModel BuildHeader(AssignmentDetailsViewModel vm) { //AC NOTE: Items will be displayed in the order in which they are added // to the ViewModel's HeaderViews list. Organize accordingly. Assignment assignment = vm.CurrentAssignment; vm.HeaderBuilder = new DefaultBuilder(); List <TeamEvaluation> teamEvaluations = null; using (OSBLEContext db = new OSBLEContext()) { //only need get these when they are needed if (assignment.Type == AssignmentTypes.TeamEvaluation) { teamEvaluations = db.TeamEvaluations.Where(te => te.TeamEvaluationAssignmentID == assignment.ID).ToList(); } } //views common to both students and teachers: if (assignment.Type == AssignmentTypes.DiscussionAssignment || assignment.Type == AssignmentTypes.CriticalReviewDiscussion) { //add initial / final post due date information //TODO: this will replace the "posts due" row vm.HeaderBuilder = new InitialFinalDueDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("InitialFinalDueDecorator"); } //not a team evaluation assignment if (assignment.Type != AssignmentTypes.TeamEvaluation && assignment.Type != AssignmentTypes.AnchoredDiscussion) { //add late policy vm.HeaderBuilder = new LatePolicyHeaderDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("LatePolicyHeaderDecorator"); } //teacher views //AC NOTE: Investigate the differences between CanGrade and CanModify if (vm.Client.AbstractRole.CanGrade || vm.Client.AbstractRole.CanModify) { //add deliverable information if needed if (assignment.HasDeliverables && assignment.Type != AssignmentTypes.AnchoredDiscussion) { //list deliverables add download link vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator"); } //is a discussion assignment if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams) { //link to classwide discussion vm.HeaderBuilder = new TeacherDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("TeacherDiscussionLinkDecorator"); } if (assignment.HasRubric) { //add link to rubric ViewAsUneditable mode vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("RubricDecorator"); //Show rubric grading progress for assignments with rubrics vm.HeaderBuilder = new RubricGradingProgressDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("RubricGradingProgressDecorator"); } if (assignment.Type == AssignmentTypes.TeamEvaluation) { //Show progress of TeamEvaluation, such as "X of Y Team Evaluations completed" vm.HeaderBuilder = new TeamEvalProgressDecorator(vm.HeaderBuilder, teamEvaluations); vm.HeaderViews.Add("TeamEvalProgressDecorator"); } else if (assignment.Type == AssignmentTypes.CriticalReview) { vm.HeaderBuilder = new PublishCriticalReviewDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("PublishCriticalReviewDecorator"); } else if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { //commented out: for now we don't need anything here for the instructor //in future implementations we may want to let the instructor also review documents with the group, but //how the teams are set up currently it wont work (no team set up for instructor) //link for critical review submission document //vm.HeaderBuilder = new AnchoredDiscussionSubmitDecorator(vm.HeaderBuilder, vm.Client); //vm.HeaderViews.Add("AnchoredDiscussionSubmitDecorator"); } // ABET outcomes - the ABETDepartment property being non-null indicates that // this assignment was labeled for ABET outcomes and assessment. if (null != assignment.ABETDepartment) { vm.HeaderBuilder = new ABETOutcomesDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("ABETOutcomesDecorator"); } } else if (vm.Client.AbstractRoleID == (int)OSBLE.Models.Courses.CourseRole.CourseRoles.Observer) { //has discussion teams? if (assignment.HasDiscussionTeams) { vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("DiscussionTeamMemberDecorator"); } if (assignment.HasRubric) { //add link to rubric ViewAsUneditable mode vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("RubricDecorator"); } if (assignment.HasDeliverables && assignment.Type != AssignmentTypes.AnchoredDiscussion) { //list deliverables add download link vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator"); } else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams) { //link to classwide discussion vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("StudentDiscussionLinkDecorator"); } else if (assignment.Type == AssignmentTypes.CriticalReview) { vm.HeaderBuilder = new TeacherDeliverablesHeaderDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("TeacherDeliverablesHeaderDecorator"); } } else if (vm.Client.AbstractRole.CanSubmit) //students { DateTime due = assignment.DueDate.AddHours(assignment.HoursLateWindow); due = due.UTCToCourse(vm.Client.AbstractCourseID); DateTime now = DateTime.UtcNow; now = now.UTCToCourse(vm.Client.AbstractCourseID); bool canSub = (now < due); //has discussion teams? if (assignment.HasDiscussionTeams) { vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("DiscussionTeamMemberDecorator"); } else if (assignment.HasTeams)//else has teams? { // add team name and list of members vm.HeaderBuilder = new TeamMembersDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("TeamMembersDecorator"); } //needs to submit? if (assignment.HasDeliverables) { if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { //link for critical review submission document vm.HeaderBuilder = new AnchoredDiscussionSubmissionDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("AnchoredDiscussionSubmissionDecorator"); } else { //add student submission link vm.HeaderBuilder = new StudentSubmissionDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("StudentSubmissionDecorator"); } } else if (assignment.Type == AssignmentTypes.CriticalReview) { //critical review submission link vm.HeaderBuilder = new CriticalReviewSubmissionDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("CriticalReviewSubmissionDecorator"); //link for student to download their reviewed assignment vm.HeaderBuilder = new CriticalReviewStudentDownloadDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("CriticalReviewStudentDownloadDecorator"); } else if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { //link for critical review submission document vm.HeaderBuilder = new AnchoredDiscussionSubmissionDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("AnchoredDiscussionSubmissionDecorator"); } else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams) { //link to classwide discussion vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("StudentDiscussionLinkDecorator"); } else if (assignment.Type == AssignmentTypes.TeamEvaluation && canSub) { vm.HeaderBuilder = new StudentTeamEvalSubmissionDecorator(vm.HeaderBuilder, teamEvaluations, vm.Client); vm.HeaderViews.Add("StudentTeamEvalSubmissionDecorator"); } //rubric? if (assignment.HasRubric) { RubricEvaluation rubricEvaluation = null; //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation //that they were the recipient of. AssignmentTeam at = OSBLEController.GetAssignmentTeam(assignment, vm.Client); int teamId = 0; if (at != null) { teamId = at.TeamID; using (OSBLEContext db = new OSBLEContext()) { //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise //the rubric evaluation is a student rubric (not interested in them here) rubricEvaluation = (from re in db.RubricEvaluations where re.AssignmentID == assignment.ID && re.Evaluator.AbstractRole.CanGrade && re.RecipientID == teamId select re).FirstOrDefault(); } } //add rubric link if (rubricEvaluation == null) { vm.HeaderBuilder = new RubricDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("RubricDecorator"); } //add link to graded rubric link else { vm.HeaderBuilder = new RubricGradeDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("RubricGradeDecorator"); } } } else if (vm.Client.AbstractRoleID == (int)CourseRole.CourseRoles.Moderator) //Moderator decorators { //has discussion teams? if (assignment.HasDiscussionTeams) { vm.HeaderBuilder = new DiscussionTeamMemberDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("DiscussionTeamMemberDecorator"); } else if (assignment.Type == AssignmentTypes.DiscussionAssignment && !assignment.HasDiscussionTeams) { //link to classwide discussion vm.HeaderBuilder = new StudentDiscussionLinkDecorator(vm.HeaderBuilder, vm.Client); vm.HeaderViews.Add("StudentDiscussionLinkDecorator"); } } if (assignment.Type == AssignmentTypes.CriticalReview || assignment.Type == AssignmentTypes.CriticalReviewDiscussion || assignment.Type == AssignmentTypes.TeamEvaluation) { vm.HeaderBuilder = new PreviousAssignmentDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("PreviousAssignmentDecorator"); } if (assignment.Type == AssignmentTypes.CriticalReviewDiscussion && vm.Client.AbstractRole.CanGrade) { vm.HeaderBuilder = new DownloadDiscussionItemsDecorator(vm.HeaderBuilder); vm.HeaderViews.Add("DownloadDiscussionItemsDecorator"); } return(vm); }
public override DynamicDictionary BuildHeader(Assignment assignment) { //TODO:clear out the un-needed actions here dynamic header = Builder.BuildHeader(assignment); header.CRSubmission = new DynamicDictionary(); header.Assignment = assignment; // get the assignment team ( team doing the review ) AssignmentTeam assignmentTeam = null; foreach (AssignmentTeam at in assignment.AssignmentTeams) { foreach (TeamMember tm in at.Team.TeamMembers) { if (tm.CourseUser.UserProfileID == Student.UserProfileID) { assignmentTeam = at; } } } header.CRSubmission.hasSubmitted = false; if (assignmentTeam != null) { List <ReviewTeam> authorTeams = new List <ReviewTeam>(); authorTeams = (from rt in assignment.ReviewTeams where rt.ReviewTeamID == assignmentTeam.TeamID select rt).ToList(); header.CRSubmission.authorTeams = authorTeams; header.CRSubmission.assignmentId = assignment.ID; List <DateTime?> submissionTimes = new List <DateTime?>(); //pass submission times to view header.CRSubmission.submissionTimes = submissionTimes; //header.CRSubmission.authorSubmissionTimes = authorSubmissionTimes; if (assignment.HasTeams) { header.CRSubmission.hasTeams = true; } else { header.CRSubmission.hasTeams = false; } } FileCache Cache = FileCacheHelper.GetCacheInstance(OsbleAuthentication.CurrentUser); //Same functionality as in the other controller. Note: These values are set in SubmissionController/Create[POST] //did the user just submit something? If so, set up view to notify user if (Cache["SubmissionReceived"] != null && Convert.ToBoolean(Cache["SubmissionReceived"]) == true) { header.CRSubmission.SubmissionReceived = true; header.CRSubmission.AuthorTeamId = (int)Cache["SubmissionForAuthorTeamID"]; Cache["SubmissionReceived"] = false; } else { header.CRSubmission.SubmissionReceived = false; Cache["SubmissionReceived"] = false; } //rubric stuff: header.CRSubmission.hasStudentRubric = assignment.HasStudentRubric; header.CRSubmission.studentRubricID = assignment.StudentRubricID; return(header); }
public ActionResult Create(int?id, IEnumerable <HttpPostedFileBase> files, int?authorTeamID = null) { if (id != null) { Assignment assignment = db.Assignments.Find(id); //submit event to the eventlog try { if (assignment != null) { var sub = new SubmitEvent { AssignmentId = id.Value, SenderId = CurrentUser.ID, SolutionName = assignment.AssignmentName, CourseId = assignment.CourseID, }; int eventLogId = Posts.SaveEvent(sub); DBHelper.AddToSubmitEventProperties(eventLogId); if (eventLogId == -1) { throw new Exception("Failed to log submit event to the eventlog table -- Posts.SaveEvent returned -1"); } else { if (DBHelper.InterventionEnabledForCourse(assignment.CourseID ?? -1)) { //process suggestions if interventions are enabled for this course. using (EventCollectionController ecc = new EventCollectionController()) { ecc.ProcessLogForInterventionSync((ActivityEvent)sub); string authKey = Request.Cookies["AuthKey"].Value.Split('=').Last(); ecc.NotifyNewSuggestion(CurrentUser.ID, assignment.CourseID ?? 0, authKey); } } } } else { var sub = new SubmitEvent { AssignmentId = id.Value, SenderId = CurrentUser.ID, SolutionName = "NULL ASSIGNMENT", }; int eventLogId = Posts.SaveEvent(sub); if (eventLogId == -1) { throw new Exception("Failed to log submit event to the eventlog table -- Posts.SaveEvent returned -1 -- Assignment is null"); } } } catch (Exception e) { throw new Exception("Failed to log submit event to the eventlog table: ", e); } if (assignment != null && (assignment.HasDeliverables == true || assignment.Type == AssignmentTypes.CriticalReview || assignment.Type == AssignmentTypes.AnchoredDiscussion)) { List <Deliverable> deliverables; if (assignment.Type == AssignmentTypes.CriticalReview) { deliverables = new List <Deliverable>((assignment.PreceedingAssignment).Deliverables); } else if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { //TODO: need to keep deliverables if no changes have been made. //need to remove old deliverables assignment.Deliverables.Clear(); db.SaveChanges(); deliverables = new List <Deliverable>((assignment).Deliverables); List <string> deliverableNames = new List <string>(); foreach (var file in files) { deliverables.Add(new Deliverable { Assignment = assignment, AssignmentID = assignment.ID, DeliverableType = DeliverableType.PDF, Name = Path.GetFileNameWithoutExtension(file.FileName), }); } foreach (Deliverable d in deliverables) { assignment.Deliverables.Add(d); } db.Entry(assignment).State = System.Data.EntityState.Modified; db.SaveChanges(); } else { deliverables = new List <Deliverable>((assignment).Deliverables); } if (assignment.CourseID == ActiveCourseUser.AbstractCourseID && (ActiveCourseUser.AbstractRole.CanSubmit == true || ActiveCourseUser.AbstractRole.CanUploadFiles == true)) { AssignmentTeam assignmentTeam = GetAssignmentTeam(assignment, ActiveCourseUser); int i = 0; //the files variable is null when submitting an in-browser text submission if (files != null) { int anchoredDiscussionDocumentCount = 0; foreach (var file in files) { anchoredDiscussionDocumentCount++; if (file != null && file.ContentLength > 0) { DeliverableType type = (DeliverableType)deliverables[i].Type; //jump over all DeliverableType.InBrowserText as they will be handled separately while (type == DeliverableType.InBrowserText) { i++; type = (DeliverableType)deliverables[i].Type; } string fileName = Path.GetFileName(file.FileName); string extension = Path.GetExtension(file.FileName).ToLower(); string deliverableName = string.Format("{0}{1}", deliverables[i].Name, extension); string[] allowFileExtensions = GetFileExtensions(type); if (allowFileExtensions.Contains(extension)) { if (assignment.Type == AssignmentTypes.CriticalReview || assignment.Type == AssignmentTypes.AnchoredDiscussion) { //TODO: clean this up AssignmentTeam authorTeam = new AssignmentTeam(); ReviewTeam reviewTeam = new ReviewTeam(); if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { authorTeam = new AssignmentTeam { Assignment = assignment, AssignmentID = assignment.ID, Team = null, TeamID = anchoredDiscussionDocumentCount, }; reviewTeam = new ReviewTeam { Assignment = assignment, AssignmentID = assignment.ID, //AuthorTeam = null, AuthorTeamID = anchoredDiscussionDocumentCount, //ReviewingTeam = null, ReviewTeamID = ActiveCourseUser.AbstractCourse.ID, }; assignment.ReviewTeams.Add(reviewTeam); //db.Entry(assignment).State = System.Data.EntityState.Modified; db.SaveChanges(); } else { authorTeam = (from at in db.AssignmentTeams where at.TeamID == authorTeamID && at.AssignmentID == assignment.PrecededingAssignmentID select at).FirstOrDefault(); reviewTeam = (from tm in db.TeamMembers join t in db.Teams on tm.TeamID equals t.ID join rt in db.ReviewTeams on t.ID equals rt.ReviewTeamID where tm.CourseUserID == ActiveCourseUser.ID && rt.AssignmentID == assignment.ID select rt).FirstOrDefault(); } //MG&MK: file system for critical review assignments is laid out a bit differently, so //critical review assignments must use different file system functions //remove all prior files OSBLE.Models.FileSystem.AssignmentFilePath fs = Models.FileSystem.Directories.GetAssignment( ActiveCourseUser.AbstractCourseID, assignment.ID); fs.Review(authorTeam.TeamID, reviewTeam.ReviewTeamID) .File(deliverableName) .Delete(); if (assignment.Type != AssignmentTypes.AnchoredDiscussion) // handle assignments that are not anchored discussion { //We need to remove the zipfile corresponding to the authorTeamId being sent in as well as the regularly cached zip. AssignmentTeam precedingAuthorAssignmentTeam = (from at in assignment.PreceedingAssignment.AssignmentTeams where at.TeamID == authorTeamID select at).FirstOrDefault(); FileSystem.RemoveZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, precedingAuthorAssignmentTeam); FileSystem.RemoveZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, assignmentTeam); } else //anchored discussion type TODO: this does nothing right now, fix! { //We need to remove the zipfile corresponding to the authorTeamId being sent in as well as the regularly cached zip. AssignmentTeam precedingAuthorAssignmentTeam = (from at in assignment.AssignmentTeams where at.TeamID == authorTeamID select at).FirstOrDefault(); FileSystem.RemoveZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, precedingAuthorAssignmentTeam); FileSystem.RemoveZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, assignmentTeam); } //add in the new file //authorTeamID is the deliverable file counter, and reviewTeamID is the courseID fs.Review(authorTeam.TeamID, reviewTeam.ReviewTeamID) .AddFile(deliverableName, file.InputStream); //unzip and rezip xps files because some XPS generators don't do it right if (extension.ToLower().CompareTo(".xps") == 0) { //XPS documents require the actual file path, so get that. OSBLE.Models.FileSystem.FileCollection fileCollection = OSBLE.Models.FileSystem.Directories.GetAssignment( ActiveCourseUser.AbstractCourseID, assignment.ID) .Review(authorTeam.TeamID, reviewTeam.ReviewTeamID) .File(deliverables[i].Name); string path = fileCollection.FirstOrDefault(); string extractPath = Path.Combine(FileSystem.GetTeamUserSubmissionFolderForAuthorID(true, ActiveCourseUser.AbstractCourse as Course, (int)id, assignmentTeam, authorTeam.Team), "extract"); using (ZipFile oldZip = ZipFile.Read(path)) { oldZip.ExtractAll(extractPath, ExtractExistingFileAction.OverwriteSilently); } using (ZipFile newZip = new ZipFile()) { newZip.AddDirectory(extractPath); newZip.Save(path); } } } else { //If a submission of any extension exists delete it. This is needed because they could submit a .c file and then a .cs file and the teacher would not know which one is the real one. string submission = FileSystem.GetDeliverable(ActiveCourseUser.AbstractCourse as Course, assignment.ID, assignmentTeam, deliverables[i].Name, allowFileExtensions); if (submission != null) { FileInfo oldSubmission = new FileInfo(submission); if (oldSubmission.Exists) { oldSubmission.Delete(); } } FileSystem.RemoveZipFile(ActiveCourseUser.AbstractCourse as Course, assignment, assignmentTeam); string path = Path.Combine(FileSystem.GetTeamUserSubmissionFolder(true, ActiveCourseUser.AbstractCourse as Course, (int)id, assignmentTeam), deliverables[i].Name + extension); file.SaveAs(path); //unzip and rezip xps files because some XPS generators don't do it right if (extension.ToLower().CompareTo(".xps") == 0) { string extractPath = Path.Combine(FileSystem.GetTeamUserSubmissionFolder(true, ActiveCourseUser.AbstractCourse as Course, (int)id, assignmentTeam), "extract"); using (ZipFile oldZip = ZipFile.Read(path)) { oldZip.ExtractAll(extractPath, ExtractExistingFileAction.OverwriteSilently); } using (ZipFile newZip = new ZipFile()) { newZip.AddDirectory(extractPath); newZip.Save(path); } } } DateTime?dueDate = assignment.DueDate; if (dueDate != null) { //TODO: add case for anchored discussion assignment (new NotificationController()).SendFilesSubmittedNotification(assignment, assignmentTeam, deliverables[i].Name); } } else { //The submission view handles incorrect extension types, so this area of code is unlikely to be reached. In the case that it does a occur, //we will ineloquently redirect them to assignment index without feedback. Cache["SubmissionReceived"] = false; return(RedirectToAction("Index", "Assignment")); } } i++; } } // Creates the text files from text boxes int j = 0; string delName; do { if (Request != null) { //delName = Request.Params["desiredName[" + j + "]"]; delName = Request.Unvalidated.Form["desiredName[" + j + "]"]; } else //TODO: change this to releveant string { delName = null; } if (delName != null) { string inbrowser; if (Request != null) { //inbrowser = Request.Params["inBrowserText[" + j + "]"]; inbrowser = Request.Unvalidated.Form["inBrowserText[" + j + "]"]; if (inbrowser.Length > 0) { var path = Path.Combine(FileSystem.GetTeamUserSubmissionFolder(true, ActiveCourseUser.AbstractCourse as Course, (int)id, assignmentTeam), CurrentUser.LastName + "_" + CurrentUser.FirstName + "_" + delName + ".txt"); System.IO.File.WriteAllText(path, inbrowser); } } } j++; } while (delName != null); Cache["SubmissionReceived"] = true; Cache["SubmissionReceivedAssignmentID"] = assignment.ID; if (authorTeamID != null) { Cache["SubmissionForAuthorTeamID"] = authorTeamID; } if (assignment.Type == AssignmentTypes.AnchoredDiscussion) { return(RedirectToAction("Index", "AnchoredDiscussionController")); } else { return(Redirect(Request.UrlReferrer.ToString())); } } } } return(Create(id)); }
// // GET: /Assignment/ public ActionResult Index(int?id) { //did the user just submit something? If so, set up view to notify user if (Cache["SubmissionReceived"] != null && Convert.ToBoolean(Cache["SubmissionReceived"]) == true) { ViewBag.SubmissionReceived = true; ViewBag.SubmissionReceivedAssignmentID = Cache["SubmissionReceivedAssignmentID"]; Cache["SubmissionReceived"] = false; } else { ViewBag.SubmissionReceived = false; Cache["SubmissionReceived"] = false; } List <Assignment> Assignments = new List <Assignment>(); //Getting the assginment list, without draft assignments. if (ActiveCourseUser.AbstractRole.CanGrade) { //For CanGrade roles, show all assignments Assignments = (from assignment in db.Assignments where assignment.CourseID == ActiveCourseUser.AbstractCourseID orderby assignment.IsDraft, assignment.ReleaseDate select assignment).ToList(); //We want the number of Posters who's initial posts should be tracked. So students in this course. ViewBag.TotalDiscussionPosters = (from cu in db.CourseUsers where cu.AbstractCourseID == ActiveCourseUser.AbstractCourseID && cu.AbstractRoleID == (int)CourseRole.CourseRoles.Student select cu).Count(); } else if (ActiveCourseUser.AbstractRole.CanSubmit) { //for CanSubmit, show all assignments except draft assignment Assignments = (from assignment in db.Assignments where !assignment.IsDraft && assignment.CourseID == ActiveCourseUser.AbstractCourseID orderby assignment.ReleaseDate select assignment).ToList(); //This Dictionary contains: //Key: AssignmentID //Value: tuple(submissionTime (as string), discussion team ID as int or null) Dictionary <int, string> submissionInfo = new Dictionary <int, string>(); Dictionary <int, DiscussionTeam> dtInfo = new Dictionary <int, DiscussionTeam>(); foreach (Assignment a in Assignments) { if (a.HasDeliverables) { AssignmentTeam at = GetAssignmentTeam(a, ActiveCourseUser); DateTime? subTime = FileSystem.GetSubmissionTime(at); string submissionTime = "No Submission"; if (subTime != null) //found a submission time, Reassign submissionTime { DateTime convertedSubTime = new DateTime(subTime.Value.Ticks, DateTimeKind.Unspecified); //Submission time comes back in UTC convertedSubTime = convertedSubTime.UTCToCourse(ActiveCourseUser.AbstractCourseID); submissionTime = convertedSubTime.ToString(); } submissionInfo.Add(a.ID, submissionTime); } else { submissionInfo.Add(a.ID, "No Submission"); } if (a.Type == AssignmentTypes.DiscussionAssignment || a.Type == AssignmentTypes.CriticalReviewDiscussion) { foreach (DiscussionTeam dt in a.DiscussionTeams) { foreach (TeamMember tm in dt.GetAllTeamMembers()) { if (tm.CourseUserID == ActiveCourseUser.ID) //Checking if Client is a member within the DiscussionTeam { if (dtInfo.ContainsKey(a.ID) == false) { dtInfo.Add(a.ID, dt); break; } } } } } else { dtInfo.Add(a.ID, null); } ViewBag.dtInfo = dtInfo; } //Gathering the Team Evaluations for the current user's teams. List <TeamEvaluation> teamEvaluations = (from t in db.TeamEvaluations where t.EvaluatorID == ActiveCourseUser.ID select t).ToList(); ViewBag.TeamEvaluations = teamEvaluations; ViewBag.CourseUser = ActiveCourseUser; ViewBag.SubmissionInfoDictionary = submissionInfo; } else if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Moderator) { //for moderators, grab only discussion/Critical review assignment types that they are to partcipate in //Or any discussions that are classwide var discussionBasedAssignment = (from assignment in db.Assignments where !assignment.IsDraft && assignment.CourseID == ActiveCourseUser.AbstractCourseID && (assignment.AssignmentTypeID == (int)AssignmentTypes.CriticalReviewDiscussion || assignment.AssignmentTypeID == (int)AssignmentTypes.DiscussionAssignment) orderby assignment.DueDate select assignment).ToList(); //going through all the discussion assignment's discussion teams looking for a team member who is the current user. foreach (Assignment assignment in discussionBasedAssignment) { //Checking if classwide if (assignment.HasDiscussionTeams == false) { Assignments.Add(assignment); continue; } //checking if user is on team bool addedAssignment = false; foreach (DiscussionTeam dt in assignment.DiscussionTeams) { if (addedAssignment) //if the assignment has already been added, then break out of this foreach and go back to assignment foreach. { break; } foreach (TeamMember tm in dt.GetAllTeamMembers()) { if (tm.CourseUserID == ActiveCourseUser.ID) { Assignments.Add(assignment); addedAssignment = true; break; } } } } } else if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Observer) { int cid = ActiveCourseUser.AbstractCourseID; Assignments = DBHelper.GetObservableAssignments(cid); //For CanGrade roles, show all assignments /* Assignments = (from assignment in db.Assignments * where assignment.CourseID == ActiveCourseUser.AbstractCourseID * orderby assignment.IsDraft, assignment.ReleaseDate * select assignment).ToList();*/ //We want the number of Posters who's initial posts should be tracked. So students in this course. ViewBag.TotalDiscussionPosters = (from cu in db.CourseUsers where cu.AbstractCourseID == ActiveCourseUser.AbstractCourseID && cu.AbstractRoleID == (int)CourseRole.CourseRoles.Student select cu).Count(); } //Seperate all assignments for organizing into one list List <Assignment> Past = (from a in Assignments where a.DueDate < DateTime.UtcNow && !a.IsDraft orderby a.DueDate select a).ToList(); List <Assignment> Present = (from a in Assignments where a.ReleaseDate <DateTime.UtcNow && a.DueDate> DateTime.UtcNow && !a.IsDraft orderby a.DueDate select a).ToList(); List <Assignment> Future = (from a in Assignments where a.DueDate >= DateTime.UtcNow && a.ReleaseDate >= DateTime.UtcNow && !a.IsDraft orderby a.DueDate select a).ToList(); List <Assignment> Draft = (from a in Assignments where a.IsDraft orderby a.DueDate select a).ToList(); //Count them ViewBag.PastCount = Past.Count(); ViewBag.PresentCount = Present.Count(); ViewBag.FutureCount = Future.Count(); ViewBag.DraftCount = Draft.Count(); //Combine back into one list. Present.AddRange(Past); Present.AddRange(Future); Present.AddRange(Draft); List <Assignment> AllAssignments = Present; ViewBag.Assignments = AllAssignments; ViewBag.CurrentDate = DateTime.UtcNow; ViewBag.Submitted = false; return(View("Index")); }
public ActionResult ExportAssignmentGrades(int assignmentID) { //get total points for this assignment int totalPoints = DBHelper.GetAssignmentPointTotal(assignmentID); //find all students for current course List <CourseUser> students = (from c in db.CourseUsers where c.AbstractCourseID == ActiveCourseUser.AbstractCourseID && c.AbstractRoleID == (int)CourseRole.CourseRoles.Student select c).ToList(); if (ActiveCourseUser.Section != -2) //instructors or all sections users can download all student grades { List <int> sections = new List <int>(); //need to keep track of multiple sections. if (ActiveCourseUser.Section == -1) //multiple sections { List <string> idList = ActiveCourseUser.MultiSection.Split(',').ToList(); foreach (string id in idList) { int section; if (Int32.TryParse(id, out section)) { sections.Add(section); } } } else { sections.Add(ActiveCourseUser.Section); } // For TAs, make rid of any student that isn't in the TA's section. for (int i = 0; i < students.Count; i++) { if (!sections.Contains(students[i].Section)) { students.RemoveAt(i); i--; } } } //key-value pair for names-grades Dictionary <string, string> grades = new Dictionary <string, string>(); //key-value pair for fullname-lastname so we can sort by lastname when creating the csv Dictionary <string, string> firstLast = new Dictionary <string, string>(); //key-value pair to keep track of the late penalty Dictionary <string, string> latePenalty = new Dictionary <string, string>(); //seed dictionary with student last, first names foreach (CourseUser student in students) { if (!grades.ContainsKey(student.UserProfile.FullName) && !firstLast.ContainsKey(student.UserProfile.FullName) && !latePenalty.ContainsKey(student.UserProfile.FullName)) { grades.Add(student.UserProfile.FullName, ""); firstLast.Add(student.UserProfile.FullName, student.UserProfile.LastName); latePenalty.Add(student.UserProfile.FullName, ""); } } //get graded rubrics List <RubricEvaluation> rubricEvaluations = null; rubricEvaluations = db.RubricEvaluations.Where(re => re.Evaluator.AbstractRole.CanGrade && re.AssignmentID == assignmentID).ToList(); if (rubricEvaluations.Count > 0) //make sure there are rubrics saved { foreach (RubricEvaluation rubricEvaluation in rubricEvaluations) { string rubricStudentName = ""; //we need to go through teams to handle team assignments. this works for individuals because an individual is a team of 1 foreach (var teamMember in rubricEvaluation.Recipient.TeamMembers) { rubricStudentName = teamMember.CourseUser.UserProfile.FullName; if (rubricEvaluation.IsPublished) { //update value to match key if (grades.ContainsKey(rubricStudentName)) { grades[rubricStudentName] = RubricEvaluation.GetGradeAsDouble(rubricEvaluation.ID).ToString(); AssignmentTeam team = new AssignmentTeam(); team.Assignment = rubricEvaluation.Assignment; team.AssignmentID = rubricEvaluation.AssignmentID; team.Team = teamMember.Team; team.TeamID = teamMember.TeamID; latePenalty[rubricStudentName] = (GetLatePenalty(team) / 100.0).ToString(); } } } } //sort the grades A-Z by last name var sortedNameList = from pair in firstLast orderby pair.Value ascending select pair; //make a csv for export var csv = new StringBuilder(); csv.Append(String.Format("{0},{1},{2},{3},{4},{5},{6}{7}", "FirstName", "LastName", "Score(PCT)", "Raw Points out of " + totalPoints.ToString(), "Late Penalty(PCT)", "Score(PCT) - Late Penalty", "Raw Score - Late Penalty", Environment.NewLine)); foreach (KeyValuePair <string, string> pair in sortedNameList) { //place quotes around name so the first, last format doesn't break the csv string firstname = "\"" + pair.Key.Split(' ').ToList().First() + "\""; //split off first name string lastname = "\"" + pair.Value + "\""; string rawScore = String.IsNullOrEmpty(grades[pair.Key]) ? "" : (Convert.ToDouble(grades[pair.Key]) * totalPoints).ToString(); double grade = String.IsNullOrEmpty(grades[pair.Key]) ? -1.0 : Convert.ToDouble(grades[pair.Key]); //string gradePCT = String.IsNullOrEmpty(grades[pair.Key]) ? "" : (Convert.ToDouble(grades[pair.Key]) * 100).ToString(); //string latePentaltyPCT = String.IsNullOrEmpty(latePenalty[pair.Key]) ? "" : (Convert.ToDouble(latePenalty[pair.Key]) * 100).ToString(); string latePentaltyPCT = String.IsNullOrEmpty(latePenalty[pair.Key]) ? "" : (Convert.ToDouble(latePenalty[pair.Key])).ToString(); double latePenaltyScore = String.IsNullOrEmpty(grades[pair.Key]) ? -1.0 : Convert.ToDouble(latePenalty[pair.Key]); string lateScorePCT = String.IsNullOrEmpty(grades[pair.Key]) ? "" : (grade - latePenaltyScore <= 0 ? 0 : grade - latePenaltyScore).ToString(); string lateRawScore = String.IsNullOrEmpty(grades[pair.Key]) ? "" : (grade - latePenaltyScore <= 0 ? 0 : (grade - latePenaltyScore) * totalPoints).ToString(); var newLine = String.Format("{0},{1},{2},{3},{4},{5},{6}{7}", firstname, lastname, grades[pair.Key], rawScore, latePentaltyPCT, lateScorePCT, lateRawScore, Environment.NewLine); csv.Append(newLine); } const string contentType = "text/plain"; var bytes = Encoding.UTF8.GetBytes(csv.ToString()); return(File(bytes, contentType, rubricEvaluations.First().Assignment.AssignmentName + " " + DateTime.Now + " (Exported Grades).csv")); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.ToString())); } else { return(RedirectToAction("Index", "Home", new { area = "AssignmentDetails", assignmentId = assignmentID })); } }
public ActionResult StudentTeamEvaluation(int assignmentId) { Assignment a = db.Assignments.Find(assignmentId); Team previousTeam; if (a.PreceedingAssignment.Type == AssignmentTypes.DiscussionAssignment) { //Note: This could have non-student types on the team, such as moderators or TAs DiscussionTeam dt = GetDiscussionTeam(a.PreceedingAssignment, ActiveCourseUser); previousTeam = new Team(); previousTeam.TeamMembers = dt.Team.TeamMembers.Where(tm => tm.CourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Student).ToList(); } else { previousTeam = GetAssignmentTeam(a.PreceedingAssignment, ActiveCourseUser).Team; } AssignmentTeam at = GetAssignmentTeam(a, ActiveCourseUser); if (at != null && a.Type == AssignmentTypes.TeamEvaluation) { ViewBag.AssignmentTeam = at; ViewBag.PreviousTeam = previousTeam; List <TeamEvaluation> teamEvals = (from te in db.TeamEvaluations where te.TeamEvaluationAssignmentID == assignmentId && te.EvaluatorID == ActiveCourseUser.ID orderby te.Recipient.UserProfile.LastName select te).ToList(); //MG: evaluator (currentuser) must have completed at as many evaluations as team members from the previous assignment. //Otherwise, use artificial team evals for view if (teamEvals.Count < previousTeam.TeamMembers.Count) //Creating new team eval { List <TeamEvaluation> artificialTeamEvals = new List <TeamEvaluation>(); foreach (TeamMember tm in previousTeam.TeamMembers.OrderBy(tm2 => tm2.CourseUser.UserProfile.LastName)) { TeamEvaluation te = new TeamEvaluation(); te.Points = 0; te.Recipient = tm.CourseUser; artificialTeamEvals.Add(te); } ViewBag.SubmitButtonValue = "Submit"; ViewBag.TeamEvaluations = artificialTeamEvals; ViewBag.InitialPointsPossible = previousTeam.TeamMembers.Count * 100; } else //using existing team evals { ViewBag.InitialPointsPossible = 0; //Must be 0 as we are reloading old TEs, and requirements for submitting initially are that points possible must be 0 ViewBag.Comment = teamEvals.FirstOrDefault().Comment; ViewBag.SubmitButtonValue = "Resubmit"; ViewBag.TeamEvaluations = teamEvals; } return(View("_StudentTeamEvaluationView")); } else { return(View("Index")); } }
public override DynamicDictionary BuildHeader(Assignment assignment) { dynamic header = Builder.BuildHeader(assignment); header.Assignment = assignment; header.CRdownload = new DynamicDictionary(); header.CRdownload.hasPublished = assignment.IsCriticalReviewPublished; header.CRdownload.publishedDate = assignment.CriticalReviewPublishDate; header.CRdownload.hasRubricToView = false; //get student's team AssignmentTeam assignmentTeam = null; assignmentTeam = OSBLEController.GetAssignmentTeam(assignment.PreceedingAssignment, Student); header.CRdownload.teamID = assignmentTeam.TeamID; header.CRdownload.hasRecievedReview = false; //PDF reviews don't get sent to the file system (they get sent to annotate) //so we can't check the file system for review items. //yc: but we can check to see if the file has been submitted into annotate //dbo.annotatedocumentreferences has a field osbledocumentcode, and we have the date it was "uploaded" //it follows the format:#-#-#-filename.PDF == courseID-PreviousAssignmentid-teamthatisreviewingreviewing-filename.PDF //we also have dbo.reviewteams that show if some one has reviewed your assignment Assignment previousAssignment = assignment.PreceedingAssignment; //yc: locate all reivew teams ReviewTeam reviewers = null; bool foundAnnotateEntry = false; using (OSBLEContext db = new OSBLEContext()) { if (assignmentTeam != null) { reviewers = (from rte in db.ReviewTeams where rte.AuthorTeamID == assignmentTeam.TeamID select rte).FirstOrDefault(); } if (reviewers != null) { //if a review team exists, determin if the annoation exisits string lookup = assignment.CourseID.ToString() + "-" + previousAssignment.ID.ToString() + "-" + assignmentTeam.TeamID.ToString() + "-"; AnnotateDocumentReference d = (from adr in db.AnnotateDocumentReferences where adr.OsbleDocumentCode.Contains(lookup) select adr).FirstOrDefault(); if (d != null && (assignment.DueDate < DateTime.Now || assignment.IsCriticalReviewPublished)) { foundAnnotateEntry = true; } } } if (foundAnnotateEntry)//( //previousAssignment.HasDeliverables //&& previousAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF //&& previousAssignment.Deliverables.Count == 1 //) { header.CRdownload.hasRecievedReview = true; } else { if (assignmentTeam != null) { //get list of all teams reviewing student List <AssignmentTeam> reviewersOfStudent = (from rt in assignment.ReviewTeams join at in assignment.AssignmentTeams on rt.ReviewTeamID equals at.TeamID where rt.AuthorTeamID == assignmentTeam.TeamID select at).ToList(); //check each team for a submission foreach (AssignmentTeam at in reviewersOfStudent) { //if(at.GetSubmissionTime() != null) if (FileSystem.GetSubmissionTime(at, assignmentTeam.Team) != null) { header.CRdownload.hasRecievedReview = true; break; } } } //check if there is at one student rubric that has been filled out for the current user if (assignment.HasStudentRubric) { using (OSBLEContext db = new OSBLEContext()) { header.CRdownload.hasRubricToView = (from e in db.RubricEvaluations where e.AssignmentID == assignment.ID && e.RecipientID == assignmentTeam.TeamID && e.Evaluator.AbstractRoleID == (int)CourseRole.CourseRoles.Student && e.DatePublished != null select e.ID).Count() > 0; } } } header.CRdownload.student = Student; header.CRdownload.assignmentID = assignment.ID; return(header); }
public static string GetDeliverable(Course course, int assignmentID, AssignmentTeam subbmitterTeam, string fileName) { return(GetTeamUserSubmissionFolder(false, course, assignmentID, subbmitterTeam) + "\\" + fileName); }
public override DynamicDictionary BuildHeader(Assignment assignment) { dynamic header = Builder.BuildHeader(assignment); header.Submission = new DynamicDictionary(); header.IsAnnotatable = new bool(); header.DeliverableType = assignment.Deliverables.FirstOrDefault().Type; DateTime?submissionTime = null; //get id of current student's team List <TeamMember> allMembers = assignment.AssignmentTeams.SelectMany(at => at.Team.TeamMembers).ToList(); TeamMember member = allMembers.Where(m => m.CourseUserID == Student.ID).FirstOrDefault(); header.Submission.allowSubmit = true; //get submission time: foreach (AssignmentTeam team in assignment.AssignmentTeams) { //if the team matches with the student if (team.TeamID == member.TeamID) { submissionTime = team.GetSubmissionTime(); break; } } if (submissionTime == null) { header.Submission.hasSubmitted = false; } else { header.Submission.hasSubmitted = true; header.Submission.SubmissionTime = submissionTime.Value.ToString(); } header.Submission.assignmentID = assignment.ID; FileCache Cache = FileCacheHelper.GetCacheInstance(OsbleAuthentication.CurrentUser); //Same functionality as in the other controller. //did the user just submit something? If so, set up view to notify user if (Cache["SubmissionReceived"] != null && Convert.ToBoolean(Cache["SubmissionReceived"]) == true) { header.Submission.SubmissionReceived = true; Cache["SubmissionReceived"] = false; } else { header.Submission.SubmissionReceived = false; Cache["SubmissionReceived"] = false; } //handle link for viewing annotated documents RubricEvaluation rubricEvaluation = null; //Getting the assignment team for Student, and if its non-null then we take that team ID and find the RubricEvaluation //that they were the recipient of. AssignmentTeam ateam = OSBLEController.GetAssignmentTeam(assignment, Student); int teamId = 0; if (ateam != null) { teamId = ateam.TeamID; header.Submission.authorTeamID = teamId; using (OSBLEContext db = new OSBLEContext()) { //Only want to look at evaluations where Evaluator.AbstractRole.CanGrade is true, otherwise //the rubric evaluation is a student rubric (not interested in them here) rubricEvaluation = (from re in db.RubricEvaluations where re.AssignmentID == assignment.ID && re.Evaluator.AbstractRole.CanGrade && re.RecipientID == teamId select re).FirstOrDefault(); //if annotatable if (assignment.IsAnnotatable) { //yc: determine if there has been an annotation for this document //there will be an issue with linking from a critical review untill further discussion on how to handle this //when an instructor grades this, the reviewerid of the annoation is the teamid string lookup = assignment.CourseID.ToString() + "-" + assignment.ID.ToString() + "-" + teamId.ToString() + "-"; AnnotateDocumentReference d = (from adr in db.AnnotateDocumentReferences where adr.OsbleDocumentCode.Contains(lookup) select adr).FirstOrDefault(); if (d != null && assignment.DueDate < DateTime.UtcNow) { header.IsAnnotatable = true; } else { header.IsAnnotatable = false; } } else { header.IsAnnotatable = false; } } } //If the Rubric has been evaluated and is published, calculate the rubric grade % to display to the student if (rubricEvaluation != null && rubricEvaluation.IsPublished) { header.IsPublished = true; } else { header.IsPublished = false; } return(header); }
// this creates the assignment teams for the cloned assignment private void SetUpClonedAssignmentTeams(Assignment oldAssignment, Assignment newAssignment) { List <CourseUser> users = (from cu in db.CourseUsers where cu.AbstractCourseID == ActiveCourseUser.AbstractCourseID && cu.AbstractRole.CanSubmit orderby cu.UserProfile.LastName, cu.UserProfile.FirstName select cu).ToList(); bool teams = false; int students = users.Count; int numberOfTeams = oldAssignment.AssignmentTeams.Count; //get actual number of users from the old assignment int oldAmountOfUsers = 0; List <AssignmentTeam> teamsFromPreviousAssignment = oldAssignment.AssignmentTeams.ToList(); foreach (AssignmentTeam at in teamsFromPreviousAssignment) { oldAmountOfUsers += at.Team.TeamMembers.Count; } // base the logic off of the previous assignment if ((int)Math.Round((decimal)oldAmountOfUsers / numberOfTeams) != 1) { teams = true; } //No teams, students each get their own team if (!teams) { //Creates an assignment team for each CourseUser who can submit documents (students) //The team name will be "FirstName LastName" foreach (CourseUser cu in users) { //Creating team Team team = new Team(); team.Name = cu.UserProfile.FirstName + " " + cu.UserProfile.LastName; //Creating Tm and adding them to team TeamMember tm = new TeamMember() { CourseUserID = cu.ID }; team.TeamMembers.Add(tm); //Creating the assignment team and adding it to the assignment AssignmentTeam at = new AssignmentTeam() { Team = team, Assignment = newAssignment }; newAssignment.AssignmentTeams.Add(at); } } // use the same number of teams from the previous assignment else { int i = 0; const string teamName = "Team "; int teamNameNumber = 1; while (students > 0) { // get the maximum amount of students per team on each iteration int maxStudentsPerTeam = (int)Math.Ceiling((decimal)students / numberOfTeams); Team team = new Team(); team.Name = teamName + teamNameNumber; while (maxStudentsPerTeam > 0) { TeamMember tm = new TeamMember() { CourseUserID = users[i].ID }; team.TeamMembers.Add(tm); i++; students--; maxStudentsPerTeam--; } AssignmentTeam at = new AssignmentTeam() { Team = team, Assignment = newAssignment }; newAssignment.AssignmentTeams.Add(at); numberOfTeams--; teamNameNumber++; } } }
/// <summary> /// Returns a list of all the course users in the team /// </summary> public static List <CourseUser> GetAllCourseUsers(AssignmentTeam team) { return(team.Team.TeamMembers.Select(tm => tm.CourseUser).ToList()); }
public static bool CreateZipFolder(Course course, ZipFile zipFile, Assignment assignment, AssignmentTeam team = null) { RemoveOldZipFiles(course); string path = getZipFolderLocation(course); string zipFileName = GeneratedUnusedFileName(path, ".zip"); zipFile.Save(zipFileName); AddEntryToZipRecords(course, zipFileName, getRealFileZipName(assignment, team), DateTime.UtcNow); return(true); }
/// <summary> /// Loads a PDF for critical review /// </summary> /// <param name="assignmentID"></param> /// <param name="authorTeamID"></param> /// <returns></returns> public ActionResult ReviewGradedDocument(int assignmentID, int authorTeamID, int anonReview = 0) { WebClient client = new WebClient(); Assignment CRassignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(CRassignment, ActiveCourseUser); bool canAccessReview = false; //Determine whether or not the current user can access the document //is the author of the docment? TeamMember tm = at.Team.TeamMembers.Where(tms => tms.CourseUserID == ActiveCourseUser.ID).FirstOrDefault(); if (tm != null) { canAccessReview = true; } if (canAccessReview) { //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (true) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)assignmentID, authorTeamID); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = CRassignment.CriticalReviewSettings; if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Instructor) { settings.AnonymizeComments = false; } if (settings == null) { settings = new CriticalReviewSettings(); settings.Assignment = CRassignment; } if (anonReview == 1) { settings.AnonymizeComments = true; } api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } } return(View("Review")); }
public override DynamicDictionary BuildHeader(Assignment assignment) { //TODO: remove un-needed code dynamic header = Builder.BuildHeader(assignment); header.CRSubmission = new DynamicDictionary(); header.Assignment = assignment; // get the assignment team ( team doing the review ) AssignmentTeam assignmentTeam = null; foreach (AssignmentTeam at in assignment.AssignmentTeams) { foreach (TeamMember tm in at.Team.TeamMembers) { if (tm.CourseUser.UserProfileID == Student.UserProfileID) { assignmentTeam = at; } } } header.CRSubmission.hasSubmitted = false; if (assignmentTeam != null) { List <ReviewTeam> authorTeams = new List <ReviewTeam>(); authorTeams = (from rt in assignment.ReviewTeams where rt.ReviewTeamID == assignmentTeam.TeamID select rt).ToList(); header.CRSubmission.authorTeams = authorTeams; header.CRSubmission.assignmentId = assignment.ID; List <DateTime?> submissionTimes = new List <DateTime?>(); // get submission times for critical review submission //List<DateTime?> authorSubmissionTimes = new List<DateTime?>(); //foreach(ReviewTeam reviewTeam in authorTeams) //{ // submissionTimes.Add(FileSystem.GetSubmissionTime(assignmentTeam, reviewTeam.AuthorTeam)); // AssignmentTeam assignTeam = (from at in assignment.PreceedingAssignment.AssignmentTeams // where at.TeamID == reviewTeam.AuthorTeamID // select at).FirstOrDefault(); // authorSubmissionTimes.Add(assignTeam.GetSubmissionTime()); //} // get submission times for original assignment submission (in order to check if they have submitted) // need to loop over each AssignmentTeam from the original assignment to get submission time //pass submission times to view header.CRSubmission.submissionTimes = submissionTimes; //header.CRSubmission.authorSubmissionTimes = authorSubmissionTimes; if (assignment.HasTeams) { header.CRSubmission.hasTeams = true; } else { header.CRSubmission.hasTeams = false; } } FileCache Cache = FileCacheHelper.GetCacheInstance(OsbleAuthentication.CurrentUser); //Same functionality as in the other controller. Note: These values are set in SubmissionController/Create[POST] //did the user just submit something? If so, set up view to notify user if (Cache["SubmissionReceived"] != null && Convert.ToBoolean(Cache["SubmissionReceived"]) == true) { header.CRSubmission.SubmissionReceived = true; header.CRSubmission.AuthorTeamId = (int)Cache["SubmissionForAuthorTeamID"]; Cache["SubmissionReceived"] = false; } else { header.CRSubmission.SubmissionReceived = false; Cache["SubmissionReceived"] = false; } //rubric stuff: header.CRSubmission.hasStudentRubric = assignment.HasStudentRubric; header.CRSubmission.studentRubricID = assignment.StudentRubricID; return(header); }
/// <summary> /// Loads a PDF for critical review /// </summary> /// <param name="assignmentID"></param> /// <param name="authorTeamID"></param> /// <returns></returns> public ActionResult Review(int assignmentID, int authorTeamID) { WebClient client = new WebClient(); Assignment CRassignment = db.Assignments.Find(assignmentID); AssignmentTeam at = GetAssignmentTeam(CRassignment, ActiveCourseUser); ReviewTeam reviewTeam = null; if (at != null) { reviewTeam = (from rt in CRassignment.ReviewTeams where rt.ReviewTeamID == at.TeamID && rt.AuthorTeamID == authorTeamID select rt).FirstOrDefault(); } bool canAccessReview = false; //Determine whether or not the current user can access the document if (CRassignment.Type == AssignmentTypes.CriticalReview) { //is the user a reviewer? if (reviewTeam != null) { canAccessReview = true; } //or, is the user an instructor? else if (ActiveCourseUser.AbstractRole.CanGrade) { canAccessReview = true; } //or, has the review been published and the current user is the author of the docment? else if (CRassignment.IsCriticalReviewPublished == true) { reviewTeam = (from rt in CRassignment.ReviewTeams where rt.AuthorTeamID == authorTeamID select rt ).FirstOrDefault(); if (reviewTeam != null) { TeamMember tm = reviewTeam.AuthorTeam.TeamMembers.Where(t => t.CourseUserID == ActiveCourseUser.ID).FirstOrDefault(); if (tm != null) { canAccessReview = true; } } } } if (canAccessReview) { //Send off to Annotate if we have exactly one deliverable and that deliverable is a PDF document if (CRassignment.PreceedingAssignment.Deliverables.Count == 1 && CRassignment.PreceedingAssignment.Deliverables[0].DeliverableType == DeliverableType.PDF) { AnnotateApi api = new AnnotateApi(ConfigurationManager.AppSettings["AnnotateUserName"], ConfigurationManager.AppSettings["AnnotateApiKey"]); AnnotateResult uploadResult = api.UploadDocument((int)CRassignment.PrecededingAssignmentID, authorTeamID); if (uploadResult.Result == ResultCode.OK) { AnnotateResult createResult = api.CreateAccount(CurrentUser); if (createResult.Result == ResultCode.OK) { //instructors get to see everyone, regardless of CR settings CriticalReviewSettings settings = CRassignment.CriticalReviewSettings; if (ActiveCourseUser.AbstractRoleID == (int)CourseRole.CourseRoles.Instructor) { settings.AnonymizeComments = false; } api.SetDocumentAnonymity(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate, settings); api.GiveAccessToDocument(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //log the user in to annotate string loginString = api.GetAnnotateLoginUrl(CurrentUser, uploadResult.DocumentCode, uploadResult.DocumentDate); //load the annotate url for the view ViewBag.AnnotateUrl = loginString; } } } else { return(RedirectToRoute(new { controller = "Home", action = "Index", area = "" })); } } return(View()); }
public static List <UserProfile> GetAllUsers(AssignmentTeam team) { //Searching through the Assignment teams and adding all the Users return(team.Team.TeamMembers.Select(tm => tm.CourseUser.UserProfile).ToList()); }