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

            Question question = _questionsRepository.GetById(id.Value);

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

            ClosedQuestion closedQuestion = question as ClosedQuestion;

            if (closedQuestion != null)
            {
                closedQuestion.AnswerChoices = _closedAnswersRepository.Find(a => a.ClosedQuestionID == closedQuestion.ID).ToList();

                //return View("ClosedQuestionDetails", closedQuestion);
                return(View(closedQuestion));
            }

            return(View(question));
        }
コード例 #2
0
ファイル: SectionForm.cs プロジェクト: lulzzz/DCAnalytics
        private void AddClosedQuestion()
        {
            ClosedQuestion     closedQuestion = (ClosedQuestion)_section.Questions.Add(QuestionTypes.Closed);
            ChoiceQuestionForm closedQnFrm    = new ChoiceQuestionForm();

            closedQnFrm.PickValues(closedQuestion);
            closedQnFrm.ShowDialog();
            RefreshQuestions();
        }
コード例 #3
0
ファイル: SectionForm.cs プロジェクト: lulzzz/DCAnalytics
 private void AddQuestion(QuestionTypes questionType)
 {
     switch (questionType)
     {
     case QuestionTypes.Closed:
         ClosedQuestion questionaire = (ClosedQuestion)_section.Questions.Add(questionType);
         break;
     }
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "ID,TimeToRespond,Text,Points,AnswerChoices")] ClosedQuestion question)
        {
            if (ModelState.IsValid)
            {
                _questionsRepository.Add(question);


                //closed question
                if (question != null && question.AnswerChoices != null)
                {
                    foreach (var answerChoice in question.AnswerChoices)
                    {
                        answerChoice.ClosedQuestionID = question.ID;
                    }
                }

                return(RedirectToAction("Index"));
            }

            return(View(question));
        }
コード例 #5
0
ファイル: TestsController.cs プロジェクト: oof3nd/Testich
        public async Task <IActionResult> CreateCQ(int idTest, int idLevel, int typeOfQuestionId, int questionIndexNumber, CreateCQViewModel createCQViewModel)
        {
            var test = await UserContext.Tests.FindAsync(idTest);

            if (!TestExists(idTest))
            {
                return(NotFound());
            }

            if (!LevelExists(idLevel))
            {
                return(NotFound());
            }


            var qot = new QuestionOfTest
            {
                TestId = idTest,
                QuestionIndexNumber = questionIndexNumber,
                LevelOfQuestionId   = idLevel,
                TypeOfQuestionId    = typeOfQuestionId,
            };

            UserContext.QuestionOfTests.Add(qot);
            await UserContext.SaveChangesAsync();

            var cq = new ClosedQuestion
            {
                QuestionOfTestId     = qot.Id,
                OnlyOneRight         = createCQViewModel.OnlyOneRight,
                QuestionContent      = createCQViewModel.QuestionContent,
                CorrectOptionNumbers = createCQViewModel.CorrectOptionNumbers,
            };

            UserContext.ClosedQuestions.Add(cq);
            await UserContext.SaveChangesAsync();

            return(RedirectToRoute("default", new { controller = "Tests", action = "Details", id = test.Id }));
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: lulzzz/DCAnalytics
        private void AddClosedQuestion()
        {
            if (!(Tree.SelectedNode.Tag is Questions))
            {
                return;
            }
            Questions          questions      = Tree.SelectedNode.Tag as Questions;
            ClosedQuestion     closedQuestion = (ClosedQuestion)questions.Add(QuestionTypes.Closed);
            ChoiceQuestionForm closedQnFrm    = new ChoiceQuestionForm();

            closedQnFrm.PickValues(closedQuestion);
            if (closedQnFrm.ShowDialog() == DialogResult.OK)
            {
                TreeNode questionsNode = Tree.SelectedNode;
                if (questionsNode != null)
                {
                    var questionNode = AddToParentNode(questionsNode, closedQuestion, closedQuestion.Name);
                    questionNode.ImageIndex         = 6;
                    questionNode.SelectedImageIndex = 6;
                }
            }
        }
コード例 #7
0
        public ActionResult Edit([Bind(Include = "ID,TimeToRespond,Text,Points,AnswerChoices,ExamID")] ClosedQuestion question)
        {
            if (ModelState.IsValid)
            {
                //ClosedQuestion question = justQuestion as ClosedQuestion;
                if (question != null && question.AnswerChoices != null)
                {
                    foreach (var answerChoice in question.AnswerChoices)
                    {
                        if (answerChoice.ToBeDeleted)
                        {
                            _closedAnswersRepository.Delete(answerChoice);
                        }
                        //added answer choice
                        else if (answerChoice.ID == 0)
                        {
                            answerChoice.ClosedQuestionID = question.ID;
                            _closedAnswersRepository.Add(answerChoice);
                        }
                        //updated answer choice
                        else
                        {
                            _closedAnswersRepository.Update(answerChoice);
                        }
                    }
                }

                _questionsRepository.Update(question);

                //some answer choices may have been removed so
                //need to be "refreshed" from db
                question.AnswerChoices =
                    _closedAnswersRepository.Find(a => a.ClosedQuestionID == question.ID).ToList();

                return(View("Details", question));
            }

            return(View(question));
        }
コード例 #8
0
        public static Question CreateQuestion(DCAnalyticsObject parent, QuestionTypes qtype)
        {
            Question question = null;

            switch (qtype)
            {
            case QuestionTypes.Closed:
                question = new ClosedQuestion(parent);
                break;

            case QuestionTypes.MultipleChoice:
                question = new MultipleChoiceQuestion(parent);
                break;

            case QuestionTypes.Open:
                question = new OpenQuestion(parent);
                break;

            case QuestionTypes.Map:
                question = new MapQuestion(parent);
                break;

            case QuestionTypes.Location:
                question = new LocationQuestion(parent);
                break;

            case QuestionTypes.Other:
                question = new OtherQuestion(parent);
                break;
            }
            if (question != null)
            {
                question.QuestionType = qtype;
            }
            return(question);
        }
コード例 #9
0
        public IHttpActionResult Create(ClosedQuestionModel closedQst)
        {
            if (!this.ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newQuestion = new ClosedQuestion
            {
                Question      = closedQst.Question,
                AnswerA       = closedQst.AnswerA,
                AnswerB       = closedQst.AnswerB,
                AnswerC       = closedQst.AnswerC,
                AnswerD       = closedQst.AnswerD,
                CorrectAnswer = closedQst.CorrectAnswer
            };


            this.data.ClosedQuestions.Add(newQuestion);
            this.data.SaveChanges();

            closedQst.Id = newQuestion.Id;
            return(Ok(closedQst));
        }
コード例 #10
0
 public ClosedQuestionState(ClosedQuestion question, string answer)
 {
     Question = question;
     Answer = answer;
 }
コード例 #11
0
ファイル: Configuration.cs プロジェクト: krystian1201/E-xam
        protected override void Seed(ApplicationDbContext dbContext)
        {
            //  This method will be called after migrating to the latest version.


            //dbContext.Exams.AddOrUpdate
            //    (
            //        e => e.ID,
            //        new Exam { ID = 0, Name = "Exam1", Date = new DateTime(2015, 6, 30), Duration = new TimeSpan(0, 1, 0, 0) },
            //        new Exam { ID = 0, Name = "Exam2", Date = new DateTime(2015, 6, 15), Duration = new TimeSpan(0, 1, 30, 0) },
            //        new Exam { ID = 0, Name = "Exam3", Date = new DateTime(2015, 5, 15), Duration = new TimeSpan(0, 0, 30, 0) },
            //        new Exam { ID = 0, Name = "Exam4", Date = new DateTime(2015, 5, 25), Duration = new TimeSpan(0, 0, 30, 0) }
            //    );

            //dbContext.SaveChanges();



            #region Courses

            IRepository <Question> questionsRepository = new Repository <Question>(dbContext);
            questionsRepository.DeleteAll();

            IRepository <Exam> examsRepository = new Repository <Exam>(dbContext);
            examsRepository.DeleteAll();

            IRepository <Course> coursesRepository = new Repository <Course>(dbContext);
            coursesRepository.DeleteAll();

            var courses = new List <Course>
            {
                new Course
                {
                    Name     = "Software System Development",
                    ECTS     = 5,
                    Semester = 2
                },
                new Course
                {
                    Name     = "Math",
                    ECTS     = 2,
                    Semester = 1
                },
                new Course
                {
                    Name     = "Physics",
                    ECTS     = 3,
                    Semester = 3
                },
                new Course
                {
                    Name     = "English B2",
                    ECTS     = 1,
                    Semester = 1
                },
                new Course
                {
                    Name     = "Computer Science",
                    ECTS     = 4,
                    Semester = 1
                },
                new Course
                {
                    Name     = "Modelling and Analysis of Web",
                    ECTS     = 2,
                    Semester = 2
                },
                new Course
                {
                    Name     = "Foundation of Knowledge Engineering",
                    ECTS     = 3,
                    Semester = 2
                }
            };

            coursesRepository.AddRange(courses);


            #endregion

            //--------------------------------------------------------------------------------------------------------------------------

            #region Questions



            var closedQuestion1 = new ClosedQuestion
            {
                Points        = 5,
                Text          = "What's your favorite color?",
                TimeToRespond = new TimeSpan(0, 0, 5, 0)
            };

            var closedQuestion2 = new ClosedQuestion
            {
                Points        = 2,
                Text          = "What's your favorite city?",
                TimeToRespond = new TimeSpan(0, 0, 5, 0)
            };

            var closedQuestion3 = new ClosedQuestion
            {
                Points        = 100,
                Text          = "Is Elvis alive?",
                TimeToRespond = new TimeSpan(0, 0, 5, 0)
            };

            var questions = new List <Question>()
            {
                new OpenQuestion {
                    Points        = 2, Text = "What's your name?",
                    TimeToRespond = new TimeSpan(0, 0, 1, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "How are you?",
                    TimeToRespond = new TimeSpan(0, 0, 2, 0)
                },
                new OpenQuestion {
                    Points        = 1, Text = "How old are you?",
                    TimeToRespond = new TimeSpan(0, 0, 4, 0)
                },
                new OpenQuestion {
                    Points        = 10, Text = "Where are you from?",
                    TimeToRespond = new TimeSpan(0, 0, 5, 0)
                },
                new OpenQuestion {
                    Points        = 10, Text = "When is your birthday?",
                    TimeToRespond = new TimeSpan(0, 0, 5, 0)
                },
                new OpenQuestion {
                    Points        = 10, Text = "Your mother maiden name?",
                    TimeToRespond = new TimeSpan(0, 0, 5, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "What's your favorite sports club?",
                    TimeToRespond = new TimeSpan(0, 0, 1, 0)
                },
                new OpenQuestion {
                    Points        = 2, Text = "What's your favorite food?",
                    TimeToRespond = new TimeSpan(0, 0, 2, 0)
                },
                new OpenQuestion {
                    Points        = 9, Text = "What's your favorite band?",
                    TimeToRespond = new TimeSpan(0, 0, 1, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "What's your favorite music genre?",
                    TimeToRespond = new TimeSpan(0, 0, 2, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "What's the biggest city in Poland?",
                    TimeToRespond = new TimeSpan(0, 0, 1, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "What's the biggest country in the world?",
                    TimeToRespond = new TimeSpan(0, 0, 3, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "What's the longest river in the world?",
                    TimeToRespond = new TimeSpan(0, 0, 5, 0)
                },
                new OpenQuestion {
                    Points        = 3, Text = "Who killed Kennedy?",
                    TimeToRespond = new TimeSpan(0, 0, 1, 0)
                },
                closedQuestion1,
                closedQuestion2,
                closedQuestion3
            };

            questionsRepository.AddRange(questions);

            #endregion


            //--------------------------------------------------------------------------------------------------------------------------

            #region Exams


            var exams = new List <Exam>
            {
                new Exam
                {
                    Name        = "Differential calculus", Course = courses.FirstOrDefault(c => c.Name == "Math"),
                    DateAndTime = new DateTime(2015, 6, 30, 15, 30, 0), Duration = new TimeSpan(0, 1, 0, 0),
                    Place       = "A1, 30", Questions = questions.GetRange(1, 8)
                },
                new Exam
                {
                    Name        = "Integrals", Course = courses.FirstOrDefault(c => c.Name == "Math"),
                    DateAndTime = new DateTime(2015, 6, 15, 13, 0, 0), Duration = new TimeSpan(0, 1, 30, 0),
                    Place       = "D20, 105", Questions = questions.GetRange(8, 9)
                },
                new Exam
                {
                    Name        = "Exam 2", Course = courses.FirstOrDefault(c => c.Name == "Physics"),
                    DateAndTime = new DateTime(2015, 5, 15, 12, 15, 0), Duration = new TimeSpan(0, 0, 30, 0),
                    Place       = "C3, 205"
                },
                new Exam
                {
                    Name        = "Final Exam", Course = courses.FirstOrDefault(c => c.Name == "Software System Development"),
                    DateAndTime = new DateTime(2015, 6, 15, 17, 5, 0), Duration = new TimeSpan(0, 1, 30, 0),
                    Place       = "C5, 301"
                },
                new Exam
                {
                    Name        = "Exam 3", Course = courses.FirstOrDefault(c => c.Name == "Computer Science"),
                    DateAndTime = new DateTime(2015, 6, 23, 11, 0, 0), Duration = new TimeSpan(0, 2, 30, 0),
                    Place       = "C7, 501"
                },
                new Exam
                {
                    Name        = "Vocabulary exam", Course = courses.FirstOrDefault(c => c.Name == "English B2"),
                    DateAndTime = new DateTime(2015, 6, 24, 9, 30, 0), Duration = new TimeSpan(0, 1, 15, 0),
                    Place       = "C13, 301"
                },
                new Exam
                {
                    Name        = "Grammar exam", Course = courses.FirstOrDefault(c => c.Name == "English B2"),
                    DateAndTime = new DateTime(2015, 6, 25, 11, 15, 0), Duration = new TimeSpan(0, 1, 0, 0),
                    Place       = "C13, 301"
                },
                new Exam
                {
                    Name        = "Quantum physics", Course = courses.FirstOrDefault(c => c.Name == "Physics"),
                    DateAndTime = new DateTime(2015, 6, 25, 13, 15, 0), Duration = new TimeSpan(0, 2, 0, 0),
                    Place       = "C1, 205"
                },
                new Exam
                {
                    Name        = "Algebra", Course = courses.FirstOrDefault(c => c.Name == "Math"),
                    DateAndTime = new DateTime(2015, 7, 5, 13, 15, 0), Duration = new TimeSpan(0, 2, 30, 0),
                    Place       = "D1, 200"
                }
            };


            examsRepository.AddRange(exams);

            #endregion



            #region ClosedAnswer

            IRepository <ClosedAnswer> closedAnswerRepository = new Repository <ClosedAnswer>(dbContext);
            closedAnswerRepository.DeleteAll();

            var colorAnswerChoices = new List <ClosedAnswer>
            {
                new ClosedAnswer {
                    AnswerText = "blue", IsCorrect = true, ClosedQuestionID = closedQuestion1.ID, ClosedQuestion = closedQuestion1
                },
                new ClosedAnswer {
                    AnswerText = "red", IsCorrect = false, ClosedQuestionID = closedQuestion1.ID, ClosedQuestion = closedQuestion1
                },
                new ClosedAnswer {
                    AnswerText = "green", IsCorrect = false, ClosedQuestionID = closedQuestion1.ID, ClosedQuestion = closedQuestion1
                },
                new ClosedAnswer {
                    AnswerText = "black", IsCorrect = false, ClosedQuestionID = closedQuestion1.ID, ClosedQuestion = closedQuestion1
                }
            };

            closedAnswerRepository.AddRange(colorAnswerChoices);

            var cityAnswerChoices = new List <ClosedAnswer>
            {
                new ClosedAnswer {
                    AnswerText = "Wroclaw", IsCorrect = true, ClosedQuestionID = closedQuestion2.ID, ClosedQuestion = closedQuestion2
                },
                new ClosedAnswer {
                    AnswerText = "London", IsCorrect = false, ClosedQuestionID = closedQuestion2.ID, ClosedQuestion = closedQuestion2
                },
                new ClosedAnswer {
                    AnswerText = "New York", IsCorrect = false, ClosedQuestionID = closedQuestion2.ID, ClosedQuestion = closedQuestion2
                }
            };

            closedAnswerRepository.AddRange(cityAnswerChoices);

            var elvisAnswerChoices = new List <ClosedAnswer>
            {
                new ClosedAnswer {
                    AnswerText = "Yes, of course!", IsCorrect = true, ClosedQuestionID = closedQuestion3.ID, ClosedQuestion = closedQuestion3
                },
                new ClosedAnswer {
                    AnswerText = "No, man, what a bullshit!", IsCorrect = false, ClosedQuestionID = closedQuestion3.ID, ClosedQuestion = closedQuestion3
                },
            };

            closedAnswerRepository.AddRange(elvisAnswerChoices);


            #endregion

            //base.Seed(dbContext);
        }
コード例 #12
0
    private void DisplayContent(Content content = null)
    {
        if (contentsStack.Count <= 0 && content == null)
        {
            //S'il n'y a plus de contenu à afficher et qu'on cherche à en afficher, c'est la fin de la scène
            //Instantiate(EndButton, tabletContentContainer);
            return;
        }
        else
        {
            GameObject contentToInstantiate;
            if (content == null)
            {
                currentContent = contentsStack.Pop();
            }
            else
            {
                currentContent = content;
            }

            //Debug.Log(currentContent.CompleteEvent.GetPersistentEventCount());
            //Si le contenu à afficher n'a pas d'événement indiqué, comme ceux ajouté dynamiquement
            if (currentContent.CompleteEvent.GetPersistentEventCount() == 0)
            {
                contentDisplayer.onContentCompleteDelegate = DisplayNextContent;
            }
            else
            {
                contentDisplayer.onContentCompleteDelegate = currentContent.CompleteEvent.Invoke;
            }

            currentContent.AddObserver(contentDisplayer);

            if (currentContent.GetType() == typeof(SimpleText))
            {
                SimpleText st = (SimpleText)currentContent;
                //Sans un titre
                if (st.textData.title == "")
                {
                    simpleTextPref.SetActive(false);

                    contentToInstantiate = Instantiate(simpleTextPref, tabletContentContainer);
                    contentToInstantiate.GetComponent <TextHolder>().simpleText = st;
                    simpleTextPref.SetActive(true);
                }
                //Avec un titre
                else
                {
                    titledTextPref.SetActive(false);

                    contentToInstantiate = Instantiate(titledTextPref, tabletContentContainer);
                    contentToInstantiate.GetComponent <TextHolder>().simpleText = st;
                    Debug.Log(contentToInstantiate.GetComponent <TextHolder>().simpleText.textData.content);
                    titledTextPref.SetActive(true);
                }
            }

            else if (currentContent.GetType() == typeof(OpenQuestion) || currentContent.GetType() == typeof(ClosedQuestion))
            {
                if (currentContent.GetType() == typeof(OpenQuestion))
                {
                    openQuestionPref.SetActive(false);
                    OpenQuestion oq = (OpenQuestion)currentContent;
                    contentToInstantiate = Instantiate(openQuestionPref, tabletContentContainer);
                    contentToInstantiate.GetComponent <OpenQuestionHolder>().openQuestion = oq;
                    openQuestionPref.SetActive(true);
                }
                else
                {
                    closedQuestionPreb.SetActive(false);
                    ClosedQuestion cq = (ClosedQuestion)currentContent;
                    contentToInstantiate = Instantiate(closedQuestionPreb, tabletContentContainer);
                    contentToInstantiate.GetComponent <ClosedQuestionHolder>().closedQuestion = cq;
                    closedQuestionPreb.SetActive(true);
                }
            }
            else
            {
                contentToInstantiate = Instantiate(fillGapsPref, tabletContentContainer);
            }

            contentToInstantiate.SetActive(true);
            currentGameObjectToShow = contentToInstantiate;
        }
        Resizer.ResizeHeight(tabletContentContainer.GetComponent <RectTransform>());

        StartCoroutine(nameof(DisplayScrollArrow));
    }