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 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); }