Esempio n. 1
0
 public Quiz createSimpleQuiz(String question, String[] answers, int[] correctAnswers)
 {
     string tmp = question;
     string[] answ = answers;
     Question tmpQuestion = new Question();
     tmpQuestion.Value = tmp;
     tmpQuestion.ID = 0;
     tmpQuestion.Type = QuestionType.ONLY_TEXT;
     writeQuestion(tmpQuestion);
     Quiz tmpQuiz = new Quiz();
     tmpQuiz.ID = 0;
     tmpQuiz.LevelID = 0;
     tmpQuiz.QuestionID = 0;
     tmpQuiz.QuestionType = QuestionType.ONLY_TEXT;
     tmpQuiz.TipType = TipType.ONLY_TEXT;
     tmpQuiz.AnswerType = AnswerType.ONLY_TEXT;
     int tmpId = 0;
     foreach (string tmpString in answ)
     {
         tmpQuiz.Answers.Add(tmpId);
         Answer answer = new Answer(tmpId, tmpString, AnswerType.ONLY_TEXT);
         writeAnswer(answer);
         tmpId++;
     }
     foreach (int tmpC in correctAnswers)
     {
         tmpQuiz.CorrectAnswers.Add(tmpC);
     }
     writeQuiz(tmpQuiz);
     return tmpQuiz;
 }
Esempio n. 2
0
 public void SaveQuiz(Quiz quiz)
 {
     SaveQuestion(GetQuestion(quiz.QuestionID));
     foreach(long tmpAnswer in quiz.Answers)
     {
         SaveAnswer(GetAnswer(tmpAnswer));
     }
     manager.SaveQuiz(quiz);
 }
Esempio n. 3
0
        public Quiz createQuiz()
        {
            Quiz tmpQuiz = new Quiz();
            Answer tmpAnswer = createAnswer();
            Question tmpQuestion = createQuestion();

            writeQuestion(tmpQuestion);
            writeAnswer(tmpAnswer);
            tmpQuiz.ID = quizID;
            tmpQuiz.QuestionType = QuestionType.ONLY_TEXT;
            tmpQuiz.MainTopic.Add(9);
            tmpQuiz.MainTopic.Add(11);
            writeQuiz(tmpQuiz);

            return null;
        }
Esempio n. 4
0
        public QuizBlock Create(Quiz quiz)
        {
            QuizBlock quizBlock = new QuizBlock();

            quizBlock.QuestionBlock = QuizFactory.Instance.CreateQuestionBlock  (quiz);
            quizBlock.AnswerBlock   = QuizFactory.Instance.CreateAnswerBlock    (quiz);
            quizBlock.TipBlock      = QuizFactory.Instance.CreateTipBlock       (quiz);

            foreach (long tmp in quiz.Answers)
            {
                Answer tmpAnswer = DataManager.Instance.GetAnswer(tmp);
                quizBlock
                    .AnswerBlock
                    .AnswerListWidget
                    .Add(QuizFactory.Instance.CreateAnswerWidget(tmpAnswer));
            }

            return quizBlock;
        }
Esempio n. 5
0
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public TipBlock CreateTipBlock(Quiz quiz)
 {
     return TipBlockStrategy.ContainsKey(quiz.QuizType)? TipBlockStrategy[quiz.QuizType]
         .Create(quiz) : new DefaultTipBlockFactory().Create(quiz);
 }
Esempio n. 6
0
 //facade + strategy
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public QuizBlock CreateQuizBlock(Quiz quiz)
 {
     QuizBlock block = QuizBlockStrategy.ContainsKey(quiz.QuizType) ? QuizBlockStrategy[quiz.QuizType]
         .Create(quiz) : ((new DefaultQuizBlockFactory()).Create(quiz));
     block.Quiz = quiz;
     return block;
 }
Esempio n. 7
0
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public QuestionBlock CreateQuestionBlock(Quiz quiz)
 {
     return QuestionBlockStrategy.ContainsKey(quiz.QuizType)? QuestionBlockStrategy[quiz.QuizType]
         .Create(quiz) : new DefaultQuestionBlockFactory().Create(quiz);
 }
Esempio n. 8
0
 /// <summary>
 ///  This class performs an important function.
 /// </summary>
 public AnswerBlock CreateAnswerBlock(Quiz quiz)
 {
     return AnswerBlockStrategy.ContainsKey(quiz.QuizType)? AnswerBlockStrategy[quiz.QuizType]
         .Create(quiz) : new DefaultAnswerBlockFactory().Create(quiz);
 }
Esempio n. 9
0
 void writeQuiz(Quiz quiz)
 {
     //FileManager.Save<Quiz>(QUIZ_PATH + quiz.ID + BASE_EXTENTIONS, quiz);
     manager.SaveQuiz(quiz);
 }
Esempio n. 10
0
 public void init()
 {
     string tmp = "Supponendo che: \n int a = 2; int b = 3; float c = 4; double d = 5; int risI; int e = 2; double risD; \n" +
         "Qual e' risultato dell’espressione seguente?\n" +
         "risD = d + c * b + a / b;";
     string[] answ = {"15","18,5","18"};
     Question tmpQuestion = new Question();
     tmpQuestion.Value = tmp;
     tmpQuestion.ID = 0;
     tmpQuestion.Type = QuestionType.ONLY_TEXT;
     writeQuestion(tmpQuestion);
     Quiz tmpQuiz = new Quiz();
     tmpQuiz.ID = 0;
     tmpQuiz.LevelID = 0;
     tmpQuiz.QuestionID = 0;
     tmpQuiz.QuestionType = QuestionType.ONLY_TEXT;
     tmpQuiz.TipType = TipType.ONLY_TEXT;
     tmpQuiz.AnswerType = AnswerType.ONLY_TEXT;
     int tmpId =0 ;
     foreach (string tmpString in answ)
     {
         tmpQuiz.Answers.Add(tmpId);
         Answer answer = new Answer(tmpId, tmpString, AnswerType.ONLY_TEXT);
         writeAnswer(answer);
         tmpId++;
     }
     tmpQuiz.CorrectAnswers.Add(0);
     writeQuiz(tmpQuiz);
 }
Esempio n. 11
0
 public QuestionBlock Create(Quiz quiz)
 {
     DefaultQuestionBlock tmp;
     tmp = new DefaultQuestionBlock();
     return tmp;
 }
Esempio n. 12
0
 public AnswerBlock Create(Quiz quiz)
 {
     DefaultAnswerBlock tmp;
     tmp = new DefaultAnswerBlock();
     return tmp;
 }
Esempio n. 13
0
 public TipBlock Create(Quiz quiz)
 {
     TipBlock tmp;
     tmp = new DefaultTipBlock();
     return tmp;
 }