コード例 #1
0
ファイル: TestController.cs プロジェクト: artoyebi/ExamPortal
        public IActionResult AddQuestion(AddQuestionViewModel model)
        {
            //var findTest = testRepository.FindTest(testId);
            //if (findTest == null)
            //{
            //    return View("NotFound");
            //}

            if (ModelState.IsValid)
            {
                QuestionAndAnswer questionAndAnswer = new QuestionAndAnswer
                {
                    Id            = Guid.NewGuid(),
                    Question      = model.Question,
                    Answer        = model.Answer,
                    Option1       = model.Option1,
                    Option2       = model.Option2,
                    Option3       = model.Option3,
                    AssignedScore = model.AssignedScore,
                    TestId        = model.TestId
                };

                testRepository.AddQuestions(questionAndAnswer);

                return(RedirectToAction("dashboard", "examiner"));
            }
            return(View(model));
        }
コード例 #2
0
        public static void InitData(QuestionType questionType)
        {
            var xmlDataDocument = new XmlDocument();

            xmlDataDocument.Load(@"C:\\Users\\Ion Ml\\source\\repos\\Quiz\\Quiz\\Models\\Questions.xml");
            foreach (XmlNode questionNode in xmlDataDocument.DocumentElement)
            {
                if (string.Equals(questionNode.Name, questionType.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    var questionName = questionNode.Attributes[0].InnerText;

                    var answerNodeList = questionNode.ChildNodes;
                    var answerList     = new List <Answer>();
                    foreach (XmlElement answerNode in answerNodeList)
                    {
                        var answerName = answerNode.InnerText;
                        var isValid    = bool.Parse(answerNode.Attributes[0].InnerText);
                        var answer     = new Answer(answerName, isValid);
                        answerList.Add(answer);
                    }

                    var questionsAndAnswer = new QuestionAndAnswer(questionName, answerList);
                    _quizQuestions.Add(questionsAndAnswer);
                }
            }
        }
        public QuestionAndAnswer InsertQandA(QuestionAndAnswer qanda)
        {
            var userEntity = dbContext.QuestionsAndAnswers.Add(qanda);

            dbContext.SaveChanges();
            return(userEntity.Entity);
        }
コード例 #4
0
 public void SetQuestionsAndAnswers(List <QuestionAndAnswer> list)
 {
     questionsAndAnswer   = list;
     currentQuestionIndex = 0;
     CurrentQuestion      = this.questionsAndAnswer.ElementAt(currentQuestionIndex);
     SetIndexLabel(currentQuestionIndex + 1, questionsAndAnswer.Count);
 }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            QuestionAndAnswer questionAndAnswer = db.QuestionAndAnswers.Find(id);

            db.QuestionAndAnswers.Remove(questionAndAnswer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult DeleteConfirmed(int?id)
        {
            QuestionAndAnswer QnA = _context.QuestionAndAnswers.Find(id);

            _context.QuestionAndAnswers.Remove(QnA);
            _context.SaveChanges();

            return(RedirectToAction("Details", new { id = QnA.TestId }));
        }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "Id,Name,UserID,CategoryID,Title,Content")] QuestionAndAnswer questionAndAnswer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(questionAndAnswer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(questionAndAnswer));
 }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "ID_CATEGORY,ID_QUESTIONS,CATEGORY_DESC,ID_USER_QUESTIONS,QUESTIONS_NAME,QUESTIONS,ANSWER,ID_USER_ANSWER,ANSWER_NAME")] QuestionAndAnswer questionAndAnswer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(questionAndAnswer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(questionAndAnswer));
 }
コード例 #9
0
 public static QuestionAndAnswer GetNextQuestion()
 {
     if (_index >= _maxQuestionsToShow || _index >= _quizQuestions.Count)
     {
         return(_currentQuestion); // check if null
     }
     _currentQuestion = _quizQuestions.ElementAt(_index);
     _index++;
     return(_currentQuestion);
 }
コード例 #10
0
        public ActionResult Create([Bind(Include = "ID_CATEGORY,ID_QUESTIONS,CATEGORY_DESC,ID_USER_QUESTIONS,QUESTIONS_NAME,QUESTIONS,ANSWER,ID_USER_ANSWER,ANSWER_NAME")] QuestionAndAnswer questionAndAnswer)
        {
            if (ModelState.IsValid)
            {
                db.QuestionAndAnswers.Add(questionAndAnswer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(questionAndAnswer));
        }
コード例 #11
0
        public ActionResult Create([Bind(Include = "Id,Name,UserID,CategoryID,Title,Content")] QuestionAndAnswer questionAndAnswer)
        {
            if (ModelState.IsValid)
            {
                db.QuestionAndAnswers.Add(questionAndAnswer);
                db.SaveChanges();
                return(RedirectToAction("SendQuestion"));
            }

            return(View("SendQuestion", questionAndAnswer));
        }
コード例 #12
0
        public ActionResult EditQuestion([Bind(Include = "Id,TestId,Question,Answer,Hint,Mnemonic")] QuestionAndAnswer QnA)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditQuestion", QnA));
            }

            _context.Entry(QnA).State = EntityState.Modified;
            _context.SaveChanges();
            return(RedirectToAction("Details", new { id = QnA.TestId }));
        }
コード例 #13
0
 public void Post([FromBody] QuestionAndAnswer qa)
 {
     try
     {
         qa.insert();
     }
     catch (Exception ex)
     {
         throw new Exception("Error in insert" + ex);
     }
 }
コード例 #14
0
        public ActionResult Index(string NextQuestion)
        {
            var latest = new QuestionAndAnswer
            {
                Question = NextQuestion,
                Answer   = AnswerGenerator.GenerateAnswer(NextQuestion)
            };

            allAnswers.Insert(0, latest);

            return(View(allAnswers));
        }
コード例 #15
0
        public async Task <IActionResult> SetQuestionProfile(QuestionAndAnswer quest)
        {
            if (ModelState.IsValid)
            {
                string userId = User.Claims.First(c => c.Type == "UserID").Value;
                var    user   = await _userManager.FindByIdAsync(userId);

                _db.questionAndAnswers.Add(quest);
                _db.SaveChanges();
                return(Ok(quest));
            }
            return(BadRequest(ModelState));
        }
コード例 #16
0
 public ActionResult CreateClient(QuestionAndAnswer questionAndAnswer)
 {
     Debug.WriteLine("OK");
     // if (ModelState.IsValid)
     // {
     //     db.QuestionAndAnswers.Add(questionAndAnswer);
     //     db.SaveChanges();
     //     return RedirectToAction("Index");
     // }
     //
     // return View(questionAndAnswer);
     return(null);
 }
コード例 #17
0
        // GET: QuestionAndAnswers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuestionAndAnswer questionAndAnswer = db.QuestionAndAnswers.Find(id);

            if (questionAndAnswer == null)
            {
                return(HttpNotFound());
            }
            return(View(questionAndAnswer));
        }
        public QuestionAndAnswer FindByAnswer(string answer)
        {
            QuestionAndAnswer result = null;

            try
            {
                result = dbContext.QuestionsAndAnswers.First(s => s.Answer.Equals(answer));
            }
            catch (InvalidOperationException)
            {
            }

            return(result);
        }
コード例 #19
0
        public ActionResult DeleteQuestion(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            QuestionAndAnswer QnA = _context.QuestionAndAnswers.Find(id);

            if (QnA == null)
            {
                return(HttpNotFound());
            }

            return(View(QnA));
        }
コード例 #20
0
        // GET: Categories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QuestionAndAnswer questionAndAnswer = db.QuestionAndAnswers.Find(id);

            if (questionAndAnswer == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "Id", "Name");
            ViewBag.UserId     = new SelectList(db.Users, "Id", "Username");
            return(View(questionAndAnswer));
        }
コード例 #21
0
        public ActionResult Index(string NextQuestion)
        {
            ViewBag.CustomerName = CMConfiguration.CustomerName;
            ViewBag.LogoUrl      = CMConfiguration.LogoUrl;
            ViewBag.DbName       = CMConfiguration.DbName;
            ViewBag.Version      = CMConfiguration.Version;

            var latest = new QuestionAndAnswer
            {
                Question = NextQuestion,
                Answer   = AnswerGenerator.GenerateAnswer(NextQuestion)
            };

            allAnswers.Insert(0, latest);

            return(View(allAnswers));
        }
コード例 #22
0
        //private static void EmbedVideo(Control container, string youTubeId, QuestionAndAnswer row,
        //  Control heading = null)
        //{
        //  if (!string.IsNullOrWhiteSpace(youTubeId))
        //  {
        //    var videoWrapper = new HtmlDiv().AddTo(container, "video-wrapper");
        //    var videoWrapperInner = new HtmlDiv().AddTo(videoWrapper, "video-wrapper-inner");
        //    var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner);
        //    iframe.Attributes.Add("width", "420");
        //    iframe.Attributes.Add("height", "236");
        //    iframe.Attributes.Add("src",
        //      "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0");
        //    iframe.Attributes.Add("frameborder", "0");
        //    iframe.Attributes.Add("allowfullscreen", "allowfullscreen");
        //  }
        //  if (heading != null) heading.AddTo(container);
        //  var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime);
        //  var key = string.Format("{0}:{1}:{2}", row.PoliticianKey, row.QuestionKey, row.Sequence);
        //  VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube,
        //    "ytdesc", key).AddTo(container);
        //  if (!string.IsNullOrWhiteSpace(row.YouTubeSource) || row.YouTubeDate != VotePage.DefaultDbDate)
        //  {
        //    var sourceTag = new HtmlP().AddTo(container, "video-source");
        //    if (!string.IsNullOrWhiteSpace(row.YouTubeSource))
        //    {
        //      new HtmlSpan { InnerText = "Source: " }.AddTo(sourceTag);
        //      if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl))
        //        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
        //      else
        //        new HtmlAnchor
        //        {
        //          HRef = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
        //          InnerHtml = row.YouTubeSource,
        //          Target = "view"
        //        }.AddTo(sourceTag);
        //      if (row.YouTubeDate != VotePage.DefaultDbDate)
        //        new LiteralControl(" ").AddTo(sourceTag);
        //    }
        //    if (row.YouTubeDate != VotePage.DefaultDbDate)
        //      new LiteralControl("(" + row.YouTubeDate.ToString("M/d/yyyy") + ")").AddTo(sourceTag);
        //  }
        //}

        private static void EmbedVideo2(Control container, string youTubeId, QuestionAndAnswer row,
                                        Control heading = null)
        {
            // uses fake YouTube player
            if (!string.IsNullOrWhiteSpace(youTubeId))
            {
                var videoWrapper = new HtmlDiv().AddTo(container, "youtube-container");
                new HtmlDiv().AddTo(videoWrapper, "youtube-player")
                .Attributes.Add("data-id", youTubeId);
                //var iframe = new HtmlGenericControl("iframe").AddTo(videoWrapperInner);
                //iframe.Attributes.Add("width", "420");
                //iframe.Attributes.Add("height", "236");
                //iframe.Attributes.Add("src",
                //  "https://www.youtube.com/embed/" + youTubeId + "?rel=0&showinfo=0");
                //iframe.Attributes.Add("frameborder", "0");
                //iframe.Attributes.Add("allowfullscreen", "allowfullscreen");
            }
            heading?.AddTo(container);
            var description = FormatYouTubeDescription(row.YouTubeDescription, row.YouTubeRunningTime);
            var key         = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}";

            VotePage.GetMorePart1(description, MoreMinForYouTube, MoreMaxForYouTube,
                                  "ytdesc", key).AddTo(container);
            if (!string.IsNullOrWhiteSpace(row.YouTubeSource) ||
                (row.YouTubeDate != VotePage.DefaultDbDate))
            {
                var sourceTag = new HtmlP().AddTo(container, "video-source");
                if (!string.IsNullOrWhiteSpace(row.YouTubeSource))
                {
                    new HtmlSpan {
                        InnerText = "Source: "
                    }.AddTo(sourceTag);
                    if (string.IsNullOrWhiteSpace(row.YouTubeSourceUrl))
                    {
                        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
                    }
                    else
                    {
                        new HtmlAnchor
                        {
                            HRef      = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
                            InnerHtml = row.YouTubeSource,
                            Target    = "view"
                        }
                    }.AddTo(sourceTag);
コード例 #23
0
 public ActionResult DeleteArrayConfirmed(string[] idArray)
 {
     try
     {
         foreach (var id in idArray)
         {
             var currentId = Int32.Parse(id);
             QuestionAndAnswer questionAndAnswer = db.QuestionAndAnswers.Find(currentId);
             db.QuestionAndAnswers.Remove(questionAndAnswer);
         }
         db.SaveChanges();
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #24
0
        private void SetQuestionsAndAnswers()
        {
            int reqIndex           = CurrentQuestionIndex / PartitionNo;
            int count              = testPortions[reqIndex].questionAndAnswersList.Count;
            QuestionAndAnswer temp = testPortions[reqIndex].questionAndAnswersList[CurrentQuestionIndex % count];

            Question.Text = temp.Question;

            //clearing the checked Answers
            AnswerButton0.IsChecked = false;
            AnswerButton1.IsChecked = false;
            AnswerButton2.IsChecked = false;
            AnswerButton3.IsChecked = false;

            AnswerButton0.Content = temp.AnswerOptions[0];
            AnswerButton1.Content = temp.AnswerOptions[1];
            AnswerButton2.Content = temp.AnswerOptions[2];
            AnswerButton3.Content = temp.AnswerOptions[3];
        }
コード例 #25
0
    static void Main(string[] args)
    {
        //Use a list to collect your QuestionAndAnswer objects
        List <QuestionAndAnswer> questions = new List <QuestionAndAnswer>();

        Console.WriteLine("Hello, please enter how many questions you would like to have on this reapeting test");
        int questionCount = 1;

        // loops until you type finished
        while (true)
        {
            Console.WriteLine(" what do you want question number " + questionCount + " to be?");
            QuestionAndAnswer question = new QuestionAndAnswer(null, null);
            string            response = Console.ReadLine();
            if (response.ToUpper() == "FINISHED")
            {
                break;
            }
            question.question = response;
            Console.WriteLine(" what do you want question number " + questionCount + "'s answer to be?");
            question.answer = Console.ReadLine();
            //Add the question (QuestionAndAnswer) to the list
            questions.Add(question);
            question.questionNumber = questionCount;
            questionCount++;
        }
        //This section will ask the questions until you type exit
        while (true)
        {
            foreach (QuestionAndAnswer qa in questions)
            {
                Console.WriteLine(String.Format("Question #{0} out of {1}: {2}", qa.questionNumber, questions.Count(), qa.question));
                Console.Write("Type you answer and hit <Enter>: ");
                if (Console.ReadLine().ToUpper() == "EXIT")
                {
                    break;
                }
                Console.WriteLine(qa.answer);
            }
        }
    }
コード例 #26
0
        public IEnumerator AskQuestion(QuestionAndAnswer questionAndAnswer)
        {
            CurrentQuestionAndAnswer = questionAndAnswer;
            SelectedAnswerIndex      = DefaultAnswerIndex;
            WasQuestionAnswered      = false;

            _questionController.Refresh(questionAndAnswer.Question);
            _answerController.Refresh(questionAndAnswer.Answers);

            TimerCoroutine = StartCoroutine(_timer.RunTimer(DefaultQuestionDuration));

            while (_timer.TimeRemaining > 0 && !WasQuestionAnswered)
            {
                yield return(null);
            }

            if (TimerCoroutine != null)
            {
                StopCoroutine(TimerCoroutine);
            }
        }
コード例 #27
0
        public ActionResult AddQuestion([Bind(Include = "TestId,Question,Answer,Hint,Mnemonic")] QnAFormViewModel QnAModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddQuestion", QnAModel));
            }

            var QnA = new QuestionAndAnswer
            {
                TestId   = QnAModel.TestId,
                Question = QnAModel.Question,
                Answer   = QnAModel.Answer,
                Hint     = QnAModel.Hint,
                Mnemonic = QnAModel.Mnemonic
            };

            _context.QuestionAndAnswers.Add(QnA);
            _context.SaveChanges();

            return(RedirectToAction("Details", new { id = QnA.TestId }));
        }
コード例 #28
0
        private static void Main(
            string region  = null,
            string session = null,
            string package = null,
            string project = null,
            string[] args  = null)
        {
            #region Main
            switch (region)
            {
            case "MutationTesting_Add":
                MutationTesting.Add_Test();
                break;

            case "MutationTesting_Subtract":
                MutationTesting.Subtract_Test();
                break;

            case "MutationTesting_Multiply":
                MutationTesting.Multiply_Test();
                break;

            case "MutationTesting_Divide":
                MutationTesting.Divide_Test();
                break;

            case "MutationTesting_Equality":
                MutationTesting.Equality_Test();
                break;

            case "MutationTesting_Linq":
                MutationTesting.Linq_Test();
                break;

            case "Q_A":
                QuestionAndAnswer.PrintMotto();
                break;
            }
            #endregion
        }
コード例 #29
0
ファイル: Form1.cs プロジェクト: JoshuaVdM/examinator
        private async void btnAnalyze_Click(object sender, EventArgs e)
        {
            root           = new TreeItem();
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                await root.LoadFromSentence(txtBox.Text);

                txtSubject.Text    = root.Children[0].Children[0].NounPhrase.toReadableString();
                txtVerbPhrase.Text = root.Children[0].Children[0].VerbPhrase.toReadableString();
                QuestionAndAnswer qa = root.Children[0].Children[0].GetQuestionAndAnswer();
                txtQuestion.Text = qa.Question;
                txtAnswer.Text   = qa.Answer;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error analyzing text", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            LoadTree();
            Cursor.Current = Cursors.Default;
            ItemTree.ExpandAll();
        }
コード例 #30
0
        private static void EmbedYouTube(Control container, string youTubeId, QuestionAndAnswer row,
                                         Control heading = null)
        {
            // uses fake YouTube player
            if (!IsNullOrWhiteSpace(youTubeId))
            {
                var videoWrapper = new HtmlDiv().AddTo(container, "video-container youtube-container");
                var videoPlayer  = new HtmlDiv().AddTo(videoWrapper, "video-player youtube-player");
                videoPlayer.Attributes.Add("data-type", "yt");
                videoPlayer.Attributes.Add("data-id", youTubeId);
            }
            heading?.AddTo(container);
            var description = FormatVideoDescription(row.YouTubeDescription, row.YouTubeRunningTime);
            var key         = $"{row.PoliticianKey}:{row.QuestionKey}:{row.Sequence}";

            VotePage.GetMorePart1(description, MoreMinForVideo, MoreMaxForVideo,
                                  "ytdesc", key).AddTo(container);
            if (!IsNullOrWhiteSpace(row.YouTubeSource) || !row.YouTubeDate.IsDefaultDate())
            {
                var sourceTag = new HtmlP().AddTo(container, "video-source");
                if (!IsNullOrWhiteSpace(row.YouTubeSource))
                {
                    new HtmlSpan {
                        InnerText = "Source: "
                    }.AddTo(sourceTag);
                    if (IsNullOrWhiteSpace(row.YouTubeSourceUrl))
                    {
                        new LiteralControl(row.YouTubeSource).AddTo(sourceTag);
                    }
                    else
                    {
                        new HtmlAnchor
                        {
                            HRef      = VotePage.NormalizeUrl(row.YouTubeSourceUrl),
                            InnerHtml = row.YouTubeSource,
                            Target    = "view"
                        }
                    }.AddTo(sourceTag);