void Initialize() { TblCourses course = new TblCourses { Name = "course" }; ServerModel.DB.Insert(course); TblOrganizations organisation = new TblOrganizations { CourseRef = course.ID, Title = "organisation" }; ServerModel.DB.Insert(organisation); TblResources resource = new TblResources { CourseRef = course.ID, Type = "bob", Identifier = "resource" }; ServerModel.DB.Insert(resource); TblItems item = new TblItems { OrganizationRef = organisation.ID, ResourceRef = resource.ID, Title = "item" }; ServerModel.DB.Insert(item); TblLearnerAttempts attempt = new TblLearnerAttempts { //bug with foreign keys! }; ServerModel.DB.Insert(attempt); TblLearnerSessions session = new TblLearnerSessions { ItemRef = item.ID, LearnerAttemptRef = attempt.ID }; ServerModel.DB.Insert(session); currentSession = session; TblUsers user = GetUniqueUserForTesting(); ServerModel.DB.Insert(user); sessionID = session.ID; userID = user.ID; }
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; }
public static IList <TblVarsInteractions> VarInteractionsOfSession(TblLearnerSessions session) { return(ServerModel.DB.Query <TblVarsInteractions>(new CompareCondition <int>( DataObject.Schema.LearnerSessionRef, new ValueCondition <int>(session.ID), COMPARE_KIND.EQUAL))); }
public static IList<TblVarsInteractions> VarInteractionsOfSession(TblLearnerSessions session) { return ServerModel.DB.Query<TblVarsInteractions>(new CompareCondition<int>( DataObject.Schema.LearnerSessionRef, new ValueCondition<int>(session.ID), COMPARE_KIND.EQUAL)); }