Exemple #1
0
        public void DeleteCache(string domainName, QuestionType questionType,
                                QuestionClass questionClass = QuestionClass.In)
        {
            var question = new Question(domainName, questionType, questionClass);

            _cache.Delete(question);
        }
Exemple #2
0
        public ActionResult Delete(int id)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                QuestionClass entity = m_FTISService.GetQuestionClassById(id);

                //檢查底下的Question數量
                IDictionary <string, string> conditions = new Dictionary <string, string>();
                conditions.Add("QuestionClassId", id.ToString());
                int subsCount = m_FTISService.GetQuestionCount(conditions);
                if (subsCount > 0)
                {
                    return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有Q&A,不可刪除。", entity.Name))));
                }

                m_FTISService.DeleteQuestionClass(entity);

                result.ErrorCode = AjaxResultStatus.Success;
                result.Message   = string.Format("{0}刪除成功", entity.Name);
            }
            catch (Exception ex)
            {
                result.ErrorCode = AjaxResultStatus.Exception;
                result.Message   = ex.Message;
            }

            return(this.Json(result));
        }
        public void ConvertToQuoteSlip(string quoteSlipServerRelativeUrl, IDocument quoteSlipDoc, IQuoteSlipSchedules schedule, IBaseTemplate sourceTemplateData)
        {
            var quoteSlipWizardPresenter = new QuoteSlipWizardPresenter(quoteSlipDoc, _view);

            var question = new QuestionClass()
            {
                Id    = schedule.Id,
                Title = schedule.Title,
                Url   = schedule.Url
            };
            var questions = new List <IQuestionClass> {
                question
            };

            quoteSlipWizardPresenter.InsertPolicySchedule(questions, true);

            var startRange = _document.GetBookmarkStartRange(Constants.WordBookmarks.FactFinderStart + schedule.LinkedQuestionId);
            var endRange   = _document.GetBookmarkEndRange(Constants.WordBookmarks.FactFinderEnd + schedule.LinkedQuestionId);

            if (startRange < 0 || endRange < 0) //todo: ???
            {
                return;
            }

            _document.CopyRange(startRange, endRange);
            quoteSlipDoc.MoveToEndOfDocument();
            quoteSlipDoc.PasteClipboard();


            quoteSlipWizardPresenter.PopulateData(sourceTemplateData);

            quoteSlipDoc.MoveToStartOfDocument();
            quoteSlipDoc.CloseInformationPanel(true);
        }
        public ActionResult Index(string keyWord, string questionClassId, int?page)
        {
            questionClassId = DecryptId(questionClassId);
            if (!string.IsNullOrWhiteSpace(questionClassId))
            {
                QuestionClass questionClass = m_FTISService.GetQuestionClassById(int.Parse(questionClassId));
                ViewData["QuestionClass"] = questionClass;
            }
            else
            {
                QuestionClass questionClass = new QuestionClass()
                {
                    Name = "全部"
                };
                ViewData["QuestionClass"] = questionClass;
            }

            SetConditions(string.Empty, questionClassId);
            m_Conditions.Add("Status", "1");
            int total     = GetGridTotal();
            int pageIndex = page.HasValue ? page.Value - 1 : 0;

            m_Conditions.Add("PageIndex", pageIndex.ToString());
            m_Conditions.Add("PageSize", AppSettings.InSitePageSize.ToString());

            var data = GetGridData();

            return(View(data.ToPagedList(pageIndex, AppSettings.InSitePageSize, total)));
        }
        /// <summary>
        /// Gets the DNS SVR records of the service name that is provided.
        /// </summary>
        /// <returns>A list of <see cref="DnsSrvRecord"/>s sorted as described in RFC2782.</returns>
        internal static List <DnsSrvRecord> GetDnsSrvRecords(string serviceName)
        {
            if (_resolver == null)
            {
                CreateResolver(serviceName);
            }

            List <DnsSrvRecord> records = new List <DnsSrvRecord>();
            const QuestionType  qType   = QuestionType.SRV;
            const QuestionClass qClass  = QuestionClass.IN;

            Response response = _resolver.Query(ServiceName, qType, qClass);

            foreach (var record in response.RecordSrv)
            {
                records.Add(record);
            }

            if (records.Count > 0)
            {
                Reset();
                return(SortSrvRecords(records));
            }
            else
            {
                throw new MySqlException(string.Format(Resources.DnsSrvNoHostsAvailable, ServiceName));
            }
        }
        public List <QuestionClass> loadAllClasses()
        {
            loadXmlDocument();

            List <QuestionClass> questionClassesList = new List <QuestionClass>();

            if (xml != null)
            {
                XmlNodeList nodelist = xml.SelectNodes(NODE_NAME);
                if (nodelist != null)
                {
                    foreach (XmlNode node in nodelist)
                    {
                        QuestionClass questionClass = new QuestionClass();

                        XmlNodeList childNodes = node.ChildNodes;
                        questionClass.classID      = int.Parse(childNodes.Item(0).InnerText);
                        questionClass.className    = childNodes.Item(1).InnerText;
                        questionClass.isReferences = bool.Parse(childNodes.Item(2).InnerText);

                        questionClassesList.Add(questionClass);
                    }
                }
            }

            return(questionClassesList);
        }
Exemple #7
0
        private void CreateQuizButton_Click(object sender, EventArgs e)
        {
            //Once the user has decided that they want to create the quiz then a few validity checks are ran
            Name = QuizNameTextBox.Text;
            if (Name == "")
            {
                MessageBox.Show("Error Enter A Quiz Name", "Error", MessageBoxButtons.OK);
                return;
            }
            else if (NewQuiz.Count() < 3 || NewQuiz.Count > 15)
            {
                MessageBox.Show("Error, Invalid number of items, please select between 3 and 15 questions. Remove items or create multiple quizzes.", "Error", MessageBoxButtons.OK);
                return;
            }

            //If all criteria is passed then the number of questions in the quiz is added to the int[] array with their question ID
            int[] IdNum = new int[NewQuiz.Count()];

            foreach (StoredQuestions id in NewQuiz)
            {
                IdNum[NewQuiz.IndexOf(id)] = id.QuestionId;
            }

            QuestionClass qc = new QuestionClass();

            //Queries the SQL database to create the quiz
            qc.CreateQuiz(IdNum, Name);

            MessageBox.Show("Quiz Created!", "Success", MessageBoxButtons.OK);
        }
        private void CreateQuizButton_Click(object sender, EventArgs e)
        {
            //User names the quiz
            Name = QuizNameTextBox.Text;
            if (Name == "")
            {
                MessageBox.Show("Error Enter A Quiz Name", "Error", MessageBoxButtons.OK);
                return;
            }
            else if (questions.Count() < 3 || questions.Count > 15)
            {
                //If the program has returned an invalid number of questions this error message will be displayed
                MessageBox.Show("Error, Invalid number of items, please select between 3 and 15 questions. Remove items or create multiple quizzes.", "Error", MessageBoxButtons.OK);
                return;
            }

            //Holds the ID`s of the question that have been selected
            int[] IdNum = new int[questions.Count()];

            foreach (StoredQuestions id in questions)
            {
                IdNum[questions.IndexOf(id)] = id.QuestionId;
            }

            //The questions that have been returned based upon the criteria are passed into the CreateQuiz Method of questionclass
            QuestionClass qc = new QuestionClass();

            qc.CreateQuiz(IdNum, Name);

            //Displays a success message
            MessageBox.Show("Quiz Created!", "Success", MessageBoxButtons.OK);
        }
Exemple #9
0
        public Response GetCachedResponse(string domainName, QuestionType questionType,
                                          QuestionClass questionClass = QuestionClass.In)
        {
            var question = new Question(domainName, questionType, questionClass);

            return(CacheLookup(question));
        }
 void ShowQuestion()
 {
     //Inicializar pregunta
     question = GameManager.GetQuestions()[questionIndex];
     if (GameManager.GetQuestions()[questionIndex] != null)
     {
         enunciado.text = GameManager.GetQuestions()[questionIndex].ToString();
     }
 }
        private void SearchButton_Click(object sender, EventArgs e)
        {
            QuestionClass        qc = new QuestionClass();
            List <StoredQuizzes> SearchedQuizzes = new List <StoredQuizzes>();

            SearchedQuizzes           = qc.LoadQuizzes(SearchBarTextBox.Text + "%"); //Loads the quizzes that start with the search criteria from the database
            QuizListBox.DataSource    = SearchedQuizzes;                             //Sets the data source to be these searched quizzes
            QuizListBox.DisplayMember = "Name";                                      //The quiz name is displayed
        }
        public QuestionClass GetQuestion4(string Q1, string Q2, string Q3)
        {
            var    record = obj.CreateEntities();
            string choice = ID + "/" + Q1 + "/" + Q2 + "/" + Q3;
            var    select = record.Questions.FirstOrDefault((e) => e.Identifier.Equals(choice));
            var    models = new QuestionClass();

            models.Convert(select);
            return(models);
        }
Exemple #13
0
 protected void LoadEntity(QuestionClass entity)
 {
     if (entity != null)
     {
         EntityId = entity.QuestionClassId;
         Name     = entity.Name;
         SortId   = entity.SortId;
         Status   = entity.Status;
     }
 }
Exemple #14
0
        public void PrintQuestion()
        {
            string []     incorrect    = new string[] { "Grand Rapids", "Detroit", "Traverse City" };
            string        correct      = "Lansing";
            string        questionText = "What is the capital of Michigan";
            QuestionClass question     = new QuestionClass(questionText, incorrect, correct);
            Game          game         = new Game();
            var           expected     = questionText;
            var           actual       = game.PrintQuestion(question);

            Assert.Equal(expected, actual);
        }
Exemple #15
0
        bool formclosing = false;                                                                      //A boolean used to hold if the form is closing or not.

        public GenerateQuizManual()
        {
            InitializeComponent();
            QuestionClass qc = new QuestionClass();

            AllQuestions = qc.LoadAllQuestions();         //Loads the questions from the SQL database
            QuestionListBox.DataSource    = AllQuestions; //Adds the questions to the question list box
            QuestionListBox.DisplayMember = "DisplayItem";
            QuestionHeaderLabel.Hide();
            AnswerHeaderLabel.Hide();
            DifficultyCheckBox.Hide();
            //Sets the question to hide the empty question details
        }
Exemple #16
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Running TestMethod ...");
            QuestionClass.TestMethod();

            System.Console.WriteLine("Running TESTModule ...");
            object input  = 1.0f;
            object result = QuestionClass.TESTModule(input);

            System.Console.WriteLine($"Input: {input}, result: {result}");

            System.Console.ReadLine();
        }
Exemple #17
0
 private void ShowQuestion()
 {
     StartCoroutine(CreateJsonObject(
                        callBack => {
         if (callBack != null)
         {
             print("Json Object is Created");
             //listen to event
             question = callBack;
         }
     }
                        , 39, question));
 }
Exemple #18
0
        public static Response Query(string name, QuestionType questionType, string dnsServer = null,
                                     QuestionClass @class = QuestionClass.In)
        {
            var builder = new ResolverContextBuilder();

            if (!string.IsNullOrEmpty(dnsServer))
            {
                builder.AddDnsServer(dnsServer);
            }

            var resolver = new Resolver(builder.Build());

            return(resolver.Query(name, questionType, @class));
        }
Exemple #19
0
        public QuestionClass GetCategory()
        {
            var record   = obj.CreateEntities();
            var selected = record.Questions.FirstOrDefault((e) => e.Identifier.Equals(ID2));

            if (selected == null)
            {
                throw new Exception("Model not found");
            }
            var models = new QuestionClass();

            models.Convert(selected);
            return(models);
        }
Exemple #20
0
        public ViewAllQuestionsForm()
        {
            InitializeComponent();
            DifficultyCheckBox.Hide();
            QuestionClass qc = new QuestionClass();

            //All of the questions are loaded from the class and are used as a base to refer to
            AllQuestions = qc.LoadAllQuestions();
            QuestionListBox.DataSource    = AllQuestions;
            QuestionListBox.DisplayMember = "DisplayItem";
            QuestionHeaderLabel.Hide();
            AnswerHeaderLabel.Hide();
            //Sets the question to hide the empty question details
        }
Exemple #21
0
        /// <summary>
        /// Do Query on specified DNS servers
        /// </summary>
        /// <param name="name">Name to query</param>
        /// <param name="qtype">Question type</param>
        /// <param name="qclass">Class type</param>
        /// <returns>Response of the query</returns>
        public Response Query(string name, QuestionType qtype, QuestionClass qclass = QuestionClass.In)
        {
            Question question      = new Question(name, qtype, qclass);
            var      cacheResponse = CacheLookup(question);

            if (cacheResponse != null)
            {
                return(cacheResponse);
            }

            Request request = new Request();

            request.AddQuestion(question);
            return(GetResponse(request));
        }
        public QuestionClass GetQuestion3(string Q1, string Q2)
        {
            var    record   = obj.CreateEntities();
            string choice   = ID + "/" + Q1 + "/" + Q2;
            var    selected = record.Questions.FirstOrDefault((e) => e.Identifier.Equals(choice));

            if (selected == null)
            {
                throw new Exception("Model not found");
            }
            var models = new QuestionClass();

            models.Convert(selected);
            return(models);
        }
Exemple #23
0
    public QuestionsHandler()
    {
        QuestionsFile loadQuestions = new QuestionsFile();

        for (int i = 0; i < loadQuestions.questions.Count; i++)
        {
            QuestionClass tmp_object = JsonUtility.FromJson <QuestionClass>(loadQuestions.questions[i]);
            //if (tmp_object.stage == 1)
            stage1.Add(tmp_object);
            //else if (tmp_object.stage == 2)
            //stage2.Add(tmp_object);
            //else if (tmp_object.stage == 3)
            //stage3.Add(tmp_object);
        }
        LoadQuestionUsed();
    }
        public ViewStoredQuizzes()
        {
            InitializeComponent();
            QuestionClass qc = new QuestionClass();

            Quizzes = qc.LoadQuizzes("%");       //Loads the quizzes from the database that contain any question text
            QuizListBox.DataSource    = Quizzes; //Sets the source for the list box to be the loaded quizzes
            QuizListBox.DisplayMember = "Name";  //The displayed item from the stored quizzes to be the name of the quiz

            //Hides the quiz display info so that it only appears when the user clicks on an item
            QuizNameLabel.Hide();
            InsertQuizNameLabel.Hide();
            QuestionsLabel.Hide();
            QuestionsListBox.Hide();
            ExpandButton.Hide();
        }
Exemple #25
0
        private void Save(QuestionClass entity)
        {
            entity.Name   = Name;
            entity.SortId = SortId;
            entity.Status = Status;

            if (entity.QuestionClassId == 0)
            {
                m_FTISService.CreateQuestionClass(entity);
            }
            else
            {
                m_FTISService.UpdateQuestionClass(entity);
            }

            LoadEntity(entity.QuestionClassId);
        }
        public async Task <IActionResult> Create(QuestionClass newQuestion)
        {
            if (ModelState.IsValid)
            {
                _db.Add(newQuestion);
                var resetAnswers = _db.Answers.Where(x => x.questionnaire_Id == newQuestion.questionnaire_id).ToList();
                foreach (var rm in resetAnswers)
                {
                    _db.Answers.Remove(rm);
                }

                await _db.SaveChangesAsync();

                return(RedirectToAction("Index", new { id = newQuestion.questionnaire_id }));
            }
            return(View(newQuestion));
        }
Exemple #27
0
 public void AddQuestion(string question, string wrongAnswer1, string wrongAnswer2, string wrongAnswer3, string rightAnswer, int score)
 {
     if (question != null && wrongAnswer1 != null && wrongAnswer2 != null && wrongAnswer3 != null && rightAnswer != null)
     {
         var thisQuestion = new QuestionClass
         {
             Question      = question,
             CorrectAnswer = rightAnswer,
             WrongAnswer1  = wrongAnswer1,
             WrongAnswer2  = wrongAnswer2,
             WrongAnswer3  = wrongAnswer3,
             Score         = score
         };
         _context.Questions.Add(thisQuestion);
         _context.SaveChanges();
     }
 }
Exemple #28
0
    private void FormatQuestions()
    {
        //Obtener archivo que contiene las preguntas
        var match = files.FirstOrDefault(stringToCheck => stringToCheck.Contains(thematic));

        //Se guarda en un array cada linea del archivo
        questionsFile = File.ReadAllLines(match);
        for (int i = 0; i < 3; i++)
        {
            questions[i] = new QuestionClass(
                nivel,
                questionsFile[i].Substring(0, questionsFile[i].IndexOf("%%")),
                //Array de respuestas
                Format(questionsFile[i].Substring(questionsFile[i].IndexOf("%%"))),
                //Respuesta correcta
                mockCorrectAnswer);
        }
    }
        private void QuizListBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //Displays the quiz info
            QuizNameLabel.Show();
            InsertQuizNameLabel.Show();
            QuestionsLabel.Show();
            QuestionsListBox.Show();
            ExpandButton.Show();

            ChosenQuiz = (StoredQuizzes)QuizListBox.SelectedItem; //The chosen quiz is saved to be the selected item from the list view
            InsertQuizNameLabel.Text = ChosenQuiz.Name;           //The quiz name is displayed
            QuestionClass qc = new QuestionClass();

            SelectedQuestionsId            = qc.FindQuestionsId(ChosenQuiz);                 //Retrives the quiz`s questions ID`s from the database
            SelectedQuestions              = qc.GetStoredQuizQuestions(SelectedQuestionsId); //The ID`s related questions are then returned from the database
            QuestionsListBox.DataSource    = SelectedQuestions;                              //The data source for the list box displaying the questions is set to the questions
            QuestionsListBox.DisplayMember = "Question";                                     //The displayed item from the stored quizzes to be the name of the quiz
        }
        private void ResetQuestionButton_Click(object sender, EventArgs e)
        {
            //This button will reset the question scores
            QuestionClass qc = new QuestionClass();

            //Resets the questions in the database
            qc.ResetScores(completedQuestion);

            //Creates new completed questions
            completedQuestion = new List <CompletedQuestion>();

            //Clears the table on the current page displaying the question stats
            listView1.Items.Clear();
            listView1.Refresh();

            //Runs the setup sub again
            setup(Student, SelectedQuiz, ListOfStoredQuestions, QuizQuestionsId, null);
        }
 public void ShowToForm(QuestionClass q)
 {
     questBox.Text = q.Question;
     string a;
     if (q.Answers != null)
     {
         a = q.Answers[0].Answer;
         for (int i = 1; i < q.Answers.Length; i++)
         {
             a = a + "\n" + q.Answers[i].Answer;
         }
     }
     else
     {
         a = "Свободный выбор ответа";
     }
     ansBox.Text = a;
 }
 public void CreateQuestion()
 {
     //xml
     _question.Add(answer.Text);
     //json
     questionJSON = new QuestionClass();
     questionJSON.Question = answer.Text;
     questionsListJSON.Add(questionJSON);
 }
 private AnswerClass FindAnswer(QuestionClass question, string answer)
 {
     foreach (AnswerClass expected in question.Answers) {
         if (expected.Answer == answer) {
             return expected;
         }
     }
     return null;
 }
        public void ShowAnswer(QuestionClass question)
        {
            if (question.Answers != null) {
                string[] toList = new string[question.Answers.Length];
                for (int i = 0; i < toList.Length; i++) {
                    toList[i] = question.Answers[i].Answer;
                }
                ShowToListBox(toList);
                State_Answer();
            } else {
                ShowToListBox(null);
                State_Answer();

            }
        }
 public void AddQuestion()
 {
     List<QuestionClass> questlist;
     if (NowDialog.Questions != null)
         questlist = NowDialog.Questions.ToList<QuestionClass>();
     else {
         questlist = new List<QuestionClass>();
     }
     QuestionClass que = new QuestionClass();
     que.Question = textBox.Text;
     questlist.Add(que);
     NowDialog.Questions = questlist.ToArray();
 }
 private bool Contains(QuestionClass question, string answer)
 {
     foreach (AnswerClass expected in question.Answers) {
         if (expected.Answer == answer) {
             return true;
         }
     }
     return false;
 }