Exemple #1
0
 private static void CheckPageType(TblPages page)
 {
     if (page.PageTypeRef != (int?)FX_PAGETYPE.Theory)
     {
         throw new Exception("Wrong handler for page");
     }
 }
Exemple #2
0
        public UserResultForPageForDate(TblUserAnswers ua, int userId)
        {
            Date = (DateTime)ua.Date;

            _page = StudentRecordFinder.GetPageForQuestion((int)ua.QuestionRef);

            _userId = userId;
        }
Exemple #3
0
        public UserResultForPage(int userId, TblPages page, DateTime? date)
        {
            _date = date;
            _userId = userId;
            _page = page;

            _pageRank = (int)_page.PageRank;
        }
Exemple #4
0
        public UserResultForPage(int userId, TblPages page, DateTime?date)
        {
            _date   = date;
            _userId = userId;
            _page   = page;

            _pageRank = (int)_page.PageRank;
        }
Exemple #5
0
        public static bool IsContainCompiledQuestions(TblPages page)
        {
            var questions = StudentRecordFinder.GetQuestionsForPage(page);

            foreach (var question in questions)
                if (question.IsCompiled)
                    return true;

            return false;
        }
Exemple #6
0
        private static int Store(int themaRef, string name, byte[] file)
        {
            TblPages p = new TblPages
            {
                ThemeRef = themaRef,
                PageName = name,
                //PageFile = file,
                PageTypeRef = ((int)FX_PAGETYPE.Theory)
            };

            ServerModel.DB.Insert(p);

            return(p.ID);
        }
Exemple #7
0
        private static void AddAnswersFromPageToReCompilationList(TblPages page, IList <TblUsers> users, List <TblUserAnswers> answersForReCompilation)
        {
            var questions = StudentRecordFinder.GetQuestionsForPage(page);

            foreach (var u in users)
            {
                foreach (var q in questions)
                {
                    TblUserAnswers lstUserAnswer = GetLastUserAnswerForCompiledQuestion(q, u);

                    AddAnswerToReCompilationList(lstUserAnswer, answersForReCompilation);
                }
            }
        }
Exemple #8
0
        private static TblPages StorePageWithoutPageFile(int themaRef, string name, int rank)
        {
            var p = new TblPages
            {
                ThemeRef = themaRef,
                PageName = name,
                PageTypeRef = (int)FX_PAGETYPE.Practice,
                PageRank = rank
            };

            ServerModel.DB.Insert(p);

            return p;
        }
Exemple #9
0
        public static Control GetPracticeControl(TblPages page, Panel p)
        {
            p.ScrollBars = ScrollBars.Auto;

            string aspText = GetControlString(page);

            string aspTextWithCorrectImagesUrls = ChangeImageUrl(aspText, page);

            var control = p.Page.ParseControl(aspTextWithCorrectImagesUrls);

            var divFromPageControl = control.Controls[0];

            return(divFromPageControl);
        }
Exemple #10
0
        private static int Store(int themaRef, string name, byte[] file)
        {
            TblPages p = new TblPages
            {
                ThemeRef = themaRef,
                PageName = name,
                //PageFile = file,
                PageTypeRef = ((int)FX_PAGETYPE.Theory)
            };

            ServerModel.DB.Insert(p);

            return p.ID;
        }
Exemple #11
0
        public static Control GetPracticeControl(TblPages page, Panel p)
        {
            p.ScrollBars = ScrollBars.Auto;

            string aspText = GetControlString(page);

            string aspTextWithCorrectImagesUrls = ChangeImageUrl(aspText, page);

            var control = p.Page.ParseControl(aspTextWithCorrectImagesUrls);

            var divFromPageControl = control.Controls[0];

            return divFromPageControl;
        }
Exemple #12
0
        public static bool IsContainCompiledQuestions(TblPages page)
        {
            var questions = StudentRecordFinder.GetQuestionsForPage(page);

            foreach (var question in questions)
            {
                if (question.IsCompiled)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #13
0
        private static TblPages StorePageWithoutPageFile(int themaRef, string name, int rank)
        {
            var p = new TblPages
            {
                ThemeRef    = themaRef,
                PageName    = name,
                PageTypeRef = (int)FX_PAGETYPE.Practice,
                PageRank    = rank
            };

            ServerModel.DB.Insert(p);

            return(p);
        }
Exemple #14
0
        private static void DeleteFiles(TblPages page)
        {
            var files = ServerModel.DB.Load<TblFiles>(ServerModel.DB.LookupIds<TblFiles>(page, null));

            foreach (var file in files)
            {
                if (file.PID != null)
                    ServerModel.DB.Delete<TblFiles>(file.ID);
            }

            var folders = ServerModel.DB.Load<TblFiles>(ServerModel.DB.LookupIds<TblFiles>(page, null));

            foreach (var file in folders)
                ServerModel.DB.Delete<TblFiles>(file.ID);
        }
        public virtual async Task <PageModel> PreparePageModelAsync(TblPages page)
        {
            PageModel result;

            if (page == null)
            {
                result = new PageModel();
            }
            else
            {
                result = page.Adapt <PageModel>();
                await page.LoadAllLocalizedStringsToModelAsync(result);
            }
            return(result);
        }
        private void AddControl(TblPages page)
        {
            Control control;

            if ((FX_PAGETYPE)page.PageTypeRef == FX_PAGETYPE.Practice)
            {
                control = TestControlHelper.GetPracticeControl(page, PageContent);
            }
            else
            {
                throw new Exception("You can't see details for theory page");
            }

            PageContent.Controls.Clear();
            PageContent.Controls.Add(control);
            FillAnswer(control);
        }
Exemple #17
0
        private void ShowPage(TblPages page)
        {
            Control control;

            if ((FX_PAGETYPE)page.PageTypeRef == FX_PAGETYPE.Practice)
            {
                control = TestControlHelper.GetPracticeControl(page, PageContent);
                RedirectSubmitEventsToThisController(control, page.ID);
            }
            else
            {
                control = TestControlHelper.GetTheoryControl(page, PageContent);
            }

            PageContent.Controls.Clear();
            PageContent.Controls.Add(control);
        }
        private void AddControl(TblPages page)
        {
            Control control;

            if ((FX_PAGETYPE)page.PageTypeRef == FX_PAGETYPE.Practice)
            {
                control = TestControlHelper.GetPracticeControl(page, PageContent);
                
            }
            else
            {
                throw new Exception("You can't see details for theory page");
            }

            PageContent.Controls.Clear();
            PageContent.Controls.Add(control);
            FillAnswer(control);
        }
Exemple #19
0
        public static string ChangeImageUrl(string pageText, TblPages page)
        {
            var imageUrlRegex = new Regex(string.Format(@"src=""(?<{0}>(?<{1}>\w+.files)/(?<{2}>\w+.\w+))""", UrlRegexGroup, FolderRegexGroup, ImageRegexGroup));
            MatchCollection matches = imageUrlRegex.Matches(pageText);
            foreach (Match m in matches)
            {
                string imageName = m.Groups[ImageRegexGroup].Value;
                string folderName = m.Groups[FolderRegexGroup].Value;

                var list = ServerModel.DB.LookupIds<TblFiles>(page, null);
                var files = ServerModel.DB.Load<TblFiles>(list);


                string newUrl = string.Concat(ImageFileRequest, FindFileId(files, folderName, imageName));
                pageText = pageText.Replace(m.Groups[UrlRegexGroup].Value, newUrl);
            }

            return pageText;
        }
Exemple #20
0
        private static void DeleteFiles(TblPages page)
        {
            var files = ServerModel.DB.Load <TblFiles>(ServerModel.DB.LookupIds <TblFiles>(page, null));

            foreach (var file in files)
            {
                if (file.PID != null)
                {
                    ServerModel.DB.Delete <TblFiles>(file.ID);
                }
            }

            var folders = ServerModel.DB.Load <TblFiles>(ServerModel.DB.LookupIds <TblFiles>(page, null));

            foreach (var file in folders)
            {
                ServerModel.DB.Delete <TblFiles>(file.ID);
            }
        }
Exemple #21
0
        public virtual async Task <int> AddAsync(TblPages record)
        {
            if (record.ShowAsWebsiteDefaultPage && record.Published)
            {
                await _dbContext.Pages.Where(p => p.ShowAsWebsiteDefaultPage)
                .UpdateAsync(p => new TblPages()
                {
                    ShowAsWebsiteDefaultPage = false
                });
            }

            _dbContext.Pages.Add(record);
            await _dbContext.SaveChangesAsync();

            QueryCacheManager.ExpireTag(CacheTags.Page);

            _eventPublisher.EntityInserted(record);

            return(record.Id);
        }
Exemple #22
0
        public static string ChangeImageUrl(string pageText, TblPages page)
        {
            var             imageUrlRegex = new Regex(string.Format(@"src=""(?<{0}>(?<{1}>\w+.files)/(?<{2}>\w+.\w+))""", UrlRegexGroup, FolderRegexGroup, ImageRegexGroup));
            MatchCollection matches       = imageUrlRegex.Matches(pageText);

            foreach (Match m in matches)
            {
                string imageName  = m.Groups[ImageRegexGroup].Value;
                string folderName = m.Groups[FolderRegexGroup].Value;

                var list  = ServerModel.DB.LookupIds <TblFiles>(page, null);
                var files = ServerModel.DB.Load <TblFiles>(list);


                string newUrl = string.Concat(ImageFileRequest, FindFileId(files, folderName, imageName));
                pageText = pageText.Replace(m.Groups[UrlRegexGroup].Value, newUrl);
            }

            return(pageText);
        }
Exemple #23
0
        public virtual async Task UpdateAsync(TblPages record)
        {
            var oldRecord = await FindByIdAsync(record.Id);

            if (record.ShowAsWebsiteDefaultPage && record.Published)
            {
                await _dbContext.Pages.Where(p => p.ShowAsWebsiteDefaultPage)
                .UpdateAsync(p => new TblPages()
                {
                    ShowAsWebsiteDefaultPage = false
                });
            }

            _dbContext.Pages.AddOrUpdate(record);
            await _dbContext.SaveChangesAsync();

            QueryCacheManager.ExpireTag(CacheTags.Page);

            _eventPublisher.EntityUpdated(record, oldRecord);
        }
        private void ShowPage()
        {
            if (PageId != 0)
            {
                TblPages page = GetPage(PageId);

                var questions = ServerModel.DB.Load <TblQuestions>(ServerModel.DB.LookupIds <TblQuestions>(page, null));

                SetHeader(page);

                AddControl(page);

                MaxPageRank.Value   = GetMaxRank(questions).ToString();
                PageRank.Value      = ((int)page.PageRank).ToString();
                QuestionCount.Value = (questions.Count).ToString();
            }
            else
            {
                throw new Exception("Page ID is not specified");
            }
        }
Exemple #25
0
        private void SetDescription(TblPages p)
        {
            Description.Value = string.Format("You open {0}({1}) page", p.PageName, (FX_PAGETYPE)p.PageTypeRef);

            PageCount.Value = string.Format("{0}/{1}", PageIndex + 1, _pages.Length);
        }
 private void SetHeader(TblPages page)
 {
     PageTitle.Value  = GetPageTitleType();
     PageHeader.Value = string.Format("{0} for Page: {1}", GetPageTitleType(), page.PageName);
 }
Exemple #27
0
        private static void AddPageFileToPage(TblPages page, int fileID)
        {
            page.PageFile = fileID.ToString();

            ServerModel.DB.Update(page);
        }
Exemple #28
0
        private void SetDescription(TblPages p)
        {
            Description.Value = string.Format("You open {0}({1}) page", p.PageName, (FX_PAGETYPE) p.PageTypeRef);

            PageCount.Value = string.Format("{0}/{1}", PageIndex + 1, _pages.Length);
        }
Exemple #29
0
        public static Control GetTheoryControl(TblPages page, Panel p)
        {
            p.ScrollBars = ScrollBars.None;

            return(p.Page.ParseControl(string.Format(@"<IFRAME ID=""_iFrame""  width=""100%"" height=""100%"" Runat=""Server""  src=""DisplayTheory.itp?PageId={0}""></IFRAME>", page.ID)));
        }
Exemple #30
0
        private void ShowPage(TblPages page)
        {
            Control control;

            if ((FX_PAGETYPE)page.PageTypeRef == FX_PAGETYPE.Practice)
            {
                control = TestControlHelper.GetPracticeControl(page, PageContent);
                RedirectSubmitEventsToThisController(control, page.ID);
            }
            else
            {
                control = TestControlHelper.GetTheoryControl(page, PageContent);
            }

            PageContent.Controls.Clear();
            PageContent.Controls.Add(control);
        }
Exemple #31
0
        private static void AddPageFileToPage(TblPages page, int fileID)
        {
            page.PageFile = fileID.ToString();

            ServerModel.DB.Update(page);
        }
 private void SetHeader(TblPages page)
 {
     PageTitle.Value = GetPageTitleType();
     PageHeader.Value = string.Format("{0} for Page: {1}", GetPageTitleType(), page.PageName); 
 }
Exemple #33
0
        private static void AddPageFileToPage(TblPages page, byte[] pageFile)
        {
            page.PageFile = pageFile;

            ServerModel.DB.Update(page);
        }
Exemple #34
0
        private static void AddPageFileToPage(TblPages page, byte[] pageFile)
        {
            page.PageFile = pageFile;

            ServerModel.DB.Update(page);
        }
Exemple #35
0
 public static IList<TblQuestions> QuestionsOfPage(TblPages page)
 {
     return ServerModel.DB.Query<TblQuestions>(new CompareCondition<int>(
                          DataObject.Schema.PageRef,
                          new ValueCondition<int>(page.ID), COMPARE_KIND.EQUAL));
 }
Exemple #36
0
        private static string GetControlString(TblPages page)
        {
            string controlString = Encoding.Unicode.GetString(page.PageFile.ToArray());

            return controlString;
        }
Exemple #37
0
        private static string GetControlString(TblPages page)
        {
            string controlString = Encoding.Unicode.GetString(page.PageFile.ToArray());

            return(controlString);
        }
Exemple #38
0
        public static Control GetTheoryControl(TblPages page, Panel p)
        {
            p.ScrollBars = ScrollBars.None;

            return p.Page.ParseControl(string.Format(@"<IFRAME ID=""_iFrame""  width=""100%"" height=""100%"" Runat=""Server""  src=""DisplayTheory.itp?PageId={0}""></IFRAME>", page.ID));
        }
        public static IList <TblQuestions> GetQuestionsForPage(TblPages page)
        {
            var questionsIDs = ServerModel.DB.LookupIds <TblQuestions>(page, null);

            return(ServerModel.DB.Load <TblQuestions>(questionsIDs));
        }
Exemple #40
0
 private static void CheckPageType(TblPages page)
 {
     if(page.PageTypeRef != (int?) FX_PAGETYPE.Theory)
         throw new Exception("Wrong handler for page");
 }
Exemple #41
0
 public static IList <TblQuestions> QuestionsOfPage(TblPages page)
 {
     return(ServerModel.DB.Query <TblQuestions>(new CompareCondition <int>(
                                                    DataObject.Schema.PageRef,
                                                    new ValueCondition <int>(page.ID), COMPARE_KIND.EQUAL)));
 }
        public static IList<TblQuestions> GetQuestionsForPage(TblPages page)
        {
            var questionsIDs = ServerModel.DB.LookupIds<TblQuestions>(page, null);

            return ServerModel.DB.Load<TblQuestions>(questionsIDs);
        }
        private static void AddAnswersFromPageToReCompilationList(TblPages page, IList<TblUsers> users, List<TblUserAnswers> answersForReCompilation)
        {
            var questions = StudentRecordFinder.GetQuestionsForPage(page);

            foreach (var u in users)
            {
                foreach (var q in questions)
                {
                    TblUserAnswers lstUserAnswer = GetLastUserAnswerForCompiledQuestion(q, u);

                    AddAnswerToReCompilationList(lstUserAnswer, answersForReCompilation);
                }
            }
        }