示例#1
0
    public void loadQuestions()
    {
        List <int> starred = GameObject.Find("Controller").GetComponent <MainController>().StarredQuestions;

        questions.Clear();
        questions = GameObject.Find("Controller").GetComponent <MainController>().GameQuestions;
        int num = 1;

        foreach (KeyValuePair <int, Questions> question in questions)
        {
            GameObject     go = Instantiate(answerContainer);
            QuestionReview qr = go.GetComponent <QuestionReview>();
            for (int q = 0; q < question.Value.Answer.Length; q++)
            {
                if (question.Value.Answer[q].Choices != null)
                {
                    if (question.Value.Answer[q].Correct)
                    {
                        qr.answerText.text = question.Value.Answer[q].Choices;
                    }
                }
            }
            qr.questionText.text       = question.Value.Question;
            qr.questionNumberText.text = num.ToString();
            if (starred.Contains(question.Value.ID))
            {
                qr.starred.sprite = starredImage;
            }
            else
            {
                qr.starred.sprite = notStarred;
            }
            qr.id = question.Value.ID;
            go.transform.parent     = questionReviewList.transform;
            go.transform.localScale = new Vector3(0, 0, 0);
            num++;

            questionContainers.Add(go);
        }
    }
        /// <summary>
        /// Save the review details
        /// </summary>
        private void SubmitReview()
        {
            _questionReview = _reviewFacade.GetAllQuestionReview(_questionId, SessionObject.LoggedInUser.UserId);

            if (_questionReview == default(QuestionReview))
                _questionReview = new QuestionReview();

            GetQuestionReview();
            GetAge();
            GetGrade();
            GetReview();
            GetReviewComment();
            GetSpecialPopulation();

            

            _reviewFacade.SubmitReview(_questionReview);
            CloseAndRefreshDialog();
        }
 /// <summary>
 /// Get the initial details from database.
 /// </summary>
 private void GetData()
 {
     _questionReview = _reviewFacade.GetAllQuestionReview(_questionId, SessionObject.LoggedInUser.UserId);
 }
 /// <summary>
 /// 
 /// </summary>
 private void GetData()
 {
     _questionReview = _reviewFacade.GetAllQuestionReview(_questionId, _userId);
 }
    public void LoadQuestions(bool star = false)
    {
        foreach (Transform child in questionReviewList.transform)
        {
            Destroy(child.gameObject);
        }

        questionContainers.Clear();
        questions = GameObject.Find("Controller").GetComponent <MainController>().GameQuestions;
        testQuestions.Clear();
        correctAnswers.Clear();
        incorrectAnswers.Clear();
        List <int> starred = GameObject.Find("Controller").GetComponent <MainController>().StarredQuestions;

        if (star)
        {
            testQuestions = starred;
            this.gameObject.transform.Find("TopBar").Find("Text").GetComponent <Text>().text = "Starred Questions";
        }
        else
        {
            correctAnswers   = Test.current.getCorrectQuestions();
            incorrectAnswers = Test.current.getIncorrectQuestions();
            testQuestions    = Test.current.getQuestionList();
            this.gameObject.transform.Find("TopBar").Find("Text").GetComponent <Text>().text = "Test " + Test.current.testID;
        }

        int num = 1;

        foreach (int questioon in testQuestions)
        {
            Questions  question = questions[questioon];
            GameObject go;
            if (Test.current.getCorrectQuestions().Contains(question.ID))
            {
                go = Instantiate(correctAnswerContainer);
            }
            else if (incorrectAnswers.Contains(question.ID))
            {
                go = Instantiate(incorrectAnswerContainer);
            }
            else
            {
                go = Instantiate(answerContainer);
            }

            QuestionReview qr = go.GetComponent <QuestionReview>();

            if (starred.Contains(question.ID))
            {
                qr.starred.sprite = starredImage;
            }
            else
            {
                qr.starred.sprite = notStarred;
            }

            for (int q = 0; q < question.Answer.Length; q++)
            {
                if (question.Answer[q].Choices != null)
                {
                    if (question.Answer[q].Correct)
                    {
                        qr.answerText.text = question.Answer[q].Choices;
                    }
                }
            }
            qr.questionText.text       = question.Question;
            qr.questionNumberText.text = num.ToString();
            qr.id = question.ID;
            go.transform.parent     = questionReviewList.transform;
            go.transform.localScale = new Vector3(0, 0, 0);
            num++;

            questionContainers.Add(go);
        }
    }
        /// <summary>
        /// Set Edit and Delete button rules.
        /// Edit button will be available only for reviewer who creates the review.
        /// Delete button will be available only for reviewer who creates the review and who has Admin role. 
        /// </summary>
        /// <param name="e"></param>
        /// <param name="questionReivew"></param>
        private void SetEditAndDeleteButtonRules(RepeaterItemEventArgs e, QuestionReview questionReivew)
        {
            RadButton btnEdit = e.Item.FindControl("btnEdit") as RadButton;
            if (btnEdit != null)
            {
                btnEdit.Visible = (questionReivew.CreatedById == SessionObject.LoggedInUser.UserId);
            }

            RadButton btnDelete = e.Item.FindControl("btnDelete") as RadButton;
            if (btnDelete != null)
            {
                btnDelete.Visible = ((questionReivew.CreatedById
                                      == SessionObject.LoggedInUser.UserId)
                                     || SessionObject.LoggedInUser.Roles.Any(
                                         any => any.RoleName.Contains("Admin")));
            }

        }
        /// <summary>
        /// Set Rating, CreatedBy and Date Control based on questionreview
        /// </summary>
        /// <param name="e"></param>
        /// <param name="questionReview"></param>
        private void SetRatingCreatedByAndDateControls(RepeaterItemEventArgs e, QuestionReview questionReview)
        {
            RadRating ctrlRating = e.Item.FindControl("rating") as RadRating;

            if (ctrlRating != null && questionReview.Rating != null)
            {
                ctrlRating.Value = questionReview.Rating.RatingValue;
            }

            Label ctrlReviewer = e.Item.FindControl("lblReviewer") as Label;

            if (ctrlReviewer != null)
            {
                ctrlReviewer.Text = String.Format(
                    "{0}{1}{2}",
                    questionReview.CreatorName,
                    HTML_NEW_LINE,
                    questionReview.Review.RoleName);
            }

            Label ctrlDate = e.Item.FindControl("lblDate") as Label;

            if (ctrlDate != null && questionReview.Review != default(Review))
            {
                ctrlDate.Text = questionReview.Review.CreatedDate.ToShortDateString();
            }
        }
        /// <summary>
        /// Set the comment control based on questionreview
        /// </summary>
        /// <param name="e"></param>
        /// <param name="questionReivew"></param>
        private void SetCommentControl(RepeaterItemEventArgs e, QuestionReview questionReivew)
        {
            Literal ctrlComment = e.Item.FindControl("ltrReviewLimited") as Literal;

            if (ctrlComment != null && questionReivew.ReviewComment != default(AdminTestQuestionComments))
            {
                ctrlComment.Text = questionReivew.ReviewComment.CommentText.Length > 100 ?
                                   questionReivew.ReviewComment.CommentText.Substring(0, 100) :
                                   questionReivew.ReviewComment.CommentText;

                if (questionReivew.ReviewComment.CommentText.Length > 100)
                {
                    LinkButton moreLink = e.Item.FindControl("btnComment") as LinkButton;
                    if (moreLink != null)
                    {
                        moreLink.Visible = true;
                    }

                    Literal ctrlCommentFull = e.Item.FindControl("ltrReviewFull") as Literal;
                    if (ctrlCommentFull != null)
                    {
                        ctrlCommentFull.Text = questionReivew.ReviewComment.CommentText;
                    }
                }
            }
        }