protected Query(QueryType queryType, QuestionType questionType)
        {
            _queryType = queryType;
            this.questionType = questionType;

            _logger = ServiceLocator.Current.GetInstance<ILog>();
        }
示例#2
0
 public Question(string title, List<Answer> answers, QuestionType questionType, Image image = null)
 {
     Title = title;
     Answers = answers;
     QuestionType = questionType;
     Image = image;
 }
        /// <summary>
        ///     Add a new entry to one of the dropdown tables in the database.
        /// </summary>
        /// <param name="table">Table to add a new entry to.</param>
        /// <param name="entry">
        ///     DropdownEntry containing the value and code,
        ///     if exists.
        /// </param>
        public void addEntry(Constants.DropdownTable table,
                             DropdownEntry entry)
        {
            switch (table) {
                case Constants.DropdownTable.Keyword:
                    var kw = new Keyword {
                        KeywordValue = entry.value
                    };

                    _db.Keywords.InsertOnSubmit(kw);
                    break;
                case Constants.DropdownTable.QuestionType:
                    var qType = new QuestionType {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.QuestionTypes.InsertOnSubmit(qType);

                    break;
                case Constants.DropdownTable.Region:
                    var region = new Region {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.Regions.InsertOnSubmit(region);

                    break;
                case Constants.DropdownTable.RequestorType:
                    var rType = new RequestorType {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.RequestorTypes.InsertOnSubmit(rType);

                    break;
                case Constants.DropdownTable.TumourGroup:
                    var tGroup = new TumourGroup {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.TumourGroups.InsertOnSubmit(tGroup);

                    break;
                case Constants.DropdownTable.UserGroup:
                    var uGroup = new UserGroup {
                        Code = entry.code,
                        Value = entry.value
                    };

                    _db.UserGroups.InsertOnSubmit(uGroup);

                    break;
            }

            _db.SubmitChanges();
        }
示例#4
0
        private Targil targil; // the Targil of form

        #endregion Fields

        #region Constructors

        public Regular(Peula peula, QuestionType qType)
        {
            InitializeComponent();

            this.Icon = new Icon(Properties.Resources.App_Icon, new Size(32, 32));

            this.targil = new Targil(qType);
            this.qT = qType;
            this.targil.peula = peula;
            this.peula = peula;

            #region set title of form

            if (peula == Peula.hibur)
                this.Text = Languages.ChosenLanguage.Default["plus"];
            else if (peula == Peula.hisur)
                this.Text = Languages.ChosenLanguage.Default["minus"];
            else if (peula == Peula.kefel)
                this.Text = Languages.ChosenLanguage.Default["kefel"];
            else if (peula == Peula.hiluk)
                this.Text = Languages.ChosenLanguage.Default["hiluk"];
            else if (peula == Peula.random)
                this.Text = Languages.ChosenLanguage.Default["random"];

            #endregion set title of form

            this.lb_time.Text = Languages.ChosenLanguage.Default["time"] + "00:00";
            this.RightToLeft = Languages.ChosenLanguage.dir;
            this.RightToLeftLayout = Languages.ChosenLanguage.dirLayout;
            bt_ok.Text = Languages.ChosenLanguage.Default["send"];

            this.Font = Code.Files.PreferrenceFile.GetReadyFont;

            SetNumbers();
        }
 public PerformingActionAtTimeQuery(QuestionType questionType, WorldAction worldAction = null, int time = -1)
     : base(QueryType.PerformingActionAtTime, questionType)
 {
     this._worldAction = worldAction;
     this._time = time;
     _logger.Info("Creates:\n " + this);
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Question" /> class.
 /// </summary>
 /// <param name="_type">    The _type. </param>
 /// <param name="_text">    The _text. </param>
 /// <param name="_correct"> The _correct. </param>
 /// <param name="_answers"> The _answers. </param>
 public Question(QuestionType _type, string _text, int _correct, ICollection<Answer> _answers)
 {
     Type = _type;
     MinCorrect = _correct;
     QuestionText = _text;
     Answers = _answers;
 }
        public QueryResultsContainer(QuestionType questionType)
        {
            _questionType = questionType;
            _results = new List<QueryResult>();

            _logger = ServiceLocator.Current.GetInstance<ILog>();
            _logger.Info("Create query result container with question type '" + _questionType);
        }
示例#8
0
 public void Edit(string name, List<Answer> answers, QuestionType type, bool required, Color color)
 {
     this.name = name;
     this.answers = answers;
     this.type = type;
     this.required = required;
     this.color = color;
 }
示例#9
0
文件: Question.cs 项目: EcoPet/EcoPet
	public Question(string questionText, string worstCaseText,
		string averageCaseText, string bestCaseText, QuestionType questionType) {
		this.questionText = questionText;
		this.worstCaseText = worstCaseText;
		this.averageCaseText = averageCaseText;
		this.bestCaseText = bestCaseText;
		this.questionType = questionType;
	}
        public override Query GetQuery(QuestionType questionType)
        {
            if (String.IsNullOrEmpty(SelectedScenario))
                throw new InvalidContentException("Scenario name is required.");

            var selectedScenario = Scenarios.First(t => t.Name.Equals(SelectedScenario));
            return new ExecutableScenarioQuery(questionType, selectedScenario);
        }
        public override Query GetQuery(QuestionType questionType)
        {
            if (!UpDownTime.Value.HasValue)
                throw new InvalidContentException("Time value is required.");
            if (SelectedAction == null)
                throw new InvalidContentException("Action is required.");

            return new PerformingActionAtTimeQuery(questionType, SelectedAction, UpDownTime.Value.Value);
        }
        public RedirectToRouteResult CreatePoll(QuestionType questionType, Poll poll, Location location)
        {
            poll.Questions = new List<Question>();
            poll.CreationLocation = LocationUtil.ParseLocation(location);

            this.Session[PollKey] = poll;

            return this.GoToCreateQuestion(questionType);
        }
        public override Query GetQuery(QuestionType questionType)
        {
            if (!UpDownTime.Value.HasValue)
                throw new InvalidContentException("Time value is required.");
            if (String.IsNullOrEmpty(TextBoxCondition.Text))
                throw new InvalidContentException("Condition is required.");

            return new ConditionAtTimeQuery(questionType, TextBoxCondition.Text, UpDownTime.Value.Value);
        }
示例#14
0
        public Answer(int id, QuestionType questionType, string title, bool isCorrect = false, Image image = null)
        {
            Id = id;
            Title = title;
            IsCorrect = isCorrect;
            _questionType = questionType;

            if (image != null)
                Image = image.ToImage();
        }
        public override Query GetQuery(QuestionType questionType)
        {
            if (String.IsNullOrEmpty(SelectedScenario))
                throw new InvalidContentException("Scenario name is required.");
            if (String.IsNullOrEmpty(TextBoxCondition.Text))
                throw new InvalidContentException("Condition is required.");

            var selectedScenario = Scenarios.First(t => t.Name.Equals(SelectedScenario));
            return new AccesibleConditionQuery(questionType, TextBoxCondition.Text, selectedScenario);
        }
        private readonly int _time; //Variable time in query, -1 means no time.

        #endregion Fields

        #region Constructors

        public ConditionAtTimeQuery(QuestionType questionType, string condition, int time = -1)
            : base(QueryType.SatisfyConditionAtTime, questionType)
        {
            _condition = condition;
            _time = time;
            _logicExp = new SimpleLogicExpression(_condition);
            _fluentNames = _logicExp.GetFluentNames();

            _logger.Info("Creates:\n " + this);
        }
示例#17
0
 GameObject ObjectForQuestionType(QuestionType type)
 {
     for (int i = 0; i < questionTypePrefabs.Count; i++)
     {
         if (questionTypePrefabs[i].questionType == type)
         {
             return(questionTypePrefabs[i].prefab);
         }
     }
     return(null);
 }
示例#18
0
 bool ContainsQuestionType(QuestionType type)
 {
     for (int i = 0; i < questionTypePrefabs.Count; i++)
     {
         if (questionTypePrefabs[i].questionType == type)
         {
             return(true);
         }
     }
     return(false);
 }
示例#19
0
        public IActionResult Update([FromBody] QuestionType questionType, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            questionType.Id = id;
            _service.Update(questionType);
            return(Ok(questionType));
        }
示例#20
0
        public void Update(QuestionTypeDTO entity)
        {
            QuestionType result = DataConverter.QuestionTypeDTOToEntity(entity);

            using (var context = new DemoContext())
            {
                var found = context.QuestionTypes.Find(result.QuestionTypeId);
                found.Description = entity.Description;
                context.SaveChanges();
            }
        }
示例#21
0
        public async Task <ActionResult> Edit([Bind(Include = "QuestionTypeID,QuestionTypeName")] QuestionType questiontype)
        {
            if (ModelState.IsValid)
            {
                db.Entry(questiontype).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(questiontype));
        }
        public RedirectToRouteResult CreateMultipleChoicesQuestion(QuestionType questionType, MultipleChoicesQuestion question)
        {
            var poll = (Poll)this.Session[PollKey];

            question.Type = QuestionType.MultipleChoices;
            question.Order = (short)poll.Questions.Count;

            poll.Questions.Add(question);

            return this.GoToCreateQuestion(questionType);
        }
        public RedirectToRouteResult CreateFreeTextQuestion(QuestionType questionType, Question question)
        {
            var poll = (Poll)this.Session[PollKey];

            question.Type = QuestionType.FreeText;
            question.Order = (short)poll.Questions.Count;

            poll.Questions.Add(question);

            return this.GoToCreateQuestion(questionType);
        }
示例#24
0
        public override Query GetQuery(QuestionType questionType)
        {
            if (String.IsNullOrEmpty(SelectedScenario))
            {
                throw new InvalidContentException("Scenario name is required.");
            }

            var selectedScenario = Scenarios.First(t => t.Name.Equals(SelectedScenario));

            return(new ExecutableScenarioQuery(questionType, selectedScenario));
        }
        private HonoplayDbContext InitAndGetDbContext()
        {
            var context = GetDbContext();
            var salt    = ByteArrayExtensions.GetRandomSalt();

            var adminUser = new AdminUser
            {
                Id           = 1,
                Email        = "*****@*****.**",
                Password     = "******".GetSHA512(salt),
                PasswordSalt = salt,
                LastPasswordChangeDateTime = DateTimeOffset.Now.AddDays(-5)
            };

            context.AdminUsers.Add(adminUser);


            var tenant = new Tenant
            {
                Name      = "testTenant",
                HostName  = "localhost",
                CreatedBy = adminUser.Id
            };

            context.Tenants.Add(tenant);

            context.TenantAdminUsers.Add(new TenantAdminUser
            {
                TenantId    = tenant.Id,
                AdminUserId = adminUser.Id,
                CreatedBy   = adminUser.Id
            });

            var question = new Question
            {
                Duration  = 3,
                Text      = "testQuestion",
                CreatedBy = adminUser.Id,
                TenantId  = tenant.Id
            };

            context.Questions.Add(question);

            var questionType = new QuestionType
            {
                Id   = 1,
                Name = "questionType1",
            };

            context.QuestionTypes.Add(questionType);

            context.SaveChanges();
            return(context);
        }
示例#26
0
        private object GetQuestionTypeForSerialization(QuestionType type)
        {
            var minType = new
            {
                Id          = type.Id,
                TypeName    = type.TypeName,
                IsAutomatic = type.IsAutomatic
            };

            return(minType);
        }
示例#27
0
 public frmJogoPergunta(QuestionType mode)
 {
     InitializeComponent();
     this.WindowState = FormWindowState.Maximized;
     if (mode == QuestionType.Title)
     {
         lblTxt.Visible      = false;
         altsPanel.Visible   = false;
         questionPic.Visible = false;
         lblTitle.Location   = new Point(lblTitle.Location.X, lblTxt.Location.Y);
     }
     else if (mode == QuestionType.Img)
     {
         lblTxt.Visible       = false;
         altsPanel.Visible    = false;
         questionPic.Width    = lblTitle.Width;
         questionPic.Location = lblTxt.Location;
     }
     else if (mode == QuestionType.Txt)
     {
         altsPanel.Visible   = false;
         questionPic.Visible = false;
         lblTxt.Width        = lblTitle.Width;
     }
     else if (mode == QuestionType.Alts)
     {
         questionPic.Visible = false;
         altsPanel.Location  = lblTxt.Location;
         questionPic.Visible = false;
         lblTxt.Visible      = false;
     }
     else if (mode == QuestionType.AltsImg)
     {
         lblTxt.Visible       = false;
         questionPic.Width    = lblTitle.Width;
         questionPic.Location = lblTxt.Location;
     }
     else if (mode == QuestionType.TxtAlts)
     {
         questionPic.Visible = false;
         lblTxt.Width        = lblTitle.Width;
     }
     else if (mode == QuestionType.TxtImg)
     {
         altsPanel.Visible = false;
     }
     else if (mode == QuestionType.Full)
     {
         //Código Provisório!
     }
     sp.Stream = Properties.Resources.tense;
     sp.Load();
 }
示例#28
0
        public QuestionForm(string question, IEnumerable <QuestionFromComboBoxItem> items)
            : this()
        {
            this.textBox1.Hide();
            this.Mode        = QuestionType.Dropdown;
            this.label1.Text = question;
            var cb = new ComboBox();

            cb.DisplayMember = "Name";
            cb.ValueMember   = "Id";
            cb.Items.AddRange(items.ToArray());
        }
        public async Task <IActionResult> PostQuestionType([FromBody] QuestionType questionType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.QuestionType.Add(questionType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetQuestionType", new { id = questionType.Id }, questionType));
        }
        public List <Question> GetQuestions(string userQuestionType)
        {
            // Get the type of the question
            QuestionType questionType = (QuestionType)Enum.Parse(typeof(QuestionType), userQuestionType);

            var questions = this.questionRepository
                            .GetAll(x => x.QuestionType == questionType)
                            .OrderBy(x => x.QuestionUploaded)
                            .ToList();

            return(questions);
        }
示例#31
0
 public static Component CreateLeafComponent(long id, long parentID,
                                             string text, string answer, QuestionType type)
 {
     return(new Question()
     {
         ID = id,
         ParentID = parentID,
         Text = text,
         Type = type,
         Answer = answer
     });
 }
示例#32
0
        public void AskQuestion(QuestionType category)
        {
            var question = _questions.FirstOrDefault(x => x.Type == category);

            if (question == null)
            {
                ShuffleDeck();
            }

            Console.WriteLine($"{question.Type} question {question.Number}");
            _questions.Remove(question);
        }
 public InputTextViewController(string title, string subtitle, string inputContent, string confirmButtonText, string hint, InputType inputType, QuestionType questionType, Action <string> positiveButton, Action negativeButton) : base("InputTextViewController", null)
 {
     _questionType      = questionType;
     _title             = title;
     _subtitle          = subtitle;
     _inputContent      = inputContent;
     _confirmButtonText = confirmButtonText;
     _hint           = hint;
     _inputType      = inputType;
     _positiveButton = positiveButton;
     _negativeButton = negativeButton;
 }
示例#34
0
        public QuestionDataQuestionType(TextData data) : base(data)
        {
            Type = QuestionDataType.QuestionType;
            string       questionTypeText = (string)data.Values["questionType"].Value;
            QuestionType?questionType     = GetQuestionType(questionTypeText);

            if (questionType == null)
            {
                throw new PBFileException($"unknow question type \"{questionTypeText}\" line {data.LineNumber} file \"{data.File}\"", data.File, data.LineNumber);
            }
            QuestionType = (QuestionType)questionType;
        }
示例#35
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,GroupId")] QuestionType questionType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(questionType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { groupId = questionType.GroupId }));
            }
            ViewData["GroupId"] = new SelectList(_context.QuestionGroups, "Id", "Id", questionType.GroupId);
            return(View(questionType));
        }
        public Question GetRandomQuestion(QuestionType topic)
        {
            var questionsData = _questionRepository.GetQuestions((int)topic);

            Random rnd   = new Random();
            int    index = rnd.Next(questionsData.Count);

            var questionData = questionsData[index];
            var answers      = _questionRepository.GetAnswerOptions(questionData.Id);

            return(MapQuestionToBussiness(questionData, answers));
        }
示例#37
0
 //Стандартный конструктор
 public Question(string Name, QuestionType Question_Type, string Text, List <string> Variants, List <int> Answers = null, string Section = "NONE", Bitmap Image = null, string SoundFileExt = null, byte[] SoundFile = null)
 {
     this.Question_Type = Question_Type;
     this.Name          = Name;
     this.Text          = Text;
     this.Section       = Section;
     this.Variants      = Variants;
     this.Answers       = Answers;
     this.Image         = Image;
     this.SoundFileExt  = SoundFileExt;
     this.SoundFile     = SoundFile;
 }
示例#38
0
    void Start()
    {
        Log("Generating Questions");
        float difficulty = 15;
        List <QuestionType> questionTypes = new List <QuestionType>();

        while (difficulty > 1)
        {
            QuestionType q    = RandomQuestionType();
            float        diff = GetDifficulty(q);
            //This if statement makes sure that we don't try t o fit in a very difficult question even tho the test is already very close to the target diff
            if (Mathf.Abs(difficulty - diff) < difficulty)
            {
                questionTypes.Add(q);
                difficulty -= diff;
            }
        }
        this.numQuestions = questionTypes.Count;
        this.matrices     = new int[this.numQuestions][, ];
        this.questions    = new string[this.numQuestions];
        this.answers      = new int[this.numQuestions];
        int iter = 0;

        foreach (var q in questionTypes)
        {
            int   i    = 0;
            float best = float.MaxValue;
            while (best > 300 && i < 20)
            {
                i++;
                var gen      = GenerateQuestion(q);
                var mat      = (int[, ])gen[0];
                var quest    = (string)gen[1];
                var answ     = (int)gen[2];
                var extremes = MatrixExtremes(mat);
                int score    = Mathf.Max(extremes[1], -extremes[0]);
                if (score < best || i == 20)
                {
                    best = score;
                    this.matrices[iter]  = mat;
                    this.questions[iter] = quest;
                    this.answers[iter]   = answ;
                }
            }
            Log(
                "Generated question " + (iter + 1) +
                ": Matrix:" + MatrixToString(this.matrices[iter]) +
                " Answer:" + ((this.answers[iter] == -1)?"Any (Error)":((this.answers[iter] == 0)?"No":"Yes")) +
                " Question:" + this.questions[iter]);
            iter++;
        }
        ShowQuestion();
    }
        public IHttpActionResult PostQuestionType(QuestionType questionType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.QuestionType.Add(questionType);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = questionType.QuestionTypeID }, questionType));
        }
示例#40
0
        public bool DeleteQuestionType(int id)
        {
            QuestionType questionType = _myDbContext.QuestionType.FirstOrDefault(c => c.Id == id);

            if (questionType == null)
            {
                return(false);
            }
            _myDbContext.QuestionType.Remove(questionType);
            _myDbContext.SaveChanges();
            return(true);
        }
示例#41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QuestionTypeDTO"/> class.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 public QuestionTypeDTO(QuestionType result)
 {
     this.questionTypeId    = result.Id;
     this.questionTypeOrder = result.QuestionTypeOrder;
     this.type = result.Type;
     this.questionTypeDescription = result.QuestionTypeDescription;
     this.instruction             = result.Instruction;
     this.correctText             = result.CorrectText;
     this.incorrectMessage        = result.IncorrectMessage;
     this.isActive   = result.IsActive;
     this.iconSource = result.IconSource;
 }
示例#42
0
        public async Task <ActionResult> Create([Bind(Include = "QuestionTypeID,QuestionTypeName")] QuestionType questiontype)
        {
            if (ModelState.IsValid)
            {
                db.QuestionTypes.Add(questiontype);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(questiontype));
        }
示例#43
0
 public SurveyQuestionDTO(int id, string question, QuestionType questionType, double excellent, double veryGood, double good, double poor, double veryPoor, double averageGrade)
 {
     this.id           = id;
     this.question     = question;
     this.questionType = questionType;
     this.excellent    = excellent;
     this.veryGood     = veryGood;
     this.good         = good;
     this.poor         = poor;
     this.veryGood     = veryPoor;
     this.averageGrade = averageGrade;
 }
    // button event
    private void OnButtonEvent(QuestionType quetionType)
    {
        if (battleUI == null)
        {
            battleUI = UIController.Instance.CreateUI <BattleUI>("UI/BattleUI", UIStyle.UI, this);
        }

        Close();
        battleUI.Init(quetionType);
        battleUI.Open();
        battleUI.StartGame();
    }
示例#45
0
        public bool SaveQuestionType(QuestionType questionType)
        {
            QuestionType dbQuestionType = _myDbContext.QuestionType.FirstOrDefault(c => c.Id == questionType.Id);

            if (dbQuestionType == null)
            {
                return(false);
            }
            dbQuestionType.QuestionTypeName = questionType.QuestionTypeName;
            _myDbContext.SaveChanges();
            return(true);
        }
示例#46
0
 public QuestionBaseModel CreateQuestion(QuestionType questionType)
 {
     switch (questionType)
     {
         case QuestionType.Checkbox:
         case QuestionType.Radio:
             return new VariantQuestionModel();                    
         case QuestionType.TextArea:
             return new TextAreaQuestionModel();                    
         default:
             throw new NotSupportedException($"Unknown question type: {questionType}");
     }
 }
示例#47
0
 public void EditQuestion(long id, string text, string answer, QuestionType type,
                          ObservableCollection <string> wrongAnswers)
 {
     if (ComponentsCache.ContainsKey(id))
     {
         Question question = ComponentsCache[id] as Question;
         question.Text         = text ?? question.Text;
         question.Answer       = answer ?? question.Answer;
         question.Type         = type;
         question.WrongAnswers = wrongAnswers;
         LogChange(question, ContentStatus.Edit);
     }
 }
示例#48
0
 public QuestionTypeViewModel(QuestionType item)
 {
     this.Id             = item.Id;
     this.ModifiedDate   = item.ModifiedDate;
     this.ModifiedUserId = item.ModifiedUserId;
     this.Type           = item.Type;
     this.Questions      = this.GetQuestionViewList(item.Questions);
     this.CreatedDate    = item.CreatedDate;
     this.CreatedUserId  = item.CreatedUserId;
     this.DeletionDate   = item.DeletionDate;
     this.DeletionUserId = item.DeletionUserId;
     this.IsDeleted      = item.IsDeleted;
 }
示例#49
0
        public bool Save(QuestionType element)
        {
            if (element.Id == 0)
            {
                element = _questionTypeRepo.Add(element);
            }
            else
            {
                element = _questionTypeRepo.Update(element);
            }

            return(true);
        }
        public AccesibleConditionQuery(QuestionType questionType, string condition, ScenarioDescription scenario)
            : base(QueryType.AccesibleCondition, questionType)
        {
            _queryType = QueryType.AccesibleCondition;
            _condition = condition;
            var logicExp = new SimpleLogicExpression(this._condition);
            _fluentNames = logicExp.GetFluentNames();
            _scenario = scenario;

            ExecQuery = new ExecutableScenarioQuery(QuestionType.Ever, _scenario);
            CondAtTimeQuery = new ConditionAtTimeQuery(QuestionType.Ever, _condition);

            _logger.Info("Creates:\n " + this);
        }
 public static string Create(QuestionType questionType)
 {
     switch (questionType)
     {
         case QuestionType.SimpleText:
             return "SimpleText";
         case QuestionType.MultipleChoice:
             return "MultipleChoice";
         case QuestionType.FiveStars:
             return "FiveStars";
         default:
             return "String";
     }
 }
        public void Build_a_response_using_Gather_if_the_question_type_is_Numeric_or_YesNo(
            int id, string body, QuestionType type)
        {
            var question = new Question { Id = id, Body = body, Type = type };
            var response = new Response(question).Build();
            var expectedResponse = string.Format(
                "<Response>\r\n" +
                "  <Say>{0}</Say>\r\n" +
                "  <Say>{1}</Say>\r\n" +
                "  <Gather action=\"/answers/create?questionId={2}\" />\r\n" +
                "</Response>", question.Body, Response.QuestionTypeToMessage[question.Type], question.Id);

            Assert.That(response.ToString(), Is.EqualTo(expectedResponse));
        }
示例#53
0
        public Question(int id, string title, List<DomainModel.Entities.Answer> answers, QuestionType questionType, Image image = null)
        {
            Id = id;
            Title = title;
            Answers = answers.Select(x => x.ToAnswer(questionType)).ToList();
            QuestionType = questionType;

            if (QuestionType == DomainModel.Entities.QuestionType.ImageQuestion)
            {
                Title = "Что на картинке?";
            }

            if (image != null)
                Image = image.ToImage();
        }
示例#54
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="num1">the first number</param>
 /// <param name="p">the peula</param>
 /// <param name="num2">the secend number</param>
 /// <param name="QType">the question type to the targil : Hiuvi or Mehuvan</param>
 public Targil(int num1, Peula p, int num2, QuestionType QType)
 {
     number1 = num1;
     number2 = num2;
     peula = p;
     if (p == Peula.hibur)
         answer = num1 + num2;
     else if (p == Peula.hisur)
         answer = num1 - num2;
     else if (p == Peula.kefel)
         answer = num1 * num2;
     else if (p == Peula.hiluk)
         answer = num1 / num2;
     if (QType == QuestionType.Mehuvan)
         this.qType = -1;
 }
示例#55
0
 public static ICaculator Create(QuestionType qType)
 {
     switch (qType)
     {
         case QuestionType.Distance:
             return new DistanceCaculator();
         case QuestionType.StartEndMaxStops:
             return new StartEndMaxStopsCaculator();
         case QuestionType.StartEndExactStops:
             return new StartEndExactStopsCaculator();
         case QuestionType.StartEndShortest:
             return new StartEndShortestCaculator();
         default:
             return null;
     }
 }
示例#56
0
        public void ConvertByteToType(byte num)
        {
            difficulty = (Difficulty)(num / 100);
            num %= 100;

            // if it is from Sort of Hiuvi / Mehuvan / Shever
            if (num < 50)
            {
                QuestionSort = (QuestionType)(num / 10 - 1);
                Type = System.Enum.GetNames(typeof(Peula))[num % 10];
            }

            else
            {
                QuestionSort = QuestionType.Other;
                Type = "???";
            }
        }
        /// <summary>
        /// 新增選擇問題
        /// </summary>
        /// <param name="Qtype"></param>
        /// <param name="name"></param>
        /// <param name="label"></param>
        /// <param name="width"></param>
        /// <param name="rows"></param>
        /// <param name="GridColXml"></param>
        /// <param name="GridDefaultXml"></param>
        public void AddQuestionSelect(QuestionType Qtype, string name, string label, string width, int rows,XElement  GridColXml,XElement GridDefaultXml)
        {
            if (_QGroup.Element("Qs") == null)
                _QGroup.SetElementValue("Qs", "");

            XElement elm = new XElement("Q");
            elm.SetAttributeValue("type", Qtype.ToString());
            elm.SetAttributeValue("name", name);
            elm.SetAttributeValue("label", label);
            elm.SetAttributeValue("width", width);

            // 解析使用 Grid 型態
            if (Qtype == QuestionType.grid)
            {
                elm.SetAttributeValue("rows", rows.ToString());
                elm.Add(GridColXml);
                elm.Add(GridDefaultXml);
            }
        }
示例#58
0
        /// <summary>
        /// This method generates a random question
        /// </summary>
        /// <param name="questionType">Type of the question</param>
        /// <returns>Random question</returns>
        private static Quest GenerateRandomQuest(QuestionType questionType)
        {
            var questionListSize = QuestionList.Count;

            Random random = new Random();
            try
            {
                do
                {
                    var question = QuestionList[random.Next(1, questionListSize)];

                    if (question.Type == questionType)
                    {
                        return question;
                    }
                } while (true);
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Error check code");
                return QuestionList[1];
            }
        }
 public void questionTypeAddLogicTest()
 {
     QuestionType m = new QuestionType();
     m.Code = "TST";
     m.FullName = "QuestionTypeAddLogicTest";
     m.Enabled = true;
     ActionResult result = dDAdminController.Add(m, "QuestionType");
     Assert.AreEqual("System.Web.Mvc.RedirectToRouteResult", result.GetType().FullName);
     QuestionType justAdded = db.QuestionTypes.ToArray().Last();
     Assert.IsTrue(justAdded.Code.Equals("TST") && justAdded.FullName.Equals("QuestionTypeAddLogicTest") && justAdded.Enabled);
 }
示例#60
0
 public Question(int id, QuestionType qt, string text, CorrectAnswer ca) : this(id, qt, text) {
     CorrectAnswers = ca;
 }