Beispiel #1
0
        private ContentModuleTracking GetTrackingHRS(ContentModuleSession session)
        {
            var contModTracking = new ContentModuleTracking
            {
                UserID          = session.SystemUserGuid,
                ContentModuleId = session.ContentModuleId
            };

            //if (session.Attempt.HasValue)
            //{
            contModTracking.ID = session.SystemUserGuid + "CTR" + IDGenerator.GetUniqueKey(16);
            //}
            contModTracking.IsResume    = session.IsReview;
            contModTracking.ContentType = session.ContentModule.ContentModuleTypeId;

            contModTracking = _contentModuleTrackingRepository.GetContentModuleLessonTracking(contModTracking);

            contModTracking.IsForAdminPreview = false; // (session.LaunchSite == LaunchSite.Admin);
            contModTracking.UserID            = session.SystemUserGuid;
            contModTracking.UserFirstLastName = session.Learner.LastName + ", " + session.Learner.FirstName;
            contModTracking.ContentModuleId   = session.ContentModuleId;
            contModTracking.SessionId         = session.SessionId;
            contModTracking.TotalNoOfPages    = session.ContentModule.TotalLessons;
            contModTracking.ContentType       = session.ContentModule.ContentModuleTypeId;

            return(contModTracking);
        }
Beispiel #2
0
        private ContentModuleTracking GetTracking(string clientId, ContentModuleSession session)
        {
            var contModTracking = new ContentModuleTracking
            {
                UserID          = session.SystemUserGuid,
                ContentModuleId = session.ContentModuleId,
                ClientId        = clientId
            };

            if (session.Attempt.HasValue)
            {
                contModTracking.ID = session.Assignment.ID + "-" + session.SystemUserGuid + "-" + session.Attempt.Value;
            }
            contModTracking.IsResume    = session.IsReview;
            contModTracking.ContentType = session.ContentModule.ContentModuleTypeId;

            contModTracking = _contentModuleTrackingRepository.GetContentModuleLessonTracking(contModTracking);

            contModTracking.IsForAdminPreview = (session.LaunchSite == LaunchSite.Admin);
            contModTracking.UserID            = session.SystemUserGuid;
            contModTracking.UserFirstLastName = session.Learner.LastName + ", " + session.Learner.FirstName;
            contModTracking.ContentModuleId   = session.ContentModuleId;
            contModTracking.SessionId         = session.SessionId;
            contModTracking.TotalNoOfPages    = session.ContentModule.TotalLessons;
            contModTracking.ContentType       = session.ContentModule.ContentModuleTypeId;

            return(contModTracking);
        }
        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);
            }
        }
Beispiel #4
0
        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 override ContentModuleTracking GetUserDataXml(ContentModuleTracking pEntContModTracking)
        {
            var entContModTrackingReturn = base.GetUserDataXml(pEntContModTracking);
            var trackingDirectory        = String.Format("{0}\\{1}", _userDataPath, entContModTrackingReturn.ContentModuleId);

            if (!Directory.Exists(trackingDirectory))
            {
                Directory.CreateDirectory(trackingDirectory);
            }
            var trackingFile = trackingDirectory + @"\" + entContModTrackingReturn.UserID + "_" + entContModTrackingReturn.ContentModuleId + "_UserDataXML.xml";

            if (File.Exists(trackingFile))
            {
                entContModTrackingReturn.UserDataXML = File.ReadAllText(trackingFile);
            }
            return(entContModTrackingReturn);
        }
        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();
        }
Beispiel #7
0
        private ContentModuleTracking SetContentModuleTracking(ContentModuleTracking contModTracking)
        {
            var scos = contModTracking.LessonTracking;

            Func <LessonTracking, bool> lessonIsComplete = l => l.IsComplete;

            int numberOfPagesCompleted = scos.Values.Count(lessonIsComplete);

            contModTracking.NoOfPagesCompleted = numberOfPagesCompleted;

            if (numberOfPagesCompleted == contModTracking.TotalNoOfPages && !contModTracking.IsCompleted())
            {
                contModTracking.DateOfCompletion = DateTime.Now;
                contModTracking.CompletionStatus = ActivityCompletionStatus.Completed;
                var lastScore = scos.Select(sco => sco.Value.RawScore).LastOrDefault(score => score.HasValue);
                if (lastScore == null)
                {
                    contModTracking.Score = null;
                }
                else
                {
                    contModTracking.Score = Math.Round(lastScore.GetValueOrDefault(100)).ToString("F0");
                }
            }
            else
            {
                contModTracking.CompletionStatus = ActivityCompletionStatus.Started;

                var lastScore = scos.Select(sco => sco.Value.RawScore).LastOrDefault(score => score.HasValue);
                //contModTracking.Score = Math.Round(lastScore.GetValueOrDefault(100)).ToString("F0");
                if (lastScore == null)
                {
                    contModTracking.Score = null;
                }
                else
                {
                    contModTracking.Score = Math.Round(lastScore.GetValueOrDefault(100)).ToString("F0");
                }
            }

            return(contModTracking);
        }
        public override ContentModuleTrackingAdaptor.ContentModuleTrackingUpdateResult EditTracking(ContentModuleTracking trackingToSave)
        {
            if (!String.IsNullOrEmpty(trackingToSave.UserDataXML))
            {
                var trackingDirectory = String.Format("{0}\\{1}", _userDataPath, trackingToSave.ContentModuleId);
                if (!Directory.Exists(trackingDirectory))
                {
                    Directory.CreateDirectory(trackingDirectory);
                }
                var trackingFile = trackingDirectory + @"\" + trackingToSave.UserID + "_" + trackingToSave.ContentModuleId + "_UserDataXML.xml";
                File.WriteAllText(trackingFile, trackingToSave.UserDataXML);

                //trackingToSave.UserDataXML = string.Empty;
            }
            return(base.EditTracking(trackingToSave));
        }
        /// <summary>
        /// Page Load event call of the page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (String.IsNullOrEmpty(Request["clientId"]) || String.IsNullOrEmpty(Request["sessionId"]))
            if (String.IsNullOrEmpty(Request["sessionId"]))
            {
                Response.Redirect("DisplayError.aspx?error=SessionTimeout");
            }

            //~ var sClientId = CommonManager.DecodeAndDecrypt(Request["clientId"]);
            var sClientId       = "HRS";
            var sessionId       = Request["sessionId"];
            var contentmoduleid = Request["contentmoduleid"];
            var learnerid       = Request["learnerid"];
            //Session["contentmoduleid"] = Request["contentmoduleid"];

            var session = ContentModuleSessionRepository.GetByIdForCourseLaunch(learnerid, contentmoduleid);
            //var session = new ContentModuleSession();

            //if (session == null)
            //{
            //    Response.Redirect("DisplayError.aspx?error=SessionTimeout");
            //}

            string sLearnerUserNameAlias = session.Learner.UserName;

            //string sManagerEmail = session.Learner.ManagerEmailId;
            //_sManagerEmail = session.Learner.ManagerEmailId;
            //~ _sManagerEmail = _sManagerEmail.Replace("'", "\'");

            //string sStudentEmail = session.Learner.EmailID;
            //~ sStudentEmail = sStudentEmail.Replace("'", "\'");


            sStudentName = session.Learner.LastName + ", " + session.Learner.FirstName;
            string sCourseID = Request["contentmoduleid"];
            //~string sCourseName = session.Assignment.ActivityName;
            string sCourseName = "HRS";
            //~string sRVSettings = session.Learner.RegionViewName;
            string sRVSettings      = "HRS";
            string sIsScoreTracking = string.Empty;
            bool   blnIsShortLanguageCode;

            ContentModuleTracking contModTracking = session.ContentModuleTracking;
            ContentModule         entContent      = session.ContentModule; //new ContentModule();

            //blnIsShortLanguageCode = entContent.IsShortLanguageCode;

            iMasteryScore = 100;///****session.ContentModule.MasteryScore;
            ////sAVPath = session.Learner.AvPath;

            sIsScoreTracking = "";

            sContentFolderUrl = System.Configuration.ConfigurationManager.AppSettings["sAppUrl"].ToString() + System.Configuration.ConfigurationManager.AppSettings["sContentFolderUrl"].ToString() + "/" + contentmoduleid;

            lblErr.Text = "";
            if (!Page.IsPostBack)
            {
                lblWelcome.Text = sLearnerUserNameAlias;

                string strIMSCourseBasePath = sContentFolderUrl + "/";

                string sAttempId = string.Empty;

                if (contModTracking.ID != null)
                {
                    sAttempId = contModTracking.ID;
                    LMSSession.AddSessionItem(ContentKeys.SESSION_ATTEMPT_ID, sAttempId);
                    SessionManager.AddAttemptNumberToSession(sClientId, sessionId, contModTracking.ID);
                }

                int TotalNoOfPages = entContent.TotalLessons;
                totalscos = TotalNoOfPages.ToString();
                LMSSession.AddSessionItem(ContentKeys.SESSION_TOTAL_NO_PAGES, TotalNoOfPages);

                lblContentModuleName.Text = sCourseName;
                lblMessage.Text           = "To receive your certificate of completion you must view each screen in each section.";
                Response.Write("<script language='Javascript'>\n\tvar gLearnerId = \"" + sLearnerUserNameAlias + "\";\n");
                Response.Write("\tvar gStudentId = \"" + sLearnerUserNameAlias + "\";\n");
                Response.Write("\tvar sessionId = \"" + sessionId + "\";\n");
                Response.Write("\tvar clientId = \"" + Request["clientId"] + "\";\n");
                Response.Write("\tgLearnerName = \"" + sStudentName + "\";\n");
                Response.Write("\tgContentPath=\"" + strIMSCourseBasePath + "\";\n");
                Response.Write("\tvar gTrackScoreSettingFromLMS=\"" + sIsScoreTracking + "\";\n");


                var sbLaunchParameter = new StringBuilder();
                sbLaunchParameter.Append("LMSID=SAI");
                if (!string.IsNullOrEmpty(sAVPath))
                {
                    sbLaunchParameter.Append("&AVPath=" + sAVPath);
                    sbLaunchParameter.Append("&AudioPath=" + sAVPath);
                    sbLaunchParameter.Append("&VideoPath=" + sAVPath);
                }
                if (!string.IsNullOrEmpty(sRVSettings))
                {
                    sbLaunchParameter.Append("&rip=" + sRVSettings);
                }
                if (!string.IsNullOrEmpty(sLearnerLanguageId))
                {
                    sLanguageCode = "en-US";
                    sbLaunchParameter.Append("&lang=" + sLanguageCode);
                }

                sLaunchParameter = sbLaunchParameter.ToString();

                Response.Write("\tvar sLearnerLanguageId='" + sLanguageCode + "';\n");
                Response.Write("\tvar gManifestId='" + sCourseID + "';\n</script>\n");
                Response.Write("<script language='Javascript' src='ScormLibrary/js/ClientScripts.js'></script>\n");
                Response.Write("<script language='Javascript' src='ScormLibrary/js/LMSRTEWrapperJS.js'></script>\n");
                Response.Write("<script language='Javascript' src='ScormLibrary/js/Master.js'></script>\n");
                Response.Write("<script language='Javascript' src='ScormLibrary/js/ScormValidations.js'></script>\n");
                Response.Write("<script language='Javascript' src='ScormLibrary/js/RTEMaster.js'></script>\n");
                Response.Write("<script language='Javascript' src='js/NewScormJS.js'></script>\n");
                Response.Write("<script language='Javascript'>\n");

                launchUrls     = new Dictionary <string, string>();
                lessonStatuses = new Dictionary <string, string>();
                sections       = entContent.Sections.SortedValues();
                foreach (var section in sections)
                {
                    foreach (var lesson in section.Lessons.SortedValues())
                    {
                        var    sco         = (Sco)lesson;
                        string sTempAVPath = sLaunchParameter != string.Empty ? sLaunchParameter : sco.DataFromLms;
                        string siTempMasterScore;
                        if (iMasteryScore > -1)
                        {
                            siTempMasterScore = Convert.ToString(iMasteryScore);
                        }
                        else
                        {
                            siTempMasterScore = sco.MasteryScore.HasValue ? sco.MasteryScore.ToString() : String.Empty;
                        }
                        var sUrl = sco.Resource.Href;
                        if (sUrl.IndexOf(strIMSCourseBasePath) <= 0)
                        {
                            sUrl = sUrl.AppendUrlParameter("passingScore", siTempMasterScore) + "&" +
                                   sLaunchParameterQueryString;
                        }
                        launchUrls[lesson.Identifier] = sUrl;

                        var arrOfNodeProp =
                            String.Format(
                                "['{0}','','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}']",
                                sco.Identifier, sco.TargetWindow, sco.Prerequisites, sTempAVPath, siTempMasterScore,
                                sco.MaxTimeAllowed, sco.TimeLimitAction, sco.Resource.Identifier, sco.Resource.ScormType,
                                sco.Resource.Type, sco.Resource.Base, sUrl);
                        Response.Write("\tarrManifestNodes[arrManifestNodes.length] = new ManifestNode(" + arrOfNodeProp +
                                       ");\n");
                        if (contModTracking.LessonTracking != null &&
                            contModTracking.LessonTracking.ContainsKey(lesson.Identifier))
                        {
                            var scoTracking = contModTracking.LessonTracking[lesson.Identifier];
                            lessonStatuses[lesson.Identifier] = CommonManager.GetScoStatus(scoTracking.LessonStatus);
                            WriteScoTracking(scoTracking);
                        }
                        else
                        {
                            lessonStatuses[lesson.Identifier] = CommonManager.GetScoStatus("not-started");
                        }
                    }
                }
                Response.Write("</script>\n");
            }
        }
Beispiel #10
0
        public string WriteLessonTracking(ContentModuleTracking contentModuleTracking)
        {
            var lessonTracking = contentModuleTracking.LessonTracking;
            var xDoc           = new XDocument(new XElement("Root",
                                                            lessonTracking.Values.Select(t => new XElement("sco", new XAttribute("identifier", t.Identifier),
                                                                                                           new XElement("cmi",
                                                                                                                        new XElement("core",
                                                                                                                                     new XElement("student_id", new XCData(t.StudentId)),
                                                                                                                                     new XElement("student_name", new XCData(t.StudentName)),
                                                                                                                                     new XElement("lesson_location", new XCData(t.LessonLocation)),
                                                                                                                                     new XElement("credit", t.Credit),
                                                                                                                                     new XElement("lesson_status", t.LessonStatus),
                                                                                                                                     new XElement("entry", t.Entry),
                                                                                                                                     new XElement("score",
                                                                                                                                                  new XElement("raw", t.RawScore.HasValue ? t.RawScore.ToString() : String.Empty),
                                                                                                                                                  new XElement("max", t.MaxScore.HasValue ? t.MaxScore.ToString() : String.Empty),
                                                                                                                                                  new XElement("min", t.MinScore.HasValue ? t.MinScore.ToString() : String.Empty)
                                                                                                                                                  ),
                                                                                                                                     new XElement("total_time", new AiccTime(t.TotalTime).ToString()),
                                                                                                                                     new XElement("lesson_mode", t.LessonMode),
                                                                                                                                     new XElement("exit", t.Exit),
                                                                                                                                     new XElement("session_time", t.SessionTime.HasValue ? new AiccTime(t.SessionTime.Value).ToString() : String.Empty)
                                                                                                                                     ),
                                                                                                                        new XElement("suspend_data", new XCData(t.SuspendData)),
                                                                                                                        new XElement("launch_data", new XCData(t.LaunchData)),
                                                                                                                        new XElement("comments", new XCData(t.Comments)),
                                                                                                                        new XElement("comments_from_lms", new XCData(t.CommentsFromLms)),
                                                                                                                        new XElement("objectives",
                                                                                                                                     new XElement("_count", t.Objectives.Count),
                                                                                                                                     t.Objectives.Select((o, i) => new XElement("_" + i, new XElement("id", o.Identifier),
                                                                                                                                                                                new XElement("score",
                                                                                                                                                                                             new XElement("raw", o.RawScore.HasValue ? o.RawScore.ToString() : String.Empty),
                                                                                                                                                                                             new XElement("max", o.MaxScore.HasValue ? o.MaxScore.ToString() : String.Empty),
                                                                                                                                                                                             new XElement("min", o.MinScore.HasValue ? o.MinScore.ToString() : String.Empty)
                                                                                                                                                                                             ),
                                                                                                                                                                                new XElement("status", o.Status)))
                                                                                                                                     ),
                                                                                                                        new XElement("student_data",
                                                                                                                                     new XElement("mastery_score", t.MasteryScore),
                                                                                                                                     new XElement("max_time_allowed", t.MaxTimeAllowed.HasValue ? new AiccTime(t.MaxTimeAllowed.Value).ToString() : String.Empty),
                                                                                                                                     new XElement("time_limit_action", t.TimeLimitAction)
                                                                                                                                     ),
                                                                                                                        new XElement("student_preference", //TODO: get these from somewhere
                                                                                                                                     new XElement("audio"),
                                                                                                                                     new XElement("language", "en-US"),
                                                                                                                                     new XElement("speed"),
                                                                                                                                     new XElement("text")
                                                                                                                                     ),
                                                                                                                        new XElement("interactions",
                                                                                                                                     new XElement("_count", "0")
                                                                                                                                     )
                                                                                                                        )))));

            if (!String.IsNullOrEmpty(contentModuleTracking.Bookmark))
            {
                xDoc.Root.Add(new XAttribute("Bookmark", contentModuleTracking.Bookmark));
            }

            //return xDoc.ToString();
            return(xDoc.ToString(SaveOptions.DisableFormatting));
        }