public WizardComponentManagerBase(UserProfile profile) { ManagerCache = FileCacheHelper.GetCacheInstance(profile); ManagerCache.DefaultRegion = Path.Combine(ManagerCache.DefaultRegion, CacheRegion); AllComponents = new List <IWizardBaseController>(); SelectedComponents = new ObservableCollection <IWizardBaseController>(); UnselectedComponents = new ObservableCollection <IWizardBaseController>(); RegisterComponents(); if (ManagerCache[selectedComponentsKey] != null) { SelectedComponents = new ObservableCollection <IWizardBaseController>(ComponentsFromString(ManagerCache[selectedComponentsKey].ToString(), "|")); } if (ManagerCache[unselectedComponentsKey] != null) { UnselectedComponents = new ObservableCollection <IWizardBaseController>(ComponentsFromString(ManagerCache[unselectedComponentsKey].ToString(), "|")); } }
private void Initialize() { // If logged in, feed user profile to view. if (Convert.ToBoolean(ConfigurationManager.AppSettings["RequireLoginValidation"]) == true) { if (OsbleAuthentication.CurrentUser != null && OsbleAuthentication.CurrentUser.IsApproved) { Cache = FileCacheHelper.GetCacheInstance(OsbleAuthentication.CurrentUser); SetupMenu(); SetCurrentUserProfile(); GetEnrolledCourses(); SetCourseListTitle(); SetDashboardDisplayMode(); } } }
/// <summary> /// Registers all components with the component manager /// </summary> private void RegisterComponents() { //use reflection to find all available components string componentNamespace = WizardComponentNamespace; List <Type> componentObjects = (from type in Assembly.GetExecutingAssembly().GetTypes() where type.GetInterfaces().Contains(typeof(IWizardBaseController)) && !type.IsAbstract && type.Namespace.CompareTo(componentNamespace) == 0 select type).ToList(); foreach (Type component in componentObjects) { IWizardBaseController controller = Activator.CreateInstance(component) as IWizardBaseController; AllComponents.Add(controller); } //pull from the cache if possible FileCache cache = FileCacheHelper.GetGlobalCacheInstance(); bool loadedFromCache = false; string[] sorted = (string[])cache.Get(componentsCacheString, CacheRegion); if (sorted != null) { //set loaded to true for now loadedFromCache = true; //make sure that the sizes match up if (sorted.Length != AllComponents.Count) { loadedFromCache = false; } //make sure all components are represented in the cache foreach (IWizardBaseController component in AllComponents) { if (!sorted.Contains(component.ControllerName)) { loadedFromCache = false; break; } } //if we're still clear to load from the cache, then do so if (loadedFromCache) { IWizardBaseController[] tempComponentList = new IWizardBaseController[sorted.Length]; for (int i = 0; i < sorted.Length; i++) { IWizardBaseController component = AllComponents.Find(c => c.ControllerName == sorted[i]); if (component != null) { tempComponentList[i] = component; } } //reassign the sorted list AllComponents = tempComponentList.ToList(); } } //if caching failed, do it the long way if (!loadedFromCache) { List <IWizardBaseController> components = SortComponents(AllComponents); AllComponents = components; //save sorted component information to cache string[] sortedComponents = new string[AllComponents.Count]; for (int i = 0; i < sortedComponents.Length; i++) { sortedComponents[i] = AllComponents[i].ControllerName; } cache.Add(componentsCacheString, sortedComponents, cache.DefaultPolicy, CacheRegion); } //attach event listeners to selection change //and apply a sort order for faster sorting in the future int counter = 1; foreach (IWizardBaseController component in AllComponents) { component.SortOrder = counter; component.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ComponentPropertyChanged); counter++; } }
public void UpdateCacheInstance(UserProfile user) { Cache = FileCacheHelper.GetCacheInstance(user); }
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); }
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); }
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); }