public void SaveActionsExecution(List <dtoItemEvaluation <long> > evaluatedLinks, int idUser) { if (evaluatedLinks != null && evaluatedLinks.Count > 0) { try { IList <long> IdLinks = (from e in evaluatedLinks select e.Item).ToList(); IList <ModuleLink> links = (from l in Manager.GetIQ <ModuleLink>() where IdLinks.Contains(l.Id) select l).ToList(); foreach (dtoItemEvaluation <long> dto in evaluatedLinks) { ModuleLink link = (from l in links where l.Id == dto.Item select l).FirstOrDefault(); if (link != null) { int croleId = Manager.GetActiveSubscriptionIdRole(idUser, link.SourceItem.CommunityID); //Manager.Get<SubActivity>(Link.SourceItem.ObjectLongID).Community.Id); Manager.BeginTransaction(); ServiceStat.InitOrUpdateSubActivityNoTransaction(link.SourceItem.ObjectLongID, idUser, croleId, idUser, "", "", dto.Completion, dto.Mark, dto.isStarted, dto.isCompleted, dto.isPassed); Manager.Commit(); } } } catch (Exception ex) { Manager.RollBack(); Debug.Write(ex); } } }
public void SaveActionExecution( ModuleLink link, bool isStarted, bool isPassed, short Completion, bool isCompleted, short mark, int idUser, bool alreadyCompleted, Dictionary <string, long> moduleUserLong = null, Dictionary <string, string> moduleUserString = null) { try { if (link.SourceItem.ObjectTypeID == (int)COL_BusinessLogic_v2.UCServices.Services_EduPath.ObjectType.SubActivity) { int croleId = Manager.GetActiveSubscriptionIdRole(idUser, link.SourceItem.CommunityID); //Manager.Get<SubActivity>(Link.SourceItem.ObjectLongID).Community.Id); Manager.BeginTransaction(); ServiceStat.InitOrUpdateSubActivityNoTransaction(link.SourceItem.ObjectLongID, idUser, croleId, idUser, "", "", Completion, mark, isStarted, isCompleted, isPassed); Manager.Commit(); } else if (link.SourceItem.ObjectTypeID == (int)COL_BusinessLogic_v2.UCServices.Services_EduPath.ObjectType.Activity) { } } catch (Exception ex) { if (Manager.IsInTransaction()) { Manager.RollBack(); } Debug.Write(ex); } }
public void SaveActionExecution(Int32 idUser, Int32 idRole, long idPath, long idSubActivity, dtoEvaluation evaluation, DateTime?referenceTime) { try { Boolean save = true; Path path = GetPath(idPath); PolicySettings settings = null; if (path != null) { settings = path.Policy; } if (settings != null) { switch (settings.Statistics) { case CompletionPolicy.UpdateAlways: break; default: List <SubActivityStatistic> items = GetUserStatistics(idSubActivity, idUser, ((referenceTime != null && referenceTime.HasValue) ? referenceTime.Value : DateTime.Now)); SubActivityStatistic last = (items == null ? null : items.FirstOrDefault()); switch (settings.Statistics) { case CompletionPolicy.NoUpdateIfCompleted: if (evaluation.isPassed && evaluation.isCompleted) { save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed)); } else { save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.Completed) || ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed)); } break; //case CompletionPolicy.UpdateOnlyIfBetter: // if (last != null) // save = (last.Completion < evaluation.Completion || ( // ((!ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.Completed) && !ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.CompletedPassed)) // && (evaluation.Status == Core.FileRepository.Domain.PackageStatus.completed // || evaluation.Status == Core.FileRepository.Domain.PackageStatus.completedpassed)) // )); // break; //case CompletionPolicy.UpdateOnlyIfWorst: // break; } break; } } if (save) { Manager.BeginTransaction(); ServiceStat.InitOrUpdateSubActivityNoTransaction(idSubActivity, idUser, idRole, idUser, UC.IpAddress, UC.ProxyIpAddress, evaluation.Completion, (short)evaluation.Completion, evaluation.isStarted, evaluation.isCompleted, evaluation.isPassed); Manager.Commit(); } } catch (Exception ex) { } }
public void SaveActionExecution(lm.Comol.Core.FileRepository.Domain.ScormPackageUserEvaluation evaluation) { try { Boolean save = true; long idSubActivity = evaluation.IdObject; long idPath = GetPathId_BySubActivityId(idSubActivity); Int32 idCommunity = GetPathIdCommunity(idPath); Int32 idRole = Manager.GetActiveSubscriptionIdRole(evaluation.IdPerson, idCommunity); Path path = GetPath(idPath); PolicySettings settings = null; if (path != null) { settings = path.Policy; } if (settings != null) { switch (settings.Statistics) { case CompletionPolicy.UpdateAlways: break; default: List <SubActivityStatistic> items = GetUserStatistics(idSubActivity, evaluation.IdPerson, (evaluation.EndPlayOn.HasValue ? evaluation.EndPlayOn.Value : DateTime.Now)); SubActivityStatistic last = (items == null ? null : items.FirstOrDefault()); switch (settings.Statistics) { case CompletionPolicy.NoUpdateIfCompleted: if (evaluation.IsPassed && evaluation.IsCompleted) { save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed)); } else { save = !items.Any(i => ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.Completed) || ServiceStat.CheckStatusStatistic(i.Status, StatusStatistic.CompletedPassed)); } break; case CompletionPolicy.UpdateOnlyIfBetter: if (last != null) { save = (last.Completion < evaluation.Completion || ( ((!ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.Completed) && !ServiceStat.CheckStatusStatistic(last.Status, StatusStatistic.CompletedPassed)) && (evaluation.Status == Core.FileRepository.Domain.PackageStatus.completed || evaluation.Status == Core.FileRepository.Domain.PackageStatus.completedpassed)) )); } break; case CompletionPolicy.UpdateOnlyIfWorst: break; } break; } } if (save) { Manager.BeginTransaction(); ServiceStat.InitOrUpdateSubActivityNoTransaction(idSubActivity, evaluation.IdPerson, idRole, evaluation.IdPerson, UC.IpAddress, UC.ProxyIpAddress, evaluation.Completion, (short)evaluation.Completion, (evaluation.Status != lm.Comol.Core.FileRepository.Domain.PackageStatus.notstarted), evaluation.IsCompleted, evaluation.IsPassed); Manager.Commit(); } } catch (Exception ex) { } }