コード例 #1
0
 public SurveyPage(IEventAggregator ea)
 {
     InitializeComponent();
     StartQuestionsButton.Text = AppTextResource.SurveyStartQuestionsButton.ToUpper(); //Force Uppercase
     YesButton.Text            = AppTextResource.SurveyYesButton.ToUpper();            //Force Uppercase
     NoButton.Text             = AppTextResource.SurveyNoButton.ToUpper();             //Force Uppercase
     _viewModel = BindingContext as SurveyPageViewModel;
     UpdateQuestion();
     ea.GetEvent <QuestionChangedEvent>().Subscribe(UpdateQuestion);
 }
コード例 #2
0
        public static SurveyPageViewModel ToSurveyPageViewModel(SurveyPage page, Survey survey)
        {
            var viewModel = new SurveyPageViewModel()
            {
                Id         = page.SurveyPageID,
                Name       = page.PageName,
                IsVisible  = page.IsVisible,
                IsSelected = page.IsSelected,
                IsSummary  = page.IsSummary,
                PageOrder  = page.SortOrder,
                Questions  = new List <SurveyQuestionViewModel>()
            };

            // Add Score & Description
            if (survey.Status != null)
            {
                var status = survey.Status.Pages.FirstOrDefault(p => p.SurveyPageID == viewModel.Id);
                viewModel.Score = status != null ? status.DisplayScore : 0;

                var description = page.ScoreRanges.FirstOrDefault(d => viewModel.Score >= d.MinDisplayScore && viewModel.Score <= d.MaxDisplayScore);
                viewModel.ScoreDescription = description != null ? description.Description : string.Empty;
            }

            // Add suggested contents
            if (page.SuggestedContents.Any())
            {
                viewModel.SuggestedContents = page.SuggestedContents
                                              .Where(sc => !string.IsNullOrWhiteSpace(sc.Title))
                                              .Select(s => new SurveyPageSuggestedContentViewModel()
                {
                    Title = s.Title, Url = s.Url
                })
                                              .OrderBy(v => v.Title)
                                              .DistinctBy(v => v.Url)
                                              .ToList();
            }

            var number = 0;

            foreach (var question in page.Questions.Where(q => q.Layout != LayoutType.EndSection).OrderBy(q => q.SortOrder))
            {
                var questionViewModel = ToSurveyQuestionViewModel(question);

                if (question.InputType != InputType.None && question.Layout == LayoutType.None && question.IsVisible)
                {
                    questionViewModel.Number = string.Format("{0}.", (++number));
                }

                viewModel.Questions.Add(questionViewModel);
            }

            return(viewModel);
        }
コード例 #3
0
 public SurveyPage()
 {
     InitializeComponent();
     BindingContext = ViewModel = new SurveyPageViewModel(Navigation);
 }