Ejemplo n.º 1
0
        public void WriteOnlySimpleCmiTest()
        {
            string[] cmiWriteOnlyTestCases = new string[]
            {
                "session_time"
            };

            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);

            for (int i = 0; i < cmiWriteOnlyTestCases.Length; i++)
            {
                try
                {
                    dataModel.GetValue(cmiWriteOnlyTestCases[i]);
                    Assert.IsTrue(false);
                }
                catch (CmiReadWriteOnlyException)
                {
                    Assert.IsTrue(true);
                }
                catch
                {
                    Assert.IsTrue(false);
                }
            }
        }
Ejemplo n.º 2
0
        public void ReadOnlyInteractionCorrectResponseCmiTest()
        {
            var cmiReadOnlyTestCases = new[] { new { Key = "interactions.0.correct_responses._count", Value = "5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = true } };

            for (int i = 0; i < cmiReadOnlyTestCases.Length; i++)
            {
                CmiDataModel dataModel = new CmiDataModel(sessionID, userID, cmiReadOnlyTestCases[i].IsSystem);
                try
                {
                    dataModel.SetValue(cmiReadOnlyTestCases[i].Key, cmiReadOnlyTestCases[i].Value);
                    Assert.IsTrue(false);
                }
                catch (Exception e)
                {
                    if (cmiReadOnlyTestCases[i].ExceptionType == e.GetType())
                    {
                        Assert.IsTrue(true);
                    }
                    else
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void InteractionCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);

            dataModel.SetValue("interactions.0.id", "test1");
            dataModel.SetValue("interactions.0.type", "choice");
            dataModel.SetValue("interactions.0.timestamp", "2003-07-25T03:00:00");
            dataModel.SetValue("interactions.0.weighting", "1,0");
            dataModel.SetValue("interactions.0.learner_response", "true");
            dataModel.SetValue("interactions.0.result", "010");
            dataModel.SetValue("interactions.0.latency", "PT5M");
            dataModel.SetValue("interactions.0.description", "Which of the following are red?");

            Assert.AreEqual(dataModel.GetValue("interactions.0.id"), "test1");
            Assert.AreEqual(dataModel.GetValue("interactions.0.type"), "choice");
            Assert.AreEqual(dataModel.GetValue("interactions.0.timestamp"), "2003-07-25T03:00:00");
            Assert.AreEqual(dataModel.GetValue("interactions.0.weighting"), "1,0");
            Assert.AreEqual(dataModel.GetValue("interactions.0.learner_response"), "true");
            Assert.AreEqual(dataModel.GetValue("interactions.0.result"), "010");
            Assert.AreEqual(dataModel.GetValue("interactions.0.latency"), "PT5M");
            Assert.AreEqual(dataModel.GetValue("interactions.0.description"), "Which of the following are red?");
            Assert.AreEqual(dataModel.GetValue("interactions._children"), "id,type,timestamp,weighting,result,latency,description,learner_response");

            //clearing database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 8; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVarsInteractions>(IDs);
        }
Ejemplo n.º 4
0
        public void GetCountInteractionCorrectResponseCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            dataModel.SetValue("interactions.0.correct_responses.0.pattern", "110");
            dataModel.SetValue("interactions.0.correct_responses.1.pattern", "010");
            Assert.AreEqual(dataModel.GetValue("interactions.0.correct_responses._count"), "2");
        }
Ejemplo n.º 5
0
        public void GetCountInteractionCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            dataModel.SetValue("interactions.0.id", "test1");
            dataModel.SetValue("interactions.1.type", "choice");
            Assert.AreEqual(dataModel.GetValue("interactions._count"), "2");
        }
Ejemplo n.º 6
0
    public API()
    {
        int LearnerSessionId = Convert.ToInt32(HttpContext.Current.Session["CurrentLearnerSessionId"].ToString());
        int UserId = ServerModel.User.Current.ID;

        CmiDM = new CmiDataModel(LearnerSessionId, UserId, false);
        LnuDM = new LnuDataModel();
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
Ejemplo n.º 7
0
    public API()
    {
        int LearnerSessionId = Convert.ToInt32(HttpContext.Current.Session["CurrentLearnerSessionId"].ToString());
        int UserId           = ServerModel.User.Current.ID;

        CmiDM = new CmiDataModel(LearnerSessionId, UserId, false);
        LnuDM = new LnuDataModel();
        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
Ejemplo n.º 8
0
        private void InitializeLearnerSession(int ItemId)
        {
            bool         isNew            = true;
            int          LearnerSessionId = 0;
            CmiDataModel CmiDM            = null;

            List <TblLearnerSessions> list = ServerModel.DB.Query <TblLearnerSessions>(
                new AndCondition(
                    new CompareCondition <int>(
                        DataObject.Schema.LearnerAttemptRef,
                        new ValueCondition <int>(learnerAttemptId),
                        COMPARE_KIND.EQUAL),
                    new CompareCondition <int>(
                        DataObject.Schema.ItemRef,
                        new ValueCondition <int>(ItemId),
                        COMPARE_KIND.EQUAL)
                    )
                );

            if (list.Count > 0)
            {
                LearnerSessionId = list[0].ID;

                CmiDM = new CmiDataModel(LearnerSessionId, ServerModel.User.Current.ID, true);

                string exitValue = CmiDM.GetValue("exit");

                if (exitValue == "" || exitValue == "suspend")
                {
                    CmiDM.SetValue("entry", "resume");
                    CmiDM.SetValue("credit", "credit");

                    isNew = false;
                }
            }

            if (isNew)
            {
                TblLearnerSessions t = new TblLearnerSessions
                {
                    LearnerAttemptRef = learnerAttemptId,
                    ItemRef           = ItemId
                };

                LearnerSessionId = ServerModel.DB.Insert <TblLearnerSessions>(t);

                CmiDM = new CmiDataModel(LearnerSessionId, ServerModel.User.Current.ID, true);

                CmiDM.SetValue("entry", "ab-initio");
                CmiDM.SetValue("credit", "credit");
            }

            HttpContext.Current.Session["CurrentLearnerSessionId"] = LearnerSessionId;
        }
Ejemplo n.º 9
0
        public void DefaultValuesCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
              Assert.AreEqual(dataModel.GetValue("completion_status"), "unknown");

              //clean database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 1; i++)
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVars>(IDs);
        }
Ejemplo n.º 10
0
        public void DefaultValuesCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            Assert.AreEqual(dataModel.GetValue("completion_status"), "unknown");

            //clean database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 1; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVars>(IDs);
        }
Ejemplo n.º 11
0
        public void InteractionCorrectResponseCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);

            dataModel.SetValue("interactions.0.correct_responses.0.pattern", "001");

            Assert.AreEqual(dataModel.GetValue("interactions.0.correct_responses.0.pattern"), "001");

            //clearing database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 1; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVarsInteractionCorrectResponses>(IDs);
        }
Ejemplo n.º 12
0
        public void SimpleCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            dataModel.SetValue("completion_status", "completed");
            dataModel.SetValue("credit", "credit");
            dataModel.SetValue("entry", "ab-initio");
            dataModel.SetValue("launch_data", "bob");
            dataModel.SetValue("location", "chkPt1.p3.f5");
            dataModel.SetValue("max_time_allowed", "105");
            dataModel.SetValue("mode", "browse");
            dataModel.SetValue("progress_measure", "0,5");
            dataModel.SetValue("scaled_passing_score", "0,5");
            dataModel.SetValue("success_status", "passed");
            dataModel.SetValue("suspend_data", "bob");
            dataModel.SetValue("time_limit_action", "continue,message");
            dataModel.SetValue("session_time", "PT1H5M");

            Assert.AreEqual(dataModel.GetValue("completion_status"), "completed");
            Assert.AreEqual(dataModel.GetValue("credit"), "credit");
            Assert.AreEqual(dataModel.GetValue("entry"), "ab-initio");
            Assert.AreEqual(dataModel.GetValue("launch_data"), "bob");
            Assert.AreEqual(dataModel.GetValue("location"), "chkPt1.p3.f5");
            Assert.AreEqual(dataModel.GetValue("max_time_allowed"), "105");
            Assert.AreEqual(dataModel.GetValue("mode"), "browse");
            Assert.AreEqual(dataModel.GetValue("progress_measure"), "0,5");
            Assert.AreEqual(dataModel.GetValue("scaled_passing_score"), "0,5");
            Assert.AreEqual(dataModel.GetValue("success_status"), "passed");
            Assert.AreEqual(dataModel.GetValue("suspend_data"), "bob");
            Assert.AreEqual(dataModel.GetValue("time_limit_action"), "continue,message");
            Assert.AreEqual(dataModel.GetValue("_version"), "1.0");
            Assert.AreEqual(dataModel.GetValue("_children"), "completion_status,credit,entry,exit,launch_data,learner_id,learner_name,location,max_time_allowed,mode,progress_measure,scaled_passing_score,success_status,suspend_data,time_limit_action,session_time,total_time");
            //Assert.AreEqual(dataModel.GetValue("total_time"), "1000");//not implemented, and as a result session_time isn't needed
            //Assert.AreEqual(dataModel.GetValue("learner_id"), userID);//?
            //Assert.AreEqual(dataModel.GetValue("learner_name"), "Santason");//?

            //clearing database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 13; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVars>(IDs);
        }
Ejemplo n.º 13
0
        public void MultipleLearnerSessionsSimpleCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            dataModel.SetValue("entry", "ab-initio");
            ServerModel.DB.Insert(currentSession);
            dataModel = new CmiDataModel(currentSession.ID, userID, true);
            dataModel.SetValue("entry", "resume");
            Assert.AreEqual(dataModel.GetValue("entry"), "resume");

            //clean database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 2; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVars>(IDs);
        }
Ejemplo n.º 14
0
        public void ValidationInteractionCmiTest()
        {
            string s1 = new string('a', 5000);
            string s2 = new string('a', 300);
            var    CmiValidationTestCases = new[] { new { Key = "interactions.0.id", Value = s1, ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.id", Value = "", ExceptionType = typeof(ArgumentException), IsSystem = false },
                                                    new { Key = "interactions.0.id", Value = "A9934_\\gdfgd%", ExceptionType = typeof(ArgumentException), IsSystem = false },
                                                    new { Key = "interactions.0.type", Value = "lol", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.timestamp", Value = "2203-07-25T03:00:00", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.timestamp", Value = "zz2003-07-25T03:00:00", ExceptionType = typeof(FormatException), IsSystem = false },
                                                    new { Key = "interactions.0.weighting", Value = "p105t", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.result", Value = "bob", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.result", Value = "NaN", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.description", Value = s2, ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false },
                                                    new { Key = "interactions.0.learner_response", Value = "NaN", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem = false }, };

            for (int i = 0; i < CmiValidationTestCases.Length; i++)
            {
                CmiDataModel dataModel = new CmiDataModel(sessionID, userID, CmiValidationTestCases[i].IsSystem);
                try
                {
                    dataModel.SetValue(CmiValidationTestCases[i].Key, CmiValidationTestCases[i].Value);
                    Assert.IsTrue(false);
                }
                catch (Exception e)
                {
                    if (CmiValidationTestCases[i].ExceptionType == e.GetType())
                    {
                        Assert.IsTrue(true);
                    }
                    else
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public void ReadOnlySimpleCmiTest()
        {
            var cmiReadOnlyTestCases = new[] { new { Key = "credit", Value = "credit", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "entry", Value = "ab-initio", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "launch_data", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "learner_id", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "learner_name", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "max_time_allowed", Value = "105", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "mode", Value = "review", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "scaled_passing_score", Value = "0,5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "time_limit_action", Value = "continue,message", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = false },
                                               new { Key = "_version", Value = "1,5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = true },
                                               new { Key = "_children", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = true },
                                               new { Key = "total_time", Value = "1000", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem = true } };

            for (int i = 0; i < cmiReadOnlyTestCases.Length; i++)
            {
                CmiDataModel dataModel = new CmiDataModel(sessionID, userID, cmiReadOnlyTestCases[i].IsSystem);
                try
                {
                    dataModel.SetValue(cmiReadOnlyTestCases[i].Key, cmiReadOnlyTestCases[i].Value);
                    Assert.IsTrue(false);
                }
                catch (Exception e)
                {
                    if (cmiReadOnlyTestCases[i].ExceptionType == e.GetType())
                    {
                        Assert.IsTrue(true);
                    }
                    else
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void ValidationSimpleCmiTest()
        {
            string s = new string('a', 1050);

            KeyValuePair <string, string>[] CmiValidationTestCases = new KeyValuePair <string, string>[]
            {
                new KeyValuePair <string, string>("credit", "lol"),
                new KeyValuePair <string, string>("entry", "lol"),
                new KeyValuePair <string, string>("completion_status", "lol"),
                new KeyValuePair <string, string>("location", s),
                new KeyValuePair <string, string>("mode", "lol"),
                new KeyValuePair <string, string>("progress_measure", "1,5"),
                new KeyValuePair <string, string>("scaled_passing_score", "1,5"),
                new KeyValuePair <string, string>("success_status", "lol"),
                new KeyValuePair <string, string>("time_limit_action", "lol"),
            };

            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);

            for (int i = 0; i < CmiValidationTestCases.Length; i++)
            {
                try
                {
                    dataModel.SetValue(CmiValidationTestCases[i].Key, CmiValidationTestCases[i].Value);
                    Assert.IsTrue(false);
                }
                catch (ArgumentOutOfRangeException)
                {
                    Assert.IsTrue(true);
                }
                catch
                {
                    Assert.IsTrue(false);
                }
            }
        }
Ejemplo n.º 17
0
        public void MultipleLearnerSessionsSimpleCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
              dataModel.SetValue("entry", "ab-initio");
              ServerModel.DB.Insert(currentSession);
              dataModel = new CmiDataModel(currentSession.ID, userID, true);
              dataModel.SetValue("entry", "resume");
              Assert.AreEqual(dataModel.GetValue("entry"), "resume");

              //clean database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 2; i++)
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVars>(IDs);
        }
Ejemplo n.º 18
0
        public void InteractionCorrectResponseCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);
              dataModel.SetValue("interactions.0.correct_responses.0.pattern", "001");

              Assert.AreEqual(dataModel.GetValue("interactions.0.correct_responses.0.pattern"), "001");

              //clearing database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 1; i++)
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVarsInteractionCorrectResponses>(IDs);
        }
Ejemplo n.º 19
0
        public void InteractionCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);
              dataModel.SetValue("interactions.0.id", "test1");
              dataModel.SetValue("interactions.0.type", "choice");
              dataModel.SetValue("interactions.0.timestamp", "2003-07-25T03:00:00");
              dataModel.SetValue("interactions.0.weighting", "1,0");
              dataModel.SetValue("interactions.0.learner_response", "true");
              dataModel.SetValue("interactions.0.result", "010");
              dataModel.SetValue("interactions.0.latency", "PT5M");
              dataModel.SetValue("interactions.0.description", "Which of the following are red?");

              Assert.AreEqual(dataModel.GetValue("interactions.0.id"), "test1");
              Assert.AreEqual(dataModel.GetValue("interactions.0.type"), "choice");
              Assert.AreEqual(dataModel.GetValue("interactions.0.timestamp"), "2003-07-25T03:00:00");
              Assert.AreEqual(dataModel.GetValue("interactions.0.weighting"), "1,0");
              Assert.AreEqual(dataModel.GetValue("interactions.0.learner_response"), "true");
              Assert.AreEqual(dataModel.GetValue("interactions.0.result"), "010");
              Assert.AreEqual(dataModel.GetValue("interactions.0.latency"), "PT5M");
              Assert.AreEqual(dataModel.GetValue("interactions.0.description"), "Which of the following are red?");
              Assert.AreEqual(dataModel.GetValue("interactions._children"), "id,type,timestamp,weighting,result,latency,description,learner_response");

              //clearing database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 8; i++)
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVarsInteractions>(IDs);
        }
Ejemplo n.º 20
0
 public void GetCountInteractionCorrectResponseCmiTest()
 {
     CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
       dataModel.SetValue("interactions.0.correct_responses.0.pattern", "110");
       dataModel.SetValue("interactions.0.correct_responses.1.pattern", "010");
       Assert.AreEqual(dataModel.GetValue("interactions.0.correct_responses._count"), "2");
 }
Ejemplo n.º 21
0
        public void SimpleCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
              dataModel.SetValue("completion_status", "completed");
              dataModel.SetValue("credit", "credit");
              dataModel.SetValue("entry", "ab-initio");
              dataModel.SetValue("launch_data", "bob");
              dataModel.SetValue("location", "chkPt1.p3.f5");
              dataModel.SetValue("max_time_allowed", "105");
              dataModel.SetValue("mode", "browse");
              dataModel.SetValue("progress_measure", "0,5");
              dataModel.SetValue("scaled_passing_score", "0,5");
              dataModel.SetValue("success_status", "passed");
              dataModel.SetValue("suspend_data", "bob");
              dataModel.SetValue("time_limit_action", "continue,message");
              dataModel.SetValue("session_time", "PT1H5M");

              Assert.AreEqual(dataModel.GetValue("completion_status"), "completed");
              Assert.AreEqual(dataModel.GetValue("credit"), "credit");
              Assert.AreEqual(dataModel.GetValue("entry"), "ab-initio");
              Assert.AreEqual(dataModel.GetValue("launch_data"), "bob");
              Assert.AreEqual(dataModel.GetValue("location"), "chkPt1.p3.f5");
              Assert.AreEqual(dataModel.GetValue("max_time_allowed"), "105");
              Assert.AreEqual(dataModel.GetValue("mode"), "browse");
              Assert.AreEqual(dataModel.GetValue("progress_measure"), "0,5");
              Assert.AreEqual(dataModel.GetValue("scaled_passing_score"), "0,5");
              Assert.AreEqual(dataModel.GetValue("success_status"), "passed");
              Assert.AreEqual(dataModel.GetValue("suspend_data"), "bob");
              Assert.AreEqual(dataModel.GetValue("time_limit_action"), "continue,message");
              Assert.AreEqual(dataModel.GetValue("_version"), "1.0");
              Assert.AreEqual(dataModel.GetValue("_children"), "completion_status,credit,entry,exit,launch_data,learner_id,learner_name,location,max_time_allowed,mode,progress_measure,scaled_passing_score,success_status,suspend_data,time_limit_action,session_time,total_time");
              //Assert.AreEqual(dataModel.GetValue("total_time"), "1000");//not implemented, and as a result session_time isn't needed
              //Assert.AreEqual(dataModel.GetValue("learner_id"), userID);//?
              //Assert.AreEqual(dataModel.GetValue("learner_name"), "Santason");//?

              //clearing database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 13;i++ )
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVars>(IDs);
        }
Ejemplo n.º 22
0
        public void ValidationInteractionCmiTest()
        {
            string s1 = new string('a', 5000);
              string s2 = new string('a', 300);
              var CmiValidationTestCases = new[] { new { Key = "interactions.0.id", Value = s1, ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false},
                                           new { Key = "interactions.0.id", Value = "", ExceptionType = typeof(ArgumentException), IsSystem=false },
                                           new { Key = "interactions.0.id", Value = "A9934_\\gdfgd%", ExceptionType = typeof(ArgumentException), IsSystem=false },
                                           new { Key = "interactions.0.type", Value = "lol", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.timestamp", Value = "2203-07-25T03:00:00", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.timestamp", Value = "zz2003-07-25T03:00:00", ExceptionType = typeof(FormatException), IsSystem=false },
                                           new { Key = "interactions.0.weighting", Value = "p105t", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.result", Value = "bob", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.result", Value = "NaN", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.description", Value = s2, ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
                                           new { Key = "interactions.0.learner_response", Value = "NaN", ExceptionType = typeof(ArgumentOutOfRangeException), IsSystem=false },
              };

              for (int i = 0; i < CmiValidationTestCases.Length; i++)
              {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, CmiValidationTestCases[i].IsSystem);
            try
            {
              dataModel.SetValue(CmiValidationTestCases[i].Key, CmiValidationTestCases[i].Value);
              Assert.IsTrue(false);
            }
            catch (Exception e)
            {
              if(CmiValidationTestCases[i].ExceptionType==e.GetType())
              {
            Assert.IsTrue(true);
              }
              else
              {
            Assert.IsTrue(false);
              }
            }
              }
        }
Ejemplo n.º 23
0
        private void fillStatisticTable()
        {
            IList <TblUsers> ilistusers;

            ilistusers = TeacherHelper.GetStudentsOfGroup(group);
            if (UserId > 0)
            {
                user = ServerModel.DB.Load <TblUsers>(UserId);
                ilistusers.Clear();
                ilistusers.Add(user);
            }
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();

            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);

            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    headerCell      = new TableHeaderCell();
                    headerCell.Text = theme.Name;
                    headerRow.Cells.Add(headerCell);
                }
            }
            headerCell      = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);

            StatisticTable.Rows.Add(headerRow);
            foreach (TblUsers student in ilistusers)
            {
                var       studentRow  = new TableRow();
                TableCell studentCell = new TableHeaderCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Controls.Add(new HyperLink
                {
                    Text        = student.DisplayName,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowGraphController
                    {
                        GroupID      = GroupID,
                        CurriculumID = curriculum.ID,
                        UserId       = student.ID,
                        BackUrl      = RawUrl
                    })
                });


                studentRow.Cells.Add(studentCell);

                double pasedCurriculum = 0;
                double totalCurriculum = 0;
                foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
                {
                    foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                    {
                        double           result       = 0;
                        double           totalresult  = 0;
                        int              learnercount = TeacherHelper.GetLastIndexOfAttempts(student.ID, theme.ID);
                        TblOrganizations organization;
                        organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                        foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                        {
                            totalresult += Convert.ToDouble(items.Rank);
                        }

                        foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                        {
                            if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                            {
                                foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                {
                                    CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                    List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                    for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                    {
                                        for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                        {
                                            if (interactionsCollection[j].Name == "result")
                                            {
                                                TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                                if (interactionsCollection[j].Value == "correct")
                                                {
                                                    result += Convert.ToDouble(itm.Rank);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }



                        string attmpt = "";
                        if (learnercount > 0)
                        {
                            attmpt = "(" + learnercount.ToString() + " attempt )";
                        }
                        else if (learnercount == 0)
                        {
                            attmpt = "";
                        }

                        studentCell = new TableCell {
                            HorizontalAlign = HorizontalAlign.Center
                        };
                        studentCell.Controls.Add(new HyperLink
                        {
                            Text        = result + "/" + totalresult + attmpt,
                            NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new ThemeResultController
                            {
                                BackUrl          = string.Empty,
                                LearnerAttemptId = TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID),
                            })
                        });

                        if (learnercount == 0)
                        {
                            studentCell.Enabled   = false;
                            studentCell.BackColor = Color.Yellow;
                        }
                        else if (learnercount > 0)
                        {
                            studentCell.BackColor = Color.YellowGreen;
                        }

                        pasedCurriculum += result;
                        totalCurriculum += totalresult;
                        studentRow.Cells.Add(studentCell);
                    }
                }

                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text            = pasedCurriculum + "/" + totalCurriculum
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                double temp_total;
                if (totalCurriculum != 0)
                {
                    temp_total = pasedCurriculum / totalCurriculum * 100;
                }
                else
                {
                    temp_total = 0;
                }
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);

                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value          = noStudents;
            }
        }
Ejemplo n.º 24
0
        public void GetCollectionCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);

            dataModel.SetValue("completion_status", "completed");
            dataModel.SetValue("credit", "credit");
            dataModel.SetValue("entry", "ab-initio");
            dataModel.SetValue("launch_data", "bob");
            dataModel.SetValue("interactions.0.id", "test1");
            dataModel.SetValue("interactions.0.type", "choice");
            dataModel.SetValue("interactions.1.type", "long-fill-in");
            dataModel.SetValue("interactions.1.weighting", "1,0");
            dataModel.SetValue("interactions.0.correct_responses.0.pattern", "110");
            dataModel.SetValue("interactions.1.correct_responses.0.pattern", "011");

            List <TblVars>             collection1 = dataModel.GetCollection <TblVars>("*");
            List <TblVarsInteractions> collection2 = dataModel.GetCollection <TblVarsInteractions>("interactions.*.*");
            List <TblVarsInteractions> collection3 = dataModel.GetCollection <TblVarsInteractions>("interactions.1.*");
            List <TblVarsInteractionCorrectResponses> collection4 = dataModel.GetCollection <TblVarsInteractionCorrectResponses>("interactions.*.correct_responses.*");
            List <TblVarsInteractionCorrectResponses> collection5 = dataModel.GetCollection <TblVarsInteractionCorrectResponses>("interactions.1.correct_responses.*");

            Assert.AreEqual(collection1[0].Name, "completion_status");
            Assert.AreEqual(collection1[1].Name, "credit");
            Assert.AreEqual(collection1[2].Name, "entry");
            Assert.AreEqual(collection1[3].Name, "launch_data");
            Assert.AreEqual(collection1[0].Value, "completed");
            Assert.AreEqual(collection1[1].Value, "credit");
            Assert.AreEqual(collection1[2].Value, "ab-initio");
            Assert.AreEqual(collection1[3].Value, "bob");

            Assert.AreEqual(collection2[0].Name, "id");
            Assert.AreEqual(collection2[1].Name, "type");
            Assert.AreEqual(collection2[2].Name, "type");
            Assert.AreEqual(collection2[3].Name, "weighting");
            Assert.AreEqual(collection2[0].Value, "test1");
            Assert.AreEqual(collection2[1].Value, "choice");
            Assert.AreEqual(collection2[2].Value, "long-fill-in");
            Assert.AreEqual(collection2[3].Value, "1,0");

            Assert.AreEqual(collection3[0].Name, "type");
            Assert.AreEqual(collection3[1].Name, "weighting");
            Assert.AreEqual(collection3[0].Value, "long-fill-in");
            Assert.AreEqual(collection3[1].Value, "1,0");

            Assert.AreEqual(collection4[0].Name, "pattern");
            Assert.AreEqual(collection4[1].Name, "pattern");
            Assert.AreEqual(collection4[0].Value, "110");
            Assert.AreEqual(collection4[1].Value, "011");

            Assert.AreEqual(collection5[0].Name, "pattern");
            Assert.AreEqual(collection5[0].Value, "011");

            //clean database
            List <int> IDs = new List <int>();

            for (int i = 1; i <= 4; i++)
            {
                IDs.Add(i);
            }
            ServerModel.DB.Delete <TblVars>(IDs);
            ServerModel.DB.Delete <TblVarsInteractions>(IDs);
            ServerModel.DB.Delete <TblVarsInteractionCorrectResponses>(IDs);
        }
Ejemplo n.º 25
0
        private void fillStatisticTable()
        {
            IList<TblUsers> ilistusers;
            ilistusers = TeacherHelper.GetStudentsOfGroup(group);
            if (UserId > 0)
            {
                user = ServerModel.DB.Load<TblUsers>(UserId);
                ilistusers.Clear();
                ilistusers.Add(user);
            }
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();
            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);

            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    headerCell = new TableHeaderCell();
                    headerCell.Text = theme.Name;
                    headerRow.Cells.Add(headerCell);
                }
            }
            headerCell = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);

            StatisticTable.Rows.Add(headerRow);
            foreach (TblUsers student in ilistusers)
            {
                var studentRow = new TableRow();
                TableCell studentCell = new TableHeaderCell { HorizontalAlign = HorizontalAlign.Center };
                studentCell.Controls.Add(new HyperLink
                {
                    Text = student.DisplayName,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowGraphController
                    {
                        GroupID = GroupID,
                        CurriculumID = curriculum.ID,
                        UserId = student.ID,
                        BackUrl = RawUrl
                    })
                });


                studentRow.Cells.Add(studentCell);

                double pasedCurriculum = 0;
                double totalCurriculum = 0;
                foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
                {
                    foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                    {
                        double result = 0;
                        double totalresult = 0;
                        int learnercount = TeacherHelper.GetLastIndexOfAttempts(student.ID, theme.ID);
                        TblOrganizations organization;
                        organization = ServerModel.DB.Load<TblOrganizations>(theme.OrganizationRef);
                        foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                        {
                            totalresult += Convert.ToDouble(items.Rank);
                        }

                        foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                        {
                            if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))

                                foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                {
                                    CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                    List<TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection<TblVarsInteractions>("interactions.*.*");

                                    for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                    {
                                        for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                        {
                                            if (interactionsCollection[j].Name == "result")
                                            {
                                                TblItems itm = ServerModel.DB.Load<TblItems>(session.ItemRef);
                                                if (interactionsCollection[j].Value == "correct") result += Convert.ToDouble(itm.Rank);
                                            }
                                        }

                                    }

                                }
                        }



                        string attmpt = "";
                        if (learnercount > 0)
                        {
                            attmpt = "(" + learnercount.ToString() + " attempt )";
                        }
                        else if (learnercount == 0)
                        {
                            attmpt = "";
                        }

                        studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };
                        studentCell.Controls.Add(new HyperLink
                        {
                            Text = result + "/" + totalresult + attmpt,
                            NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new ThemeResultController
                            {
                                BackUrl = string.Empty,
                                LearnerAttemptId = TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID),

                            })
                        });

                        if (learnercount == 0)
                        {
                            studentCell.Enabled = false;
                            studentCell.BackColor = Color.Yellow;
                        }
                        else if (learnercount > 0) studentCell.BackColor = Color.YellowGreen;

                        pasedCurriculum += result;
                        totalCurriculum += totalresult;
                        studentRow.Cells.Add(studentCell);

                    }
                }

                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text = pasedCurriculum + "/" + totalCurriculum
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };
                double temp_total;
                if (totalCurriculum != 0)
                    temp_total = pasedCurriculum / totalCurriculum * 100;
                else temp_total = 0;
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);

                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value = noStudents;
            }



        }
Ejemplo n.º 26
0
        public void ReadOnlyInteractionCorrectResponseCmiTest()
        {
            var cmiReadOnlyTestCases = new[] { new { Key = "interactions.0.correct_responses._count", Value = "5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=true }
              };

              for (int i = 0; i < cmiReadOnlyTestCases.Length; i++)
              {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, cmiReadOnlyTestCases[i].IsSystem);
            try
            {
              dataModel.SetValue(cmiReadOnlyTestCases[i].Key, cmiReadOnlyTestCases[i].Value);
              Assert.IsTrue(false);
            }
            catch (Exception e)
            {
              if (cmiReadOnlyTestCases[i].ExceptionType == e.GetType())
              {
            Assert.IsTrue(true);
              }
              else
              {
            Assert.IsTrue(false);
              }
            }
              }
        }
Ejemplo n.º 27
0
        public void WriteOnlySimpleCmiTest()
        {
            string[] cmiWriteOnlyTestCases = new string[]
              {
            "session_time"
              };

              CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);
              for (int i = 0; i < cmiWriteOnlyTestCases.Length; i++)
              {
            try
            {
              dataModel.GetValue(cmiWriteOnlyTestCases[i]);
              Assert.IsTrue(false);
            }
            catch (CmiReadWriteOnlyException)
            {
              Assert.IsTrue(true);
            }
            catch
            {
              Assert.IsTrue(false);
            }
              }
        }
Ejemplo n.º 28
0
        public void ReadOnlySimpleCmiTest()
        {
            var cmiReadOnlyTestCases = new[] { new { Key = "credit", Value = "credit", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false},
                                         new { Key = "entry", Value = "ab-initio", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "launch_data", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "learner_id", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "learner_name", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "max_time_allowed", Value = "105", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "mode", Value = "review", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "scaled_passing_score", Value = "0,5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "time_limit_action", Value = "continue,message", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=false },
                                         new { Key = "_version", Value = "1,5", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=true },
                                         new { Key = "_children", Value = "bob", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=true },
                                         new { Key = "total_time", Value = "1000", ExceptionType = typeof(CmiReadWriteOnlyException), IsSystem=true }
              };

              for (int i = 0; i < cmiReadOnlyTestCases.Length; i++)
              {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, cmiReadOnlyTestCases[i].IsSystem);
            try
            {
              dataModel.SetValue(cmiReadOnlyTestCases[i].Key, cmiReadOnlyTestCases[i].Value);
              Assert.IsTrue(false);
            }
            catch (Exception e)
            {
              if (cmiReadOnlyTestCases[i].ExceptionType == e.GetType())
              {
            Assert.IsTrue(true);
              }
              else
              {
            Assert.IsTrue(false);
              }
            }
              }
        }
Ejemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var currentUser = ServerModel.User.Current;

        if (currentUser != null)
        {
            SetHeaderText(Theme.Name, CurriculumnName, StageName, User.DisplayName);
            //Dictionary<int, TableRow> rows = new Dictionary<int, TableRow>();
            List <TableRow> rows = new List <TableRow>();

            foreach (TblLearnerSessions learnerSession in LearnerSessions)
            {
                //List<TblVarsInteractions> userResults = StatisticManager.GetStatisticForLearnerSession(learnerSession.ID);
                TblItems item = ServerModel.DB.Load <TblItems>(learnerSession.ItemRef);

                string correctAnswer = null;
                string userAnswer    = null;
                string result        = null;

                CmiDataModel cmiDataModel = new CmiDataModel(learnerSession.ID, ServerModel.User.Current.ID, false);
                List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");
                List <TblVarsInteractionCorrectResponses> interactionCorrectResponsesCollection = cmiDataModel.GetCollection <TblVarsInteractionCorrectResponses>("interactions.*.correct_responses.*");
                int count = int.Parse(cmiDataModel.GetValue("interactions._count"));

                for (int i = 0, j = 0; i < count; i++)
                {
                    if (interactionCorrectResponsesCollection[i].Value != null)
                    {
                        correctAnswer = interactionCorrectResponsesCollection[i].Value;
                    }
                    else
                    {
                        continue;
                    }
                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                    {
                        if (interactionsCollection[j].Name == "learner_response")
                        {
                            userAnswer = interactionsCollection[j].Value;
                        }
                        else if (interactionsCollection[j].Name == "result")
                        {
                            result = interactionsCollection[j].Value;
                        }
                    }

                    var row = new TableRow();
                    row.Cells.Add(new TableCell {
                        Text = item.Title
                    });
                    row.Cells.Add(new TableCell {
                        Text = userAnswer
                    });
                    row.Cells.Add(new TableCell {
                        Text = correctAnswer
                    });
                    row.Cells.Add(new TableCell {
                        Text = result
                    });

                    rows.Add(row);
                }

                /*for (int i = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count"));i++)
                 * {
                 * correctAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.correct_responses.0.pattern", i));
                 * userAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.learner_response", i));
                 * result = cmiDataModel.GetValue(String.Format("interactions.{0}.result", i));
                 *
                 * if (correctAnswer == null)
                 * {
                 *  continue;
                 * }
                 *
                 * var row = new TableRow();
                 * row.Cells.Add(new TableCell { Text = item.Title });
                 * row.Cells.Add(new TableCell { Text = userAnswer });
                 * row.Cells.Add(new TableCell { Text = correctAnswer });
                 * row.Cells.Add(new TableCell { Text = result });
                 *
                 * rows.Add(row);
                 * }*/
            }

            foreach (TableRow row in rows)
            {
                _resultTable.Rows.Add(row);
            }
        }
    }
Ejemplo n.º 30
0
        public void fillStatistic()
        {
            double totalstudntresoult = 0;
            double totalstagerank = 0;
            user = ServerModel.DB.Load<TblUsers>(UserId);
            curriculum = ServerModel.DB.Load<TblCurriculums>(CurriculumID);
            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {

                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    double result = 0; Name_Stage.Add(theme.Name);
                    double totalresult = 0;
                    int learnercount = TeacherHelper.GetLastIndexOfAttempts(user.ID, theme.ID);
                    TblOrganizations organization;
                    organization = ServerModel.DB.Load<TblOrganizations>(theme.OrganizationRef);
                    foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                    {
                        totalresult += Convert.ToDouble(items.Rank);
                    }

                    foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                    {
                        if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(user.ID, theme.ID))

                            foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                            {
                                CmiDataModel cmiDataModel = new CmiDataModel(session.ID, user.ID, false);
                                List<TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection<TblVarsInteractions>("interactions.*.*");

                                for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                {
                                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                    {
                                        if (interactionsCollection[j].Name == "result")
                                        {
                                            TblItems itm = ServerModel.DB.Load<TblItems>(session.ItemRef);
                                            if (interactionsCollection[j].Value == "correct") result += Convert.ToDouble(itm.Rank);
                                        }
                                    }

                                }

                            }
                    }
                    totalstudntresoult += result;
                    totalstagerank += totalresult;
                    Student_Stage_Count.Add(result);
                    Total_Stage_Count.Add(totalresult);
                }
            }

            Name_Stage.Add("Total");
            Student_Stage_Count.Add(totalstudntresoult);
            Total_Stage_Count.Add(totalstagerank);


            Saveto_Excel_Click();
        }
        private void fillStatisticTable()
        {
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();
            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);


            foreach (TblCurriculums curr in curriculums)
            {
                headerCell = new TableHeaderCell { HorizontalAlign = HorizontalAlign.Center };


                headerCell.Controls.Add(new HyperLink
                {
                    Text = curr.Name,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                    {
                        GroupID = GroupID,
                        CurriculumID = curr.ID,
                        BackUrl = RawUrl
                    })
                });
                headerRow.Cells.Add(headerCell);
            }

            headerCell = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);


            StatisticTable.Rows.Add(headerRow);

            foreach (TblUsers student in TeacherHelper.GetStudentsOfGroup(group))
            {
                var studentRow = new TableRow();
                TableCell studentCell = new TableHeaderCell { Text = student.DisplayName };

                studentRow.Cells.Add(studentCell);

                double pasedCurriculums = 0;
                double totalCurriculums = 0;
                foreach (TblCurriculums curr in curriculums)
                {
                    double pasedCurriculum = 0;
                    double totalCurriculum = 0;
                    foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curr))
                    {
                        foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                        {
                            double result = 0;
                            double totalresult = 0;
                            bool islearnerattempt = false;
                            TblOrganizations organization;
                            organization = ServerModel.DB.Load<TblOrganizations>(theme.OrganizationRef);
                            foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                            {
                                totalresult += Convert.ToDouble(items.Rank);
                            }
                            foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                            {
                                if (attempt != null) islearnerattempt = true;
                                if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                                    foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                    {

                                        CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                        List<TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection<TblVarsInteractions>("interactions.*.*");

                                        for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                        {
                                           
                                            for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                            {
                                                if (interactionsCollection[j].Name == "result")
                                                {
                                                    TblItems itm = ServerModel.DB.Load<TblItems>(session.ItemRef);
                                                    if (interactionsCollection[j].Value == "correct") result += Convert.ToDouble(itm.Rank);
                                                }
                                            }

                                        }




                                    }
                            }
                            pasedCurriculum += result;
                            totalCurriculum += totalresult;
                        }
                    }
                    studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };

                    studentCell.Controls.Add(new HyperLink
                    {
                        Text = pasedCurriculum + "/" + totalCurriculum,
                        NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                        {
                            GroupID = GroupID,
                            CurriculumID = curr.ID,
                            UserId = student.ID,
                            BackUrl = RawUrl
                        })
                    });
                    studentRow.Cells.Add(studentCell);

                    pasedCurriculums += pasedCurriculum;
                    totalCurriculums += totalCurriculum;


                }
                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text = pasedCurriculums + "/" + totalCurriculums
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };
                double temp_total;
                if (totalCurriculums != 0)
                    temp_total = pasedCurriculums / totalCurriculums * 100;
                else temp_total = 0;
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell { HorizontalAlign = HorizontalAlign.Center };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);
                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
                StatisticTable.HorizontalAlign = HorizontalAlign.Center;
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value = noStudents;
            }
        }
Ejemplo n.º 32
0
        public void ValidationSimpleCmiTest()
        {
            string s = new string('a',1050);
              KeyValuePair<string, string>[] CmiValidationTestCases = new KeyValuePair<string, string>[]
              {
            new KeyValuePair<string, string>("credit", "lol"),
            new KeyValuePair<string, string>("entry", "lol"),
            new KeyValuePair<string, string>("completion_status", "lol"),
            new KeyValuePair<string, string>("location", s),
            new KeyValuePair<string, string>("mode", "lol"),
            new KeyValuePair<string, string>("progress_measure", "1,5"),
            new KeyValuePair<string, string>("scaled_passing_score", "1,5"),
            new KeyValuePair<string, string>("success_status", "lol"),
            new KeyValuePair<string, string>("time_limit_action", "lol"),
              };

              CmiDataModel dataModel = new CmiDataModel(sessionID, userID, false);
              for (int i = 0; i < CmiValidationTestCases.Length; i++)
              {
            try
            {
              dataModel.SetValue(CmiValidationTestCases[i].Key, CmiValidationTestCases[i].Value);
              Assert.IsTrue(false);
            }
            catch (ArgumentOutOfRangeException)
            {
              Assert.IsTrue(true);
            }
            catch
            {
              Assert.IsTrue(false);
            }
              }
        }
Ejemplo n.º 33
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var currentUser = ServerModel.User.Current;
        
        if (currentUser != null)
        {
            SetHeaderText(Theme.Name, CurriculumnName, StageName, User.DisplayName);
            //Dictionary<int, TableRow> rows = new Dictionary<int, TableRow>();
            List<TableRow> rows = new List<TableRow>();

            foreach (TblLearnerSessions learnerSession in LearnerSessions)
            {
                //List<TblVarsInteractions> userResults = StatisticManager.GetStatisticForLearnerSession(learnerSession.ID);
                TblItems item = ServerModel.DB.Load<TblItems>(learnerSession.ItemRef);
                
                string correctAnswer = null;
                string userAnswer = null;
                string result = null;

                CmiDataModel cmiDataModel = new CmiDataModel(learnerSession.ID, ServerModel.User.Current.ID, false);
                List<TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection<TblVarsInteractions>("interactions.*.*");
                List<TblVarsInteractionCorrectResponses> interactionCorrectResponsesCollection = cmiDataModel.GetCollection<TblVarsInteractionCorrectResponses>("interactions.*.correct_responses.*");
                int count=int.Parse(cmiDataModel.GetValue("interactions._count"));

                for (int i = 0, j = 0; i < count; i++)
                {
                  if (interactionCorrectResponsesCollection[i].Value!=null)
                  {
                    correctAnswer = interactionCorrectResponsesCollection[i].Value;
                  }
                  else
                  {
                    continue;
                  }
                  for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                  {
                    if (interactionsCollection[j].Name == "learner_response")
                    {
                      userAnswer = interactionsCollection[j].Value;
                    }
                    else if (interactionsCollection[j].Name == "result")
                    {
                      result = interactionsCollection[j].Value;
                    }
                  }

                  var row = new TableRow();
                  row.Cells.Add(new TableCell { Text = item.Title });
                  row.Cells.Add(new TableCell { Text = userAnswer });
                  row.Cells.Add(new TableCell { Text = correctAnswer });
                  row.Cells.Add(new TableCell { Text = result });

                  rows.Add(row);
                }
                /*for (int i = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count"));i++)
                {
                  correctAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.correct_responses.0.pattern", i));
                  userAnswer = cmiDataModel.GetValue(String.Format("interactions.{0}.learner_response", i));
                  result = cmiDataModel.GetValue(String.Format("interactions.{0}.result", i));

                  if (correctAnswer == null)
                  {
                    continue;
                  }

                  var row = new TableRow();
                  row.Cells.Add(new TableCell { Text = item.Title });
                  row.Cells.Add(new TableCell { Text = userAnswer });
                  row.Cells.Add(new TableCell { Text = correctAnswer });
                  row.Cells.Add(new TableCell { Text = result });

                  rows.Add(row);
                }*/
            }

            foreach(TableRow row in rows)
            {
              _resultTable.Rows.Add(row);
            }
        }
    }
Ejemplo n.º 34
0
        public void GetCollectionCmiTest()
        {
            CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
              dataModel.SetValue("completion_status", "completed");
              dataModel.SetValue("credit", "credit");
              dataModel.SetValue("entry", "ab-initio");
              dataModel.SetValue("launch_data", "bob");
              dataModel.SetValue("interactions.0.id", "test1");
              dataModel.SetValue("interactions.0.type", "choice");
              dataModel.SetValue("interactions.1.type", "long-fill-in");
              dataModel.SetValue("interactions.1.weighting", "1,0");
              dataModel.SetValue("interactions.0.correct_responses.0.pattern", "110");
              dataModel.SetValue("interactions.1.correct_responses.0.pattern", "011");

              List<TblVars> collection1 = dataModel.GetCollection<TblVars>("*");
              List<TblVarsInteractions> collection2 = dataModel.GetCollection<TblVarsInteractions>("interactions.*.*");
              List<TblVarsInteractions> collection3 = dataModel.GetCollection<TblVarsInteractions>("interactions.1.*");
              List<TblVarsInteractionCorrectResponses> collection4 = dataModel.GetCollection<TblVarsInteractionCorrectResponses>("interactions.*.correct_responses.*");
              List<TblVarsInteractionCorrectResponses> collection5 = dataModel.GetCollection<TblVarsInteractionCorrectResponses>("interactions.1.correct_responses.*");

              Assert.AreEqual(collection1[0].Name, "completion_status");
              Assert.AreEqual(collection1[1].Name, "credit");
              Assert.AreEqual(collection1[2].Name, "entry");
              Assert.AreEqual(collection1[3].Name, "launch_data");
              Assert.AreEqual(collection1[0].Value, "completed");
              Assert.AreEqual(collection1[1].Value, "credit");
              Assert.AreEqual(collection1[2].Value, "ab-initio");
              Assert.AreEqual(collection1[3].Value, "bob");

              Assert.AreEqual(collection2[0].Name, "id");
              Assert.AreEqual(collection2[1].Name, "type");
              Assert.AreEqual(collection2[2].Name, "type");
              Assert.AreEqual(collection2[3].Name, "weighting");
              Assert.AreEqual(collection2[0].Value, "test1");
              Assert.AreEqual(collection2[1].Value, "choice");
              Assert.AreEqual(collection2[2].Value, "long-fill-in");
              Assert.AreEqual(collection2[3].Value, "1,0");

              Assert.AreEqual(collection3[0].Name, "type");
              Assert.AreEqual(collection3[1].Name, "weighting");
              Assert.AreEqual(collection3[0].Value, "long-fill-in");
              Assert.AreEqual(collection3[1].Value, "1,0");

              Assert.AreEqual(collection4[0].Name, "pattern");
              Assert.AreEqual(collection4[1].Name, "pattern");
              Assert.AreEqual(collection4[0].Value, "110");
              Assert.AreEqual(collection4[1].Value, "011");

              Assert.AreEqual(collection5[0].Name, "pattern");
              Assert.AreEqual(collection5[0].Value, "011");

              //clean database
              List<int> IDs = new List<int>();
              for (int i = 1; i <= 4; i++)
              {
            IDs.Add(i);
              }
              ServerModel.DB.Delete<TblVars>(IDs);
              ServerModel.DB.Delete<TblVarsInteractions>(IDs);
              ServerModel.DB.Delete<TblVarsInteractionCorrectResponses>(IDs);
        }
Ejemplo n.º 35
0
        private void fillStatisticTable()
        {
            StatisticTable.Rows.Clear();

            TableHeaderRow headerRow = new TableHeaderRow();

            TableHeaderCell headerCell = new TableHeaderCell();

            headerCell.Text = studentStr;
            headerRow.Cells.Add(headerCell);


            foreach (TblCurriculums curr in curriculums)
            {
                headerCell = new TableHeaderCell {
                    HorizontalAlign = HorizontalAlign.Center
                };


                headerCell.Controls.Add(new HyperLink
                {
                    Text        = curr.Name,
                    NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                    {
                        GroupID      = GroupID,
                        CurriculumID = curr.ID,
                        BackUrl      = RawUrl
                    })
                });
                headerRow.Cells.Add(headerCell);
            }

            headerCell      = new TableHeaderCell();
            headerCell.Text = totalStr;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = Translations.StatisticShowController_fillStatisticTable_Percent;
            headerRow.Cells.Add(headerCell);

            headerCell      = new TableHeaderCell();
            headerCell.Text = "ECTS";
            headerRow.Cells.Add(headerCell);


            StatisticTable.Rows.Add(headerRow);

            foreach (TblUsers student in TeacherHelper.GetStudentsOfGroup(group))
            {
                var       studentRow  = new TableRow();
                TableCell studentCell = new TableHeaderCell {
                    Text = student.DisplayName
                };

                studentRow.Cells.Add(studentCell);

                double pasedCurriculums = 0;
                double totalCurriculums = 0;
                foreach (TblCurriculums curr in curriculums)
                {
                    double pasedCurriculum = 0;
                    double totalCurriculum = 0;
                    foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curr))
                    {
                        foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                        {
                            double           result           = 0;
                            double           totalresult      = 0;
                            bool             islearnerattempt = false;
                            TblOrganizations organization;
                            organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                            foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                            {
                                totalresult += Convert.ToDouble(items.Rank);
                            }
                            foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                            {
                                if (attempt != null)
                                {
                                    islearnerattempt = true;
                                }
                                if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(student.ID, theme.ID))
                                {
                                    foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                                    {
                                        CmiDataModel cmiDataModel = new CmiDataModel(session.ID, student.ID, false);
                                        List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                        for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                        {
                                            for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                            {
                                                if (interactionsCollection[j].Name == "result")
                                                {
                                                    TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                                    if (interactionsCollection[j].Value == "correct")
                                                    {
                                                        result += Convert.ToDouble(itm.Rank);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            pasedCurriculum += result;
                            totalCurriculum += totalresult;
                        }
                    }
                    studentCell = new TableCell {
                        HorizontalAlign = HorizontalAlign.Center
                    };

                    studentCell.Controls.Add(new HyperLink
                    {
                        Text        = pasedCurriculum + "/" + totalCurriculum,
                        NavigateUrl = ServerModel.Forms.BuildRedirectUrl(new StatisticShowController
                        {
                            GroupID      = GroupID,
                            CurriculumID = curr.ID,
                            UserId       = student.ID,
                            BackUrl      = RawUrl
                        })
                    });
                    studentRow.Cells.Add(studentCell);

                    pasedCurriculums += pasedCurriculum;
                    totalCurriculums += totalCurriculum;
                }
                studentCell = new TableCell
                {
                    HorizontalAlign = HorizontalAlign.Center,
                    Text            = pasedCurriculums + "/" + totalCurriculums
                };
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                double temp_total;
                if (totalCurriculums != 0)
                {
                    temp_total = pasedCurriculums / totalCurriculums * 100;
                }
                else
                {
                    temp_total = 0;
                }
                studentCell.Text = (temp_total).ToString("F2");
                studentRow.Cells.Add(studentCell);
                studentCell = new TableCell {
                    HorizontalAlign = HorizontalAlign.Center
                };
                studentCell.Text = TeacherHelper.ECTS_code(temp_total);
                studentRow.Cells.Add(studentCell);
                StatisticTable.Rows.Add(studentRow);
                StatisticTable.HorizontalAlign = HorizontalAlign.Center;
            }

            if (StatisticTable.Rows.Count == 1)
            {
                StatisticTable.Visible = false;
                Message.Value          = noStudents;
            }
        }
Ejemplo n.º 36
0
        public void fillStatistic()
        {
            double totalstudntresoult = 0;
            double totalstagerank     = 0;

            user       = ServerModel.DB.Load <TblUsers>(UserId);
            curriculum = ServerModel.DB.Load <TblCurriculums>(CurriculumID);
            foreach (TblStages stage in TeacherHelper.StagesOfCurriculum(curriculum))
            {
                foreach (TblThemes theme in TeacherHelper.ThemesOfStage(stage))
                {
                    double           result       = 0; Name_Stage.Add(theme.Name);
                    double           totalresult  = 0;
                    int              learnercount = TeacherHelper.GetLastIndexOfAttempts(user.ID, theme.ID);
                    TblOrganizations organization;
                    organization = ServerModel.DB.Load <TblOrganizations>(theme.OrganizationRef);
                    foreach (TblItems items in TeacherHelper.ItemsOfOrganization(organization))
                    {
                        totalresult += Convert.ToDouble(items.Rank);
                    }

                    foreach (TblLearnerAttempts attempt in TeacherHelper.AttemptsOfTheme(theme))
                    {
                        if (attempt.ID == TeacherHelper.GetLastLearnerAttempt(user.ID, theme.ID))
                        {
                            foreach (TblLearnerSessions session in TeacherHelper.SessionsOfAttempt(attempt))
                            {
                                CmiDataModel cmiDataModel = new CmiDataModel(session.ID, user.ID, false);
                                List <TblVarsInteractions> interactionsCollection = cmiDataModel.GetCollection <TblVarsInteractions>("interactions.*.*");

                                for (int i = 0, j = 0; i < int.Parse(cmiDataModel.GetValue("interactions._count")); i++)
                                {
                                    for (; j < interactionsCollection.Count && i == interactionsCollection[j].Number; j++)
                                    {
                                        if (interactionsCollection[j].Name == "result")
                                        {
                                            TblItems itm = ServerModel.DB.Load <TblItems>(session.ItemRef);
                                            if (interactionsCollection[j].Value == "correct")
                                            {
                                                result += Convert.ToDouble(itm.Rank);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    totalstudntresoult += result;
                    totalstagerank     += totalresult;
                    Student_Stage_Count.Add(result);
                    Total_Stage_Count.Add(totalresult);
                }
            }

            Name_Stage.Add("Total");
            Student_Stage_Count.Add(totalstudntresoult);
            Total_Stage_Count.Add(totalstagerank);


            Saveto_Excel_Click();
        }
Ejemplo n.º 37
0
 public void GetCountInteractionCmiTest()
 {
     CmiDataModel dataModel = new CmiDataModel(sessionID, userID, true);
       dataModel.SetValue("interactions.0.id", "test1");
       dataModel.SetValue("interactions.1.type", "choice");
       Assert.AreEqual(dataModel.GetValue("interactions._count"), "2");
 }