public async Task <IActionResult> Edit(int id, [Bind("TypeQuestionId,Name,Wording,CreationDate")] TypeQuestion typeQuestion)
        {
            if (id != typeQuestion.TypeQuestionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeQuestion);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeQuestionExists(typeQuestion.TypeQuestionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeQuestion));
        }
Exemple #2
0
 public void AddTypeQuestion(TypeQuestion typeQuestion)
 {
     using (var dbContext = new FilRougeDBContext())
     {
         dbContext.TypeQuestion.Add(typeQuestion);
         dbContext.SaveChanges();
     }
 }
Exemple #3
0
 public Multible(TypeQuestion type, string title, int bound) : base(type, title)
 {
     this.bound = bound;
     this.List_multiable_Answer = new LinkedList <Multiable_answer>();
     this.answer                  = new string[bound];
     multiable_Answer             = new Multiable_answer(bound);
     this.list_multichoice_answer = new LinkedList <MultiChoiceAnswercs>();
 }
Exemple #4
0
 public void Initialize(TypeQuestion _type, string _question, bool require_Ans, string _answer)
 {
     type               = _type;
     question           = _question;
     requireAnswer      = require_Ans;
     answer             = _answer;
     list_multi_answers = new LinkedList <Multiable_answer>();
 }
Exemple #5
0
 public Question(int QuestionID, string QuestionText, string File, TypeQuestion TypeQuest, List <Answer> Answers)
 {
     this.QuestionID   = QuestionID;
     this.QuestionText = QuestionText;
     this.File         = File;
     this.TypeQuest    = TypeQuest;
     this.Answers      = Answers;
 }
Exemple #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            TypeQuestion typeQuestion = db.TypeQuestion.Find(id);

            db.TypeQuestion.Remove(typeQuestion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #7
0
 public Matrix(TypeQuestion type, string[] title, int boundAnswer, int boundQustion) : base(type, title[0], boundAnswer)
 {
     this.bound2        = boundQustion;
     multiable_question = new Multible[boundQustion];
     for (int i = 0; i < boundQustion; i++)
     {
         multiable_question[i] = new Multible(type, title[i], boundAnswer);
     }
 }
Exemple #8
0
        public async Task <TypeQuestion> CreateTypeQuestion(TypeQuestion newTypeQuestion)
        {
            await _unitOfWork.TypesQuestion
            .AddAsync(newTypeQuestion);

            await _unitOfWork.CommitAsync();

            return(newTypeQuestion);
        }
        private List <User>[] Analys_multi(Question question)
        {
            this.question = (Multible)question;

            typeQuestion = TypeQuestion.Multible;
            user         = Get_UsersMultiChoice(((Multible)question).list_multiChoice_properties.ToList(), ((Multible)question).answer);

            return(this.user);
        }
        private void AddAnalyzeButton(int i, TypeQuestion type)
        {
            //(stackQuestions.Children[i] as StackLayout).
            var Analyzebtn = new Button
            {
                Text              = Lang.Resource.btnAnalyse,
                Image             = "analytics.png",
                FontSize          = 15,
                FontAttributes    = FontAttributes.Bold,
                TextColor         = Color.FromHex("18d94b"),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                BackgroundColor   = Color.FromHex("efefef"),
                WidthRequest      = 150
            };

            if (type == TypeQuestion.Text)
            {
                Analyzebtn.Clicked += (sender, e) => {
                    Navigation.PushAsync(new AnalyzeTextQuestionPage(SelectedSurvey, i));
                };
            }
            else if (type == TypeQuestion.Slider)
            {
                Analyzebtn.Clicked += (sender, e) => {
                    Navigation.PushAsync(new AnalyzeSliderQuestionPage(SelectedSurvey, i));
                };
            }
            else
            {
                Analyzebtn.Clicked += (sender, e) => {
                    Navigation.PushAsync(new AnalyzeMultiChoiceQuestionPage(SelectedSurvey, i));
                };
            }
            //TapGestureRecognizer tapText = new TapGestureRecognizer();
            //tapText.Tapped += (sender, e) => {
            //    Navigation.PushModalAsync(new AnalyzeTextQuestionPage());
            //};
            //TapGestureRecognizer tapMuliChoices = new TapGestureRecognizer();
            //tapMuliChoices.Tapped += (sender, e) => {
            //    Navigation.PushModalAsync(new AnalyzeMultiChoiceQuestionPage(SelectedSurvey));
            //};
            //TapGestureRecognizer tapSlider = new TapGestureRecognizer();
            //tapSlider.Tapped += (sender, e) => {
            //    Navigation.PushModalAsync(new AnalyzeSliderQuestionPage());
            //};
            //if (type == TypeQuestion.Text)
            //    Analyzebtn.GestureRecognizers.Add(tapText);
            //else if (type == TypeQuestion.Slider)
            //    Analyzebtn.GestureRecognizers.Add(tapSlider);
            //else
            //    Analyzebtn.GestureRecognizers.Add(tapMuliChoices);
            (stackQuestions.Children[i + 1] as StackLayout).Children.Add(new Label {
                HeightRequest = 2, BackgroundColor = Color.FromHex("1fe887")
            });
            (stackQuestions.Children[i + 1] as StackLayout).Children.Add(Analyzebtn);
        }
Exemple #11
0
 public ActionResult Edit([Bind(Include = "TypeQuestionId,NameType")] TypeQuestion typeQuestion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(typeQuestion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(typeQuestion));
 }
Exemple #12
0
        /// <summary>
        /// Edition d'un type de question
        /// </summary>
        /// <param name="typeQuestion"></param>
        /// <returns></returns>
        public TypeQuestion EditTypeQuestion(TypeQuestion typeQuestion)
        {
            using (var dbContext = new FilRougeDBContext())
            {
                dbContext.Entry(typeQuestion).State = EntityState.Modified;
                dbContext.SaveChanges();
            }

            return(typeQuestion);
        }
Exemple #13
0
        /// <summary>
        /// Retourne le type de question par son "Id"
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TypeQuestion GetTypeQuestion(int?id)
        {
            var typeQuestion = new TypeQuestion();

            using (var dbContext = new FilRougeDBContext())
            {
                typeQuestion = dbContext.TypeQuestion.Find(id);
            }

            return(typeQuestion);
        }
        public async Task <IActionResult> Create([Bind("TypeQuestionId,Name,Wording,CreationDate")] TypeQuestion typeQuestion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typeQuestion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeQuestion));
        }
Exemple #15
0
        /// <summary>
        /// Suppression d'un type de question
        /// </summary>
        /// <param name="id"></param>
        public void RemoveTypeQuestion(int id)
        {
            var typeQuestion = new TypeQuestion();

            using (var dbContext = new FilRougeDBContext())
            {
                typeQuestion = dbContext.TypeQuestion.Find(id);
                dbContext.TypeQuestion.Remove(typeQuestion);
                dbContext.SaveChanges();
            }
        }
Exemple #16
0
        public ActionResult Create([Bind(Include = "TypeQuestionId,NameType")] TypeQuestion typeQuestion)
        {
            if (ModelState.IsValid)
            {
                db.TypeQuestion.Add(typeQuestion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(typeQuestion));
        }
Exemple #17
0
    private string GetType(TypeQuestion typeQuestion)
    {
        switch (typeQuestion)
        {
        case TypeQuestion.Image: return("Рисунок");

        case TypeQuestion.Text: return("Текст");

        case TypeQuestion.Sound: return("Звук");
        }
        return(null);
    }
    void AddSubAssetAtIndex(string name, TypeQuestion type)
    {
        Question newAsset = SelectQuestion(type);

        newAsset.name = name;
        AssetDatabase.AddObjectToAsset(newAsset, category);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAsset));
        category.questions.Add(newAsset);
        Debug.Log(AssetDatabase.GetAssetPath(category));
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
    Question SelectQuestion(TypeQuestion type)
    {
        switch (type)
        {
        case TypeQuestion.Image: return(CreateInstance <ImageQuestion>());

        case TypeQuestion.Sound: return(CreateInstance <SoundQuestion>());

        case TypeQuestion.Text: return(CreateInstance <TextQuestion>());

        default: return(CreateInstance <Question>());
        }
    }
Exemple #20
0
        // GET: TypeQuestions/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TypeQuestion typeQuestion = db.TypeQuestion.Find(id);

            if (typeQuestion == null)
            {
                return(HttpNotFound());
            }
            return(View(typeQuestion));
        }
Exemple #21
0
 public UserControl this[TypeQuestion type]
 {
     get
     {
         if (_controls != null)
         {
             foreach (IQuestion q in _controls)
             {
                 if (q.Type == type)
                 {
                     return(q.ControlQuestion);
                 }
             }
         }
         return(null);
     }
 }
        public List <Question> RandomQuestions(TypeQuestion type, int count)
        {
            List <Question> listQuestion = new List <Question>();
            Random          random       = new Random();
            List <Question> questions    = getQuestionsByType(type).Where(q => q.StatusQuest == true).ToList();

            while (listQuestion.Count < count && listQuestion.Count != questions.Count)
            {
                int      index    = random.Next(questions.Count);
                Question question = questions[index];
                if (!listQuestion.Contains(question))
                {
                    listQuestion.Add(question);
                }
            }
            return(listQuestion);
        }
        private void LoadData()
        {
            //treeView1.HideSelection = false;
            for (int i = 0; i < testDataSet1.Voprosy.Rows.Count; i++)
            {
                _isAnswered = new bool[testDataSet1.Voprosy.Rows.Count];
                _questions.Clear();
                //получаем текст вопроса
                Otvety o = new Otvety();
                o.textOtveta = testDataSet1.Voprosy.Rows[i][3].ToString();
                _questions.Add(o);

                //заносим ответ в treeView
                //treeView1.BeginUpdate();
                //treeView1.Nodes.Add(i.ToString(), o.textOtveta);
                //treeView1.EndUpdate();

                int idQuestion = Convert.ToInt32(testDataSet1.Voprosy.Rows[i][6]);

                //получаем ответы на вопрос
                TestDataSet.OtvetyDataTable table = new TestDataSet.OtvetyDataTable();
                otvetyTableAdapter1.FillByOtvety(table, Convert.ToInt32(idQuestion));
                List <Otvety> otv = new List <Otvety>();
                _questions.AddRange(ConvertDataTable.GetOtvety(table).ToArray());

                //для каждого ответа проверяем правильный ли он
                for (int j = 1; j < _questions.Count; j++)
                {
                    bool?b = otvety_naVoprosyTableAdapter1.IsRightAnswer(Convert.ToInt32(_questions[j].idOtveta));
                    _questions[j].isWright = (bool)b;
                }

                //получаем панели с вопросами по типу вопроса
                TypeQuestion type  = (TypeQuestion)(Convert.ToInt32(testDataSet1.Voprosy.Rows[i][0]) - 1);
                UserControl  panel = _la[type];
                ((IQuestion)panel).SetData(_questions);
                _questPanels.Add(panel);
            }
            splitContainer2.Panel1.Controls.Add(_questPanels[_indexQuestion]);
            splitContainer2.Panel1.Invalidate();
            //TreeNode[] node = treeView1.Nodes.Find(_indexQuestion.ToString(), false);
            //treeView1.SelectedNode = node[0];
        }
        public List <User>[] Analys(Question question)
        {
            if (question.typeQuestion_properties == TypeQuestion.Multible || question.typeQuestion_properties == TypeQuestion.DropDown)
            {
                this.question = (Multible)question;

                typeQuestion = TypeQuestion.Multible;

                user = Get_Users_Multi(((Multible)question).List_List_multiable_Answer_properity.ToList(), ((Multible)question).answer);
                return(this.user);
            }
            else if (question.typeQuestion_properties == TypeQuestion.Slider)
            {
                this.question = (Slider_Question)question;
                typeQuestion  = TypeQuestion.Slider;
                user          = new List <User> [((Slider_Question)question).Max_Value_Property];

                for (int i = 0; i < user.Length; i++)
                {
                    user[i] = new List <User>();
                }

                foreach (Multiable_answer multiable_Answer in ((Slider_Question)question).List_multiable_Answer_properity)
                {
                    user[int.Parse(multiable_Answer.Choosen_Answer_Property)].Add(multiable_Answer.user_Property);
                }

                return(this.user);
            }
            else if (question.typeQuestion_properties == TypeQuestion.Matrix)
            {
                typeQuestion    = TypeQuestion.Matrix;
                this.usermatrix = AnalysMatrix((Matrix)question);
            }
            else if (question.typeQuestion_properties == TypeQuestion.MultiChoice)
            {
                typeQuestion = TypeQuestion.MultiChoice;
                this.user    = Analys_multi(question);
                return(this.user);
            }
            return(null);
        }
        public List <Question> getQuestionsByType(TypeQuestion type)
        {
            List <Question> questions = questRepository.GetAll().Where(q => q.TypeQuest == type).ToList();

            return(questions);
        }
Exemple #26
0
 public Text_Question(TypeQuestion typeQuestion, string _question) : base(typeQuestion, _question)
 {
 }
Exemple #27
0
        void OnChangedProperty(TypeQuestion type)
        {
            IQuestion q = (IQuestion)_uc;

            q.SetData(_questionPanel.GetData());
        }
        // Deserialize Multible Questions
        static public KeyValuePair <Multible, int> deserialize_MultibleChoice(string Content, int iter, string type)
        {
            string title = "", require = "";

            iter++;
            char i = Content[iter];

            while (i != '~')
            {
                title += i.ToString();
                iter++;
                i = Content[iter];
            }
            iter++;
            i = Content[iter];
            while (i != '~')
            {
                require += i.ToString();
                iter++;
                i = Content[iter];
            }
            iter++;
            KeyValuePair <string[], int> pair = DESERILIZE_answer(Content, iter);

            string[] answers = pair.Key;
            int      bound   = answers.Length;

            iter = pair.Value;
            KeyValuePair <MultiChoiceAnswercs, int> Pair = DESERIALIZE_multichoiceAnswer(Content, iter);

            iter = Pair.Value;
            if (Content[iter] == '~')
            {
                iter++;
            }
            i = Content[iter];
            string count_answers1 = "";

            while (i != '~')
            {
                count_answers1 += i.ToString();
                iter++;
                i = Content[iter];
            }
            LinkedList <MultiChoiceAnswercs> multiable_Answers1 = new LinkedList <MultiChoiceAnswercs>();

            for (int j = 0; j < Int32.Parse(count_answers1); j++)
            {
                iter++;
                Pair = DESERIALIZE_multichoiceAnswer(Content, iter);
                iter = Pair.Value;
                multiable_Answers1.AddLast(Pair.Key);
            }
            iter++;
            KeyValuePair <Multiable_answer, int> Pair1 = DESERIALIZE_Multiable_answer(Content, iter);

            iter = Pair1.Value;
            TypeQuestion _type = TypeQuestion.Multible;

            if (type.Contains("MultiChoice"))
            {
                _type = TypeQuestion.MultiChoice;
            }
            else if (type.Contains("DropDown"))
            {
                _type = TypeQuestion.DropDown;
            }
            Multible multible = new Multible(_type, title, bound);

            multible.answer = answers;
            multible.bound  = bound;
            multible.multiChoiceAnswercs_properties = Pair.Key;
            multible.list_multiChoice_properties    = multiable_Answers1;
            multible.multiable_Answer = Pair1.Key;
            // iter--;
            if (require.Contains("True"))
            {
                multible.require_Ans = true;
            }
            else
            {
                multible.require_Ans = false;
            }
            if (Content[iter].Equals('~'))
            {
                iter++;
            }
            i = Content[iter];
            string count_answers = "";

            while (i != '~')
            {
                count_answers += i.ToString();
                iter++;
                i = Content[iter];
            }
            LinkedList <Multiable_answer> multiable_Answers = new LinkedList <Multiable_answer>();

            for (int j = 0; j < Int32.Parse(count_answers); j++)
            {
                iter++;
                Pair1 = DESERIALIZE_Multiable_answer(Content, iter);
                iter  = Pair1.Value;
                multiable_Answers.AddLast(Pair1.Key);
            }
            multible.List_List_multiable_Answer_properity = multiable_Answers;
            return(new KeyValuePair <Multible, int>(multible, iter));
        }
Exemple #29
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            splitContainer1.Panel2.Controls.Clear();
            splitContainer2.Panel2.Controls.Clear();
            int          i    = comboBox1.SelectedIndex;
            TypeQuestion type = (TypeQuestion)i;

            switch (type)
            {
            case TypeQuestion.ChroniceSequence:
                PanelChronice p9 = new PanelChronice();
                p9.Dock = DockStyle.Fill;
                p9.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p9);
                _questionPanel = p9;
                break;

            case TypeQuestion.Compare:
                PanelCompare p1 = new PanelCompare();
                p1.Dock = DockStyle.Fill;
                p1.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p1);
                _questionPanel = p1;
                break;

            case TypeQuestion.FullAnswer:
                PanelFullAnswer p2 = new PanelFullAnswer();
                p2.Dock = DockStyle.Fill;
                p2.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p2);
                _questionPanel = p2;
                break;

            case TypeQuestion.Graphic:
                PanelGraphic p3 = new PanelGraphic();
                p3.Dock = DockStyle.Fill;
                p3.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p3);
                _questionPanel = p3;
                break;

            case TypeQuestion.InsertWords:
                PanelInsertWord p4 = new PanelInsertWord();
                p4.Dock = DockStyle.Fill;
                p4.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p4);
                _questionPanel = p4;
                break;

            case TypeQuestion.LogicRelation:
                PanelLogicRelation p5 = new PanelLogicRelation();
                p5.Dock = DockStyle.Fill;
                p5.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p5);
                _questionPanel = p5;
                break;

            case TypeQuestion.Matching:
                PanelMatching p6 = new PanelMatching();
                p6.Dock = DockStyle.Fill;
                p6.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p6);
                _questionPanel = p6;
                break;

            case TypeQuestion.MoreOneVariant:
                PanelOneVariant p7 = new PanelOneVariant();
                p7.Dock = DockStyle.Fill;
                p7.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p7);
                _questionPanel = p7;
                break;

            case TypeQuestion.OneVariant:
                PanelOneVariant p = new PanelOneVariant();
                p.OnChangedProperty += OnChangedProperty;
                p.Dock = DockStyle.Fill;
                splitContainer2.Panel2.Controls.Add(p);
                _questionPanel = p;
                break;

            case TypeQuestion.Selection:
                PanelSelection p8 = new PanelSelection();
                p8.Dock = DockStyle.Fill;
                p8.OnChangedProperty += OnChangedProperty;
                splitContainer2.Panel2.Controls.Add(p8);
                _questionPanel = p8;
                break;
            }
            _uc = lo[type];
            splitContainer1.Panel2.Controls.Add(_uc);
            splitContainer1.Panel2.Invalidate();
            splitContainer2.Panel2.Invalidate();
        }
Exemple #30
0
 public Question(TypeQuestion type, string title)
 {
     this.Type  = type;
     Id         = ++ID;
     this.title = title;
 }