async void OnItemTapped(object sender, ItemTappedEventArgs e)
 {
     var item = e.Item as Question;
     var questions = QuestionList.Where(x => x.StudyPlan.Equals(StudyPlan)).ToList();
     var dataCtx = new QuestionSessionManager(questions, SessionType.PractiseMode);
     await Navigation.PushAsync(new QuestionPage(dataCtx, item != null ? item.DispalyId : 0));
 }
Esempio n. 2
0
 public QuestionPage(QuestionSessionManager mgr, int selectedId)
 {
     //BindingContext = mgr;
     InitializeComponent();
     //for  test only
        Initialize(mgr, selectedId);
 }
        public ExamModeConfigPage()
        {
            InitializeComponent();
            GetQuestionMasterList();
            DataContextType = new ExamModeQuestionNo();
            SelectedCategories = new List<QuestionTemplateCategory>();
            this.BindingContext = DataContextType;
            StartButton.Clicked += async (sender, e) =>
            {
                StringBuilder thisCompose = new StringBuilder();
                const string display = "Exam Session Details:";
                thisCompose.AppendLine();
                thisCompose.Append("Total Questions -  ");
                thisCompose.Append(DataContextType.NoOfQuestions.ToString());
                thisCompose.AppendLine();
                if (this.TimeSwitch.IsToggled)
                {
                    thisCompose.Append("Session Duration -  ");
                    thisCompose.Append(DataContextType.NoOfQuestions.ToString());
                    thisCompose.Append(" mins");
                    thisCompose.AppendLine();
                }
                if (DataContextType.NoOfQuestions == 0)
                {
                    await DisplayAlert("Alert", "Unable to proceed with 0 question", "OK");
                    return;
                }

               var action = await  DisplayAlert(display, thisCompose.ToString(), "Start Test", "Cancel");
                if (action)
                {
                    var ctx = AllStudyPlan.BindingContext;
                    if (ctx != null)
                    {
                        var selct = SelectedCategories;
                        if (QuestionList == null)
                        {
                            GetQuestionMasterList();
                        }
                        var quesBuild = new List<Question>();
                        foreach (var questionTemplateCategory in SelectedCategories)
                        {
                            quesBuild.AddRange(QuestionList.Where(x => x.StudyPlan.Equals(questionTemplateCategory.CategoryName)).ToList());
                        }
                        if (quesBuild.Count == 0) return;
                        foreach (var ert in QuestionList)
                        {
                            if (ert != null) ert.RefreshForRandom();
                        }
                        var dataCtx = new QuestionSessionManager(AppCache.AssignNumberToQuestion(quesBuild, SessionType.ExamMode).ToList(), SessionType.ExamMode);
                       await Navigation.PushModalAsync(new ExamQuestionPage(dataCtx, 0));
                    }
                }
            };
        }
        private void Initialize(QuestionSessionManager mgr, int selectedId)
        {
            
            var list = mgr.QuestionList;
            var indexOfSelectedItem = 0;
            if (selectedId != 0)
            {
                //we wont have id of zero
                indexOfSelectedItem = list.FindIndex(a => a.DispalyId == selectedId);
            }
            var listToProcess = list.GetRange(indexOfSelectedItem + 1, list.Count - 1 - indexOfSelectedItem);
            var currItem = list[indexOfSelectedItem];
            listToProcess.Reverse();
            _next = new Stack<Question>(listToProcess);
            _prev = new Stack<Question>(list.GetRange(0, indexOfSelectedItem));
            SetBindingContext(currItem);
            SetNavButtons();
            StopButton.Clicked += async (sender, e) =>
            {
                var action = await DisplayAlert("End Session?", "This will end current session", "YES", "NO");
                if (action)
                {
                   // Acr.UserDialogs()
                 Result result =   GradeManager.GradeSession(mgr.QuestionList);
                    if (result == null) return;
                    var action1 =
                        await
                            DisplayActionSheet("SESSION RESULT", "CLOSE", "SAVE", "EXIT VIEW", "Answered Correctly - " + result.TotalPointsScored.ToString(),
                              "Answered Incorecctly - " + (result.TotalAvailablePoints - result.TotalPointsScored).ToString(),
                             "Total Questions - " + result.TotalAvailablePoints.ToString(),
                              "Total Score - " + string.Format("{0:0.##}", result.PercentScore) + "%");

                    if (action1.Equals("SAVE"))
                    {
                        var sess = PrepSessionData(result, mgr);
                        DependencyService.Get<ISaveAndLoad>().SaveText("temp.txt", sess);
                        await Navigation.PopModalAsync();
                    }
                    else if (action1.Equals("EXIT VIEW"))
                    {
                        await Navigation.PopModalAsync();
                    }
                }
            };
            
        }
Esempio n. 5
0
 private void Initialize(QuestionSessionManager mgr, int selectedId)
 {
     var list = mgr.QuestionList;
     var indexOfSelectedItem = 0;
     if (selectedId != 0)
     {
         //we wont have id of zero
         indexOfSelectedItem = list.FindIndex(a => a.DispalyId == selectedId);
     }
     var listToProcess = list.GetRange(indexOfSelectedItem + 1, list.Count - 1 - indexOfSelectedItem);
     var currItem = list[indexOfSelectedItem];
     listToProcess.Reverse();
     _next = new Stack<Question>(listToProcess);
     _prev = new Stack<Question>(list.GetRange(0, indexOfSelectedItem));
     SetBindingContext(currItem);
     SetNavButtons();
 }
        private Session PrepSessionData(Result result, QuestionSessionManager mgr)
        {
            Session thisSession = new Session
            {
                SessionResult = result,
                SessionQuestion = mgr.QuestionList
            };

            return thisSession;
        }
        async void Button_OnClicked(object sender, EventArgs e)
        {
            StringBuilder thisCompose = new StringBuilder();
            const string display = "Exam Session Details:";
            thisCompose.AppendLine();
            thisCompose.Append("Total Questions -  ");
            thisCompose.Append(LabelQuestionSelection.Text);
            thisCompose.AppendLine();
            if (this.TimeSwitch.IsToggled)
            {
                thisCompose.Append("Session Duration -  ");
                thisCompose.Append(LabelQuestionSelection.Text);
                thisCompose.Append(" mins");
                thisCompose.AppendLine();
            }

            var result = default(int);
            if (!int.TryParse(LabelQuestionSelection.Text, out result)) return;

            if (result == 0)
            {
                await DisplayAlert("Alert", "Unable to proceed with 0 question", "OK");
                return;
            }

            var action = await DisplayAlert(display, thisCompose.ToString(), "Start Test", "Cancel");
            if (!action) return;
            
            var _rand = new Random();
            if (QuestionList == null)
            {
                GetQuestionMasterList();
            }
            if (QuestionList == null) return;
            var quesBuild = new List<Question>();
            quesBuild = UtilLibrary.GetRandoms(QuestionList.ToArray(), result).ToList();
            if (quesBuild.Count == 0) return;
            foreach (var ert in QuestionList)
            {
                if (ert != null) ert.RefreshForRandom();
            }
            var dataCtx =
                new QuestionSessionManager(
                    AppCache.AssignNumberToQuestion(quesBuild, SessionType.ExamMode).ToList(),
                    SessionType.ExamMode);
            await Navigation.PushModalAsync(new ExamQuestionPage(dataCtx, 0));
        }