Beispiel #1
0
 public Question_iPhone(BusinessModel.UserQuestion aUserQuestion) : base("Question_iPhone", null)
 {
     m_currentQuestionToDisplay =
         (from x in AppSession.SelectedExamUserQuestionList
          where x.UserQuestionID == aUserQuestion.UserQuestionID select x).FirstOrDefault();
     m_currentQuestionToDisplayIndex = AppSession.SelectedExamUserQuestionList.IndexOf(m_currentQuestionToDisplay);
     m_totalQuestionInExam           = AppSession.SelectedExamUserQuestionList.Count;
 }
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                UITableViewCell cell;

                cell = tableView.DequeueReusableCell("cell");
                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Default, "cell");
                }

                BusinessModel.UserQuestion _userQuestion = AppSession.SelectedExamUserQuestionList [indexPath.Row];

                cell.TextLabel.Text = "Question " + _userQuestion.Sequence;
                cell.Accessory      = UITableViewCellAccessory.DisclosureIndicator;
                if (_userQuestion.HasAnswered)
                {
                    if (AppSession.SelectedUserExam.IsSubmitted || AppSession.SelectedUserExam.IsLearningMode)
                    {
                        //If exam is submitted or the exam is in learning mode, we show whether the answer is correct or not
                        if (_userQuestion.HasAnsweredCorrectly)
                        {
                            cell.ImageView.Image       = UIImage.FromBundle("Images/Icon-Yes.png").Scale(new SizeF(24, 24));
                            cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                        }
                        else
                        {
                            cell.ImageView.Image       = UIImage.FromBundle("Images/Icon-No.png").Scale(new SizeF(24, 24));
                            cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                        }
                    }
                    else
                    {
                        //Otherwise, we just show the fact that the question has been answered (by removing the not answered mark)
                        cell.ImageView.Image       = UIImage.FromBundle("Images/Transparent.png").Scale(new SizeF(24, 24));
                        cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                    }
                }
                else
                {
                    cell.ImageView.Image       = UIImage.FromBundle("Images/Icon-QuestionMark.png").Scale(new SizeF(24, 24));
                    cell.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
                }

                return(cell);
            }
Beispiel #3
0
            public Question_iPhoneTableSource(BusinessModel.UserQuestion aUserQuestion, Question_iPhone aParentViewControlller)
            {
                m_currentViewController = aParentViewControlller;
                m_userQuestion          = aUserQuestion;
                m_question       = BusinessModel.Question.GetQuestionByQuestionID(aUserQuestion.QuestionID);
                m_questionImages = BusinessModel.Image.GetImagesByQuestionID(aUserQuestion.QuestionID);
                if (m_questionImages == null)
                {
                    m_questionImages = new List <BusinessModel.Image> ();
                }
                m_questionImages        = (from x in m_questionImages orderby x.Title select x).ToList();
                m_questionAnswerOptions = BusinessModel.UserAnswerOptionDetail.GetUserAnswerOptionDetailListByUserQuestionID(aUserQuestion.UserQuestionID);
                m_questionAnswerOptions = (from x in m_questionAnswerOptions orderby x.Sequence select x).ToList();

                if (AppSession.SelectedUserExam.IsSubmitted || (aUserQuestion.HasAnswered && AppSession.SelectedUserExam.IsLearningMode))
                {
                    m_showQuestionAnswer = true;
                }
                else
                {
                    m_showQuestionAnswer = false;
                }
            }
Beispiel #4
0
 public void ReloadCurrentQuestion()
 {
     m_currentQuestionToDisplay = AppSession.SelectedExamUserQuestionList [m_currentQuestionToDisplayIndex];
     tblvCurrentQuestion.Source = new Question_iPhoneTableSource(AppSession.SelectedExamUserQuestionList[m_currentQuestionToDisplayIndex], this);
     tblvCurrentQuestion.ReloadData();
 }
Beispiel #5
0
        private void svQuestionPager_Scrolled(object sender, EventArgs e)
        {
            int _scrollViewDisplayIndex = (int)Math.Floor((svQuestionPager.ContentOffset.X + svQuestionPager.Frame.Width / 2) / svQuestionPager.Frame.Width);

            if (_scrollViewDisplayIndex == m_currentQuestionToDisplayIndex)
            {
                return;
            }

            if (_scrollViewDisplayIndex == m_currentQuestionToDisplayIndex + 1)
            {
                //Set the next question as current one and load the next one
                //-----------------------------------------------------

                //Remove the previous question tableview from scrollview to save memory
                if (tblvPreviousQuestion != null)
                {
                    tblvPreviousQuestion.RemoveFromSuperview();
                }

                tblvPreviousQuestion = tblvCurrentQuestion;             //The current question becomes the previous one
                tblvCurrentQuestion  = tblvNextQuestion;                //The next question becomes the current one

                m_currentQuestionToDisplayIndex++;
                m_currentQuestionToDisplay = AppSession.SelectedExamUserQuestionList [m_currentQuestionToDisplayIndex];

                if (m_currentQuestionToDisplayIndex < m_totalQuestionInExam - 1)
                {
                    //Load the question to populate to the next question tableview
                    RectangleF _nextQuestionFrame    = svQuestionPager.Frame;
                    PointF     _nextQuestionLocation = new PointF();
                    _nextQuestionLocation.X     = svQuestionPager.Frame.Width * (m_currentQuestionToDisplayIndex + 1);
                    _nextQuestionFrame.Location = _nextQuestionLocation;
                    tblvNextQuestion            = new UITableView(_nextQuestionFrame, UITableViewStyle.Grouped);
                    tblvNextQuestion.Source     = new Question_iPhoneTableSource(AppSession.SelectedExamUserQuestionList[m_currentQuestionToDisplayIndex + 1], this);
                    svQuestionPager.AddSubview(tblvNextQuestion);
                }
                else
                {
                    //We are at the last question in exam, there are no next question available
                    tblvNextQuestion = null;
                }
            }
            else if (_scrollViewDisplayIndex == m_currentQuestionToDisplayIndex - 1)
            {
                //Set the previous question as current one and load the previous one
                //-----------------------------------------------------

                //Remove the next question tableview from scrollview to save memory
                if (tblvNextQuestion != null)
                {
                    tblvNextQuestion.RemoveFromSuperview();
                }

                tblvNextQuestion    = tblvCurrentQuestion;              //The current question becomes the next question
                tblvCurrentQuestion = tblvPreviousQuestion;             //The previous question becomes the current one

                m_currentQuestionToDisplayIndex--;
                m_currentQuestionToDisplay = AppSession.SelectedExamUserQuestionList [m_currentQuestionToDisplayIndex];

                if (m_currentQuestionToDisplayIndex > 0)
                {
                    //Load the question to populate to the previous question tableview
                    RectangleF _previousQuestionFrame    = svQuestionPager.Frame;
                    PointF     _previousQuestionLocation = new PointF();
                    _previousQuestionLocation.X     = svQuestionPager.Frame.Width * (m_currentQuestionToDisplayIndex - 1);
                    _previousQuestionFrame.Location = _previousQuestionLocation;
                    tblvPreviousQuestion            = new UITableView(_previousQuestionFrame, UITableViewStyle.Grouped);
                    tblvPreviousQuestion.Source     = new Question_iPhoneTableSource(AppSession.SelectedExamUserQuestionList[m_currentQuestionToDisplayIndex - 1], this);
                    svQuestionPager.AddSubview(tblvPreviousQuestion);
                }
                else
                {
                    //We are at the first question in exam, there are no previous question available
                    tblvPreviousQuestion = null;
                }
            }
            else
            {
                throw new Exception("Scroll view index should only return the question before or after the current question");
            }

            this.Title = string.Format("{0} of {1}", m_currentQuestionToDisplay.Sequence,
                                       m_totalQuestionInExam);
        }
Beispiel #6
0
 public QuestionSelectedEventArgs(BusinessModel.UserQuestion aSelectedQuestion) : base()
 {
     SelectedQuestion = aSelectedQuestion;
 }