Exemple #1
0
 protected override void LoadViewState(object savedState)
 {
     base.LoadViewState(savedState);
     if (ViewState["coursePageRecordId"] is int)
     {
         var                     coursePageRecordId      = ( int )ViewState["coursePageRecordId"];
         RockContext             rockContext             = new RockContext();
         CoursePageRecordService coursePageRecordService = new CoursePageRecordService(rockContext);
         coursePageRecord = coursePageRecordService.Get(coursePageRecordId);
         if (coursePageRecord != null)
         {
             DisplayCoursePage();
         }
     }
 }
Exemple #2
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            //Need to recreate the coursePageRecord with our own context
            RockContext             rockContext             = new RockContext();
            CoursePageRecordService coursePageRecordService = new CoursePageRecordService(rockContext);

            coursePageRecord = coursePageRecordService.Get(coursePageRecord.Id);

            var component = GetPageComponent();

            component.ScoreCourse(controls, coursePageRecord);
            coursePageRecord.CompletionDateTime = Rock.RockDateTime.Now;
            rockContext.SaveChanges();

            coursePageRecord = GetCurrentCoursePageRecord(rockContext);
            if (coursePageRecord != null)
            {
                DisplayCoursePage();
            }
        }
Exemple #3
0
        private void UpdateTableOfContents(CoursePage coursePage)
        {
            phTOC.Controls.Clear();
            phMobileTOC.Controls.Clear();

            var course = coursePage.Chapter.Course;
            var passed = false;
            var first  = true;

            var mostAdvancedCoursePageId = coursePage.Id;

            if (ViewState["coursePageRecordId"] is int)
            {
                RockContext             rockContext             = new RockContext();
                CoursePageRecordService coursePageRecordService = new CoursePageRecordService(rockContext);
                mostAdvancedCoursePageId = coursePageRecordService.Get(( int )ViewState["coursePageRecordId"]).CoursePageId;
            }



            foreach (var chapter in course.Chapters.OrderBy(c => c.Order).ToList())
            {
                var ltChapter = new Literal
                {
                    ID = "ltChapter" + chapter.Id.ToString(),
                };
                if (coursePage.ChapterId == chapter.Id)
                {
                    ltChapter.Text = string.Format("<b>{0}</b></br>", chapter.Name);
                }
                else
                {
                    ltChapter.Text = string.Format("{0}</br>", chapter.Name);
                }
                phTOC.Controls.Add(ltChapter);

                //Mobile
                if (!first)
                {
                    HtmlGenericControl liDivider = new HtmlGenericControl("li");
                    liDivider.AddCssClass("divider");
                    phMobileTOC.Controls.Add(liDivider);
                }
                first = false;

                HtmlGenericControl liChapter = new HtmlGenericControl("li");
                liChapter.AddCssClass("dropdown-header");
                liChapter.InnerText = chapter.Name;
                phMobileTOC.Controls.Add(liChapter);


                //Add the course pages
                foreach (var page in chapter.CoursePages.OrderBy(c => c.Order).ToList())
                {
                    phTOC.Controls.Add(new Literal {
                        Text = "&emsp;"
                    });

                    if (page.Id == coursePage.Id)
                    {
                        Literal ltPage = new Literal
                        {
                            ID   = "ltPage" + page.Id.ToString(),
                            Text = string.Format("<a href='#'><i class='fa fa-caret-right'></i> {0}</a><br>", page.Name)
                        };

                        phTOC.Controls.Add(ltPage);

                        //Mobile
                        phMobileTitle.Controls.Clear();
                        Literal mobileTitle = new Literal
                        {
                            Text = page.Name
                        };
                        phMobileTitle.Controls.Add(mobileTitle);

                        HtmlGenericControl li = new HtmlGenericControl("li")
                        {
                            InnerHtml = string.Format("<a href='#'><i class='fa fa-caret-right'></i> {0}</a>", page.Name)
                        };
                        phMobileTOC.Controls.Add(li);
                    }
                    else
                    {
                        LinkButton lbPage = new LinkButton
                        {
                            ID   = "lbPage" + page.Id.ToString(),
                            Text = string.Format("{0}<br>", page.Name)
                        };

                        HtmlGenericControl li = new HtmlGenericControl("li");
                        phMobileTOC.Controls.Add(li);

                        LinkButton lbMobile = new LinkButton
                        {
                            ID   = "lbMobile" + page.Id.ToString(),
                            Text = page.Name
                        };

                        if (passed)
                        {
                            lbPage.Enabled   = false;
                            lbMobile.Enabled = false;
                        }
                        else
                        {
                            lbPage.Click   += (s, e) => { MoveToPage(page.Id); };
                            lbMobile.Click += (s, e) => { MoveToPage(page.Id); };
                        }

                        phTOC.Controls.Add(lbPage);
                        li.Controls.Add(lbMobile);
                    }


                    if (page.Id == mostAdvancedCoursePageId)
                    {
                        passed = true;
                    }
                }
            }
        }