Exemple #1
0
        protected int SetVariable(string n, string m, string name, string value)
        {
            if (_variables[name].Write == false)
            {
                throw new Exception("Requested variable is read-only");
            }

            List <TblLearnerSessionsVars> list = ServerModel.DB.Query <TblLearnerSessionsVars>(
                new AndCondtion(
                    new CompareCondition <int>(
                        DataObject.Schema.LearnerSessionRef,
                        new ValueCondition <int>(LearnerSessionId), COMPARE_KIND.EQUAL),
                    new CompareCondition <string>(
                        DataObject.Schema.Name,
                        new ValueCondition <string>("cmi.interactions." + n + ".correct_responses." + m + "." + name), COMPARE_KIND.EQUAL)));

            if (list.Count > 0)
            {
                list[0].Value = value;
                ServerModel.DB.Update <TblLearnerSessionsVars>(list[0]);

                return(list[0].ID);
            }
            else
            {
                TblLearnerSessionsVars lsv = new TblLearnerSessionsVars
                {
                    LearnerSessionRef = LearnerSessionId,
                    Name  = "cmi.interactions." + n + ".correct_responses." + m + "." + name,
                    Value = value
                };

                return(ServerModel.DB.Insert <TblLearnerSessionsVars>(lsv));
            }
        }
Exemple #2
0
        protected int SetVariable(string n, string m, string name, string value)
        {
            if (_variables[name].Write == false)
            {
                throw new Exception("Requested variable is read-only");
            }

            List<TblLearnerSessionsVars> list = ServerModel.DB.Query<TblLearnerSessionsVars>(
                        new AndCondtion(
                            new CompareCondition<int>(
                                DataObject.Schema.LearnerSessionRef,
                                new ValueCondition<int>(LearnerSessionId), COMPARE_KIND.EQUAL),
                            new CompareCondition<string>(
                                DataObject.Schema.Name,
                                new ValueCondition<string>("cmi.interactions." + n + ".correct_responses." + m + "." + name), COMPARE_KIND.EQUAL)));

            if (list.Count > 0)
            {
                list[0].Value = value;
                ServerModel.DB.Update<TblLearnerSessionsVars>(list[0]);

                return list[0].ID;
            }
            else
            {
                TblLearnerSessionsVars lsv = new TblLearnerSessionsVars
                {
                    LearnerSessionRef = LearnerSessionId,
                    Name = "cmi.interactions." + n + ".correct_responses." + m + "." + name,
                    Value = value
                };

                return ServerModel.DB.Insert<TblLearnerSessionsVars>(lsv);
            }
        }