public void authorTest()
 {
     QuizQuestion target = new QuizQuestion(); // TODO: Initialize to an appropriate value
     string expected = string.Empty; // TODO: Initialize to an appropriate value
     string actual;
     target.author = expected;
     actual = target.author;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 private void CreateQuizQuestion(object sender)
 {
     var creationTimeAndId = SandRibbonObjects.DateTimeFactory.Now().Ticks;
     var quiz = new QuizQuestion(creationTimeAndId, creationTimeAndId, "Unused", Globals.me, question.Text, new List<Option>());
     quiz.Url = identity;
     foreach (object obj in quizQuestions.Items)
     {
         var answer = (Option)obj;
         if (!string.IsNullOrEmpty(answer.optionText))
             quiz.Options.Add(answer);
     }
     Commands.SendQuiz.ExecuteAsync(quiz);
     App.auditor.trace("CreatedPollQuestion {0}", question.Text);
     this.Close();
 }
 public void receiveQuiz(QuizQuestion qq) { }
        public ViewEditAQuiz(QuizQuestion thisQuiz)
        {
            Dispatcher.adopt(delegate
            {
                DataContext = thisQuiz;

                InitializeComponent();
                var closeCommand = new DelegateCommand<object>((_unused) => { Close(); });
                this.Loaded += (s, e) =>
                {
                    Commands.JoinConversation.RegisterCommand(closeCommand);
                    Commands.ShowConversationSearchBox.RegisterCommand(closeCommand);
                };
                this.Unloaded += (s, e) =>
                {
                    Commands.JoinConversation.UnregisterCommand(closeCommand);
                    Commands.ShowConversationSearchBox.UnregisterCommand(closeCommand);
                };
                question.Options.CollectionChanged += UpdateOptionError;
                //QuestionError = false;
                ResultsExist = CheckResultsExist(question);
            });
        }
        private bool ValidQuiz(QuizQuestion editedQuiz)
        {
            var questionError = false;
            var optionError = false;
            var questionValid = question.Validate(out questionError, out optionError);
            QuestionError = questionError;
            OptionError = optionError;

            return questionValid;
        }
 public bool CheckResultsExist(QuizQuestion quizQuestion)
 {
     return Globals.quiz.answers.FirstOrDefault(answer => answer.Key == quizQuestion.Id).Value.Count > 0;
 }
Esempio n. 7
0
 public void SendQuizQuestion(QuizQuestion qq)
 {
     Trace.TraceInformation("Beginning QuizQuestion send: " + qq.id);
     Action work = delegate
     {
         wire.SendQuiz(qq);
     };
     tryIfConnected(work);
 }
        public void EndEdit()
        {
            foreach (var option in Options)
            {
                option.EndEdit();
            }

            _cachedCopy = null;
            IsInEditMode = false;
        }
 private void ReceiveQuiz(QuizQuestion quiz)
 {
     Dispatcher.adoptAsync(() =>
     {
         int oldQuizIndex = -1;
         if (Globals.quiz.activeQuizzes.Any(q => q.Id == quiz.Id))
         {
             List<QuizQuestion> oldQuizzes = Globals.quiz.activeQuizzes.Where(q => q.Id == quiz.Id).ToList();
             QuizQuestion oldQuiz = oldQuizzes.First();
             if (quiz.Created >= oldQuiz.Created)
             {
                 oldQuizIndex = Globals.quiz.activeQuizzes.IndexOf(oldQuiz);
                 foreach (var q in oldQuizzes)
                 {
                     Globals.quiz.activeQuizzes.Remove(q);
                 }
             }
         }
         if (!Globals.quiz.answers.ContainsKey(quiz.Id))
             Globals.quiz.answers[quiz.Id] = new ObservableCollection<QuizAnswer>();
         if (!quiz.IsDeleted)
         {
             if (oldQuizIndex == -1)
                 Globals.quiz.activeQuizzes.Add(quiz);
             else
                 Globals.quiz.activeQuizzes.Insert(oldQuizIndex, quiz);
         }
         // force the UI to update the labels. this is horrible
         var tempQuizzes = new List<QuizQuestion>();
         tempQuizzes.AddRange(Globals.quiz.activeQuizzes);
         Globals.quiz.activeQuizzes.Clear();
         foreach (var reindexQuiz in tempQuizzes)
         {
             Globals.quiz.activeQuizzes.Add(reindexQuiz);
         }
         quizzes.ScrollToEnd();
     });
 }
        public QuizQuestion DeepCopy()
        {
            var quizQuestion = new QuizQuestion(Id, Title, Author, Question, new List<Option>());
            quizQuestion.IsDeleted = IsDeleted;
            quizQuestion.Url = Url;
            quizQuestion.Created = Created;
            foreach (var option in Options)
            {
                quizQuestion.Options.Add(option.DeepCopy());
            }

            return quizQuestion;
        }
 public QuizInfo(QuizQuestion question, List<QuizAnswer> answers )
 {
     Question = question;
     Answers = answers;
 }
 public void QuizQuestionConstructorTest()
 {
     QuizQuestion target = new QuizQuestion();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void optionsTest()
 {
     QuizQuestion target = new QuizQuestion(); // TODO: Initialize to an appropriate value
     List<Option> expected = null; // TODO: Initialize to an appropriate value
     List<Option> actual;
     target.options = expected;
     actual = target.options;
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Esempio n. 14
0
 void IReceiveEvents.receiveQuiz(QuizQuestion qq)
 {
     QuizQuestionAvailable(this, new QuizQuestionAvailableEventArgs { quizQuestion = qq });
 }
 public Quiz(QuizQuestion parameters)
     : this()
 {
     this.parameters = parameters;
 }
        public void BeginEdit()
        {
            _cachedCopy = DeepCopy();

            IsInEditMode = true;

            foreach (var option in Options)
            {
                option.BeginEdit();
            }
        }
 private void SendQuiz(QuizQuestion qq)
 {
     client.SendQuizQuestion(qq, Globals.conversationDetails.Jid);
 }
        private void receiveQuiz(QuizQuestion details)
        {

        }