Beispiel #1
0
        protected void sortQuestionRadioButton_OnCheckedChanged(object sender, EventArgs e)
        {
            var radioButton = (RadioButton)sender;

            QuestionSortValue.Value = radioButton.Text.ToLower();
            QuestionsList.DataBind();
        }
Beispiel #2
0
    private void ReadCSV()
    {
        QuestionsList questionsList = new QuestionsList();

        string[,] arr = CSVReader.GetCSVGridString(file.text, ";");
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            string phrase = arr[i, 0];
            if (phrase == "" || phrase == null)
            {
                continue;
            }
            string answer = arr[i, 1].Replace("\r", "");
            phrasesList.Add(phrase);
            answersList.Add(answer);

            questionsList.questions.Add(new Question(GenerateQuestionString(phrase), answer));
        }

        // write to JSON
        string jsonString = JsonUtility.ToJson(questionsList);

        StreamWriter outStream = System.IO.File.CreateText(Application.dataPath + "/TextAssets/Fill-Phrases.json");

        outStream.WriteLine(jsonString);
        outStream.Close();
    }
Beispiel #3
0
        private ActionResult StartCountryByFlagGame(GameSettings settings)
        {
            string         language  = (Session["Language"] as string)?.ToUpper();
            List <Country> countries = GetSelectedCountries(settings);

            // Assemble questions for each country
            int calculatedDistractorsAmount     = Math.Max((int)settings.Difficulty, settings.DistractorsAmount);
            List <QuestionAnswerPair> questions = new List <QuestionAnswerPair>();

            foreach (Country c in countries)
            {
                string question = c.Id.ToString();
                var    country  = c.Localizations.Where(x => x.Language == language).FirstOrDefault();
                string answer   = country?.Name ?? c.Name;
                string alias    = country?.AliasName;
                // Everything as in flags mode, but now question is country ID (flag image selected by id) and answer and distractors are country names
                string[] distractors = db.FlagNeighbours
                                       .Where(fn => fn.CountryId1 == c.Id &&
                                              settings.Continents.Contains(fn.Country1.Continent) &&
                                              (fn.Country1.IsSovereign || settings.AllowedNonSovereignIds.Contains(fn.CountryId2)))
                                       .OrderBy(x => x.Distance)
                                       .Take(calculatedDistractorsAmount)
                                       .Shuffle()
                                       .Take(settings.DistractorsAmount)
                                       .Select(x => x.Country1.Localizations.Where(z => z.Language == language).Select(z => z.Name).FirstOrDefault() ?? x.Country1.Name)
                                       .ToArray();

                questions.Add(new QuestionAnswerPair(question, answer, distractors, alias));
            }

            QuestionsList questionsList = new QuestionsList(questions);

            Session["Questions"] = questionsList;
            return(View(nameof(Quiz), GetQuestionViewModel(questionsList)));
        }
    // Load dialogue content from file to a list
    void LoadQuestions(double score)
    {
        string jsonString;

        if (score < scoreMed)
        {
            jsonString = File.ReadAllText(Application.dataPath + "/Scripts/questions_easy.json");
        }
        else if (score < scoreHard)
        {
            jsonString = File.ReadAllText(Application.dataPath + "/Scripts/questions_medium.json");
        }
        else
        {
            jsonString = File.ReadAllText(Application.dataPath + "/Scripts/questions_hard.json");
        }

        QuestionsList temp = JsonUtility.FromJson <QuestionsList>(jsonString);

        questionList = new Dictionary <string, List <string> >();
        foreach (var questionPair in temp.list)
        {
            questionList.Add(questionPair.type, questionPair.questions);
        }
        questionLeft = new Dictionary <string, int>();
        foreach (string topic in questionList.Keys)
        {
            questionLeft.Add(topic, questionNum);
        }
    }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ql = QuestionsList.CreateList();

                ListItem x = new ListItem();
                x.Value = txtQuestion.Text.Trim();

                if (txtQuestion.Text != "" && !(lstQuestions.Items.Contains(x)))
                {
                    newQuestion = new Questions();

                    newQuestion.QuestionContent = txtQuestion.Text.Trim();
                    newQuestion.QuestionID      = count++;

                    ql.questions.Add(newQuestion);

                    this.FillQuestionListBox();

                    txtQuestion.Text = "";
                    txtQuestion.Focus();

                    lblValidate.Visible = false;
                }
                else
                {
                    lblValidate.Visible = true;
                }
            }
        }
    // Start is called before the first frame update
    void Awake()
    {
        questionsList = GetComponent <QuestionsList>();
        clone         = Instantiate(cardObjectPrefab, cardCanvas.transform);
        players.Add(mario.GetComponent <Player>());
        players.Add(luigi.GetComponent <Player>());
        players.Add(peach.GetComponent <Player>());
        players.Add(goombella.GetComponent <Player>());

        UpdateScore();
        P1ScoreAddText = GameObject.Find("P1ScoreAddText").GetComponent <Text>();
        P1ScoreAddText.gameObject.SetActive(false);
        P2ScoreAddText = GameObject.Find("P2ScoreAddText").GetComponent <Text>();
        P2ScoreAddText.gameObject.SetActive(false);
        P3ScoreAddText = GameObject.Find("P3ScoreAddText").GetComponent <Text>();
        P3ScoreAddText.gameObject.SetActive(false);
        P4ScoreAddText = GameObject.Find("P4ScoreAddText").GetComponent <Text>();
        P4ScoreAddText.gameObject.SetActive(false);

        audioManager = GetComponent <AudioManager>();
        if (Data.Singleton.turn == 1)
        {
            currentScoreText = P1ScoreText; currentScore = Data.P1Score;
        }
    }
Beispiel #7
0
        //set three images and three labels for the game
        public void ThreeQuestion(string type)
        {
            taken1 = false;
            taken2 = false;
            taken3 = false;
            taken4 = false;
            taken5 = false;
            taken6 = false;

            int rdm1 = rdm.Next(1, 7);
            int rdm2 = rdm.Next(1, 7);
            int rdm3 = rdm.Next(1, 7);
            int rdm4 = rdm.Next(1, 7);
            int rdm5 = rdm.Next(1, 7);
            int rdm6 = rdm.Next(1, 7);

            int qindex1 = rdm.Next(0, QuestionsList.Count);

            randomizeImage(rdm1, qindex1);
            randomizeLabel(rdm4, qindex1, type);
            QuestionsList.RemoveAt(qindex1);

            int qindex2 = rdm.Next(0, QuestionsList.Count);

            randomizeImage(rdm2, qindex2);
            randomizeLabel(rdm5, qindex2, type);
            QuestionsList.RemoveAt(qindex2);

            int qindex3 = rdm.Next(0, QuestionsList.Count);

            randomizeImage(rdm3, qindex3);
            randomizeLabel(rdm6, qindex3, type);
            QuestionsList.RemoveAt(qindex3);
        }
Beispiel #8
0
        private ActionResult StartCapitalByCountryGame(GameSettings settings)
        {
            string         language  = (Session["Language"] as string)?.ToUpper();
            List <Country> countries = GetSelectedCountries(settings);

            // Assemble questions for each country
            int calculatedDistractorsAmount     = Math.Max((int)settings.Difficulty, settings.DistractorsAmount);
            List <QuestionAnswerPair> questions = new List <QuestionAnswerPair>();

            foreach (Country c in countries)
            {
                var    country  = c.Localizations.Where(x => x.Language == language).FirstOrDefault();
                string question = country?.Name ?? c.Name;
                string answer   = country?.Capital ?? c.Capital;
                string alias    = country?.AliasName;
                // Everything as in flags mode, but now question is country ID (flag image selected by id) and answer and distractors are country names
                string[] distractors = countries
                                       .Where(x => x.Id != c.Id)
                                       .Shuffle()
                                       .Take(settings.DistractorsAmount)
                                       .Select(x => x.Localizations.Where(z => z.Language == language).Select(z => z.Capital).FirstOrDefault() ?? x.Capital)
                                       .ToArray();

                questions.Add(new QuestionAnswerPair(question, answer, distractors, alias));
            }

            QuestionsList questionsList = new QuestionsList(questions);

            Session["Questions"] = questionsList;
            return(View(nameof(Quiz), GetQuestionViewModel(questionsList)));
        }
Beispiel #9
0
 public ActionResult Results(QuestionsList questions, GameSettings settings)
 {
     return(View(new ResultsViewModel()
     {
         Questions = questions, GameSettings = settings
     }));
 }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ql = QuestionsList.CreateList();

                ddlQuestion1.Items.Add("Please select a question.");
                ddlQuestion2.Items.Add("Please select a question.");
                ddlQuestion3.Items.Add("Please select a question.");
                ddlQuestion4.Items.Add("Please select a question.");
                ddlQuestion5.Items.Add("Please select a question.");

                foreach (Questions q in ql.questions)
                {
                    ddlQuestion1.Items.Add(q.GetDisplayText());
                    ddlQuestion2.Items.Add(q.GetDisplayText());
                    ddlQuestion3.Items.Add(q.GetDisplayText());
                    ddlQuestion4.Items.Add(q.GetDisplayText());
                    ddlQuestion5.Items.Add(q.GetDisplayText());
                }

                ddlQuestion1.SelectedIndex = 0;
                ddlQuestion2.SelectedIndex = 0;
                ddlQuestion3.SelectedIndex = 0;
                ddlQuestion4.SelectedIndex = 0;
                ddlQuestion5.SelectedIndex = 0;
            }
        }
Beispiel #11
0
        public IActionResult Index(int p = 1, int s = 10)
        {
            // PagingTagHelper will use totalRecords to calculate total pages required
            var totalRecords = _context.Questions.Count();
            var questions    = new List <Questions>();

            if (totalRecords > 0)
            {
                questions =
                    _context.Questions

                    // we make sure to order the collection before paging
                    .OrderByDescending(x => x.Question)

                    // skip previously listed items
                    .Skip((p - 1) * s)

                    // take only defined page size
                    .Take(s)

                    // call ToList method to fetch the query and get the results
                    .ToList();
            }

            // create the model to be returned
            var model = new QuestionsList
            {
                PageNo       = p,
                PageSize     = s,
                TotalRecords = totalRecords,
                Items        = questions
            };

            return(View(model));
        }
Beispiel #12
0
    private void ReadCSV()
    {
        QuestionsList questionsList = new QuestionsList();

        string[,] arr = CSVReader.GetCSVGridString(elementsListFile.text);
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            string element = arr[i, 0];
            if (element == "" || element == null)
            {
                continue;
            }
            string symbol = arr[i, 1].Replace("\r", "");
            elementNamesList.Add(element);
            elementSymbolsList.Add(symbol);

            questionsList.questions.Add(new Question(element, symbol));
        }

        // write to JSON
        string jsonString = JsonUtility.ToJson(questionsList);

        StreamWriter outStream = System.IO.File.CreateText(Application.dataPath + "/TextAssets/Chem-Elements.json");

        outStream.WriteLine(jsonString);
        outStream.Close();
    }
Beispiel #13
0
    private void ReadCSV()
    {
        QuestionsList questionsList = new QuestionsList();

        string[,] arr = CSVReader.GetCSVGridString(file.text);
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            string discipline = arr[i, 0];
            if (discipline == "" || discipline == null)
            {
                continue;
            }
            string field = arr[i, 1].Replace("\r", "");
            discipline = discipline.ToUpper()[0] + discipline.Substring(1, discipline.Length - 1); // first letter caps

            questionsList.questions.Add(new Question(GenerateQuestionString(discipline), field));
        }

        // write to JSON
        string jsonString = JsonUtility.ToJson(questionsList);

        StreamWriter outStream = System.IO.File.CreateText(Application.dataPath + "/TextAssets/StudyOf.json");

        outStream.WriteLine(jsonString);
        outStream.Close();
    }
Beispiel #14
0
        public ActionResult Index(GameSettings settings)
        {
            List <Country>  countries = GetSelectedCountries(settings);
            string          language  = HttpContext.Session.GetString("Language")?.ToUpper();
            QuestionBuilder questionBuilder;

            switch (settings.GameMode)
            {
            case GameMode.FlagByCountry:
                questionBuilder = new FlagByCountryQuestionBuilder(settings, db, language); break;

            case GameMode.CountryByFlag:
                questionBuilder = new CountryByFlagQuestionBuilder(settings, db, language); break;

            case GameMode.CapitalByCountry:
                questionBuilder = new CapitalByCountryQuestionBuilder(settings, db, language); break;

            default:
                return(RedirectToAction(nameof(MenuController.Index), MenuController.Nameof));
            }

            QuestionsList questionsList = new QuestionsList(countries, questionBuilder);

            HttpContext.Session.SetObjectAsJson("Questions", questionsList);
            return(View(nameof(Quiz), GetQuestionViewModel(questionsList)));
        }
Beispiel #15
0
    private void ReadCSV()
    {
        QuestionsList questionsList = new QuestionsList();

        string[,] arr = CSVReader.GetCSVGridString(file.text);
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            string acronym = arr[i, 0];
            if (acronym == "" || acronym == null)
            {
                continue;
            }
            string meaning = arr[i, 1].Replace("\r", "");
            acronymsList.Add(acronym);
            acronymMeaningsList.Add(meaning);

            questionsList.questions.Add(new Question(GenerateQuestionString(acronym), meaning));
        }

        // write to JSON
        string jsonString = JsonUtility.ToJson(questionsList);

        StreamWriter outStream = System.IO.File.CreateText(Application.dataPath + "/TextAssets/Acronyms.json");

        outStream.WriteLine(jsonString);
        outStream.Close();
    }
Beispiel #16
0
    private void ReadCSV()
    {
        QuestionsList questionsList = new QuestionsList();

        string[,] arr = CSVReader.GetCSVGridString(file.text);
        for (int i = 0; i < arr.GetLength(0); i++)
        {
            string animal = arr[i, 0];
            if (animal == "" || animal == null)
            {
                continue;
            }
            animal = animal.ToLower();
            string collection = arr[i, 1].Replace("\r", "");

            questionsList.questions.Add(new Question(GenerateQuestionString(animal), collection));
        }

        // write to JSON
        string jsonString = JsonUtility.ToJson(questionsList);

        StreamWriter outStream = System.IO.File.CreateText(Application.dataPath + "/TextAssets/AnimalCollections.json");

        outStream.WriteLine(jsonString);
        outStream.Close();
    }
Beispiel #17
0
 void generateQuestion()
 {
     if (qList.Count > 0)
     {
         if (scoreText.gameObject.activeSelf)
         {
             scoreText.GetComponent <Animation>().Play("Bubble_Close_3");
         }
         randQ = Random.Range(0, qList.Count);
         crntQ = qList[randQ] as QuestionsList;
         if (crntQ != null)
         {
             questionText.text = crntQ.Question;
             questionText.GetComponent <Animation>().Play("Bubble_Open_1");
             List <string> answers = new List <string>(crntQ.answers);
             for (int i = 0; i < crntQ.answers.Length; i++)
             {
                 int randA = Random.Range(0, answers.Count);
                 answersText[i].text = answers[randA];
                 answers.RemoveAt(randA);
             }
         }
         StartCoroutine(answersBttnsInAnim());
         timeCount = publicTimeCount;
         currentQ++;
     }
     else
     {
         StartCoroutine(final());
     }
 }
        public async Task <JsonResult> AddQuestion(string question, string answer)
        {
            bool result = QuestionsList <Question> .GetInstance(_questionSerializer).AddQuestion(new Question {
                Quest = question, Answer = answer
            }, _questionSerializer);

            return(Json(result));
        }
 private void FillSurveyObject()
 {
     if (Survey?.EndDate != null)
     {
         Survey.EndDate = Survey.EndDate.Value.SetHours(23, 59, 59, 999);
     }
     Survey.Questions = QuestionsList.Select(x => x.ToDto()).ToList();
     Survey.CourseId  = SelectedCourse?.Id;
 }
Beispiel #20
0
    public void AddAnswer(string username, string answer, uint networkId)
    {
        answers [networkId].username = username;

        if (answer.Equals(QuestionsList.GetCurrentQuestion().Correct))
        {
            leaderboard [networkId]++;
        }
    }
Beispiel #21
0
    // Use this for initialization
    void Awake()
    {
        questionsList = JsonUtility.FromJson <QuestionsList>(jsonQuestions.text);

        // initialise for all generators' use
        Random.InitState((int)System.DateTime.Now.Ticks);

        InitAvailableInt(questionsList.questions.Count);
    }
        private void DeleteQuestion(object obj)
        {
            var question = obj as QuestionModel;

            QuestionsList.Remove(question);
            for (int i = 0; i < QuestionsList.Count; ++i)
            {
                QuestionsList[i].Index = i + 1;
            }
        }
Beispiel #23
0
        //Set questions and all other properties
        private void WriteQuestionnaire(Func <List <QuestionRep> > quests, string title)
        {
            List <QuestionRep> analysis = quests();

            questionsH.InnerText   = title;
            Session["currentPage"] = title;

            QuestionsList.DataSource = analysis;
            QuestionsList.DataBind();
        }
Beispiel #24
0
        private async void AddQuestionControl_SubmitClicked(object sender, Question e)
        {
            AddQuestionFormStatusText.Text = "";
            AddQuestionForm.Clear();
            Question result = await NetworkService.AddQuestion(MasterMenuItem.PlayerInfo.Id, e);

            AddQuestionFormStatusText.Text = $"Question with ID: {result?.Id} added.";
            await LoadQuestions();

            QuestionsList.ScrollIntoView(Questions.Last(), ScrollIntoViewAlignment.Leading);
        }
    // This function is use to load question from the json file included in the application
    // Questions will be filtered by the world and stage that player have chosen
    // Assigning of option text to the specific button
    // counter() function will called to update the necessary parameters
    void loadQuestions()
    {
        // loadJson
        TextAsset asset = Resources.Load("Questions") as TextAsset;

        QuestionsList = JsonUtility.FromJson <QuestionsList>(asset.text);

        // stage test
        Text quesCnt = GameObject.Find("questionCount").GetComponent <Text>();

        quesCnt.text = "Stage " + prefStage + " (" + (count + 1) + "\\5)";

        // loop through
        for (int a = 0; a < QuestionsList.Questions.Count; a++)
        {
            if ((prefStage == QuestionsList.Questions[a].stage && count == QuestionsList.Questions[a].level) && prefWorld == QuestionsList.Questions[a].world)
            {
                // question text
                Text qnstxt = GameObject.Find("questionsTxt").GetComponent <Text>();
                qnstxt.text = QuestionsList.Questions[qCount].qns_text;

                repeat = 0;

                if (QuestionsList.Questions[a].choice == 0)
                {
                    GameObject.Find("option_0").GetComponentInChildren <Text>().text = QuestionsList.Questions[a].answer;
                    aa = QuestionsList.Questions[a].choice;
                    ee = QuestionsList.Questions[a].boolen;
                }
                else if (QuestionsList.Questions[a].choice == 1)
                {
                    GameObject.Find("option_1").GetComponentInChildren <Text>().text = QuestionsList.Questions[a].answer;
                    bb = QuestionsList.Questions[a].choice;
                    ff = QuestionsList.Questions[a].boolen;
                }
                else if (QuestionsList.Questions[a].choice == 2)
                {
                    GameObject.Find("option_2").GetComponentInChildren <Text>().text = QuestionsList.Questions[a].answer;
                    cc = QuestionsList.Questions[a].choice;
                    gg = QuestionsList.Questions[a].boolen;
                }
                else if (QuestionsList.Questions[a].choice == 3)
                {
                    GameObject.Find("option_3").GetComponentInChildren <Text>().text = QuestionsList.Questions[a].answer;
                    dd  = QuestionsList.Questions[a].choice;
                    hhh = QuestionsList.Questions[a].boolen;
                }
            }
        }

        counter();
    }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            ql = QuestionsList.CreateList();

            int i = lstQuestions.SelectedIndex;

            if (i != -1)
            {
                txtQuestion.Text = lstQuestions.SelectedItem.Text.ToString();
                ql.questions.RemoveAt(i);
                FillQuestionListBox();
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ql = QuestionsList.CreateList();

            int i = lstQuestions.SelectedIndex;

            if (i != -1)
            {
                ql.questions.RemoveAt(i);
                FillQuestionListBox();
            }

            txtQuestion.Focus();
        }
Beispiel #28
0
    public void OnQuestionSent(string text)
    {
        if (!isServer)
        {
            return;
        }

        UIController.Instance.serverUI.SetActive(false);
        amountOfAnswers = 0;
        questionText    = text;
        Question q = QuestionsList.GetCurrentQuestion();

        RpcSendAnwers(q.Answers);
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            ql = QuestionsList.CreateList();

            if (!IsPostBack)
            {
                if (ql.questions.Count > 0)
                {
                    FillQuestionListBox();
                }
            }

            txtQuestion.Focus();
        }
    IEnumerator GameOverRoutine()
    {
        audioManager.audioPitch   = 1;
        questionsList.questions   = QuestionsList.Shuffle <Question>(questionsList.questions);
        Data.Singleton.isGameOver = true;
        ButtonController.DisableButton();
        ButtonController.HideStopButton();
        greenPipeClone = Instantiate(greenPipePrefab, greenPipeSpawn.position, greenPipePrefab.transform.rotation);
        Destroy(greenPipeClone, 10f);
        yield return(new WaitForSeconds(3f));

        KillPlayer();
        //gameOverCanvas.gameObject.SetActive(true);
        //FinishTurn();
        StartCoroutine(MoveBack());
    }