public ContentModuleTracking UpdateTracking(LessonTracking tracking, ContentModuleTracking contModTracking) { var forCredit = tracking.ForCredit; var browseMode = tracking.BrowseMode; var trackingExists = contModTracking.LessonTracking.ContainsKey(tracking.Identifier); var masteryScore = tracking.MasteryScore; var currentScore = tracking.RawScore; var currentStatus = tracking.LessonStatus; var totalTime = new TimeSpan(0); if (trackingExists) { var existingTracking = contModTracking.LessonTracking[tracking.Identifier]; masteryScore = existingTracking.MasteryScore; currentStatus = existingTracking.LessonStatus; currentScore = existingTracking.RawScore; totalTime = existingTracking.TotalTime; } else if (browseMode || !forCredit) { currentStatus = "browsed"; currentScore = null; } //Note: site had only been calculating status based on mastery score for AICC courses, //but we should make it do that for all courses eventually. if (contModTracking.ContentType == ActivityContentType.AICC.ToString() && masteryScore.HasValue && tracking.RawScore.HasValue && masteryScore.Value != -1) { tracking.LessonStatus = (tracking.RawScore.Value >= masteryScore.Value) ? "passed" : "failed"; } //when taking course not for credit, keep existing score/status/time, or if none exists, use "browsed"/null/zero time if (browseMode || !forCredit) { tracking.LessonStatus = currentStatus; tracking.RawScore = currentScore; tracking.TotalTime = totalTime; } else { tracking.TotalTime = tracking.SessionTime.HasValue ? tracking.SessionTime.Value + totalTime : totalTime; } contModTracking.LessonTracking[tracking.Identifier] = tracking; contModTracking.Bookmark = tracking.Identifier; return(SetContentModuleTracking(contModTracking)); }
public ContentModuleTracking SaveTracking(LessonTracking tracking, TrackingSessionMetaData metaData) { ContentModuleTracking trackingToGet = new ContentModuleTracking { ClientId = metaData.ClientId, ContentType = metaData.ContentType, SessionId = metaData.SessionId, UserID = metaData.LearnerId, ContentModuleId = metaData.CourseId }; var currentTracking = _dataManager.GetContentModuleLessonTracking(trackingToGet); if (String.IsNullOrEmpty(currentTracking.ID)) { var session = _sessionRepository.GetByIdForCourseLaunch(metaData.LearnerId, metaData.CourseId); currentTracking = session.ContentModuleTracking; } currentTracking.SessionId = metaData.SessionId; currentTracking.ClientId = metaData.ClientId; currentTracking.ContentType = metaData.ContentType; if (tracking.RawScore.HasValue) { //var clientCourseConfig = _courseConfigurationRepository.GetConfiguration(metaData.ClientId); int iMasteryScore; bool bGetMasteryScore = Int32.TryParse(System.Configuration.ConfigurationSettings.AppSettings["MasteryScore"].ToString(), out iMasteryScore); tracking.MasteryScore = iMasteryScore; //clientCourseConfig.MasteryScore; //if (!clientCourseConfig.ScoreTracking) //{ // tracking.RawScore = null; //} } //if (currentTracking.LessonTracking == null) //{ // currentTracking.LessonTracking = tracking; //} var trackingToSave = _trackingUpdater.UpdateTracking(tracking, currentTracking); return(_dataManager.UpdateContentModuleTracking(trackingToSave)); //return new ContentModuleTracking(); }
private void WriteScoTracking(LessonTracking scoTracking) { var objectiveTracking = String.Empty; for (int k = 0; k < scoTracking.Objectives.Count; k++) { objectiveTracking = objectiveTracking + String.Format("{0},{1},{2},{3},{4}", scoTracking.Objectives[k].Identifier, scoTracking.Objectives[k].RawScore, scoTracking.Objectives[k].MaxScore, scoTracking.Objectives[k].MinScore, scoTracking.Objectives[k].Status); if (k != scoTracking.Objectives.Count - 1) { objectiveTracking = objectiveTracking + " #&bv&#"; } } string siTempMasterScore; if (iMasteryScore > -1) { siTempMasterScore = Convert.ToString(iMasteryScore); } else { siTempMasterScore = scoTracking.MasteryScore.HasValue ? scoTracking.MasteryScore.ToString() : String.Empty; } Response.Write(string.Format( "\tarrParams = ['{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}',\"{24}\"];\n" , scoTracking.Identifier, scoTracking.StudentId, ValidationManager.MaskCharForJS(scoTracking.StudentName), scoTracking.LessonLocation, scoTracking.Credit, scoTracking.LessonStatus, scoTracking.Entry, scoTracking.RawScore, scoTracking.MaxScore, scoTracking.MinScore, scoTracking.TotalTime, scoTracking.LessonMode, scoTracking.Exit, scoTracking.SessionTime, scoTracking.SuspendData, sLaunchParameter == string.Empty ? scoTracking.LaunchData : sLaunchParameter, scoTracking.Comments, scoTracking.CommentsFromLms, scoTracking.Objectives.Count, objectiveTracking, siTempMasterScore, scoTracking.MaxTimeAllowed, scoTracking.TimeLimitAction, "", _sManagerEmail)); Response.Write("\tarrSCO[arrSCO.length] = new CSCO(arrParams);\n"); }