/// <summary> /// Method for loading default motivation model - specified by asset settings /// </summary> /// <returns></returns> internal MotivationModel loadDefaultMotivationModel() { loggingMAs("Loading default Domain model."); MotivationAssessmentAssetSettings maas = (MotivationAssessmentAssetSettings)getMAsA().Settings; IDataStorage ids = MotivationAssessmentAsset.Instance.getInterfaceFromAsset <IDataStorage>(); if (ids != null) { if (!ids.Exists(maas.XMLLoadingId)) { loggingMAs("File " + maas.XMLLoadingId + " not found for loading Motivation model.", Severity.Error); //throw new Exception("EXCEPTION: File "+ maas.XMLLoadingId + " not found for loading Motivation model.") ; return(null); } loggingMAs("Loading Motivation model from File."); return(this.getMMFromXmlString(ids.Load(maas.XMLLoadingId))); } else { loggingMAs("IDataStorage bridge absent for requested local loading method of the Motivation model.", Severity.Error); //throw new Exception("EXCEPTION: IDataStorage bridge absent for requested local loading method of the Motivation model."); return(null); } }
/// <summary> /// Method for sending the motivation values to the tracker /// </summary> internal void sendMotivationValuesToTracker() { //get the tracker if (tracker == null) { if (AssetManager.Instance.findAssetsByClass("TrackerAsset").Count >= 1) { tracker = (TrackerAsset)AssetManager.Instance.findAssetsByClass("TrackerAsset")[0]; loggingMAs("Found tracker for tracking motivation values!"); } else { //no tracking loggingMAs("No tracker implemented - motivational state is not send to the server"); return; } } if (tracker.CheckHealth()) { loggingMAs(tracker.Health); MotivationAssessmentAssetSettings maas = (MotivationAssessmentAssetSettings)getMAsA().Settings; if (tracker.Login(maas.TrackerName, maas.TrackerPassword)) { loggingMAs("logged in - tracker"); } else { loggingMAs("Maybe you forgot to store name/password for the tracker to the Motivation Assessment Asset Settings."); } } if (tracker.Connected) { tracker.Start(); Dictionary <string, double> ms = getMotivationState().getMotivation(); foreach (string motivationAspect in ms.Keys) { tracker.setVar(motivationAspect, ms[motivationAspect].ToString()); } tracker.Completable.Completed("MotivationAssessmentAsset"); #if !PORTABLE new Thread(() => { //next line: thread is killed after all foreground threads are dead Thread.CurrentThread.IsBackground = true; tracker.Flush(); }).Start(); #else tracker.Flush(); #endif } else { loggingMAs("Not connected to tracker."); } }
/// <summary> /// Updates the motivation state of a player with an motivation evidence. /// </summary> /// /// <param name="me"> Motivation evidence for the update. </param> internal void updateMotivationState(MotivationEvidence me) { loggingMAs("Start updating motivation state."); MotivationState currentMs = getMotivationState(); MotivationState newMs = currentMs.getCopy(); MotivationAssessmentAssetSettings maas = (MotivationAssessmentAssetSettings)getMAsA().Settings; if (me.EvidenceType == EvidenceType.LevelReached) { updatePrimaryMotivationAspect(newMs, "satisfaction", true); lastTimeUpdated = DateTime.Now; } else if (me.EvidenceType == EvidenceType.ProblemSolved) { if (me.FirstTryDuration < maas.FirstTryMinDuration) { updatePrimaryMotivationAspect(newMs, "attention", false); } else { if (me.SolvingDuration > maas.SolutionMaxDuration) { updatePrimaryMotivationAspect(newMs, "attention", false); } else { updatePrimaryMotivationAspect(newMs, "attention", true); } if (me.NoOfErrors > maas.MaxNoErrors || me.NoOfHelpRequests > maas.MaxNoHelpRequests) { updatePrimaryMotivationAspect(newMs, "confidence", false); } else { updatePrimaryMotivationAspect(newMs, "confidence", true); } } } else { loggingMAs("Warning: Evidence Type unknown!", Severity.Warning); } //downgrade satisfaction, if too much time passed by checkSatisfactionDowngrade(newMs); //Method for storing changes storeNewMotivationState(newMs); }
/// <summary> /// Method for updating the motivation state aspect satisfaction due to 'too much time no new level' /// </summary> /// <param name="newMs"> the new motivation state</param> private bool checkSatisfactionDowngrade(MotivationState newMs) { MotivationAssessmentAssetSettings maas = (MotivationAssessmentAssetSettings)getMAsA().Settings; if (lastTimeUpdated.AddSeconds(maas.SatisfactionDowngradeTime) < DateTime.Now) { updatePrimaryMotivationAspect(newMs, "satisfaction", false); lastTimeUpdated = DateTime.Now; return(true); } return(false); }
/// <summary> /// Initializes a new instance of the MotivationAssessmentAsset.Asset class. /// </summary> private MotivationAssessmentAsset() : base() { //! Create Settings and let it's BaseSettings class assign Defaultvalues where it can. settings = new MotivationAssessmentAssetSettings(); }