public RiskScore GetRiskScore(long id) { Assessment entity = AssessmentService.Get(id); CheckAccess(entity); return(AssessmentService.GetRiskScore(entity)); }
public Assessment Get(long id) { Assessment entity = AssessmentService.Get(id); CheckAccess(entity); return(entity); }
public OverallRiskRatingReport GetOverallRiskRatingReport(long assessmentId) { Assessment entity = AssessmentService.Get(assessmentId); CheckAccess(entity); return(AssessmentService.GetOverallRiskRatingReport(entity)); }
public HttpResponseMessage ExportAssessment(long id, ExportFormat format) { Assessment entity = AssessmentService.Get(id); CheckAccess(entity); return(ExportAssessment(entity, format)); }
/// <summary> /// Handles the Click event of the btnNext control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnNext_Click(object sender, EventArgs e) { int pageNumber = hfPageNo.ValueAsInt() + 1; GetResponse(); LinkButton btn = ( LinkButton )sender; string commandArgument = btn.CommandArgument; var totalQuestion = pageNumber * QuestionCount; if ((_assessmentResponses.Count > totalQuestion && !_assessmentResponses.All(a => a.Response.HasValue)) || "Next".Equals(commandArgument)) { BindRepeater(pageNumber); } else { SpiritualGiftsService.AssessmentResults result = SpiritualGiftsService.GetResult(_assessmentResponses.ToDictionary(a => a.Code, b => b.Response.Value)); SpiritualGiftsService.SaveAssessmentResults(_targetPerson, result); var resultData = _assessmentResponses.ToDictionary(a => a.Code, b => b.Response.Value); var rockContext = new RockContext(); var assessmentService = new AssessmentService(rockContext); Assessment assessment = null; if (hfAssessmentId.ValueAsInt() != 0) { assessment = assessmentService.Get(int.Parse(hfAssessmentId.Value)); } if (assessment == null) { var assessmentType = new AssessmentTypeService(rockContext).Get(Rock.SystemGuid.AssessmentType.GIFTS.AsGuid()); assessment = new Assessment() { AssessmentTypeId = assessmentType.Id, PersonAliasId = _targetPerson.PrimaryAliasId.Value }; assessmentService.Add(assessment); } assessment.Status = AssessmentRequestStatus.Complete; assessment.CompletedDateTime = RockDateTime.Now; assessment.AssessmentResultData = new { Result = resultData, TimeToTake = RockDateTime.Now.Subtract(StartDateTime).TotalSeconds }.ToJson(); rockContext.SaveChanges(); ShowResult(result, assessment); } }
public void Reject(long assessmentId, [FromBody] string rejectionReason) { WithTransaction(() => { Assessment entity = AssessmentService.Get(assessmentId); if (entity.ApprovalStatus == ApprovalStatus.AwaitingBUFunctionalApproval) { CheckCanReject(entity, Role.BUFunctionalApprover); entity.RejectPhase = RejectPhase.BUFunctionalApproval; entity.ApprovalStatus = ApprovalStatus.Rejected; } else if (entity.ApprovalStatus == ApprovalStatus.AwaitingBURiskManagementApproval) { CheckCanReject(entity, Role.BURiskManagementApprover); entity.RejectPhase = RejectPhase.BURiskManagementApproval; entity.ApprovalStatus = ApprovalStatus.AwaitingBUFunctionalApproval; } else if (entity.ApprovalStatus == ApprovalStatus.AwaitingDivisionalRiskManagementApproval) { CheckCanReject(entity, Role.DivisionalRiskManagementApprover); entity.RejectPhase = RejectPhase.DivisionalRiskManagementApproval; entity.ApprovalStatus = ApprovalStatus.AwaitingBURiskManagementApproval; } else { throw new ServiceException("Cannot reject the assessment in current status."); } entity.Rejecter = CurrentUser; entity.RejectTime = DateTime.Now; entity.RejectionReason = rejectionReason; // retrieve entity state before updating Assessment oldEntity = AssessmentService.Get(assessmentId); // populate audit fields PopulateAuditFields(entity, entity); // update and audit Assessment newEntity = AssessmentService.Update(entity); Helper.Audit(AuditService, oldEntity, newEntity, CommonHelper.GetFullActionName(ActionContext, includeController: false), CurrentUser.Username, _propertiesToSkipAuditing); }); }
public void Approve(long assessmentId) { WithTransaction(() => { var entity = AssessmentService.Get(assessmentId); if (entity.ApprovalStatus == ApprovalStatus.AwaitingBUFunctionalApproval) { CheckCanApprove(entity, Role.BUFunctionalApprover); entity.ApprovalStatus = ApprovalStatus.AwaitingBURiskManagementApproval; entity.BUFunctionalApprover = CurrentUser; entity.BUFunctionalApproveTime = DateTime.Now; } else if (entity.ApprovalStatus == ApprovalStatus.AwaitingBURiskManagementApproval) { CheckCanApprove(entity, Role.BURiskManagementApprover); entity.ApprovalStatus = ApprovalStatus.AwaitingDivisionalRiskManagementApproval; entity.BURiskManagementApprover = CurrentUser; entity.BURiskManagementApproveTime = DateTime.Now; } else if (entity.ApprovalStatus == ApprovalStatus.AwaitingDivisionalRiskManagementApproval) { CheckCanApprove(entity, Role.DivisionalRiskManagementApprover); entity.ApprovalStatus = ApprovalStatus.Approved; entity.DivisionalRiskManagementApprover = CurrentUser; entity.DivisionalRiskManagementApproveTime = DateTime.Now; } else { throw new AuthorizationException("Cannot approve the assessment in current status."); } // retrieve entity state before updating Assessment oldEntity = AssessmentService.Get(assessmentId); // populate audit fields PopulateAuditFields(entity); // update and audit Assessment newEntity = AssessmentService.Update(entity); Helper.Audit(AuditService, oldEntity, newEntity, CommonHelper.GetFullActionName(ActionContext, includeController: false), CurrentUser.Username, _propertiesToSkipAuditing); }); }
public Assessment Update(long id, Assessment entity) { return(WithTransaction(() => { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Assessment existing = AssessmentService.Get(id); CheckCanModify(existing); entity.Title = CreateAssessmentTitle(existing, entity); // populate audit fields PopulateAuditFields(entity, existing); // following fields should not be changed entity.Submitter = existing.Submitter; entity.ApprovalStatus = existing.ApprovalStatus; entity.BUFunctionalApprover = existing.BUFunctionalApprover; entity.BUFunctionalApproveTime = existing.BUFunctionalApproveTime; entity.BURiskManagementApprover = existing.BURiskManagementApprover; entity.BURiskManagementApproveTime = existing.BURiskManagementApproveTime; entity.DivisionalRiskManagementApprover = existing.DivisionalRiskManagementApprover; entity.DivisionalRiskManagementApproveTime = existing.DivisionalRiskManagementApproveTime; entity.Rejecter = existing.Rejecter; entity.RejectTime = existing.RejectTime; entity.RejectionReason = existing.RejectionReason; existing.SubmitTime = existing.SubmitTime; // update entity.Id = id; Assessment updated = AssessmentService.Update(entity); Helper.Audit(AuditService, existing, updated, CommonHelper.GetFullActionName(ActionContext, includeController: false), CurrentUser.Username, _propertiesToSkipAuditing); return updated; })); }
public Assessment Submit(Assessment entity) { return(WithTransaction(() => { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Assessment existing = null; if (entity.Id > 0) { existing = AssessmentService.Get(entity.Id); CheckCanSubmit(existing); } CheckPerformedSitesSum(entity); // populate audit fields PopulateAuditFields(entity, existing, existing == null); entity.Title = CreateAssessmentTitle(existing, entity); // the submitter must be set to current user entity.Submitter = CurrentUser; entity.SubmitTime = DateTime.Now; entity.ApprovalStatus = ApprovalStatus.AwaitingBUFunctionalApproval; // following fields should not be set ResetCreatedAssessmentFields(entity); Assessment result = entity.Id > 0 ? AssessmentService.Update(entity) : AssessmentService.Create(entity); Helper.Audit(AuditService, existing, result, CommonHelper.GetFullActionName(ActionContext, includeController: false), CurrentUser.Username, _propertiesToSkipAuditing); return result; })); }
public Assessment.Entities.Assessment Get(int id) { return(_service.Get(id)); }
/// <summary> /// Handles the Click event of the btnNext control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnNext_Click(object sender, EventArgs e) { int pageNumber = hfPageNo.ValueAsInt() + 1; GetResponse(); LinkButton btn = ( LinkButton )sender; string commandArgument = btn.CommandArgument; var totalQuestion = pageNumber * QuestionCount; if ((_assessmentResponses.Count > totalQuestion && !_assessmentResponses.All(a => a.Response.HasValue)) || "Next".Equals(commandArgument)) { BindRepeater(pageNumber); } else { MotivatorService.AssessmentResults result = MotivatorService.GetResult(_assessmentResponses.ToDictionary(a => a.Code, b => b.Response.Value)); MotivatorService.SaveAssessmentResults(_targetPerson, result); var rockContext = new RockContext(); var assessmentService = new AssessmentService(rockContext); Assessment assessment = null; if (hfAssessmentId.ValueAsInt() != 0) { assessment = assessmentService.Get(int.Parse(hfAssessmentId.Value)); } if (assessment == null) { var assessmentType = new AssessmentTypeService(rockContext).Get(Rock.SystemGuid.AssessmentType.MOTIVATORS.AsGuid()); assessment = new Assessment() { AssessmentTypeId = assessmentType.Id, PersonAliasId = _targetPerson.PrimaryAliasId.Value }; assessmentService.Add(assessment); } assessment.Status = AssessmentRequestStatus.Complete; assessment.CompletedDateTime = RockDateTime.Now; assessment.AssessmentResultData = new { Result = result.AssessmentData, TimeToTake = RockDateTime.Now.Subtract(StartDateTime).TotalSeconds }.ToJson(); rockContext.SaveChanges(); // Since we are rendering chart.js we have to register the script or reload the page. if (_assessmentId == 0) { var removeParams = new List <string> { PageParameterKey.AssessmentId }; NavigateToCurrentPageReferenceWithRemove(removeParams); } else { this.NavigateToCurrentPageReference(); } } }
/// <summary> /// Handles the Click event of the btnNext control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnNext_Click(object sender, EventArgs e) { int pageNumber = hfPageNo.ValueAsInt() + 1; GetResponse(); LinkButton btn = ( LinkButton )sender; string commandArgument = btn.CommandArgument; var totalQuestion = pageNumber * QuestionCount; if ((_assessmentResponses.Count > totalQuestion && !_assessmentResponses.All(a => !string.IsNullOrEmpty(a.MostScore) && !string.IsNullOrEmpty(a.LeastScore))) || "Next".Equals(commandArgument)) { BindRepeater(pageNumber); } else { try { var moreD = _assessmentResponses.Where(a => a.MostScore == "D").Count(); var moreI = _assessmentResponses.Where(a => a.MostScore == "I").Count(); var moreS = _assessmentResponses.Where(a => a.MostScore == "S").Count(); var moreC = _assessmentResponses.Where(a => a.MostScore == "C").Count(); var lessD = _assessmentResponses.Where(a => a.LeastScore == "D").Count(); var lessI = _assessmentResponses.Where(a => a.LeastScore == "I").Count(); var lessS = _assessmentResponses.Where(a => a.LeastScore == "S").Count(); var lessC = _assessmentResponses.Where(a => a.LeastScore == "C").Count(); // Score the responses and return the results DiscService.AssessmentResults results = DiscService.Score(moreD, moreI, moreS, moreC, lessD, lessI, lessS, lessC); // Now save the results for this person DiscService.SaveAssessmentResults( _targetPerson, results.AdaptiveBehaviorD.ToString(), results.AdaptiveBehaviorI.ToString(), results.AdaptiveBehaviorS.ToString(), results.AdaptiveBehaviorC.ToString(), results.NaturalBehaviorD.ToString(), results.NaturalBehaviorI.ToString(), results.NaturalBehaviorS.ToString(), results.NaturalBehaviorC.ToString(), results.PersonalityType); var assessmentData = _assessmentResponses.ToDictionary(a => a.QuestionNumber, b => new { Most = new string[2] { b.MostScore, b.Questions[b.MostScore] }, Least = new string[2] { b.LeastScore, b.Questions[b.LeastScore] } }); var rockContext = new RockContext(); var assessmentService = new AssessmentService(rockContext); Assessment assessment = null; if (hfAssessmentId.ValueAsInt() != 0) { assessment = assessmentService.Get(int.Parse(hfAssessmentId.Value)); } if (assessment == null) { var assessmentType = new AssessmentTypeService(rockContext).Get(Rock.SystemGuid.AssessmentType.DISC.AsGuid()); assessment = new Assessment() { AssessmentTypeId = assessmentType.Id, PersonAliasId = _targetPerson.PrimaryAliasId.Value }; assessmentService.Add(assessment); } assessment.Status = AssessmentRequestStatus.Complete; assessment.CompletedDateTime = RockDateTime.Now; assessment.AssessmentResultData = new { Result = assessmentData, TimeToTake = RockDateTime.Now.Subtract(StartDateTime).TotalSeconds }.ToJson(); rockContext.SaveChanges(); ShowResult(results, assessment); } catch (Exception ex) { nbError.Visible = true; nbError.Title = "We're Sorry..."; nbError.Text = "Something went wrong while trying to save your test results."; LogException(ex); } } }