Пример #1
0
        /// <summary>
        /// This for refresh my partail view atfer any edit in list
        /// </summary>
        /// <returns></returns>

        /// <summary>
        /// This create view for get a question to add it
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateQuestion(int Type)
        {
            try
            {
                TypeOfQuestion QuestionType = (TypeOfQuestion)Type;
                switch (QuestionType)
                {
                case TypeOfQuestion.Slider:
                    QuestionModel Slider = new QuestionModel();
                    Slider.TypeOfQuestion = TypeOfQuestion.Slider;
                    return(View(Slider));

                case TypeOfQuestion.Smily:
                    QuestionModel Smile = new QuestionModel();
                    Smile.TypeOfQuestion = TypeOfQuestion.Smily;
                    return(View(Smile));

                case TypeOfQuestion.Stars:
                    QuestionModel Star = new QuestionModel();
                    Star.TypeOfQuestion = TypeOfQuestion.Stars;
                    return(View(Star));

                default:
                    return(View(@SurveyWebSite.Resources.Messages.ErrorCreate));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                return(RedirectToAction(SurveyWebSite.Resources.Constants.ErrorView, new { ErrorMessage = SurveyWebSite.Resources.Messages.ErrorCreate }));
            }
        }
Пример #2
0
        public ResponseToQuestion(TypeOfQuestion type, string wording,
                                  ObservableCollection <AnswerCorrect> one, ObservableCollection <AnswerCorrect> many)
        {
            Type            = type;
            QuestionWording = wording;
            switch (Type)
            {
            case TypeOfQuestion.oneCorrect:
                foreach (AnswerCorrect answer in one)
                {
                    AnswerOne.Add(new AnswerCorrect()
                    {
                        Answer = answer.Answer
                    });
                }
                break;

            case TypeOfQuestion.manyCorrect:
                foreach (AnswerCorrect answer in many)
                {
                    AnswerMany.Add(new AnswerCorrect()
                    {
                        Answer = answer.Answer
                    });
                }
                break;

            case TypeOfQuestion.inputAnswer:
                break;

            case TypeOfQuestion.accordance:
                break;
            }
        }
        public TypeOfQuestion Create(TypeOfQuestion typeofquestion)
        {
            ETypeOfQuestion eTypeOfQuestion = ETypeOfQuestion(typeofquestion);

            eTypeOfQuestion = _iDTypeOfQuestion.Create(eTypeOfQuestion);
            return(TypeOfQuestion(eTypeOfQuestion));
        }
Пример #4
0
 public Question(string questionid, string questions, string postive, string negative, TypeOfQuestion typeOfQuestion)
 {
     QuestionID     = questionid;
     Questions      = questions;
     Postive        = postive;
     Negative       = negative;
     TypeOfQuestion = typeOfQuestion;
 }
        private TypeOfQuestion TypeOfQuestion(ETypeOfQuestion eTypeOfQuestion)
        {
            TypeOfQuestion returnTypeOfQuestion = new TypeOfQuestion
            {
                TypeOfQuestionId   = eTypeOfQuestion.TypeOfQuestionId,
                TypeOfQuestionName = eTypeOfQuestion.TypeOfQuestionName
            };

            return(returnTypeOfQuestion);
        }
        private ETypeOfQuestion ETypeOfQuestion(TypeOfQuestion typeofquestion)
        {
            ETypeOfQuestion returnETypeOfQuestion = new ETypeOfQuestion
            {
                TypeOfQuestionId   = typeofquestion.TypeOfQuestionId,
                TypeOfQuestionName = typeofquestion.TypeOfQuestionName
            };

            return(returnETypeOfQuestion);
        }
        /// <summary>
        /// This function to select a question from database using his type from manger.
        /// </summary>
        private static int SelectIdType(TypeOfQuestion TypeOfQustion, ref int Id)
        {
            try
            {
                if (IsServerConnected())
                {
                    int ResultOfBulid = BuildConnectionString();
                    if (ResultOfBulid == GenralVariables.Succeeded)
                    {
                        string SelectIdTypeStatment = GenralVariables.SelectMaxId + TypeOfQustion.ToString();
                        Id = -1;
                        using (SqlConnection Connection = new SqlConnection(GenralVariables.ConnectionString))
                        {
                            SqlCommand CommandForSelectIdType = new SqlCommand(SelectIdTypeStatment, Connection);
                            CommandForSelectIdType.Connection.Open();
                            SqlDataReader Reader = CommandForSelectIdType.ExecuteReader();
                            while (Reader.Read())
                            {
                                Id = Convert.ToInt32(Reader[GenralVariables.IdQuestion]);
                                //break;
                            }

                            Reader.Close();
                            if (Id != -1)
                            {
                                return(GenralVariables.Succeeded);
                            }
                        }
                        return(GenralVariables.ErrorInDataBase);
                    }
                    return(ResultOfBulid);
                }
                return(GenralVariables.ErrorWhileConnectiong);
            }
            catch (Exception ex)
            {
                Id = -1;
                GenralVariables.Errors.Log(ex.Message);
                return(GenralVariables.ErrorInSelectionQuestion);
            }
        }
 public Questions(string question, TypeOfQuestion typeOfQuestion, int score)
 {
     Question     = question;
     TypeQuestion = typeOfQuestion;
     Score        = score;
 }
Пример #9
0
        /// <summary>
        /// This Function to Check validation of data
        /// </summary>
        private bool CheckTheData(TypeOfQuestion TypeQuestion)
        {
            try
            {
                if (NewText.Text == "")
                {
                    MessageBox.Show(Survey.Properties.Messages.QuestionIsEmptyMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);;
                    return(false);
                }
                else if (IsNumber(NewText.Text))
                {
                    MessageBox.Show(Survey.Properties.Messages.QuestionIsJustANumberMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                else if (NewOrder.Value <= 0)
                {
                    MessageBox.Show(Survey.Properties.Messages.NewOrderLessThanZeroMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }

                if (TypeQuestion == TypeOfQuestion.Slider)
                {
                    if (NewStartValue.Value <= 0)
                    {
                        MessageBox.Show(Survey.Properties.Messages.StartValueLessThanZeroMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewEndValue.Value <= 0)
                    {
                        MessageBox.Show(Survey.Properties.Messages.EndValueLessThanZeroMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewStartValue.Value > 100)
                    {
                        MessageBox.Show(Survey.Properties.Messages.StartValueGreaterThanOneHundredMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewEndValue.Value > 100)
                    {
                        MessageBox.Show(Survey.Properties.Messages.EndValueGreaterThanOneHundredMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewStartValue.Value >= NewEndValue.Value)
                    {
                        MessageBox.Show(Survey.Properties.Messages.TheEndValueSholudGreaterThanStartValueMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewStartValueCaption.Text == "")
                    {
                        MessageBox.Show(Survey.Properties.Messages.StartCaptionEmptyMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (IsNumber(NewStartValueCaption.Text))
                    {
                        MessageBox.Show(Survey.Properties.Messages.StartCaptionJustNumberMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (NewStartValueCaption.Text == "")
                    {
                        MessageBox.Show(Survey.Properties.Messages.EndCaptionEmptyMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else if (IsNumber(NewStartValueCaption.Text))
                    {
                        MessageBox.Show(Survey.Properties.Messages.EndCaptionJustNumberMessage, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else if (TypeQuestion == TypeOfQuestion.Smily)
                {
                    if (NewNumberOfSmiles.Value <= 1 || NewNumberOfSmiles.Value > 5)
                    {
                        MessageBox.Show(Survey.Properties.Messages.NumberOfSmileBetweenFiveAndTow, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else if (TypeQuestion == TypeOfQuestion.Stars)
                {
                    if (NewNumberOfStars.Value <= 0 || NewNumberOfStars.Value > 10)
                    {
                        MessageBox.Show(Survey.Properties.Messages.NumberOfStrasBetweenTenAndOne, GenralVariables.ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                GenralVariables.Errors.Log(ex.Message);
                MessageBox.Show(Survey.Properties.Messages.MessageError);

                return(false);
            }
            return(true);
        }
Пример #10
0
 private void InsertProperTags(TypeOfQuestion typeOfQuestion, string textQuestionContent = null, string imageQuestionContent = null)
 {
     switch(typeOfQuestion)
     {
         case TypeOfQuestion.isImgIsTxt:
             writer.RenderBeginTag(HtmlTextWriterTag.B);
             writer.RenderBeginTag(HtmlTextWriterTag.P);
             writer.WriteLine("Pytanie nr " + questionNumerator.ToString() + ") ");
             writer.WriteLine(textQuestionContent);
             writer.RenderEndTag();
             writer.RenderEndTag();
             writer.AddAttribute(HtmlTextWriterAttribute.Src, imageQuestionContent);
             writer.RenderBeginTag(HtmlTextWriterTag.Img);
             writer.RenderEndTag();
             break;
         case TypeOfQuestion.isTxt:
             writer.RenderBeginTag(HtmlTextWriterTag.B);
             writer.RenderBeginTag(HtmlTextWriterTag.P);
             writer.WriteLine("Pytanie nr " + questionNumerator.ToString() + ") ");
             writer.Write(textQuestionContent);
             writer.RenderEndTag();
             writer.RenderEndTag();
             writer.WriteLine();
             break;
         case TypeOfQuestion.isImg:
             writer.RenderBeginTag(HtmlTextWriterTag.B);
             writer.RenderBeginTag(HtmlTextWriterTag.P);
             writer.WriteLine("Pytanie nr " + questionNumerator.ToString() + ") ");
             writer.RenderEndTag();
             writer.RenderEndTag();
             writer.AddAttribute(HtmlTextWriterAttribute.Src, imageQuestionContent);
             writer.RenderBeginTag(HtmlTextWriterTag.Img);
             writer.RenderEndTag();
             break;
     }
 }
Пример #11
0
 public ShortQuestions(string question, TypeOfQuestion typeOfQuestion, int score, ShortOption shortOption) : base(question, typeOfQuestion, score)
 {
     ShortOptions = shortOption;
 }
 public void Delete(TypeOfQuestion typeofquestion)
 {
     _iDTypeOfQuestion.Delete(ETypeOfQuestion(typeofquestion));
 }
        public TypeOfQuestion Update(TypeOfQuestion typeofquestion)
        {
            var eTypeOfQuestion = _iDTypeOfQuestion.Update(ETypeOfQuestion(typeofquestion));

            return(TypeOfQuestion(eTypeOfQuestion));
        }
Пример #14
0
 public LongQuestions(string question, TypeOfQuestion typeOfQuestion, int score, LongOption longOption) : base(question, typeOfQuestion, score)
 {
     LongOptionS = longOption;
 }