private void SaveCurrentSco(XmlDocument requestXml)
        {
            //TrackingSessionMetaData trackingMetaData = new TrackingSessionMetaData(); //// ///*** GetTrackingMetaData();
            TrackingSessionMetaData trackingMetaData = GetTrackingMetaData();
            //trackingMetaData.CourseId = "COM22A5EFEB602941E0";
            //trackingMetaData.LearnerId = "LERDE6B953039A04B17"; ///*** CHANGE THIS hardcode
            //Since only SCORM clients will call this, initializing the serializer is ok
            var    lesson             = new ScoTrackingSerializer().ParseLesson(requestXml.SelectSingleNode("//sco"));
            string strContentModuleId = string.Empty;
            //string strClientId = string.Empty;


            //if (LMSSession.IsInSession(Client.CLIENT_SESSION_ID))
            //    strClientId = Convert.ToString(LMSSession.GetValue(Client.CLIENT_SESSION_ID));

            //if (string.IsNullOrEmpty(strClientId) && !string.IsNullOrEmpty(hdnClientId.Value))
            //{
            //    strClientId = EncryptionManager.Decrypt(hdnClientId.Value);
            //}

            //int hCount = 0;
            //int.TryParse(Convert.ToString(hdnCount.Value), out hCount);

            //if (hCount == 2)
            //    strClientId = "";

            //if (!string.IsNullOrEmpty(strClientId))
            //{
            ContentModuleTracking objTrack = null;

            //For Not update data in second attempt
            if (ViewState["objTrack"] == null)
            {
                objTrack = new ContentModuleTracking();
                //objTrack.ClientId = strClientId;
                //objTrack.ActivityId = trackingMetaData.CourseId;
                objTrack.ContentModuleId = trackingMetaData.CourseId;
                //objTrack.LearnerId = trackingMetaData.LearnerId;
                objTrack.UserID    = trackingMetaData.LearnerId;
                objTrack.SessionId = trackingMetaData.SessionId;
                objTrack           = new ContentModuleTrackingManager().Execute(objTrack, ContentModuleTracking.Method.Get);
            }
            else
            {
                objTrack = (ContentModuleTracking)ViewState["objTrack"];
            }

            //if (objTrack != null)
            //{
            //string userdataxml = objTrack.UserDataXML;
            objTrack = new ContentModuleTrackingManager().Execute(objTrack, ContentModuleTracking.Method.GenerateLog);
            //}
            if (objTrack == null || objTrack.CompletionStatus != ActivityCompletionStatus.Completed)
            {
                TrackingManager.SaveTracking(lesson, trackingMetaData);
            }
        }
        private TrackingSessionMetaData GetTrackingMetaData()
        {
            var metaData = new TrackingSessionMetaData
            {
                SessionId   = sessionId,
                LearnerId   = learnerId,
                CourseId    = courseId,
                ContentType = ActivityContentType.Scorm12.ToString()
            };

            return(metaData);
        }
        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();
        }