示例#1
0
        protected override void Fill()
        {
            // if the course number does not exist, them bad course
            TrngCourse course = new TrngCourse(CourseID);

            Session["CourseID"]         = course.ID.ToString();
            Session["QuestionsCorrect"] = 0;
            //lblErrorMessage.Text += "Correct Answers: " + Session["QuestionsCorrect"].ToString();
            if (course.ID == 0)
            {
                Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.TrainingCourseInvalid), false);
            }
            else if (TrngSlide.ActiveCount(CourseID) == 0)
            {
                Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.TrainingSlideCountZero), false);
            }
            else
            {
                Action.Write(string.Format("Started Course: {0}", course.Name), CurrentUser.DisplayName);
                BuildSlide(CourseID, SlideNumber);
            }
        }
示例#2
0
        private void BuildSlide(int CourseID, int SlideNumber)
        {
            try {
                trFinished.Visible = false;
                int SlideCount = TrngSlide.ActiveCount(CourseID);
                btnPrevious.Enabled = SlideNumber > 1 ? true : false;
                //btnNext.Enabled = SlideNumber < SlideCount ? true : false;
                btnNext.Text = SlideNumber == SlideCount ? "Finish" : "Next";

                TrngSlide     slide  = new TrngSlide(CourseID, SlideNumber);
                TrngSlideType type   = new TrngSlideType(slide.SlideTypeID);
                TrngCourse    course = new TrngCourse(CourseID);
                lblHeader.Text          = course.Name;
                lblPageDescription.Text = course.Name;
                lblDescription.Text     = slide.Description;
                trDescription.Visible   = slide.Description.Length > 5 ? true : false;
                lblPager.Text           = string.Format("Slide Number: {0} of {1}</br>", slide.Number.ToString(), SlideCount);
                int displayWith = int.Parse(Setting.KeyValue("CourseSlideWidth"));
                if (course.IsGraded)
                {
                    btnPrevious.Enabled = false;
                }

                if (type.Name.ToUpper() == "CONTENT")
                {
                    trContent.Visible   = true;
                    trQuestion.Visible  = false;
                    trFreeText.Visible  = false;
                    trVideo.Visible     = false;
                    imgContent.ImageUrl = slide.ContentURL.Length > 5 ? slide.ContentURL : "/_layouts/15/images/SPA/SlideNotFound.PNG";
                    imgContent.Width    = Unit.Percentage(displayWith);
                }
                else if (type.Name.ToUpper() == "FREETEXT")
                {
                    trFreeText.Visible = true;
                    trContent.Visible  = false;
                    trQuestion.Visible = false;
                    trVideo.Visible    = false;
                    lblRichText.Text   = slide.RichText;
                    lblRichText.Width  = Unit.Percentage(displayWith);
                }
                else if (type.Name.ToUpper() == "VIDEO")
                {
                    trFreeText.Visible = false;
                    trContent.Visible  = false;
                    trQuestion.Visible = false;
                    trVideo.Visible    = true;

                    string media = slide.ContentURL.Length > 5 ? slide.ContentURL : string.Format("{0}/_layouts/15/spa/videoplayer/sample.wmv", SPContext.Current.Web.Url);

                    html.Text  = "<object data = 'data:application/x-silverlight-2,' type = 'application/x-silverlight-2' width = '640' height = '480'>" + Environment.NewLine;
                    html.Text += "<param name = 'source' value = '/_layouts/15/spa/videoplayer/videoplayer.xap' />" + Environment.NewLine;
                    html.Text += "<param name = 'background' value = 'white' />" + Environment.NewLine;
                    html.Text += string.Format("<param name = 'initParams' value = 'm=/{0},autostart=true' />", media) + Environment.NewLine;
                    html.Text += "<param name = 'minruntimeversion' value = '2.0.31005.0' />" + Environment.NewLine;
                    html.Text += "</object >" + Environment.NewLine;
                }
                else
                {
                    //tblQuestion.Width = string.Format("{0}%", displayWith);
                    trQuestion.Visible = true;
                    trContent.Visible  = false;
                    trFreeText.Visible = false;
                    trVideo.Visible    = false;
                    // build question for slide number
                    scoredQuestions++;
                    TrngQuestion question = new TrngQuestion(CourseID, slide.ID);
                    lblQuestion.Text = question.Question;
                    //lblQuestion.Width = Unit.Percentage(displayWith);
                    //lblQuestionComment.Text = string.Format("<br>{0}<br>", question.Comment);
                    //lblQuestionComment.Visible = question.Comment.Length > 5 ? true : false;
                    //lblQuestionComment.Width = Unit.Percentage(displayWith);

                    // get answer(s)
                    DataView dv = new DataView(TrngAnswer.Items(question.ID).Tables[0]);
                    rbtnlAnswers.DataSource     = dv;
                    rbtnlAnswers.DataTextField  = "Answer";
                    rbtnlAnswers.DataValueField = "ID";
                    rbtnlAnswers.DataBind();
                    //rbtnlAnswers.Width = Unit.Percentage(displayWith - 10);
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }