/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person"></param> /// <param name="ABd">Adaptive Behavior D</param> /// <param name="ABi">Adaptive Behavior I</param> /// <param name="ABs">Adaptive Behavior S</param> /// <param name="ABc">Adaptive Behavior C</param> /// <param name="NBd">Natural Behavior D</param> /// <param name="NBi">Natural Behavior I</param> /// <param name="NBs">Natural Behavior S</param> /// <param name="NBc">Natural Behavior C</param> /// <param name="personalityType">One or two letters of DISC that represents the personality.</param> static public void SaveAssessmentResults(Person person, string ABd, string ABi, string ABs, string ABc, string NBd, string NBi, string NBs, string NBc, string personalityType) { person.LoadAttributes(); var discAttributes = person.Attributes.Values.Where(a => a.Categories.Any(c => c.Guid == SystemGuid.Category.PERSON_ATTRIBUTES_DISC.AsGuid() || c.Guid == SystemGuid.Category.PERSON_ATTRIBUTES_PERSONALITY_ASSESSMENT_DATA.AsGuid())).Select(a => a.Key); foreach (string attrib in discAttributes) { switch (attrib) { case AttributeKeys.AdaptiveD: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABd); break; case AttributeKeys.AdaptiveI: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABi); break; case AttributeKeys.AdaptiveS: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABs); break; case AttributeKeys.AdaptiveC: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABc); break; case AttributeKeys.NaturalD: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBd); break; case AttributeKeys.NaturalI: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBi); break; case AttributeKeys.NaturalS: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBs); break; case AttributeKeys.NaturalC: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBc); break; case AttributeKeys.PersonalityType: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], personalityType); break; case AttributeKeys.LastSaveDate: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], RockDateTime.Now.ToString("o")); break; case AttributeKeys.DISCProfile: var definedValueCache = LookupPersonalityTypeProfile(personalityType); Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], definedValueCache.Guid.ToStringSafe()); break; } } person.SaveAttributeValues(); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); var discAttributes = person.Attributes.Values.Where(a => a.Categories.Any(c => c.Guid == new Guid("0B187C81-2106-4875-82B6-FBF1277AE23B"))).Select(a => a.Key); foreach (string attrib in discAttributes) { switch (attrib) { case AttributeKeys.AdaptiveD: savedScores.AdaptiveBehaviorD = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveI: savedScores.AdaptiveBehaviorI = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveS: savedScores.AdaptiveBehaviorS = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveC: savedScores.AdaptiveBehaviorC = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalD: savedScores.NaturalBehaviorD = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalI: savedScores.NaturalBehaviorI = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalS: savedScores.NaturalBehaviorS = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalC: savedScores.NaturalBehaviorC = AttributeValueLookup(person, attrib); break; case AttributeKeys.PersonalityType: savedScores.PersonalityType = person.AttributeValues[attrib].Value; break; case AttributeKeys.LastSaveDate: DateTime lastAssessmentDate = DateTime.MinValue; bool bCatch = DateTime.TryParse(person.AttributeValues[attrib].Value, out lastAssessmentDate); savedScores.LastSaveDate = lastAssessmentDate; break; } } return(savedScores); }
/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person">The person.</param> /// <param name="assessmentResults">The assessment results.</param> static public void SaveAssessmentResults(Person person, AssessmentResults assessmentResults) { person.LoadAttributes(); person.SetAttributeValue(ATTRIBUTE_DOMINANT_GIFTS, assessmentResults.DominantGifts.AsDelimited(",")); person.SetAttributeValue(ATTRIBUTE_SUPPORTIVE_GIFTS, assessmentResults.SupportiveGifts.AsDelimited(",")); person.SetAttributeValue(ATTRIBUTE_OTHER_GIFTS, assessmentResults.OtherGifts.AsDelimited(",")); person.SetAttributeValue(ATTRIBUTE_LAST_SAVE_DATE, assessmentResults.LastSaveDate); person.SaveAttributeValues(); }
/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person"></param> /// <param name="ABd">Adaptive Behavior D</param> /// <param name="ABi">Adaptive Behavior I</param> /// <param name="ABs">Adaptive Behavior S</param> /// <param name="ABc">Adaptive Behavior C</param> /// <param name="NBd">Natural Behavior D</param> /// <param name="NBi">Natural Behavior I</param> /// <param name="NBs">Natural Behavior S</param> /// <param name="NBc">Natural Behavior C</param> /// <param name="personalityType">One or two letters of DISC that represents the personality.</param> static public void SaveAssessmentResults(Person person, string ABd, string ABi, string ABs, string ABc, string NBd, string NBi, string NBs, string NBc, string personalityType) { person.LoadAttributes(); var discAttributes = person.Attributes.Values.Where(a => a.Categories.Any(c => c.Guid == new Guid("0B187C81-2106-4875-82B6-FBF1277AE23B"))).Select(a => a.Key); foreach (string attrib in discAttributes) { switch (attrib) { case AttributeKeys.AdaptiveD: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABd); break; case AttributeKeys.AdaptiveI: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABi); break; case AttributeKeys.AdaptiveS: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABs); break; case AttributeKeys.AdaptiveC: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], ABc); break; case AttributeKeys.NaturalD: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBd); break; case AttributeKeys.NaturalI: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBi); break; case AttributeKeys.NaturalS: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBs); break; case AttributeKeys.NaturalC: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], NBc); break; case AttributeKeys.PersonalityType: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], personalityType); break; case AttributeKeys.LastSaveDate: Rock.Attribute.Helper.SaveAttributeValue(person, person.Attributes[attrib], RockDateTime.Now.ToString("o")); break; } } person.SaveAttributeValues(); }
/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person">The person.</param> /// <param name="assessmentResults">The assessment results.</param> static public void SaveAssessmentResults(Person person, AssessmentResults assessmentResults) { person.LoadAttributes(); person.SetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_SELF_AWARENESS, assessmentResults.SelfAwareConstruct); person.SetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_SELF_REGULATING, assessmentResults.SelfRegulatingConstruct); person.SetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_OTHERS_AWARENESS, assessmentResults.OtherAwarenessContruct); person.SetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_OTHERS_REGULATING, assessmentResults.OthersRegulatingConstruct); person.SetAttributeValue(ATTRIBUTE_EQ_SCALES_PROBLEM_SOLVING, assessmentResults.EQ_ProblemSolvingScale); person.SetAttributeValue(ATTRIBUTE_EQ_SCALES_UNDER_STRESS, assessmentResults.EQ_UnderStressScale); person.SaveAttributeValues(); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); savedScores.DominantGifts = person.GetAttributeValues(ATTRIBUTE_DOMINANT_GIFTS).AsGuidList(); savedScores.SupportiveGifts = person.GetAttributeValues(ATTRIBUTE_SUPPORTIVE_GIFTS).AsGuidList(); savedScores.OtherGifts = person.GetAttributeValues(ATTRIBUTE_OTHER_GIFTS).AsGuidList(); savedScores.LastSaveDate = person.GetAttributeValue(ATTRIBUTE_LAST_SAVE_DATE).AsDateTime(); return(savedScores); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); savedScores.SelfAwareConstruct = person.GetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_SELF_AWARENESS).AsDecimal(); savedScores.SelfRegulatingConstruct = person.GetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_SELF_REGULATING).AsDecimal(); savedScores.OtherAwarenessContruct = person.GetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_OTHERS_AWARENESS).AsDecimal(); savedScores.OthersRegulatingConstruct = person.GetAttributeValue(ATTRIBUTE_EQ_CONSTRUCTS_OTHERS_REGULATING).AsDecimal(); savedScores.EQ_ProblemSolvingScale = person.GetAttributeValue(ATTRIBUTE_EQ_SCALES_PROBLEM_SOLVING).AsDecimal(); savedScores.EQ_UnderStressScale = person.GetAttributeValue(ATTRIBUTE_EQ_SCALES_UNDER_STRESS).AsDecimal(); return(savedScores); }
/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person">The person.</param> /// <param name="assessmentResults">The assessment results.</param> static public void SaveAssessmentResults(Person person, AssessmentResults assessmentResults) { person.LoadAttributes(); person.SetAttributeValue(ATTRIBUTE_MODE_WINNING, assessmentResults.ModeWinningScore); person.SetAttributeValue(ATTRIBUTE_MODE_RESOLVING, assessmentResults.ModeResolvingScore); person.SetAttributeValue(ATTRIBUTE_MODE_COMPROMISING, assessmentResults.ModeCompromisingScore); person.SetAttributeValue(ATTRIBUTE_MODE_AVOIDING, assessmentResults.ModeAvoidingScore); person.SetAttributeValue(ATTRIBUTE_MODE_YEILDING, assessmentResults.ModeYieldingScore); person.SetAttributeValue(ATTRIBUTE_THEME_ACCOMMODATING, assessmentResults.EngagementAccommodatingScore); person.SetAttributeValue(ATTRIBUTE_THEME_WINNING, assessmentResults.EngagementWinningScore); person.SetAttributeValue(ATTRIBUTE_THEME_SOLVING, assessmentResults.EngagementSolvingScore); person.SaveAttributeValues(); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); var motivatorThemeScores = new Dictionary <DefinedValueCache, decimal>(); var motivatorScores = new Dictionary <DefinedValueCache, decimal>(); var motivatorThemeTypes = DefinedTypeCache.Get(SystemGuid.DefinedType.MOTIVATOR_THEME_TYPE.AsGuid()); foreach (var motivatorThemeType in motivatorThemeTypes.DefinedValues) { var scoreKey = motivatorThemeType.GetAttributeValue("AttributeScoreKey"); motivatorThemeScores.Add(motivatorThemeType, person.GetAttributeValue(scoreKey).AsDecimal()); } savedScores.MotivatorThemeScores = motivatorThemeScores .OrderByDescending(a => a.Value) .Select(a => new MotivatorScore() { DefinedValue = a.Key, Value = a.Value }) .ToList(); var motivatorTypes = DefinedTypeCache.Get(SystemGuid.DefinedType.MOTIVATOR_TYPE.AsGuid()); foreach (var motivatorType in motivatorTypes.DefinedValues) { var scoreKey = motivatorType.GetAttributeValue("AttributeScoreKey"); motivatorScores.Add(motivatorType, person.GetAttributeValue(scoreKey).AsDecimal()); } savedScores.MotivatorScores = motivatorScores .OrderByDescending(a => a.Value) .Select(a => new MotivatorScore() { DefinedValue = a.Key, Value = a.Value }) .ToList(); savedScores.TopFiveMotivatorScores = savedScores.MotivatorScores.Take(5).ToList(); savedScores.GrowthScore = person.GetAttributeValue(ATTRIBUTE_MOTIVATOR_GROWTHPROPENSITY).AsDecimal(); return(savedScores); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); savedScores.ModeWinningScore = person.GetAttributeValue(ATTRIBUTE_MODE_WINNING).AsDecimal(); savedScores.ModeResolvingScore = person.GetAttributeValue(ATTRIBUTE_MODE_RESOLVING).AsDecimal(); savedScores.ModeCompromisingScore = person.GetAttributeValue(ATTRIBUTE_MODE_COMPROMISING).AsDecimal(); savedScores.ModeAvoidingScore = person.GetAttributeValue(ATTRIBUTE_MODE_AVOIDING).AsDecimal(); savedScores.ModeYieldingScore = person.GetAttributeValue(ATTRIBUTE_MODE_YEILDING).AsDecimal(); savedScores.EngagementAccommodatingScore = person.GetAttributeValue(ATTRIBUTE_THEME_ACCOMMODATING).AsDecimal(); savedScores.EngagementWinningScore = person.GetAttributeValue(ATTRIBUTE_THEME_WINNING).AsDecimal(); savedScores.EngagementSolvingScore = person.GetAttributeValue(ATTRIBUTE_THEME_SOLVING).AsDecimal(); return(savedScores); }
/// <summary> /// Saves Assessment results to a Person's PersonProperties /// </summary> /// <param name="person">The person.</param> /// <param name="assessmentResults">The assessment results.</param> static public void SaveAssessmentResults(Person person, AssessmentResults assessmentResults) { person.LoadAttributes(); var topFiveMotivatorScores = assessmentResults.MotivatorScores.OrderByDescending(x => x.Value).Take(5).Select(x => x.DefinedValue.Guid).ToList().AsDelimited(","); person.SetAttributeValue(ATTRIBUTE_MOTIVATOR_TOP_5_MOTIVATORS, topFiveMotivatorScores); //var motivatorTypes = DefinedTypeCache.Get( SystemGuid.DefinedType.MOTIVATOR_TYPE.AsGuid() ); foreach (var motivatorScore in assessmentResults.MotivatorScores) { var scoreKey = motivatorScore.DefinedValue.GetAttributeValue("AttributeScoreKey"); person.SetAttributeValue(scoreKey, motivatorScore.Value); } //var motivatorClusterTypes = DefinedTypeCache.Get( SystemGuid.DefinedType.MOTIVATOR_THEME_TYPE.AsGuid() ); foreach (var motivatorThemeScore in assessmentResults.MotivatorThemeScores) { var scoreKey = motivatorThemeScore.DefinedValue.GetAttributeValue("AttributeScoreKey"); person.SetAttributeValue(scoreKey, motivatorThemeScore.Value); } person.SaveAttributeValues(); }
/// <summary> /// Gets the existing value for a specific field for the given registrant. /// </summary> /// <param name="registrant">The registrant.</param> /// <param name="person">The person.</param> /// <param name="family">The family.</param> /// <param name="Field">The field.</param> /// <param name="rockContext">The rock context.</param> /// <returns></returns> public object GetRegistrantValue(RegistrationRegistrant registrant, Person person, Group family, RegistrationTemplateFormField Field, RockContext rockContext) { if (Field.FieldSource == RegistrationFieldSource.PersonField) { if (person != null) { DefinedValueCache dvPhone = null; switch (Field.PersonFieldType) { case RegistrationPersonFieldType.FirstName: return(person.NickName); case RegistrationPersonFieldType.LastName: return(person.LastName); case RegistrationPersonFieldType.Campus: { if (family != null) { return(family.CampusId); } break; } case RegistrationPersonFieldType.Address: { var location = person.GetHomeLocation(rockContext); if (location != null) { return(location.Clone()); } break; } case RegistrationPersonFieldType.Email: return(person.Email); case RegistrationPersonFieldType.Birthdate: return(person.BirthDate); case RegistrationPersonFieldType.Grade: return(person.GraduationYear); case RegistrationPersonFieldType.Gender: return(person.Gender); case RegistrationPersonFieldType.MaritalStatus: return(person.MaritalStatusValueId); case RegistrationPersonFieldType.MobilePhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE); break; } case RegistrationPersonFieldType.HomePhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME); break; } case RegistrationPersonFieldType.WorkPhone: { dvPhone = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK); break; } } if (dvPhone != null) { var phoneNumber = new PersonService(rockContext).GetPhoneNumber(person, dvPhone); if (phoneNumber != null) { return(phoneNumber.Clone()); } } } } else { var attribute = AttributeCache.Read(Field.AttributeId ?? 0); if (attribute != null) { switch (Field.FieldSource) { case RegistrationFieldSource.PersonAttribute: { if (person != null) { if (person.Attributes == null) { person.LoadAttributes(); } return(person.GetAttributeValue(attribute.Key)); } break; } case RegistrationFieldSource.GroupMemberAttribute: { if (registrant != null && registrant.GroupMember != null) { if (registrant.GroupMember.Attributes == null) { registrant.GroupMember.LoadAttributes(); } return(registrant.GroupMember.GetAttributeValue(attribute.Key)); } break; } case RegistrationFieldSource.RegistrationAttribute: { if (registrant != null) { if (registrant.Attributes == null) { registrant.LoadAttributes(); } return(registrant.GetAttributeValue(attribute.Key)); } break; } } } } return(null); }
/// <summary> /// Loads and returns saved Assessment scores for the Person. /// </summary> /// <param name="person">The Person to get the scores for.</param> /// <returns>AssessmentResults</returns> static public AssessmentResults LoadSavedAssessmentResults(Person person) { AssessmentResults savedScores = new AssessmentResults(); person.LoadAttributes(); var discAttributes = person.Attributes.Values.Where(a => a.Categories.Any(c => c.Guid == SystemGuid.Category.PERSON_ATTRIBUTES_DISC.AsGuid() || c.Guid == SystemGuid.Category.PERSON_ATTRIBUTES_PERSONALITY_ASSESSMENT_DATA.AsGuid())).Select(a => a.Key); foreach (string attrib in discAttributes) { switch (attrib) { case AttributeKeys.AdaptiveD: savedScores.AdaptiveBehaviorD = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveI: savedScores.AdaptiveBehaviorI = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveS: savedScores.AdaptiveBehaviorS = AttributeValueLookup(person, attrib); break; case AttributeKeys.AdaptiveC: savedScores.AdaptiveBehaviorC = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalD: savedScores.NaturalBehaviorD = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalI: savedScores.NaturalBehaviorI = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalS: savedScores.NaturalBehaviorS = AttributeValueLookup(person, attrib); break; case AttributeKeys.NaturalC: savedScores.NaturalBehaviorC = AttributeValueLookup(person, attrib); break; case AttributeKeys.PersonalityType: savedScores.PersonalityType = person.AttributeValues[attrib].Value; break; case AttributeKeys.LastSaveDate: DateTime lastAssessmentDate = DateTime.MinValue; bool bCatch = DateTime.TryParse(person.AttributeValues[attrib].Value, out lastAssessmentDate); savedScores.LastSaveDate = lastAssessmentDate; break; case AttributeKeys.DISCProfile: savedScores.DISCProfile = DefinedValueCache.Get(person.AttributeValues[attrib].Value); break; } } return(savedScores); }