Example #1
0
    public void AddImg(Img img)
    {
        this.imgs.Add(img);

        if (this.loadMode == PhysicsModelLoadMode.Col)
        {
            foreach (var entry in img.DataEntries)
            {
                if (entry.Key.EndsWith(".col"))
                {
                    try
                    {
                        var col = new ColFile(entry.Value.Data).Col;

                        foreach (var combo in col.ColCombos)
                        {
                            var fullString = string.Join("", combo.Header.Name);
                            var name       = fullString.Substring(0, fullString.IndexOf('\0')).ToLower();
                            this.namedColCombos[name] = combo;
                        }
                    }
                    catch (Exception)
                    {
                        this.logger.LogTrace($"Unable to locate col {entry.Value.Data}");
                    }
                }
            }
        }
    }
Example #2
0
        //Effettivamente utilizzati
        public dtoEvaluation EvaluateModuleLink(ModuleLink link, Int32 idUser, Dictionary <String, long> moduleUserLong = null, Dictionary <String, String> moduleUserString = null)
        {
            //if (Link.SourceItem.ObjectTypeID == ??)

            Int64 FileId = link.SourceItem.ObjectLongID;

            IList <Int64> FilesIds = new List <Int64>();

            FilesIds.Add(FileId);

            IList <int> UsersIds = new List <int>();

            UsersIds.Add(idUser);

            IList <ColFile> ColFiles = this.ColScormManager.GetStatFileUser(FilesIds, UsersIds);


            dtoEvaluation EvalML = new dtoEvaluation();

            if (ColFiles.Count > 0)
            {
                ColFile File = ColFiles[0];
                //Stat.Status
                switch (File.UserStats[0].Status)
                {
                case lm.Comol.Modules.ScormStat.Icodeon.StatusCode.Completed:
                    EvalML.isStarted   = true;
                    EvalML.isCompleted = true;
                    EvalML.isPassed    = true;
                    break;

                case lm.Comol.Modules.ScormStat.Icodeon.StatusCode.Started:
                    EvalML.isStarted   = true;
                    EvalML.isCompleted = false;
                    EvalML.isPassed    = false;
                    break;

                default:
                    EvalML.isStarted   = false;
                    EvalML.isCompleted = false;
                    EvalML.isPassed    = false;
                    break;
                }

                EvalML.Completion = (short)((File.UserStats[0].NumActivity / File.Package.ActivityCount) * 100);
            }

            return(EvalML);
        }
Example #3
0
        public IList <ColFile> GetFileStat(IList <StatFileTreeLeaf> StatTreeLeafs, IList <Int32> UsersIds, Int32 CurrentUserId)
        {
            List <long> AllPermFileIds = (from StatFileTreeLeaf STL in StatTreeLeafs
                                          where (((StatTreeLeafType.Advanced | StatTreeLeafType.Personal) == STL.Type) || (StatTreeLeafType.Advanced == STL.Type))
                                          select STL.Id).ToList <long>();

            List <long> SinglePermFileIds = (from StatFileTreeLeaf STL in StatTreeLeafs
                                             where STL.Type == StatTreeLeafType.Personal
                                             select STL.Id).ToList <long>();

            List <StatFileTreeLeaf> NoPermSFTLs = (from StatFileTreeLeaf STL in StatTreeLeafs
                                                   where STL.Type == StatTreeLeafType.None
                                                   select STL).ToList();

            List <ColFile> NPFile = new List <ColFile>();

            foreach (StatFileTreeLeaf SFTL in NoPermSFTLs)
            {
                ColFile file = new ColFile();
                file.Id         = SFTL.Id;
                file.Guid       = Guid.Empty;
                file.Name       = SFTL.Name;
                file.Permission = 0;
                file.Extension  = SFTL.Extension;

                NPFile.Add(file);
            }

            //Seleziono QUI i GUID,
            //perchè così posso avere SOLO i GUID dei file SCORM e non tutti i guid dei file che non mi interessano...
            List <Guid> AllGuids = (from StatFileTreeLeaf STL in StatTreeLeafs
                                    where (STL.isScorm &&
                                           ((StatTreeLeafType.Advanced | StatTreeLeafType.Personal) == STL.Type) || (StatTreeLeafType.Advanced == STL.Type) || (StatTreeLeafType.Personal == STL.Type))
                                    select STL.UniqueID).ToList <Guid>();

            String guidstr = "";

            AllGuids.ForEach(delegate(Guid g)
                             { guidstr += " ### " + g.ToString(); });

            List <Guid> SingleGuids = (from StatFileTreeLeaf STL in StatTreeLeafs
                                       where (STL.isScorm &&
                                              (StatTreeLeafType.Personal == STL.Type))
                                       select STL.UniqueID).ToList <Guid>();

            IDictionary <String, Int32> DownInfo = GetDonwloadStat(UsersIds, AllPermFileIds);

            return(this.ColScormManager.GetStatGenericFile(AllPermFileIds, SinglePermFileIds, NPFile, AllGuids, SingleGuids, UsersIds, CurrentUserId, DownInfo));
        }
Example #4
0
        public IList <ColPerson> GetUsersStat(IList <StatFileTreeLeaf> StatTreeLeafs, IList <Int32> UsersIds, Int32 CurrentUserId)
        {
            List <long> AllPermFileIds = (from StatFileTreeLeaf STL in StatTreeLeafs
                                          where (((StatTreeLeafType.Advanced | StatTreeLeafType.Personal) == STL.Type) || (StatTreeLeafType.Advanced == STL.Type))
                                          select STL.Id).ToList <long>();

            List <long> SinglePermFileIds = (from StatFileTreeLeaf STL in StatTreeLeafs
                                             where STL.Type == StatTreeLeafType.Personal
                                             select STL.Id).ToList <long>();


            List <StatFileTreeLeaf> NoPermSFTLs = (from StatFileTreeLeaf STL in StatTreeLeafs
                                                   where STL.Type == StatTreeLeafType.None
                                                   select STL).ToList();

            List <ColFile> NPFile = new List <ColFile>();

            foreach (StatFileTreeLeaf SFTL in NoPermSFTLs)
            {
                ColFile file = new ColFile();
                file.Id         = SFTL.Id;
                file.Guid       = Guid.Empty;
                file.Name       = SFTL.Name;
                file.Permission = 0;
                file.Extension  = SFTL.Extension;

                NPFile.Add(file);
            }

            List <Guid> AllGuids = (from StatFileTreeLeaf STL in StatTreeLeafs
                                    where (STL.isScorm &&
                                           ((StatTreeLeafType.Advanced | StatTreeLeafType.Personal) == STL.Type) || (StatTreeLeafType.Advanced == STL.Type) || (StatTreeLeafType.Personal == STL.Type))
                                    select STL.UniqueID).ToList <Guid>();

            IDictionary <String, Int32> DownInfo = GetDonwloadStat(UsersIds, AllPermFileIds);

            return(this.ColScormManager.GetStatGenericUser(
                       AllPermFileIds,
                       SinglePermFileIds,
                       NPFile,
                       AllGuids,
                       UsersIds,
                       CurrentUserId,
                       DownInfo));
        }
Example #5
0
        //public IList<ColFile> GetFileStat_OLD(IList<StatFileTreeLeaf> StatTreeLeafs, IList<Int32> UsersIds, Int32 CurrentUserId)
        //{


        //    //Recupero i dati sui file dagli ID appena recuperati

        //    //INFO SUI DOWNLOAD:



        //    //IList<FileDownloadInfo> SinglePermFDIs = (from f in Manager.GetIQ<FileDownloadInfo>()
        //    //                                          where SinglePermFileIds.Contains(f.File.Id) && UsersIds.Contains(f.Downloader.Id)
        //    //                                          select f).ToList();

        //    //IList<FileDownloadInfo> NoPermFDIs = (from f in Manager.GetIQ<FileDownloadInfo>()
        //    //                                          where NoPermFileIds.Contains(f.File.Id) && UsersIds.Contains(f.Downloader.Id)
        //    //                                          select f).ToList();

        //    //Definizione di alcune "variabili interne":
        //    //Permessi per tutti gli utenti
        //    IList<ColFile> AllPermFiles = new List<ColFile>();
        //    IList<Guid> AllPermGuids = new List<Guid>();

        //    //Permessi solo per l'utente corrente
        //    IList<ColFile> SinglePermFiles = new List<ColFile>();
        //    IList<Guid> SinglePermGuids = new List<Guid>();

        //    IList<Int32> SingleUserId = new List<Int32>();
        //    if (CurrentUserId != null || CurrentUserId != 0)
        //    {
        //        SingleUserId.Add(CurrentUserId);
        //    }

        //    //No permessi
        //    IList<ColFile> NoPermFiles = new List<ColFile>();


        //    //"Trasformo" le info raccolte da COMOL, nel DTO per le statistiche SCORM
        //    //foreach (FileDownloadInfo fdi in AllPermFDIs)
        //    //{
        //    //    AllPermFiles.Add(FileDownloadInfo_to_ColFile(fdi,2));
        //    //    if (fdi.File.isSCORM)
        //    //    {
        //    //        AllPermGuids.Add(fdi.UniqueID);
        //    //    }
        //    //}

        //    //foreach (FileDownloadInfo fdi in SinglePermFDIs)
        //    //{
        //    //    SinglePermFiles.Add(FileDownloadInfo_to_ColFile(fdi,1));
        //    //    if (fdi.File.isSCORM)
        //    //    {
        //    //        SinglePermGuids.Add(fdi.UniqueID);
        //    //    }
        //    //}

        //    //foreach (FileDownloadInfo fdi in NoPermFDIs)
        //    //{
        //    //    ColFile file = new ColFile();
        //    //    file.Id = fdi.File.Id;
        //    //    file.Guid = Guid.Empty;
        //    //    file.Name = fdi.File.DisplayName;
        //    //    file.Permission = 0;

        //    //    NoPermFiles.Add(file);
        //    //}

        //    //Recupero le statistiche per i file di cui ho tutti i permessi
        //    IList<ColFile> AllFiles = this.ColScormManager.GetStatGenericFile(AllPermFiles, AllPermGuids, UsersIds);

        //    //Recupero le statistiche per i file di cui posso visualizzare solo l'utente corrente
        //    IList<ColFile> SingleFiles = new List<ColFile>();

        //    if (SingleUserId.Count >= 0)
        //    {
        //        SingleFiles = this.ColScormManager.GetStatGenericFile(SinglePermFiles, SinglePermGuids, SingleUserId);
        //    }

        //    //I file di cui non ho permessi, non vado a raccogliere nulla...

        //    //Ritorno la UNION delle 3 precedenti, ordinata per nome file...
        //    return (from ColFile file
        //                in AllFiles.Union(SingleFiles.Union(NoPermFiles))
        //                orderby file.Name select file).ToList();
        //}

        private ColFile FileDownloadInfo_to_ColFile(FileDownloadInfo fdi, long Permission)
        {
            ColFile file = new ColFile();

            file.Id         = fdi.Id;
            file.Guid       = fdi.UniqueID;
            file.Name       = fdi.File.DisplayName;
            file.Permission = Permission;   //fdi.Link.Permission;

            //file.Package
            //file.PlayCount
            //file.TotActivity
            file.UploadDate = fdi.File.CreatedOn;

            ColPerson person = new ColPerson();

            person.Id         = fdi.File.Owner.Id;
            person.Name       = fdi.File.Owner.Name;
            person.SecondName = fdi.File.Owner.Surname;

            file.UploadedBy = person;

            return(file);
        }