/// <summary> /// Save weekly feedback and corresponding survey response /// </summary> /// <param name="response">instance of response</param> /// <returns>success flag </returns> public bool SaveWeeklySurveyResponseForTrainee(SurveyResponse response) { // Weekly feedback must have team associated with it. if (!response.AddedBy.TeamId.HasValue) { return(false); } try { Survey survey = SurveyDataAccesor.GetWeeklySurveySetForTeam(response.AddedBy.TeamId.Value); Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1, (int)Common.Enumeration.FeedbackType.Weekly) .FirstOrDefault(); response.CodeReviewForTheWeek = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1000, (int)Common.Enumeration.FeedbackType.CodeReview) .Where(x => x.AddedOn.Date >= response.Feedback.StartDate && (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn)) .ToList(); response.Feedback.FeedbackText = GenerateHtmlforFeedback(response, survey); response.Feedback.FeedbackId = SurveyDataAccesor.SaveWeeklySurveyResponseForTrainee(response, survey); return(response.Feedback.FeedbackId > 0 && new NotificationBl().AddFeedbackNotification(response.Feedback)); } catch (Exception ex) { LogUtility.ErrorRoutine(ex); return(false); } }
/// <summary> /// fetches the user feedback based on filters /// </summary> /// <param name="traineeId">trainee's id</param> /// <param name="startDate">start date</param> /// <param name="endDate">end date</param> /// <param name="arrayFeedbackType">array of feedback type</param> /// <param name="trainerId">trainer id</param> /// <returns>returns instances of Feedback Plots</returns> public FeedbackPlot GetUserFeedbackOnFilterForPlot(int traineeId, DateTime?startDate, DateTime?endDate, string arrayFeedbackType, int trainerId) { FeedbackPlot objfeedbackPlot = new FeedbackPlot { AssignmentFeedbacks = new List <Feedback>(), CodeReviewFeedbacks = new List <Feedback>(), WeeklyFeedbacks = new List <Feedback>() }; if (string.IsNullOrEmpty(arrayFeedbackType)) { return(objfeedbackPlot); } int[] feedbackTypes = Array.ConvertAll(arrayFeedbackType.Split(','), int.Parse); foreach (var type in feedbackTypes) { switch (type) { case 3: objfeedbackPlot.AssignmentFeedbacks = FeedbackDataAccesor.GetUserFeedback(traineeId, 1000, type) .Where(x => (trainerId == 0 || x.AddedBy.UserId == trainerId) && (!startDate.HasValue || x.AddedOn > startDate.Value.AddDays(-1)) && (!endDate.HasValue || x.AddedOn < endDate.Value.AddDays(1)) ) .ToList(); break; case 4: // var testtt = FeedbackDataAccesor.GetUserFeedback(traineeId, 1000, type); objfeedbackPlot.CodeReviewFeedbacks = FeedbackDataAccesor.GetUserFeedback(traineeId, 1000, type) .Where(x => (trainerId == 0 || x.AddedBy.UserId == trainerId) && (!startDate.HasValue || x.AddedOn > startDate.Value.AddDays(-1)) && (!endDate.HasValue || x.AddedOn < endDate.Value.AddDays(1)) ) .ToList(); break; case 5: objfeedbackPlot.WeeklyFeedbacks = FeedbackDataAccesor.GetUserFeedback(traineeId, 1000, type) .Where(x => (trainerId == 0 || x.AddedBy.UserId == trainerId) && ((!startDate.HasValue || x.StartDate > startDate.Value.AddDays(-1)) && (!endDate.HasValue || x.EndDate < endDate.Value.AddDays(1))) ) .ToList(); break; } } return(objfeedbackPlot); }
/// <summary> /// Fetches all feedback Threads /// </summary> /// <param name="feedbackId">feedbackId</param> /// <param name="currentUser">current user</param> public List <Threads> GetFeedbackThreads(int feedbackId, User currentUser) { int feedbackForUserId = FeedbackDataAccesor.GetTraineebyFeedbackId(feedbackId); if (!(currentUser.IsAdministrator || currentUser.IsManager || currentUser.IsTrainer || currentUser.UserId == feedbackForUserId)) { return(null); } return(FeedbackDataAccesor.GetFeedbackThreads(feedbackId)); }
/// <summary> /// Add New feedback for user /// </summary> /// <param name="feedback">instance of feedback object</param> /// <returns>success flag wether feedback was added or not</returns> public bool AddFeedback(Feedback feedback) { feedback.Project = feedback.Project ?? new Project(); if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Skill) { if (!string.IsNullOrEmpty(feedback.Title)) { Skill newSkill = new Skill { Name = feedback.Title, AddedBy = feedback.AddedBy.UserId, AddedOn = DateTime.Now }; newSkill.SkillId = SkillDataAccesor.AddNewSkillForId(newSkill); //Since new skill update the skill data feedback.Skill.SkillId = newSkill.SkillId; feedback.Skill.Name = feedback.Title; } feedback.Title = feedback.Skill.Name; feedback.Skill = new Skill { SkillId = feedback.Skill.SkillId }; } else { feedback.Skill = new Skill(); } // no way comment can have feedback rating if (feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Comment || feedback.FeedbackType.FeedbackTypeId == (int)FeedbackType.Course) { feedback.Rating = 0; } feedback.Title = string.IsNullOrEmpty(feedback.Title) ? feedback.FeedbackType.Description : feedback.Title; int feedbackId = FeedbackDataAccesor.AddFeedback(feedback); if (!(feedbackId > 0)) { return(false); } feedback.FeedbackId = feedbackId; return(new NotificationBl().AddFeedbackNotification(feedback)); }
/// <summary> /// Bussiness method to Fecth weekly survey Questions for team /// </summary> /// <param name="traineeId">trainee id</param> /// <param name="startDate">feedback start Date</param> /// <param name="endDate">feedback end date</param> /// <param name="teamId">team id</param> /// <returns>Instance of survey id</returns> public SurveyVm FetchWeeklySurveyQuestionForTeam(int traineeId, DateTime startDate, DateTime endDate, int teamId) { Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(traineeId, 1, (int)Common.Enumeration.FeedbackType.Weekly) .FirstOrDefault(); return(new SurveyVm() { Survey = SurveyDataAccesor.GetWeeklySurveySetForTeam(teamId), IsCodeReviewedForTrainee = FeedbackDataAccesor.GetUserFeedback(traineeId, 1000, (int)Common.Enumeration.FeedbackType.CodeReview).Any(x => x.AddedOn.Date >= startDate.Date && (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn)) }); }
/// <summary> /// Fetches user Feedback based on filter /// </summary> /// <param name="userId">user id</param> /// <param name="pageSize">no of record count</param> /// <param name="feedbackId">feedback type id</param> /// <param name="startAddedOn">start date </param> /// <param name="endAddedOn">end date</param> /// <returns></returns> public List <Feedback> GetUserFeedbackOnFilter(int userId, int pageSize, int feedbackId, DateTime?startAddedOn = null, DateTime?endAddedOn = null) { // truncate any time part from the filter, if only if the variables have any value if (startAddedOn.HasValue) { startAddedOn = startAddedOn.Value.Date; } if (endAddedOn.HasValue) { endAddedOn = endAddedOn.Value.Date; } return(FeedbackDataAccesor.GetUserFeedback(userId, pageSize, feedbackId, startAddedOn, endAddedOn)); }
/// <summary> /// Fetch Weekly feedback preview generated by survey /// </summary> /// <param name="response">instance of response</param> /// <returns>generated Html</returns> public string FetchWeeklyFeedbackPreview(SurveyResponse response) { // Weekly feedback must have team associated with it. if (!response.AddedBy.TeamId.HasValue) { return(string.Empty); } Survey survey = SurveyDataAccesor.GetWeeklySurveySetForTeam(response.AddedBy.TeamId.Value); Feedback lastWeeklyFeedback = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1, (int)Common.Enumeration.FeedbackType.Weekly) .FirstOrDefault(); response.CodeReviewForTheWeek = FeedbackDataAccesor.GetUserFeedback(response.AddedFor.UserId, 1000, (int)Common.Enumeration.FeedbackType.CodeReview) .Where(x => x.AddedOn.Date >= response.Feedback.StartDate && (lastWeeklyFeedback == null || x.AddedOn >= lastWeeklyFeedback.AddedOn)) .ToList(); return(GenerateHtmlforFeedback(response, survey)); }
/// <summary> /// Get view model for user profile page /// </summary> /// <param name="userId">user id</param> /// <param name="loggedInUser"></param> /// <returns>instance of User vm</returns> public UserProfileVm GetUserProfileVm(int userId, User loggedInUser) { User requestedUser = userId == loggedInUser.UserId ? loggedInUser : UserDataAccesor.GetUserById(userId); CodeReview codeReview = loggedInUser.IsTrainer || loggedInUser.IsManager ? CodeReviewConverter.ConvertFromCore(UnitOfWork.CodeReviewRepository.GetSavedCodeReviewForTrainee(userId, loggedInUser.UserId)) : null; var commonTags = UnitOfWork.CodeReviewRepository .GetCommonlyUsedTags(userId, 5) .Select(skill => new CodeReviewTag { CodeReviewTagId = 0, Skill = new Skill { Name = skill.Name, SkillId = skill.SkillId } }).ToList(); if (codeReview != null) { codeReview.CodeReviewPreviewHtml = UtilityFunctions.GenerateCodeReviewPreview(codeReview, true); codeReview.SystemRating = new FeedbackBl().CalculateCodeReviewRating(codeReview); } return(new UserProfileVm { User = userId == loggedInUser.UserId ? null : requestedUser, Skills = requestedUser.IsTrainee ? SkillDataAccesor.GetSkillsByUserId(userId) : null, TraineeSynopsis = requestedUser.IsTrainee ? FeedbackDataAccesor.GetTraineeFeedbackSynopsis(requestedUser.UserId) : null, Sessions = requestedUser.IsTrainee ? SessionConverter.ConvertListFromCore(UnitOfWork.SessionRepository.GetAllSessionForAttendee(userId)) : null, Projects = null, Feedbacks = requestedUser.IsTrainee ? FeedbackDataAccesor.GetUserFeedback(userId, 5) : FeedbackDataAccesor.GetFeedbackAddedByUser(userId), TrainorSynopsis = requestedUser.IsTrainer || requestedUser.IsManager ? FeedbackDataAccesor.GetTrainorFeedbackSynopsis(requestedUser.UserId) : null, AllAssignedCourses = requestedUser.IsTrainee ? LearningPathDataAccessor.GetAllCoursesForTrainee(requestedUser.UserId).OrderByDescending(x => x.PercentageCompleted).ToList() : new List <CourseTrackerDetails>(), SavedCodeReview = codeReview, CommonTags = commonTags // SavedCodeReviewData = logedInUser.IsTrainer && (codeReview != null && codeReview.Id > 0) ? UtilityFunctions.GenerateCodeReviewPreview(codeReview, true) : string.Empty }); }
/// <summary> /// Add Notification for Thread /// </summary> /// <param name="thread"></param> internal bool AddNewThreadNotification(Threads thread) { int userId = FeedbackDataAccesor.GetTraineebyFeedbackId(thread.FeedbackId); if (userId == 0) { return(false); } var notification = new Notification { Description = "New Note Added To Feedback", Link = string.Format(FeedbackLink, userId, thread.FeedbackId), TypeOfNotification = NotificationType.NewNoteToFeedback, AddedBy = thread.AddedBy.UserId, Title = "New Note Added to Feedback", AddedOn = DateTime.Now, }; new MailerBl().AddNewFeedbackThreadMail(notification, thread.FeedbackId); return(AddNotification(notification, UserDataAccesor.GetUserId(notification, userId))); }
public bool SubmitCodeReviewFeedback(CodeReview codeReview) { CodeReviewMetaData codeReviewMetaData = UnitOfWork.CodeReviewRepository.GetCodeReviewWithAllData(codeReview.Id); CodeReview codeReviewDetailsFromCore = CodeReviewConverter.ConvertFromCore(codeReviewMetaData); Feedback feedback = new Feedback { AddedBy = new User { UserId = codeReview.AddedBy.UserId }, AddedFor = new User { UserId = codeReview.AddedFor.UserId }, FeedbackType = new Common.Entity.FeedbackType { FeedbackTypeId = (int)FeedbackType.CodeReview }, FeedbackText = UtilityFunctions.GenerateCodeReviewPreview(codeReviewDetailsFromCore, true), Skill = new Skill(), Project = new Project(), Title = codeReviewDetailsFromCore.Title, Rating = codeReview.Rating }; int feedbackId = FeedbackDataAccesor.AddFeedback(feedback); if (!(feedbackId > 0)) { return(false); } codeReviewMetaData.FeedbackId = feedback.FeedbackId = feedbackId; codeReviewMetaData.SystemRating = CalculateCodeReviewRating(codeReviewDetailsFromCore); UnitOfWork.Commit(); return(new NotificationBl().AddFeedbackNotification(feedback)); // return AddFeedback(feedback); }
public bool AddFeedback(Feedback feedback) { feedback.Project = feedback.Project ?? new Project(); //feedback.Skill = (feedback.Skill == null) ? new Skill() : feedback.Skill; feedback.Title = string.IsNullOrEmpty(feedback.Title) ? feedback.FeedbackType.Description : feedback.Title; if (feedback.FeedbackType.FeedbackTypeId == 2) { feedback.Title = feedback.Skill.Name; feedback.Skill = new Skill { SkillId = feedback.Skill.SkillId }; } else { feedback.Skill = new Skill(); } return(FeedbackDataAccesor.AddFeedback(feedback)); }
public UserProfileVm GetUserProfileVm(int userId) { return(new UserProfileVm { User = UserDataAccesor.GetUserById(userId), Skills = SkillDataAccesor.GetSkillsByUserId(userId), AllSkills = SkillDataAccesor.GetAllSkillsForApp(), Sessions = SessionDataAccesor.GetSessionsByUserId(userId), Projects = ProjectDataAccesor.GetProjectsByUserId(userId), Feedbacks = FeedbackDataAccesor.GetUserFeedback(userId, 5), RecentCrFeedback = FeedbackDataAccesor.GetUserFeedback(userId, 100, 4), FeedbackTypes = new List <FeedbackType> { new FeedbackType { FeedbackTypeId = 1, Description = "Comment" }, new FeedbackType { FeedbackTypeId = 2, Description = "Skill" }, new FeedbackType { FeedbackTypeId = 3, Description = "Assignment" }, new FeedbackType { FeedbackTypeId = 4, Description = "Code Review" }, new FeedbackType { FeedbackTypeId = 5, Description = "Weekly Feedback" } } }); }
/// <summary> /// authorize Current user for team's Feedback /// </summary> /// <param name="feedbackId">feedback Id</param> /// <param name="currentUser">Current User</param> /// <returns>Success flag</returns> public bool AuthorizeCurrentUserForFeedback(int feedbackId, User currentUser) { return((currentUser.IsAdministrator && !currentUser.TeamId.HasValue) || FeedbackDataAccesor.GetFeedbackWithThreads(feedbackId).AddedBy.UserId == Constants.AppBotUserId || FeedbackDataAccesor.GetFeedbackWithThreads(feedbackId).AddedBy.TeamId == currentUser.TeamId); }
/// <summary> /// Add New Thread to Feedback /// </summary> /// <param name="thread"></param> /// <returns></returns> public bool AddNewThread(Threads thread) { return(FeedbackDataAccesor.AddNewThread(thread) && new NotificationBl().AddNewThreadNotification(thread)); }
public bool UpdateAssignmentProgress(Assignment data, User currentUser, out int feedbackId) { feedbackId = 0; bool isAssignmentFeedback = false; if (data != null && data.TraineeId > 0) { // return false if trainee will not allowed to approve the completion of assignment or trainer cannot mark assignment as completed or trainer cannot approve/reassign assignment without feedback. if ((currentUser.IsTrainee && data.TraineeId != currentUser.UserId && data.IsApproved) || (!currentUser.IsTrainee && data.IsCompleted && !data.IsApproved) || (!currentUser.IsTrainee && data.Feedback.Count < 1)) { return(false); } if (!currentUser.IsTrainee) { var feedback = data.Feedback.FirstOrDefault(x => x.FeedbackId == 0); feedback.AddedBy = currentUser; feedback.AddedFor = new UserBl().GetUserByUserId(data.TraineeId); feedback.AddedOn = DateTime.Now; if (feedback.FeedbackType.FeedbackTypeId == (int)Common.Enumeration.FeedbackType.Comment) { feedback.Rating = 0; } feedback.Skill = new Skill(); feedback.Project = new Project(); feedbackId = FeedbackDataAccesor.AddFeedback(feedback); if (feedbackId == 0 || !FeedbackDataAccesor.AddFeedbackAssignmentMapping(feedbackId, data.Id)) { return(false); } feedback.FeedbackId = feedbackId; new NotificationBl().AddFeedbackNotification(feedback); data.ApprovedBy = currentUser.UserId; if (feedback.FeedbackType.FeedbackTypeId == (int)Common.Enumeration.FeedbackType.Assignment) { isAssignmentFeedback = true; } } var status = LearningPathDataAccessor.UpdateAssignmentProgress(data); if (!status || !isAssignmentFeedback || currentUser.IsTrainee) { return(status); } CourseTrackerDetails courseDetails = LearningPathDataAccessor.GetCourseDetailBasedOnParameters(data.TraineeId, data.Id); if (courseDetails != null && courseDetails.PercentageCompleted.CompareTo(100) == 0) { return(LearningPathDataAccessor.CompleteCourseForTrainee(courseDetails.Id, data.TraineeId) && new FeedbackBl().GenerateCourseFeedback(courseDetails.Id, data.TraineeId)); } return(true); } return(false); }
/// <summary> /// Fetches user Feedback based on filter /// </summary> /// <param name="userId"></param> /// <param name="pageSize"></param> /// <param name="feedbackId"></param> /// <returns></returns> public List <Feedback> GetUserFeedbackOnFilter(int userId, int pageSize, int feedbackId) { return(FeedbackDataAccesor.GetUserFeedback(userId, pageSize, feedbackId)); }