public CurrentTopicTestResultsModel(int topicId, ILmsService lmsService)
        {
            User currenUser = lmsService.FindService<IUserService>().GetCurrentUser();
            Topic topic = lmsService.FindService<ICurriculumService>().GetTopic(topicId);
            if (currenUser != null & topic != null)
            {
                IEnumerable<AttemptResult> attemptResults = lmsService.FindService<ITestingService>().GetResults(currenUser, topic);
                if (attemptResults != null & attemptResults.Count() >= 1)
                {

                    _Attempt = attemptResults.Last();
                    if (_Attempt != null)
                    {
                        _UserAnswers = lmsService.FindService<ITestingService>().GetAnswers(_Attempt);
                        if (_UserAnswers != null)
                            _NoData = false;
                        else
                            _NoData = true;
                    }
                }
                else
                    _NoData = true;
            }
            else
                _NoData = true;
        }
Exemple #2
0
        public TopicModel(ILmsService ilmsService, long selectDisciplineId)
        {
            IEnumerable <Topic> temp_allowedTopics = ilmsService.FindService <IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId);

            this.disciplineName = ilmsService.FindService <IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name;

            if (temp_allowedTopics != null & temp_allowedTopics.Count() != 0)
            {
                double tempDisciplineQuality = 0;
                var    temp = new List <KeyValuePair <Topic, double> >();
                foreach (var topic in temp_allowedTopics)
                {
                    List <double> quality = new List <double>();
                    quality.Add(0);
                    tempDisciplineQuality += quality.Sum() / quality.Count;
                    temp.Add(new KeyValuePair <Topic, double>(topic, quality.Sum() / quality.Count));
                }

                this.disciplineQuality = tempDisciplineQuality / temp.Count;
                this.allowedTopics     = temp;
            }
            else
            {
                this.disciplineQuality = 0;
                this.allowedTopics     = null;
            }
        }
        public CurrentTopicTestResultsModel(int topicId, ILmsService lmsService)
        {
            User  currenUser = lmsService.FindService <IUserService>().GetCurrentUser();
            Topic topic      = lmsService.FindService <ICurriculumService>().GetTopic(topicId);

            if (currenUser != null & topic != null)
            {
                IEnumerable <AttemptResult> attemptResults = lmsService.FindService <ITestingService>().GetResults(currenUser, topic);
                if (attemptResults != null & attemptResults.Count() >= 1)
                {
                    _Attempt = attemptResults.Last();
                    if (_Attempt != null)
                    {
                        _UserAnswers = lmsService.FindService <ITestingService>().GetAnswers(_Attempt);
                        if (_UserAnswers != null)
                        {
                            _NoData = false;
                        }
                        else
                        {
                            _NoData = true;
                        }
                    }
                }
                else
                {
                    _NoData = true;
                }
            }
            else
            {
                _NoData = true;
            }
        }
        private IEnumerable <UserAnswers> StudentsAnswers(ILmsService iLmsService, int[] selectGroupIds, CurriculumChapterTopic selectedCurriculumChapterTopic)
        {
            List <UserAnswers> listOfUserAnswers = new List <UserAnswers>();
            //Creation of list of all students in selected groups
            IEnumerable <User> studentsFromSelectedGroups = new List <User>();

            foreach (var groupId in selectGroupIds)
            {
                Group temp = iLmsService.FindService <IUserService>().GetGroup(groupId);
                studentsFromSelectedGroups = studentsFromSelectedGroups.Union(iLmsService.FindService <IUserService>().GetUsersByGroup(temp));
            }
            //
            foreach (User student in studentsFromSelectedGroups)
            {
                IEnumerable <AttemptResult> temp = iLmsService.FindService <ITestingService>().GetResults(student, selectedCurriculumChapterTopic);
                if (temp != null & temp.Count() != 0)
                {
                    temp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed)
                           .OrderBy(attempt => attempt.StartTime);
                    if (temp.Count() != 0)
                    {
                        listOfUserAnswers.Add(new UserAnswers(student, temp.First(), iLmsService));
                    }
                }
            }
            return(listOfUserAnswers);
        }
        /// <summary>
        /// constructor that get all information from Testing System
        /// </summary>
        /// <param name="attemptId">id of attempt to show</param>
        /// <param name="attList">list of attempts from Session Context</param>
        /// <param name="lmsService">ILmsService for conection to Testing System</param>
        public TopicTestResultsModel(long attemptId, IEnumerable<AttemptResult> attList, int groupId, ILmsService lmsService)
        {
            if (attemptId != -1)
            {
                this.group = lmsService.FindService<IUserService>().GetGroup(groupId);
                // hotfix: added checking of Course id
                this.attempt =
                    attList.FirstOrDefault(
                        c =>
                        c.AttemptId == attemptId && c.CurriculumChapterTopic.Topic.TestCourseRef == c.IudicoCourseRef);
                if (this.attempt != null)
                {
                    this.userAnswers = lmsService.FindService<ITestingService>().GetAnswers(this.attempt);
                    this.courseInfo =
                            lmsService.FindService<ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef);

                    this.hasNoData = this.userAnswers == null;
                }
                else
                {
                    this.hasNoData = true;
                }                
            }
            else
                this.hasNoData = true;
        }
Exemple #6
0
        public TopicModel(ILmsService ilmsService, long selectDisciplineId)
        {
            IEnumerable<Topic> temp_allowedTopics = ilmsService.FindService<IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId);
            this.disciplineName = ilmsService.FindService<IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name;

            if (temp_allowedTopics != null & temp_allowedTopics.Count() != 0)
            {
                double tempDisciplineQuality = 0;
                var temp = new List<KeyValuePair<Topic, double>>();
                foreach (var topic in temp_allowedTopics)
                {
                    List<double> quality = new List<double>();
                    quality.Add(0);
                    tempDisciplineQuality += quality.Sum() / quality.Count;
                    temp.Add(new KeyValuePair<Topic, double>(topic, quality.Sum() / quality.Count));
                }

                this.disciplineQuality = tempDisciplineQuality / temp.Count;
                this.allowedTopics = temp;
            }
            else
            {
                this.disciplineQuality = 0;
                this.allowedTopics = null;
            }
        }
Exemple #7
0
        public TopicInfoModel(int groupId, int curriculumId, ILmsService lmsService)
        {
            this.lastAttempts = new List <AttemptResult>();
            this.lmsService   = lmsService;

            this.curriculumId = curriculumId;

            var group = lmsService.FindService <IUserService>().GetGroup(groupId);

            this.selectedGroupStudents = lmsService.FindService <IUserService>().GetUsersByGroup(group);

            this.selectedCurriculumChapterTopics = lmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(this.curriculumId);
            foreach (var temp in from student in this.selectedGroupStudents
                     from curriculumChapterTopic in this.selectedCurriculumChapterTopics
                     select lmsService.FindService <ITestingService>().GetResults(student, curriculumChapterTopic) into temp
                     where temp != null
                     select temp)
            {
                // hotfix: added checking of Course id
                var attempt = temp.Where(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);
                if (attempt.Any())
                {
                    this.lastAttempts.Add(attempt.First());
                }
            }
        }
Exemple #8
0
        public TopicInfoModel(int groupId, int curriculumId, ILmsService lmsService)
        {
            this.lastAttempts = new List<AttemptResult>();
            this.lmsService = lmsService;

            this.curriculumId = curriculumId;

            var group = lmsService.FindService<IUserService>().GetGroup(groupId);
            this.selectedGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(group);

            this.selectedCurriculumChapterTopics = lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(this.curriculumId);
            foreach (var temp in from student in this.selectedGroupStudents
                                 from curriculumChapterTopic in this.selectedCurriculumChapterTopics
                                 select lmsService.FindService<ITestingService>().GetResults(student, curriculumChapterTopic) into temp 
                                 where temp != null 
                                 select temp)
            {
                // hotfix: added checking of Course id
                var attempt = temp.Where(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);
                if (attempt.Any())
                {
                    this.lastAttempts.Add(attempt.First());
                }
            }
        }
 public CurrentTopicTestResultsModel(int curriculumChapterTopicId, TopicTypeEnum topicType, int groupId, ILmsService lmsService)
 {
     this.group = lmsService.FindService<IUserService>().GetGroup(groupId);
     var currenUser = lmsService.FindService<IUserService>().GetCurrentUser();
     var curriculumChapterTopic = lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicById(curriculumChapterTopicId);
     if (currenUser != null & curriculumChapterTopic != null)
     {
         var attemptResults = lmsService.FindService<ITestingService>().GetResults(currenUser, curriculumChapterTopic, topicType).ToList();
         if (attemptResults.Any())
         {
             // hotfix: added checking of Course id
             this.attempt =
                 attemptResults.FirstOrDefault(x => x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);
             if (this.attempt != null)
             {
                 this.courseInfo =
                     lmsService.FindService<ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef);
                 this.userAnswers = lmsService.FindService<ITestingService>().GetAnswers(this.attempt);
                 
                 this.hasNoData = this.userAnswers == null;
             }
         }
         else
             this.hasNoData = true;
     }
     else
         this.hasNoData = true;
 }
Exemple #10
0
 public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService)
 {
     LmsService     = lmsService;
     CurriculumId   = curriculumId;
     SelectStudents = LmsService.FindService <IUserService>().GetUsersByGroup
                      (
         LmsService.FindService <IUserService>().GetGroup(groupId)
                      );
     SelectCurriculumThemes = LmsService.FindService <ICurriculumService>().GetThemesByCurriculumId
                              (
         CurriculumId
                              );
     //LastAttempts = LmsService.FindService<ITestingService>().GetLastCompleteAttemptsForThemes
     //    (
     //    LmsService.FindService<IUserService>().GetGroup(groupId),
     //    SelectCurriculumThemes
     //    );
     LastAttempts = new List <AttemptResult>();
     foreach (User student in SelectStudents)
     {
         foreach (Theme theme in SelectCurriculumThemes)
         {
             IEnumerable <AttemptResult> temp = LmsService.FindService <ITestingService>().GetResults(student, theme);
             if (temp != null)
             {
                 LastAttempts.Add(temp.First());
             }
         }
     }
 }
Exemple #11
0
        public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService)
        {
            _LastAttempts = new List <AttemptResult>();

            CurriculumId = curriculumId;

            Group group = lmsService.FindService <IUserService>().GetGroup(groupId);

            SelectGroupStudents = lmsService.FindService <IUserService>().GetUsersByGroup(group);

            SelectCurriculumThemes = lmsService.FindService <ICurriculumService>().GetThemesByCurriculumId(CurriculumId);

            foreach (var temp in from student in SelectGroupStudents
                     from theme in SelectCurriculumThemes
                     select lmsService.FindService <ITestingService>().GetResults(student, theme)
                     into temp where temp != null select temp)
            {
                var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed)
                                   .OrderBy(attempt => attempt.StartTime);
                if (filteredTemp.Count() != 0)
                {
                    _LastAttempts.Add(filteredTemp.First());
                }
            }
        }
Exemple #12
0
        public void LmsGetLogged()
        {
            IWindsorContainer container = new WindsorContainer();

            InitializeWindsor(ref container);
            Common.Log4NetLoggerService.InitLogger();
            Assembly a        = Assembly.GetExecutingAssembly();
            string   fullPath = a.CodeBase;

            fullPath = Path.GetDirectoryName(fullPath);
            fullPath = Path.GetDirectoryName(fullPath);
            fullPath = Path.GetDirectoryName(fullPath);
            fullPath = Path.GetDirectoryName(fullPath);
            fullPath = Path.Combine(fullPath, "IUDICO.LMS", "log.xml");
            ILmsService service = container.Resolve <ILmsService>();

            fullPath = fullPath.Remove(0, 6);
            Common.Log4NetLoggerService.InitLogger();
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(fullPath));
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(ILmsService));
            service.Inform(LMSNotifications.ApplicationStop);
            fullPath = Path.GetDirectoryName(fullPath);
            fullPath = Path.Combine(fullPath, "Data", "Logs", "log4net.log");
            StreamReader reader = new StreamReader(fullPath);
            string       toRead = reader.ReadToEnd();

            Assert.That(toRead.IndexOf("Notification:application/stop") != -1);
        }
Exemple #13
0
 public DataPreparer(
     IDisciplineStorage disciplineStorage, ICurriculumStorage curriculumStorage, ILmsService lmsService)
 {
     this.disciplineStorage = disciplineStorage;
     this.curriculumStorage = curriculumStorage;
     this.courseService = lmsService.FindService<ICourseService>();
     this.userService = lmsService.FindService<IUserService>();
 }
Exemple #14
0
 public DatabaseBanStorage(ILmsService lmsService)
 {
     _LmsService = lmsService;
     _CreateIDataContext = () =>
         {
             return new DBDataContext();
         };
 }
Exemple #15
0
 public DatabaseBanStorage(ILmsService lmsService)
 {
     _LmsService         = lmsService;
     _CreateIDataContext = () =>
     {
         return(new DBDataContext());
     };
 }
Exemple #16
0
        public void ContainerIsBeingDesposedProperly()
        {
            IWindsorContainer container = new WindsorContainer();

            InitializeWindsor(ref container);
            ILmsService service = container.Resolve <ILmsService>();

            container.Dispose();
            Assert.That(container.ResolveAll <Object>().Count(item => item != null) == 0);
        }
        public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String disciplineName, int selectedCurriculumChapterTopicId)
        {
            _DisciplineName = disciplineName;

            var seletedCurriculumChapterTopic = iLmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicById(selectedCurriculumChapterTopicId);

            _TopicName = seletedCurriculumChapterTopic.Topic.Name;

            //Creation of list of students answers
            _ListOfUserAnswers    = StudentsAnswers(iLmsService, selectGroupIds, seletedCurriculumChapterTopic);
            _ListOfQuestionModels = CreationOfQuestionModels();
        }
        public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectedCurriculumIds, ILmsService lmsServiceParam)
        {
            this.lmsService = lmsServiceParam;
            var asr = new AllSpecializedResults
                {
                    Users = users.ToList(),
                    // SelectedDisciplineIds = selectedCurriculumIds,
                    Curriculums =
                        this.lmsService.FindService<ICurriculumService>().GetCurriculums(
                            curr => selectedCurriculumIds.Contains(curr.Id))
                };


            foreach (var usr in asr.Users)
            {
                var specializedResult = new SpecializedResult
                    {
                        Curriculums = asr.Curriculums
                    };

                foreach (var curriculum in specializedResult.Curriculums)
                {
                    var disciplineResult = new DisciplineResult
                        {
                            CurriculumChapterTopics =
                                this.lmsService.FindService<ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(curriculum.Id)
                        };

                    #region TopicResult

                    foreach (var curriculumChapterTopic in disciplineResult.CurriculumChapterTopics)
                    {
                        var topicResult = new TopicResult(usr, curriculumChapterTopic)
                            {
                                AttemptResults =
                                    this.lmsService.FindService<ITestingService>().GetResults(
                                        usr, curriculumChapterTopic)
                            };
                        topicResult.Res = topicResult.GetTopicResultScore(lmsServiceParam);
                        disciplineResult.TopicResults.Add(topicResult);
                    }

                    #endregion

                    disciplineResult.CalculateSumAndMax(usr, curriculum);
                    specializedResult.DisciplineResults.Add(disciplineResult);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResults.Add(specializedResult);
            }
            return asr;
        }
        public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectedCurriculumIds, ILmsService lmsServiceParam)
        {
            this.lmsService = lmsServiceParam;
            var asr = new AllSpecializedResults
            {
                Users = users.ToList(),
                // SelectedDisciplineIds = selectedCurriculumIds,
                Curriculums =
                    this.lmsService.FindService <ICurriculumService>().GetCurriculums(
                        curr => selectedCurriculumIds.Contains(curr.Id))
            };


            foreach (var usr in asr.Users)
            {
                var specializedResult = new SpecializedResult
                {
                    Curriculums = asr.Curriculums
                };

                foreach (var curriculum in specializedResult.Curriculums)
                {
                    var disciplineResult = new DisciplineResult
                    {
                        CurriculumChapterTopics =
                            this.lmsService.FindService <ICurriculumService>().GetCurriculumChapterTopicsByCurriculumId(curriculum.Id)
                    };

                    #region TopicResult

                    foreach (var curriculumChapterTopic in disciplineResult.CurriculumChapterTopics)
                    {
                        var topicResult = new TopicResult(usr, curriculumChapterTopic)
                        {
                            AttemptResults =
                                this.lmsService.FindService <ITestingService>().GetResults(
                                    usr, curriculumChapterTopic)
                        };
                        topicResult.Res = topicResult.GetTopicResultScore(lmsServiceParam);
                        disciplineResult.TopicResults.Add(topicResult);
                    }

                    #endregion

                    disciplineResult.CalculateSumAndMax(usr, curriculum);
                    specializedResult.DisciplineResults.Add(disciplineResult);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResults.Add(specializedResult);
            }
            return(asr);
        }
Exemple #20
0
 public IndexModel(ILmsService iLmsService)
 {
     IEnumerable<Discipline> allowedDisciplines;
     User teacherUser;
     teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser();
     allowedDisciplines = iLmsService.FindService<ICurriculumService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser);
     //
     if (allowedDisciplines != null & allowedDisciplines.Count() != 0)
         _AllowedDisciplines = allowedDisciplines;
     else
         _AllowedDisciplines = null;
     _TeacherUser = teacherUser;
 }
Exemple #21
0
        public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String curriculumName, int selectThemeId)
        {
            _CurriculumName = curriculumName;

            //Theme object that needs for geting user answers
            Theme selectTheme = iLmsService.FindService <ICurriculumService>().GetTheme(selectThemeId);

            _ThemeName = selectTheme.Name;

            //Creation of list of students answers
            _ListOfUserAnswers    = StudentsAnswers(iLmsService, selectGroupIds, selectTheme);
            _ListOfQuestionModels = CreationOfQuestionModels();
        }
        public ShowQualityTestModel(ILmsService iLmsService, int[] selectGroupIds, String disciplineName, int selectTopicId)
        {
            _DisciplineName = disciplineName;

            //Topic object that needs for geting user answers
            Topic selectTopic = iLmsService.FindService <ICurriculumService>().GetTopic(selectTopicId);

            _TopicName = selectTopic.Name;

            //Creation of list of students answers
            _ListOfUserAnswers    = StudentsAnswers(iLmsService, selectGroupIds, selectTopic);
            _ListOfQuestionModels = CreationOfQuestionModels();
        }
Exemple #23
0
 public IndexModel(ILmsService iLmsService)
 {
     IEnumerable<Curriculum> allowedCurriculums;
     User teacherUser;
     teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser();
     allowedCurriculums = iLmsService.FindService<ICurriculumService>().GetCurriculumsWithThemesOwnedByUser(teacherUser);
     //
     if (allowedCurriculums != null & allowedCurriculums.Count() != 0)
         _AllowedCurriculums = allowedCurriculums;
     else
         _AllowedCurriculums = null;
     _TeacherUser = teacherUser;
 }
Exemple #24
0
        public void WindsorCanResolveLmsService()
        {
            IWindsorContainer container = new WindsorContainer();

            InitializeWindsor(ref container);
            try
            {
                ILmsService lms = container.Resolve <ILmsService>();
            }
            catch (Exception e)
            {
                Assert.Fail("LmsService instance could not be resolved from Windsor container");
            }
        }
Exemple #25
0
 public IndexModel(ILmsService iLmsService)
 {
     IEnumerable<Discipline> allowedDisciplines;
     User teacherUser;
     teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser();
     //TODO: review this method
     allowedDisciplines=new Discipline[]{};
     //allowedDisciplines = iLmsService.FindService<IDisciplineService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser);
     //
     if (allowedDisciplines != null & allowedDisciplines.Count() != 0)
         _AllowedDisciplines = allowedDisciplines;
     else
         _AllowedDisciplines = null;
     _TeacherUser = teacherUser;
 }
Exemple #26
0
 public SelectGroupsModel(ILmsService iLmsService, int selectThemeId, String teacherUserName, String curriculumName)
 {
     IEnumerable<Group> allowedGroups;
     Theme selectTheme;
     selectTheme = iLmsService.FindService<ICurriculumService>().GetTheme(selectThemeId);
     _ThemeName = selectTheme.Name;
     _TeacheUserName = teacherUserName;
     _CurriculumName = curriculumName;
     allowedGroups = iLmsService.FindService<ICurriculumService>().GetGroupsAssignedToTheme(selectThemeId);
     //
     if (allowedGroups != null & allowedGroups.Count() != 0)
         _AllowedGroups = allowedGroups;
     else
         _AllowedGroups = null;
 }
Exemple #27
0
        public DatabaseBanStorage(ILmsService lmsService, LinqLogger logger)
        {
            this.LmsService = lmsService;
            this.Logger = logger;
            this.CreateIDataContext = () =>
                {
                    var db = new DBDataContext();

#if DEBUG
                    db.Log = logger;
#endif

                    return db;
                };
        }
Exemple #28
0
        public LuceneThread(ILmsService lmsService)
        {
            this.LmsService          = lmsService;
            this.luceneDataDirectory = new DirectoryInfo(this.LuceneDataPath);

            this.SearchTypes.Add(typeof(User), new SearchType <User>(new UserDefinition(), this.LuceneDataPath));
            this.SearchTypes.Add(typeof(Group), new SearchType <Group>(new GroupDefinition(), this.LuceneDataPath));
            this.SearchTypes.Add(typeof(Discipline), new SearchType <Discipline>(new DisciplineDefinition(), this.LuceneDataPath));
            this.SearchTypes.Add(typeof(Course), new SearchType <Course>(new CourseDefinition(), this.LuceneDataPath));
            this.SearchTypes.Add(typeof(Topic), new SearchType <Topic>(new TopicDefinition(), this.LuceneDataPath));
            this.SearchTypes.Add(typeof(Node), new SearchType <Node>(new NodeDefinition()
            {
                CourseService = this.LmsService.FindService <ICourseService>()
            }, this.LuceneDataPath));
        }
Exemple #29
0
 public SelectGroupsModel(ILmsService iLmsService, int selectTopicId, String teacherUserName, String disciplineName)
 {
     IEnumerable<Group> allowedGroups;
     Topic selectTopic;
     selectTopic = iLmsService.FindService<ICurriculumService>().GetTopic(selectTopicId);
     _TopicName = selectTopic.Name;
     _TeacheUserName = teacherUserName;
     _DisciplineName = disciplineName;
     allowedGroups = iLmsService.FindService<ICurriculumService>().GetGroupsAssignedToTopic(selectTopicId);
     //
     if (allowedGroups != null & allowedGroups.Count() != 0)
         _AllowedGroups = allowedGroups;
     else
         _AllowedGroups = null;            
 }
Exemple #30
0
        public DatabaseBanStorage(ILmsService lmsService, LinqLogger logger)
        {
            this.LmsService         = lmsService;
            this.Logger             = logger;
            this.CreateIDataContext = () =>
            {
                var db = new DBDataContext();

#if DEBUG
                db.Log = logger;
#endif

                return(db);
            };
        }
Exemple #31
0
 public SelectThemeModel(ILmsService iLmsService,long selectCurriculumId, String teacherUserName)
 {
     IEnumerable<Theme> allowedThemes;
     User teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser();
     IEnumerable<Course> availableCourses = iLmsService.FindService<ICourseService>().GetCourses(teacherUser);
     //
     allowedThemes = iLmsService.FindService<ICurriculumService>().GetThemesByCurriculumId((int)selectCurriculumId)
         .Where(theme => availableCourses.Count(course => course.Id == theme.CourseRef) != 0);
     //
     if (allowedThemes != null & allowedThemes.Count() != 0)
         _AllowedThemes = allowedThemes;
     else
         _AllowedThemes = null;
     _TeacheUserName = teacherUserName;
     _CurriculumName = iLmsService.FindService<ICurriculumService>().GetCurriculum((int)selectCurriculumId).Name;
 }
Exemple #32
0
 public SelectTopicModel(ILmsService iLmsService,long selectDisciplineId, String teacherUserName)
 {
     IEnumerable<Topic> allowedTopics;
     User teacherUser = iLmsService.FindService<IUserService>().GetCurrentUser();
     IEnumerable<Course> availableCourses = iLmsService.FindService<ICourseService>().GetCourses(teacherUser);
     //
     allowedTopics = iLmsService.FindService<IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId)
         .Where(topic => availableCourses.Count(course => course.Id == topic.TestCourseRef) != 0);
     //
     if (allowedTopics != null & allowedTopics.Count() != 0)
         _AllowedTopics = allowedTopics;
     else
         _AllowedTopics = null;
     _TeacheUserName = teacherUserName;
     _DisciplineName = iLmsService.FindService<IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name;
 }
Exemple #33
0
        public IndexModel(ILmsService iLmsService)
        {
            IEnumerable <Curriculum> allowedCurriculums;
            User teacherUser;

            teacherUser        = iLmsService.FindService <IUserService>().GetCurrentUser();
            allowedCurriculums = iLmsService.FindService <ICurriculumService>().GetCurriculumsWithThemesOwnedByUser(teacherUser);
            //
            if (allowedCurriculums != null & allowedCurriculums.Count() != 0)
            {
                _AllowedCurriculums = allowedCurriculums;
            }
            else
            {
                _AllowedCurriculums = null;
            }
            _TeacherUser = teacherUser;
        }
Exemple #34
0
        public IndexModel(ILmsService iLmsService)
        {
            IEnumerable <Discipline> allowedDisciplines;
            User teacherUser;

            teacherUser        = iLmsService.FindService <IUserService>().GetCurrentUser();
            allowedDisciplines = iLmsService.FindService <ICurriculumService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser);
            //
            if (allowedDisciplines != null & allowedDisciplines.Count() != 0)
            {
                _AllowedDisciplines = allowedDisciplines;
            }
            else
            {
                _AllowedDisciplines = null;
            }
            _TeacherUser = teacherUser;
        }
Exemple #35
0
        public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectCurriculumIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult     specializedResult;
            CurriculumResult      curRes;
            ThemeResult           themeResult;


            asr.Users = users.ToList();
            asr.SelectCurriculumIds = selectCurriculumIds;
            asr.Curriculums         = _LmsService.FindService <ICurriculumService>().GetCurriculums(selectCurriculumIds);

            IEnumerable <int> ieIds = selectCurriculumIds;

            foreach (User usr in asr.Users)
            {
                specializedResult             = new SpecializedResult();
                specializedResult.Curriculums = _LmsService.FindService <ICurriculumService>().GetCurriculums(ieIds);
                foreach (Curriculum curr in specializedResult.Curriculums)
                {
                    curRes        = new CurriculumResult();
                    curRes.Themes = _LmsService.FindService <ICurriculumService>().GetThemesByCurriculumId(curr.Id);

                    #region ThemeResult

                    foreach (Theme theme in curRes.Themes)
                    {
                        themeResult = new ThemeResult(usr, theme);
                        themeResult.AttemptResults = _LmsService.FindService <ITestingService>().GetResults(usr, theme);
                        themeResult.Res            = themeResult.GetThemeResultScore();
                        curRes.ThemeResult.Add(themeResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.CurriculumResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return(asr);
        }
        public AllSpecializedResults GetResults(IEnumerable <User> users, int[] selectDisciplineIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult     specializedResult;
            DisciplineResult      curRes;
            TopicResult           topicResult;


            asr.Users = users.ToList();
            asr.SelectDisciplineIds = selectDisciplineIds;
            asr.Disciplines         = _LmsService.FindService <ICurriculumService>().GetDisciplines(selectDisciplineIds);

            IEnumerable <int> ieIds = selectDisciplineIds;

            foreach (User usr in asr.Users)
            {
                specializedResult             = new SpecializedResult();
                specializedResult.Disciplines = _LmsService.FindService <ICurriculumService>().GetDisciplines(ieIds);
                foreach (Discipline curr in specializedResult.Disciplines)
                {
                    curRes        = new DisciplineResult();
                    curRes.Topics = _LmsService.FindService <ICurriculumService>().GetTopicsByDisciplineId(curr.Id);

                    #region TopicResult

                    foreach (Topic topic in curRes.Topics)
                    {
                        topicResult = new TopicResult(usr, topic);
                        topicResult.AttemptResults = _LmsService.FindService <ITestingService>().GetResults(usr, topic);
                        topicResult.Res            = topicResult.GetTopicResultScore();
                        curRes.TopicResult.Add(topicResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.DisciplineResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return(asr);
        }
Exemple #37
0
        public double?GetTopicResultScore(ILmsService lmsService)
        {
            if (this.AttemptResults.Count() == 0 || this.AttemptResults.First().Score.ScaledScore == null)
            {
                this.Res    = 0.0;
                this.ResMax = 0.0;
            }
            else
            {
                // hotfix: added checking of Course id
                var attemptResult =
                    this.AttemptResults.FirstOrDefault(
                        x =>
                        x.User.Id == this.user.Id & x.CurriculumChapterTopic.Id == this.curriculumChapterTopic.Id &
                        x.CurriculumChapterTopic.Topic.TestCourseRef == x.IudicoCourseRef);

                if (attemptResult == null)
                {
                    this.Res    = 0.0;
                    this.ResMax = 0.0;

                    return(this.Res);
                }

                this.Res = attemptResult.Score.RawScore;

                var answerResults = lmsService.FindService <ITestingService>().GetAnswers(attemptResult);

                int iudicoCourseRef = attemptResult.IudicoCourseRef;
                var courseInfo      = lmsService.FindService <ICourseService>().GetCourseInfo(iudicoCourseRef);

                double maxScore = 0;
                foreach (var node in courseInfo.NodesInfo)
                {
                    if (answerResults.Any(answer => int.Parse(answer.PrimaryResourceFromManifest.Replace(".html", string.Empty)) == node.Id))
                    {
                        maxScore += node.MaxScore;
                    }
                }
                this.ResMax = maxScore;
            }

            return(this.Res);
        }
Exemple #38
0
        public void LmsDoesNotThrowsExceptionWhenNoActionsFound()
        {
            HttpContext.Current = null;
            IWindsorContainer cont = new WindsorContainer();

            InitializeWindsor(ref cont);
            ILmsService serv   = cont.Resolve <ILmsService>();
            var         plugin = cont.Resolve <IPlugin>();

            try
            {
                plugin.BuildActions();
            }
            catch
            {
                Assert.Fail();
            }
            Assert.Pass();
        }
        public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectDisciplineIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult specializedResult;
            DisciplineResult curRes;
            TopicResult topicResult;

            
            asr.Users = users.ToList();
            asr.SelectDisciplineIds = selectDisciplineIds;
            asr.Disciplines = _LmsService.FindService<ICurriculumService>().GetDisciplines(selectDisciplineIds);

            IEnumerable<int> ieIds = selectDisciplineIds;
            foreach (User usr in asr.Users)
            {
                specializedResult = new SpecializedResult();
                specializedResult.Disciplines = _LmsService.FindService<ICurriculumService>().GetDisciplines(ieIds);
                foreach (Discipline curr in specializedResult.Disciplines)
                {
                    curRes = new DisciplineResult();
                    curRes.Topics = _LmsService.FindService<ICurriculumService>().GetTopicsByDisciplineId(curr.Id);
                    
                    #region TopicResult

                    foreach (Topic topic in curRes.Topics)
                    {
                        topicResult = new TopicResult(usr, topic);
                        topicResult.AttemptResults = _LmsService.FindService<ITestingService>().GetResults(usr, topic);
                        topicResult.Res = topicResult.GetTopicResultScore();
                        curRes.TopicResult.Add(topicResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.DisciplineResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return asr;
        }
        public AllSpecializedResults GetResults(IEnumerable<User> users, int[] selectCurriculumIds, ILmsService ILMS)
        {
            _LmsService = ILMS;
            AllSpecializedResults asr = new AllSpecializedResults();
            SpecializedResult specializedResult;
            CurriculumResult curRes;
            ThemeResult themeResult;

            
            asr.Users = users.ToList();
            asr.SelectCurriculumIds = selectCurriculumIds;
            asr.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(selectCurriculumIds);

            IEnumerable<int> ieIds = selectCurriculumIds;
            foreach (User usr in asr.Users)
            {
                specializedResult = new SpecializedResult();
                specializedResult.Curriculums = _LmsService.FindService<ICurriculumService>().GetCurriculums(ieIds);
                foreach (Curriculum curr in specializedResult.Curriculums)
                {
                    curRes = new CurriculumResult();
                    curRes.Themes = _LmsService.FindService<ICurriculumService>().GetThemesByCurriculumId(curr.Id);
                    
                    #region ThemeResult

                    foreach (Theme theme in curRes.Themes)
                    {
                        themeResult = new ThemeResult(usr, theme);
                        themeResult.AttemptResults = _LmsService.FindService<ITestingService>().GetResults(usr, theme);
                        themeResult.Res = themeResult.GetThemeResultScore();
                        curRes.ThemeResult.Add(themeResult);
                    }

                    #endregion

                    curRes.CalculateSumAndMax(usr, curr);
                    specializedResult.CurriculumResult.Add(curRes);
                }
                specializedResult.CalculateSpecializedResult(usr);
                asr.SpecializedResult.Add(specializedResult);
            }
            return asr;
        }
Exemple #41
0
        public IndexModel(ILmsService iLmsService)
        {
            IEnumerable <Discipline> allowedDisciplines;
            User teacherUser;

            teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser();
            //TODO: review this method
            allowedDisciplines = new Discipline[] {};
            //allowedDisciplines = iLmsService.FindService<IDisciplineService>().GetDisciplinesWithTopicsOwnedByUser(teacherUser);
            //
            if (allowedDisciplines != null & allowedDisciplines.Count() != 0)
            {
                _AllowedDisciplines = allowedDisciplines;
            }
            else
            {
                _AllowedDisciplines = null;
            }
            _TeacherUser = teacherUser;
        }
Exemple #42
0
        public SelectGroupsModel(ILmsService iLmsService, int selectTopicId, String teacherUserName, String disciplineName)
        {
            IEnumerable <Group> allowedGroups;
            Topic selectTopic;

            selectTopic     = iLmsService.FindService <IDisciplineService>().GetTopic(selectTopicId);
            _TopicName      = selectTopic.Name;
            _TeacheUserName = teacherUserName;
            _DisciplineName = disciplineName;
            allowedGroups   = iLmsService.FindService <IDisciplineService>().GetGroupsAssignedToTopic(selectTopicId);
            //
            if (allowedGroups != null & allowedGroups.Count() != 0)
            {
                _AllowedGroups = allowedGroups;
            }
            else
            {
                _AllowedGroups = null;
            }
        }
Exemple #43
0
        public SelectGroupsModel(ILmsService iLmsService, int selectThemeId, String teacherUserName, String curriculumName)
        {
            IEnumerable <Group> allowedGroups;
            Theme selectTheme;

            selectTheme     = iLmsService.FindService <ICurriculumService>().GetTheme(selectThemeId);
            _ThemeName      = selectTheme.Name;
            _TeacheUserName = teacherUserName;
            _CurriculumName = curriculumName;
            allowedGroups   = iLmsService.FindService <ICurriculumService>().GetGroupsAssignedToTheme(selectThemeId);
            //
            if (allowedGroups != null & allowedGroups.Count() != 0)
            {
                _AllowedGroups = allowedGroups;
            }
            else
            {
                _AllowedGroups = null;
            }
        }
Exemple #44
0
        public SelectTopicModel(ILmsService iLmsService, long selectDisciplineId, String teacherUserName)
        {
            IEnumerable <Topic> allowedTopics;
            User teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser();
            IEnumerable <Course> availableCourses = iLmsService.FindService <ICourseService>().GetCourses(teacherUser);

            //
            allowedTopics = iLmsService.FindService <IDisciplineService>().GetTopicsByDisciplineId((int)selectDisciplineId)
                            .Where(topic => availableCourses.Count(course => course.Id == topic.TestCourseRef) != 0);
            //
            if (allowedTopics != null & allowedTopics.Count() != 0)
            {
                _AllowedTopics = allowedTopics;
            }
            else
            {
                _AllowedTopics = null;
            }
            _TeacheUserName = teacherUserName;
            _DisciplineName = iLmsService.FindService <IDisciplineService>().GetDiscipline((int)selectDisciplineId).Name;
        }
Exemple #45
0
        public ThemeInfoModel(int groupId, int curriculumId, ILmsService lmsService)
        {
            _LastAttempts = new List<AttemptResult>();

            CurriculumId = curriculumId;

            SelectGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(lmsService.FindService<IUserService>().GetGroup(groupId));

            SelectCurriculumThemes = lmsService.FindService<ICurriculumService>().GetThemesByCurriculumId(CurriculumId);

            foreach (var temp in from student in SelectGroupStudents
                                 from theme in SelectCurriculumThemes
                                 select lmsService.FindService<ITestingService>().GetResults(student, theme)
                                 into temp where temp != null select temp)
            {
                var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed)
                        .OrderBy(attempt => attempt.StartTime);
                if (filteredTemp.Count() != 0)
                    _LastAttempts.Add(filteredTemp.First());
            }
        }
 /// <summary>
 /// constructor that get all information from Testing System
 /// </summary>
 /// <param name="attemptId">id of attempt to show</param>
 /// <param name="attList">list of attempts from Session Context</param>
 /// <param name="lmsService">ILmsService for conection to Testing System</param>
 public TopicTestResultsModel(long attemptId, IEnumerable<AttemptResult> attList, ILmsService lmsService)
 {
     if (attemptId != -1)
     {
         Attempt = attList.First(c => c.AttemptId == attemptId);
         if (Attempt != null)
         {
             UserAnswers = lmsService.FindService<ITestingService>().GetAnswers(Attempt);
             if (UserAnswers != null)
                 _NoData = false;
             else
                 _NoData = true;
         }
         else
         {
             _NoData = true;
         }                
     }
     else
         _NoData = true;
 }
Exemple #47
0
        public SelectThemeModel(ILmsService iLmsService, long selectCurriculumId, String teacherUserName)
        {
            IEnumerable <Theme> allowedThemes;
            User teacherUser = iLmsService.FindService <IUserService>().GetCurrentUser();
            IEnumerable <Course> availableCourses = iLmsService.FindService <ICourseService>().GetCourses(teacherUser);

            //
            allowedThemes = iLmsService.FindService <ICurriculumService>().GetThemesByCurriculumId((int)selectCurriculumId)
                            .Where(theme => availableCourses.Count(course => course.Id == theme.CourseRef) != 0);
            //
            if (allowedThemes != null & allowedThemes.Count() != 0)
            {
                _AllowedThemes = allowedThemes;
            }
            else
            {
                _AllowedThemes = null;
            }
            _TeacheUserName = teacherUserName;
            _CurriculumName = iLmsService.FindService <ICurriculumService>().GetCurriculum((int)selectCurriculumId).Name;
        }
Exemple #48
0
        public TopicInfoModel(int groupId, int disciplineId, ILmsService lmsService)
        {
            _LastAttempts = new List<AttemptResult>();

            DisciplineId = disciplineId;

            Group group = lmsService.FindService<IUserService>().GetGroup(groupId);
            SelectGroupStudents = lmsService.FindService<IUserService>().GetUsersByGroup(group);

            SelectDisciplineTopics = lmsService.FindService<ICurriculumService>().GetTopicsByDisciplineId(DisciplineId);

            foreach (var temp in from student in SelectGroupStudents
                                 from topic in SelectDisciplineTopics
                                 select lmsService.FindService<ITestingService>().GetResults(student, topic)
                                 into temp where temp != null select temp)
            {
                var filteredTemp = temp//.Where(attempt => attempt.CompletionStatus == CompletionStatus.Completed)
                        .OrderBy(attempt => attempt.StartTime);
                if (filteredTemp.Count() != 0)
                    _LastAttempts.Add(filteredTemp.First());
            }
        }
 public MixedAnalyticsStorage(ILmsService lmsService)
 {
     this.lmsService = lmsService;
 }
 public MixedAnalyticsStorage(ILmsService lmsService)
 {
     _LmsService = lmsService;
     RefreshState();
 }
Exemple #51
0
 public MixedCourseStorage(ILmsService lmsService)
 {
     _LmsService = lmsService;
 }
 public MixedStatisticsStorage(ILmsService lmsService)
 {
     LmsService = lmsService;
 }
Exemple #53
0
 public DatabaseBanStorage(ILmsService lmsService, Func<ISecurityDataContext> createIDataContext)
 {
     this.LmsService = lmsService;
     this.CreateIDataContext = createIDataContext;
 }
Exemple #54
0
        public void GenerateMenuUsingRoleNone()
        {
            var httpRequest = new HttpRequest(string.Empty, "http://mySomething/", string.Empty);
            var stringWriter = new StringWriter();
            var httpResponce = new HttpResponse(stringWriter);

            // httpResponce.Filter = new FileStream("asd.pdo",FileMode.CreateNew);
            var httpConextMock = new HttpContext(httpRequest, httpResponce);

            HttpContext.Current = httpConextMock;
            var menu = new Menu();
            var menu1 = new Menu();
            container = new WindsorContainer();

            // HttpContext.Current = new HttpContext(new HttpRequest("", "http://iudico.com", null), new HttpResponse(new StreamWriter("mayBeDeleted.txt")));
            InitializeWindsor(ref container);

            service = container.Resolve<ILmsService>();
            PluginController.LmsService = service;
            var plugins = container.ResolveAll<IPlugin>();
            var actions = new Dictionary<IPlugin, IEnumerable<Action>>();
            var roles = new List<Role> { Role.None };

            var currentRole = from rol in roles select rol;
            var userServiceMock = new Mock<IUserService>();
            userServiceMock.Setup(item => item.GetCurrentUserRoles()).Returns(currentRole);
            var userServiceVar = service.FindService<IUserService>();
            userServiceVar = userServiceMock.Object;
            var lmsservice = new Mock<ILmsService>();
            lmsservice.Setup(item => item.FindService<IUserService>()).Returns(userServiceMock.Object);
            var acct = new AccountController(new DatabaseUserStorage(service));
            lmsservice.Setup(item => item.GetMenu()).Returns(menu);

            try
            {
                service = lmsservice.Object;
                service.Inform(LMSNotifications.ApplicationRequestStart);
            }
            catch (Exception)
            {
            }

            foreach (var plugin in plugins)
            {
                menu.Add(plugin.BuildMenuItems().Where(m => this.IsAllowed(m.Controller, m.Action, roles)));
            }

            foreach (var plugin in plugins)
            {
                var menu11 = plugin.BuildMenuItems();

                foreach (var menu2 in menu.Items)
                {
                    if (menu11.Count(item => item == menu2) == 0)
                    {
                        Assert.Fail("Iterms mismatch");
                    }
                }
            }
        }
Exemple #55
0
 public MixedAnalyticsStorage(ILmsService lmsService)
 {
     _LmsService = lmsService;
     RefreshState();
 }
Exemple #56
0
 /// <summary>
 /// Constructor with parameters .
 /// </summary>
 /// <param name="lmsService">ILmsService service .</param>
 public StatisticsProxy(ILmsService lmsService)
 {
     _LmsService = lmsService;
 }
Exemple #57
0
        /// <summary>
        /// constructor that get all information from Testing System
        /// </summary>
        /// <param name="attemptId">id of attempt to show</param>
        /// <param name="attList">list of attempts from Session Context</param>
        /// <param name="lmsService">ILmsService for conection to Testing System</param>
        public TopicTestResultsModel(long attemptId, IEnumerable <AttemptResult> attList, int groupId, ILmsService lmsService)
        {
            if (attemptId != -1)
            {
                this.group = lmsService.FindService <IUserService>().GetGroup(groupId);
                // hotfix: added checking of Course id
                this.attempt =
                    attList.FirstOrDefault(
                        c =>
                        c.AttemptId == attemptId && c.CurriculumChapterTopic.Topic.TestCourseRef == c.IudicoCourseRef);
                if (this.attempt != null)
                {
                    this.userAnswers = lmsService.FindService <ITestingService>().GetAnswers(this.attempt);
                    this.courseInfo  =
                        lmsService.FindService <ICourseService>().GetCourseInfo(this.attempt.IudicoCourseRef);

                    this.hasNoData = this.userAnswers == null;
                }
                else
                {
                    this.hasNoData = true;
                }
            }
            else
            {
                this.hasNoData = true;
            }
        }
 public DatabaseUserStorage(ILmsService lmsService) : this(lmsService, null)
 {
 }
Exemple #59
0
 public MixedCourseStorage(ILmsService lmsService)
 {
     _LmsService = lmsService;
 }
        /*protected const string EmailPassword = "******";*/

        public DatabaseUserStorage(ILmsService lmsService, LinqLogger logger)
        {
            this.lmsService = lmsService;
            this.Logger = logger;
        }