async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Questions.Clear();
                var questions = await DataStore.GetItemsAsync(true);

                foreach (var question in questions)
                {
                    Questions.Add(question);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 2
0
        public async Task LoadQuestionsAsync(bool saveNewQuestions = true)
        {
            // Load questions for all tags
            var questionLists = new List <IEnumerable <Question> >();

            foreach (var tag in Tags)
            {
                var questionsForTag = await StackOverflowConnector.GetUnansweredQuestionByTag(tag);

                questionLists.Add(questionsForTag);
            }

            // Merge and oder questions, remove dublicates
            var orderedQuestions = StackOverflowConnector.MergeQuestions(questionLists);

            // Mark new questions
            var oldQuestionsJson = await LocalStorage.LoadAsync("questions.json");

            if (oldQuestionsJson != null)
            {
                var oldQuestions = JsonConvert.DeserializeObject <ObservableCollection <Question> >(oldQuestionsJson);
                NewQuestionCount = StackOverflowConnector.MarkNewQuestions(orderedQuestions, oldQuestions);
            }

            // Sync questions with ViewModel
            Questions.Clear();
            Questions = new ObservableCollection <Question>(orderedQuestions);

            // Save questions locally
            if (saveNewQuestions)
            {
                var newQuestionsJson = JsonConvert.SerializeObject(Questions);
                await LocalStorage.SaveAsync("questions.json", newQuestionsJson);
            }
        }
        void ExecuteLoadQuestionsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Questions.Clear();
                var questions = Category.Questions;
                foreach (var question in questions)
                {
                    Questions.Add(question);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 4
0
        public virtual void ReadXml(System.Xml.Linq.XElement element)
        {
            //CurrentID
            Question.CurrentID = element.ReadInt("QuCurrentID");
            Answer.CurrentID   = element.ReadInt("AnCurrentID");
            //qustions
            XElement elem = element.Element("Questions");

            Questions.Clear();
            foreach (XElement e in elem.Elements())
            {
                Question qustion = new Question(true);

                qustion.ReadXml(e);


                Questions.Add(qustion);
            }
            //answers
            elem = element.Element("Answers");
            Answers.Clear();
            foreach (XElement e in elem.Elements())
            {
                Answer answer = new Answer(true);
                answer.ReadXml(e);
                Answers.Add(answer);
            }
        }
Ejemplo n.º 5
0
        public QuestionsViewModel(IApplicationViewModel application = null, ISearchViewModel search = null, INetworkApi networkApi = null)
            : base(application)
        {
            NetworkApi    = networkApi ?? Api <INetworkApi>();
            Search        = Service(search);
            LoadQuestions = ReactiveCommand.CreateFromTask(LoadQuestionsImpl);
            Clear         = ReactiveCommand.Create(() =>
            {
                Questions.Clear();
            });
            Refresh = ReactiveCommand.CreateFromTask(async() =>
            {
                await Clear.Execute();
                await LoadQuestions.Execute();
            }, canExecute: Clear.CanExecute.CombineLatest(LoadQuestions.CanExecute, (canClearExecute, canLoadExecute) => canClearExecute && canLoadExecute));
            DisplayQuestion = ReactiveCommand.CreateFromTask(async(QuestionItemViewModel question) =>
            {
                await Application.Navigate.Handle(new NavigationParams(typeof(QuestionPage), question.Question));
            });

            this.WhenActivated(d =>
            {
                SelectedQuestion = null;

                d(Search.WhenAnyValue(s => s.SelectedSite)
                  .Skip(1)
                  .Select(svm => Unit.Default)
                  .InvokeCommand(this, vm => vm.Refresh));

                d(this.WhenAnyValue(s => s.SelectedQuestion)
                  .Skip(1)
                  .Where(question => question != null)
                  .InvokeCommand(this, vm => vm.DisplayQuestion));
            });
        }
Ejemplo n.º 6
0
        public TestPaper(int id, string userId, int subjectId, DateTime beginTime, int testDuration, int singleCount,
                         decimal singPer, int multiCount, decimal multiPer, int judgeCount, decimal judgePer, List <Question> questions)
        {
            if (id <= 0)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (questions == null)
            {
                throw new ArgumentNullException(nameof(questions));
            }
            if (questions.Count <= 0)
            {
                throw new ArgumentNullException(nameof(questions));
            }

            Id           = id;
            UserId       = userId;
            SubjectId    = subjectId;
            BeginTime    = beginTime;
            TestDuration = testDuration;
            SingleCount  = singleCount;
            SingPer      = singPer;
            MultiCount   = multiCount;
            MultiPer     = multiPer;
            JudgeCount   = judgeCount;
            JudgePer     = judgePer;


            Questions.Clear();
            Questions.AddRange(questions);
        }
 void EffacerSousPopulation()
 {
     Questions.Clear();
     Reponses.Clear();
     PollAnswerID.Clear();
     QuestionnairePublication.PersonnesSousPopulation = new PersonneCollection();
 }
 void EffacerSousPopulation()
 {
     Questions.Clear();
     Reponses.Clear();
     PollAnswerID.Clear();
     PersonnesOntReponduATout.Clear();
     QuestionnaireControlStatAll.PersonnesSousPopulation = new PersonneCollection();
 }
Ejemplo n.º 9
0
        private void SearchQuestionsMethod()
        {
            if (String.IsNullOrEmpty(Keyword) && Questions != null)
            {
                Questions.Clear();
            }

            Questions = new IncrementalLoading <Question>(GetMoreQuestions, "search?t=question&q={0}", FirstOffset, false);
        }
Ejemplo n.º 10
0
        void ParseQueue(Queue <NonnullRichTextBuilder> richTexts)
        {
            Questions.Clear();
            int stride = 1 + MultiChoiceItem.N_OPTIONS;

            while (richTexts.Count > 0)
            {
                Questions.Add(MultiChoiceItem.NewWith(richTexts));
            }
        }
Ejemplo n.º 11
0
        private void SynchronizeQuestionsCollections()
        {
            if (Questions.Any())
            {
                Questions.Clear();
            }

            foreach (var question in Test.Question)
            {
                Questions.Add(question);
            }
        }
        private void UpdateQuestions(QuestionList questionList)
        {
            foreach (var question in questionList.items)
            {
                question.title = WebUtility.HtmlDecode(question.title);
            }

            using (Questions.SuppressChangeNotifications()) {
                Questions.Clear();
                Questions.AddRange(questionList.items);
            }
        }
Ejemplo n.º 13
0
        public void Dispose()
        {
            Questions.Clear();
            Answers.Clear();
            Authorities.Clear();
            Additionals.Clear();

            Questions   = null;
            Answers     = null;
            Authorities = null;
            Additionals = null;

            Header?.Dispose();
            Error = null;
        }
Ejemplo n.º 14
0
        async Task ExecuteRefreshCommandAsync()
        {
            var result = await StoreManager.QuestionsService.GetQuestionsAsync(position, pageIndex, pageSize);

            if (result.Success)
            {
                var questions = JsonConvert.DeserializeObject <List <Questions> >(result.Message.ToString());
                if (questions.Count > 0)
                {
                    if (pageIndex == 1 && Questions.Count > 0)
                    {
                        Questions.Clear();
                    }
                    Questions.AddRange(questions);
                    if (position != 4)
                    {
                        await SqliteUtil.Current.UpdateQuestions(questions);
                    }
                    pageIndex++;
                    if (Questions.Count >= pageSize)
                    {
                        LoadStatus  = LoadMoreStatus.StausDefault;
                        CanLoadMore = true;
                    }
                    else
                    {
                        LoadStatus  = LoadMoreStatus.StausEnd;
                        CanLoadMore = false;
                    }
                }
                else
                {
                    CanLoadMore = false;
                    LoadStatus  = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata;
                }
            }
            else
            {
                Crashes.TrackError(new Exception()
                {
                    Source = result.Message
                });
                LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail;
            }
        }
Ejemplo n.º 15
0
 public MainViewModel()
 {
     CreateRule = new RelayCommand <Project>(param =>
     {
         Questions.Clear();
         PublicEventConnection.Dispose();
         Rules.Add(new Rule()
         {
             What       = param.Work.What,
             Enabled    = true,
             Comparison = RuleType.Equals,
             From       = new TimeSpan(0, 0, 0),
             To         = new TimeSpan(23, 59, 59),
             Do         = Rule.Ignore
         });
         PublicEventConnection = PublicEvents.Connect();
     });
 }
Ejemplo n.º 16
0
        private async Task LoadQuestions()
        {
            if (MasterMenuItem == null)
            {
                return;
            }
            Questions.Clear();
            AddQuestionFormStatusText.Text = "";
            var questions = await NetworkService.GetPlayerQuestions(MasterMenuItem.PlayerInfo.Id);

            if (questions != null)
            {
                foreach (var question in questions)
                {
                    Questions.Add(question);
                }
            }
        }
Ejemplo n.º 17
0
 private void DeleteQuestion()
 {
     if (_selectedIndex >= 0)
     {
         SetMaxPoints(-_questions[_selectedIndex].Points);
         QuestionsIds.RemoveAt(_selectedIndex);
         Questions.RemoveAt(_selectedIndex);
         ObservableCollection <IQuestion> questions = new ObservableCollection <IQuestion>();
         foreach (var question in Questions)
         {
             questions.Add(question);
         }
         ;
         Questions.Clear();
         Questions = new ObservableCollection <IQuestion>(questions);
         RaisePropertyChanged(() => Questions);
     }
     SetAnswers(false);
 }
Ejemplo n.º 18
0
        protected async Task ExecuteLoadQuestionsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Questions.Clear();
                object responce = await QuestionsService.DoQuestionsGetRequest(LessonId);

                if (responce is ErrorMessage)
                {
                    ErrorMessage error = responce as ErrorMessage;
                    Debug.WriteLine(error.ErrorCode + " " + error.ErrorDescription);
                }
                else
                {
                    var questions = responce as IEnumerable <Question>;
                    foreach (var question in questions)
                    {
                        Questions.Add(question);
                    }
                }


                MessagingCenter.Send <QuestionsListViewModel>(this, "QuestionsLoaded");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("[!] ExecuteLoadQuestionsCommand --- " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 19
0
        async Task ExecuteRefreshCommandAsync()
        {
            var result = await StoreManager.QuestionsService.GetQuestionsAsync(position, pageIndex, pageSize);

            if (result.Success)
            {
                var questions = JsonConvert.DeserializeObject <List <Questions> >(result.Message.ToString());
                if (questions.Count > 0)
                {
                    if (pageIndex == 1 && Questions.Count > 0)
                    {
                        Questions.Clear();
                    }
                    Questions.AddRange(questions);
                    pageIndex++;
                    if (Questions.Count >= pageSize)
                    {
                        LoadStatus  = LoadMoreStatus.StausDefault;
                        CanLoadMore = true;
                    }
                    else
                    {
                        LoadStatus  = LoadMoreStatus.StausEnd;
                        CanLoadMore = false;
                    }
                }
                else
                {
                    CanLoadMore = false;
                    LoadStatus  = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata;
                }
            }
            else
            {
                Log.SendLog("QuestionsViewModel.GetQuestionsAsync:" + result.Message);
                LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Executes the load items command.
        /// </summary>
        /// <returns></returns>
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Questions.Clear();
                var questionList = await DataStore.GetQuestionsAsync(string.Empty);

                foreach (var question in questionList)
                {
                    Questions.Add(question);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 21
0
        public async Task OnLoadAsync(INavigationParameters parameters, int attempt = 0)
        {
            try
            {
                var rawEndpoints = await FeedbackEndpointService.GetAsync();

                _endpoints = rawEndpoints.Select(x => x.Route);

                var rawQuestions = await FeedbackService.GetAsync();

                Questions.Clear();
                foreach (var item in rawQuestions)
                {
                    var question = new SurveyQuestion
                    {
                        Question    = item.Question,
                        HelpMessage = item.Help,
                        Type        = (Question)item.Type,
                        IsRequired  = item.IsRequired
                    };

                    if (question.Type == Question.CustomOptions)
                    {
                        foreach (var option in item.Options)
                        {
                            question.Options.Add(option);
                        }
                    }

                    Questions.Add(question);
                }
            }
            catch (Exception)
            {
                await ErrorRetryManager.HandleRetryAsync(this, parameters, attempt);
            }
        }
        private void CreateMockData()
        {
            if (Questions == null)
            {
                Questions = new ObservableCollection <Question>();
            }
            else
            {
                Questions.Clear();
            }

            for (int i = 1; i <= 5; i++)
            {
                Question q = new Question
                {
                    QuestionId          = i,
                    QuestionDescription = "Sample Question " + i.ToString(),
                    IsYes = false,
                    IsNA  = false,
                    IsNo  = false
                };
                Questions.Add(q);
            }
        }
        public async Task ExecuteLoadQuestionsCommandAsync(string filter)
        {
            if (IsBusy)
            {
                return;
            }

            ProgressDialogManager.LoadProgressDialog("Loading...");

            try
            {
                IsBusy = true;
                Questions.Clear();
                DateTime now = RestService.GetServerTime();

                followedOppors.Clear();

                try
                {
                    followedOppors.AddRange((await ParseAccess.GetUser(ParseAccess.CurrentUser().ObjectId)).Get <IList <string> >("followedOppors"));
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }

                IEnumerable <Parse.ParseObject> questions;
                if (filter == "Followed Tasks")
                {
                    questions = await ParseAccess.LoadFollowedOppors(followedOppors);
                }
                else if (filter == "Followed Topics")
                {
                    questions = await ParseAccess.LoadOpporsBasedOnTopics();
                }
                else if (filter == "My Requests")
                {
                    questions = await ParseAccess.LoadMyRequests();
                }
                else
                {
                    questions = await ParseAccess.LoadQuestions();
                }

                foreach (var question in questions)
                {
                    var isFollowed = false;
                    var state      = "Closed";
                    var stateFlag  = question.Get <int>("stateFlag");

                    var topicObjects = question.Get <IList <ParseObject> >("topics");
                    var topics       = new List <string>();
                    foreach (var topic in topicObjects)
                    {
                        topics.Add(topic.Get <string>("topicText"));
                    }

                    if (stateFlag == (int)RequestState.Active)
                    {
                        state = "Active";
                    }
                    else if (stateFlag == (int)RequestState.InProgress)
                    {
                        state = "In Progress";
                    }

                    if (followedOppors.Contains(question.ObjectId))
                    {
                        isFollowed = true;
                    }
                    var q = new Question
                    {
                        ObjectId   = question.ObjectId,
                        Title      = question.Get <string>("title"),
                        Body       = question.Get <string>("body"),
                        TimeAgo    = HelperFunctions.TimeAgo(question.UpdatedAt.Value, now),
                        IsFollowed = isFollowed,
                        State      = state,
                        Topics     = topics
                    };
                    Questions.Add(q);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            finally
            {
                IsBusy = false;
                ProgressDialogManager.DisposeProgressDialog();
            }
        }
Ejemplo n.º 24
0
 public void Clear()
 {
     Questions.Clear();
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Remove repeated values from the wording fields (PreP, PreI, PreA, LitQ, PstI, Pstp, RespOptions, NRCodes) unless they are requested.
        /// This applies only to series questions, which are questions whose Qnum ends in a letter.
        /// </summary>
        public void RemoveRepeatsTC()
        {
            string mainTopic   = "";
            string mainContent = "";
            string currTopic   = "";
            string currContent = "";

            bool           firstRow = true;
            SurveyQuestion refQ     = null;// this will hold the 'a' question's fields

            // only try to remove repeats if there are more than 0 rows
            if (Questions.Count == 0)
            {
                return;
            }

            // sort questions by their topic and then content labels
            var sorted = Questions.OrderBy(q => q.VarName.Topic.LabelText).ThenBy(q => q.VarName.Content.LabelText).ToList();

            Questions.Clear();
            AddQuestions(new BindingList <SurveyQuestion>(sorted));
            sorted = null;

            foreach (SurveyQuestion sq in Questions)
            {
                currTopic   = sq.VarName.Topic.LabelText;
                currContent = sq.VarName.Content.LabelText;

                // if this is a non-series row, the first member of a series, the first row in the report, or a new Qnum, make this row the reference row
                if (!currTopic.Equals(mainTopic) || (!currContent.Equals(mainContent)) || firstRow)
                {
                    mainTopic   = currTopic;
                    mainContent = currContent;
                    // copy the row's contents into an array
                    refQ = new SurveyQuestion
                    {
                        PreP        = sq.PreP,
                        PreI        = sq.PreI,
                        PreA        = sq.PreA,
                        LitQ        = sq.LitQ,
                        PstI        = sq.PstI,
                        PstP        = sq.PstP,
                        RespOptions = sq.RespOptions,
                        NRCodes     = sq.NRCodes
                    };
                }
                else
                {
                    // if we are inside a series, compare the wording fields to the reference question
                    // if the current column is a standard wording column and has not been designated as a repeated field, compare wordings
                    if ((StdFields.Contains("PreP") && !RepeatedFields.Contains("PreP")))
                    {
                        // if the current question's wording field matches the reference question's, clear it.
                        // otherwise, set the reference question's field to the current question's field
                        // this will cause a new reference point for that particular field, but not the fields that were identical to the original reference question
                        if (Utilities.RemoveTags(sq.PreP).Equals(Utilities.RemoveTags(refQ.PreP)))
                        {
                            sq.PreP = "";
                        }
                        else
                        {
                            refQ.PreP = sq.PreP;
                        }
                    }
                    // PreI
                    if ((StdFields.Contains("PreI") && !RepeatedFields.Contains("PreI")))
                    {
                        if (Utilities.RemoveTags(sq.PreI).Equals(Utilities.RemoveTags(refQ.PreI)))
                        {
                            sq.PreI = "";
                        }
                        else
                        {
                            refQ.PreI = sq.PreI;
                        }
                    }
                    // PreA
                    if ((StdFields.Contains("PreA") && !RepeatedFields.Contains("PreA")))
                    {
                        if (Utilities.RemoveTags(sq.PreA).Equals(Utilities.RemoveTags(refQ.PreA)))
                        {
                            sq.PreA = "";
                        }
                        else
                        {
                            refQ.PreA = sq.PreA;
                        }
                    }
                    // LitQ
                    if ((StdFields.Contains("LitQ") && !RepeatedFields.Contains("LitQ")))
                    {
                        if (Utilities.RemoveTags(sq.LitQ).Equals(Utilities.RemoveTags(refQ.LitQ)))
                        {
                            sq.LitQ = "";
                        }
                        else
                        {
                            refQ.LitQ = sq.LitQ;
                        }
                    }
                    // PstI
                    if ((StdFields.Contains("PstI") && !RepeatedFields.Contains("PstI")))
                    {
                        if (Utilities.RemoveTags(sq.PstI).Equals(Utilities.RemoveTags(refQ.PstI)))
                        {
                            sq.PstI = "";
                        }
                        else
                        {
                            refQ.PstI = sq.PstI;
                        }
                    }
                    // RespOptions
                    if ((StdFields.Contains("RespOptions") && !RepeatedFields.Contains("RespOptions")))
                    {
                        if (Utilities.RemoveTags(sq.RespOptions).Equals(Utilities.RemoveTags(refQ.RespOptions)))
                        {
                            sq.RespOptions = "";
                        }
                        else
                        {
                            refQ.RespOptions = sq.RespOptions;
                        }
                    }
                    // NRCodes
                    if ((StdFields.Contains("NRCodes") && !RepeatedFields.Contains("NRCodes")))
                    {
                        if (Utilities.RemoveTags(sq.NRCodes).Equals(Utilities.RemoveTags(refQ.NRCodes)))
                        {
                            sq.NRCodes = "";
                        }
                        else
                        {
                            refQ.NRCodes = sq.NRCodes;
                        }
                    }
                }
                firstRow = false; // after once through the loop, we are no longer on the first row
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Removes all questions from the Survey's question list.
 /// </summary>
 /// <param name="newQ"></param>
 public void RemoveAllQuestions()
 {
     Questions.Clear();
     EssentialList = "";
 }
Ejemplo n.º 27
0
 public void Clear()
 {
     Questions.Clear();
     PeopleInGroup = 0;
 }
Ejemplo n.º 28
0
 public void ResetQuestions()
 {
     Questions.Clear();
 }