コード例 #1
0
    public static void SaveQuestion(QuestionDataBase dataBaseToEdit, Question question)
    {
        string answerCorrectness = "X";

        foreach (Answer answer in question.Answers)
        {
            if (answer.IsCorrect)
            {
                answerCorrectness += 1.ToString();
            }
            else
            {
                answerCorrectness += 0.ToString();
            }
        }

        List <string> questionContentLines = new List <string>();

        questionContentLines.Add(answerCorrectness);
        questionContentLines.Add(question.QuestionText);
        foreach (Answer answer in question.Answers)
        {
            questionContentLines.Add(answer.AnswerText);
        }

        File.WriteAllLines(@dataBaseToEdit.Path + "/" + question.QuestionName + ".txt", questionContentLines);
    }
コード例 #2
0
ファイル: QuestionPanel.cs プロジェクト: zuojiashun/src
    void SetFanKuiBtn()
    {
        if (status2 == RewardStatus.Reward_Get)
        {
            m_label_feedLabel.text = "我要反馈";
            m_sprite_FeedWarning.gameObject.SetActive(false);
        }
        else if (status2 == RewardStatus.Reward_Open)
        {
            m_label_feedLabel.text = "领取奖励";
            m_sprite_FeedWarning.gameObject.SetActive(true);
        }
        else
        {
            m_label_feedLabel.text = "我要反馈";
            m_sprite_FeedWarning.gameObject.SetActive(false);
        }
        UILabel          label = m_label_times.GetComponent <UILabel>();
        QuestionDataBase table = GameTableManager.Instance.GetTableItem <QuestionDataBase>((uint)QuestionTab.FanKui);

        if (label != null && table != null)
        {
            label.text = string.Format("{0}/{1}", (table.rewarn_time - DataManager.Manager <QuestionManager>().FeedRewardLeftTime), table.rewarn_time);
        }
    }
コード例 #3
0
    // Use this for initialization


    private void Start()
    {
        QuestionDataBase qb = new QuestionDataBase();
        var testQuestion    = new Question
        {
            m_question = "what is love ?",
            m_fact     = "baby don't hurt me.",
            m_answers  = new List <string> {
                "don't hurt me", "don't hurt me", "no more"
            },
            m_illustrations = new List <string> {
                "eddy", "malou"
            },
            m_questionSoundClipName = "WhatIsLove",
            m_factSoundClipName     = "Baby don't hurt me"
        };

        var q1 = new Question
        {
            m_question = "Qui a prédit l'existence des Protons?",
            m_fact     = "Mr. Prout en 1815",
            m_answers  = new List <string>
            {
                "Albert Einstein", "Mr Fladislas IVth, Duc de Durambour, Esqu.", "MR PROUT!!!!!!!"
            }
        };

        qb.m_questions.Add(testQuestion);
        qb.m_questions.Add(q1);

        qb.Save(Path.Combine(Application.dataPath, "questions.xml"));
    }
コード例 #4
0
ファイル: Game.cs プロジェクト: LukCore95/Testoquest
 public override void OnDisable()
 {
     _isTime = false;
     _questionRepeats.Clear();
     _timeSpent = new TimeSpan(0, 0, 0);
     _timer     = 0;
     _selectedQuestionDataBase = null;
 }
コード例 #5
0
    public void UpdateQuestionToAnswered(QuestionDataBase DataBase, Question updatedAnsweredQuestion)
    {
        Question _answeredQuestion =
            DataBase.Questions.First(question => question.QuestionName == updatedAnsweredQuestion.QuestionName);
        int index = QuestionDataBaseNames.FindIndex(name => name == DataBase.Name);

        _answeredQuestion = updatedAnsweredQuestion;
        PlayerPrefsManager.SaveQuestionState(index, _answeredQuestion);
    }
コード例 #6
0
 public void SetFromChooseBaseBaseIsEmpty(QuestionDataBase selectedBaseQuestionDataBase, UnityAction editBaseMethod)
 {
     _questionText.text = "Baza '" + selectedBaseQuestionDataBase.Name + "' jest pusta, czy chcesz dodać do niej pytania?";
     _noButton.onClick.AddListener(UIManager.Instance.GoBack);
     _yesButton.onClick.AddListener(delegate
     {
         editBaseMethod.Invoke();
     });
 }
コード例 #7
0
 public void SetQuestionBase(QuestionDataBase questionDataBase)
 {
     QuestionDataBase         = questionDataBase;
     BaseProgressSlider.value = QuestionDataBase.GetPercentageOfAnsweredQuestions();
     BaseName.text            = QuestionDataBase.Name;
     ScoreNumberText.text     =
         questionDataBase.Questions.Count(question => question != null && question.IsAnswered) + "/" +
         questionDataBase.Questions.Count;
 }
コード例 #8
0
 public void SetFromDeleteQuestionButton(QuestionDataBase baseToEdit, Question question)
 {
     _questionText.text = "Czy na pewno chcesz usunąć pytanie '" + question.QuestionName + "' z bazy'" + baseToEdit.Name + "'? To trwale usunie plik pytania z folderu.";
     _noButton.onClick.AddListener(UIManager.Instance.GoBack);
     _yesButton.onClick.AddListener(delegate
     {
         QuestionDataBaseManager.Instance.DeleteQuestionFromDatabase(baseToEdit.Name, question.QuestionName);
         UIManager.Instance.GoBack();
     });
 }
コード例 #9
0
 public void SetFromChooseBaseDeleteButton(QuestionDataBase contentElementQuestionDataBase)
 {
     _questionText.text = "Czy na pewno chcesz usunąć bazę '" + contentElementQuestionDataBase.Name + "'? To usunie tylko bazę z aplikacji, folder z bazą pozostanie na telefonie.";
     _noButton.onClick.AddListener(UIManager.Instance.GoBack);
     _yesButton.onClick.AddListener(delegate
     {
         QuestionDataBaseManager.Instance.DeleteDataBase(contentElementQuestionDataBase.Name);
         UIManager.Instance.GoBack();
     });
 }
コード例 #10
0
 public void SetFromChooseBaseResetButton(QuestionDataBase contentElementQuestionDataBase)
 {
     _questionText.text = "Czy na pewno chcesz zresetoweać postęp bazy '" + contentElementQuestionDataBase.Name + "'?";
     _noButton.onClick.AddListener(UIManager.Instance.GoBack);
     _yesButton.onClick.AddListener(delegate
     {
         QuestionDataBaseManager.Instance.ResetDataBaseState(contentElementQuestionDataBase.Name);
         UIManager.Instance.GoBack();
     });
 }
コード例 #11
0
 public static void SaveQuestionDataBaseState(QuestionDataBase dataBaseToSave, int index)
 {
     foreach (Question question in dataBaseToSave.Questions)
     {
         string key   = "QuestionDataBase" + index + "_" + question.QuestionName;
         int    value = Convert.ToInt32(question.IsAnswered);
         PlayerPrefs.SetInt(key, value);
     }
     PlayerPrefs.Save();
 }
コード例 #12
0
 public void SetFromChooseBaseBaseIs100Percent(QuestionDataBase contentElementQuestionDataBase, UnityAction GoToGameMethod)
 {
     _questionText.text = "Wybór bazy '" + contentElementQuestionDataBase.Name + "' sprawi reset postępu, kontynuować?";
     _noButton.onClick.AddListener(UIManager.Instance.GoBack);
     _yesButton.onClick.AddListener(delegate
     {
         QuestionDataBaseManager.Instance.ResetDataBaseState(contentElementQuestionDataBase.Name);
         UIManager.Instance.DeleteFromHistory(this);
         GoToGameMethod.Invoke();
     });
 }
コード例 #13
0
ファイル: QuestionDataBase.q.cs プロジェクト: zuojiashun/src
        /// <summary>
        /// 通过[ID]二分快速查表
        /// </summary>
        /// <param name="ID">ID</param>
        /// <returns></returns>
        public static QuestionDataBase Query(this List <QuestionDataBase> sorted, uint ID)
        {
            var key = new QuestionDataBase()
            {
                ID = ID
            };
            var comparer = new Comparer1();
            var index    = sorted.BinarySearch(key, comparer);

            return(index >= 0 ? sorted[index] : default(QuestionDataBase));
        }
コード例 #14
0
ファイル: TestPageViewModel.cs プロジェクト: HerrRegent/Files
        public TestPageViewModel()
        {
            var relayCommand = new RelayCommand(CompleteTest, CheckTest);

            CompleteTestCommand = relayCommand;

            Questions = new ObservableCollection <Question>(QuestionDataBase.GetQuestions());
            Questions.CollectionChanged += (send, e) =>
            {
                PropertyChange(nameof(Questions));
            };
        }
コード例 #15
0
    public void DeleteQuestionFromDatabase(string dataBaseName, string questionQuestionName)
    {
        QuestionDataBase dataBase = QuestionDataBases.Find(database => database.Name == dataBaseName);
        Question         question = dataBase.Questions.First(q => q.QuestionName == questionQuestionName);
        int index = QuestionDataBaseNames.FindIndex(name => name == dataBase.Name);

        if (question != null)
        {
            LocalDataManager.DeleteQuestion(dataBase, question);
            PlayerPrefsManager.DeleteQuestionState(index, question);
            dataBase.Questions.Remove(question);
        }
    }
コード例 #16
0
    public void ResetDataBaseState(string dataBaseName)
    {
        QuestionDataBase dataBase = QuestionDataBases.Find(database => database.Name == dataBaseName);
        int index = QuestionDataBaseNames.FindIndex(name => name == dataBaseName);

        dataBase.TimeSpent = new TimeSpan();
        foreach (Question question in dataBase.Questions)
        {
            question.IsAnswered = false;
            PlayerPrefsManager.SaveQuestionState(index, question);
        }
        PlayerPrefsManager.SaveQuestionDataBaseState(dataBase, index);
        PlayerPrefsManager.SaveQuestionDataBaseTimeSpent(index, dataBase.TimeSpent.ToString());
    }
コード例 #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         user = new User("123");
         user.startTestAllRand("c1_1Questions");
         questionData  = user.getTest().getQuestionDataInstance();
         questionNum   = questionData.getSize();
         yourAnswer    = new int[questionNum];
         questionScore = new Boolean[questionNum];
         showQuestion();
         showQuestionInfo();
         ASPxLabelPeopleInfo1.Text = "考生姓名:" + (String)Session["userName"];
     }
 }
コード例 #18
0
        public App(string dbPath, ISQLitePlatform sqlitePlatform, int id)
        {
            //set database path first, then retrieve main page
            ChapitreDb = new ChapitreDataBase(sqlitePlatform, dbPath);
            EntiteDb   = new EntityDataBase(sqlitePlatform, dbPath);
            CoursDb    = new CoursDataBase(sqlitePlatform, dbPath);
            QuestionDb = new QuestionDataBase(sqlitePlatform, dbPath, id);
            ReponseDb  = new ReponseDataBase(sqlitePlatform, dbPath);

            this.MainPage = new Menu();
            //this.MainPage = new TestPage();
            //this.MainPage = new Hello();

            //this.MainPage = new ListeChapitre_CSharp();
        }
コード例 #19
0
ファイル: QuestionPanel.cs プロジェクト: zuojiashun/src
    void CreateRewardObj(Transform parent, QuestionDataBase db)
    {
        AddCreator(parent);
        m_lst_UIItemRewardDatas.Clear();
        if (!string.IsNullOrEmpty(db.money_reward))
        {
            string[] param = db.money_reward.Split(';');
            for (int m = 0; m < param.Length; m++)
            {
                string[] param2 = param[m].Split('_');
                uint     money  = 0;
                uint     num    = 0;
                if (uint.TryParse(param2[0], out money) && uint.TryParse(param2[1], out num))
                {
                    CurrencyIconData data = CurrencyIconData.GetCurrencyIconByMoneyType((ClientMoneyType)money);
                    if (data == null)
                    {
                        return;
                    }
                    m_lst_UIItemRewardDatas.Add(new UIItemRewardData()
                    {
                        itemID = data.itemID,
                        num    = num,
                    });
                }
            }
        }
        if (!string.IsNullOrEmpty(db.item_reward))
        {
            uint     itemID  = 0;
            uint     itemNum = 0;
            string[] data    = db.item_reward.Split(';');

            for (int i = 0; i < data.Length; i++)
            {
                string[] data2 = data[i].Split('_');
                if (uint.TryParse(data2[0], out itemID) && uint.TryParse(data2[1], out itemNum))
                {
                    m_lst_UIItemRewardDatas.Add(new UIItemRewardData()
                    {
                        itemID = itemID,
                        num    = itemNum,
                    });
                }
            }
        }
        m_ctor_UIItemRewardCreator.CreateGrids(m_lst_UIItemRewardDatas.Count);
    }
コード例 #20
0
    public void DeleteDataBase(string dataBaseName)
    {
        int index                 = QuestionDataBaseNames.FindIndex(name => name == dataBaseName);
        int iterations            = QuestionDataBaseNames.Count;
        QuestionDataBase database = QuestionDataBases.Find(_database => _database.Name == dataBaseName);

        foreach (Question question in database.Questions)
        {
            PlayerPrefsManager.DeleteQuestionState(index, question);
        }
        PlayerPrefsManager.DeleteQuestionDataBaseName(index);
        PlayerPrefsManager.DeleteQuestionDataBasePath(index);
        PlayerPrefsManager.DeleteQuestionDataBaseTimeSpent(index);
        QuestionDataBaseNames.Remove(dataBaseName);
        RefreshDataBases(iterations);
    }
コード例 #21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         String userName = (String)Session["userName"];
         questionNum          = 100;
         currentQuestionIndex = 1;
         wrongID       = new List <int>();
         user          = new User(userName);
         questionScore = new Boolean[questionNum];
         yourAnswer    = new int[questionNum];
         user.startTestSimulation("c1_1Questions");
         questionData = user.getTest().getQuestionDataInstance();
         showQuestion();
         showQuestionInfo();
         ASPxLabelPeopleInfo1.Text = "考生姓名:" + userName;
     }
 }
コード例 #22
0
    public void AddNewQuestion(QuestionDataBase dataBase, Question newQuestion)
    {
        QuestionDataBase dataBaseToEdit = QuestionDataBases.Find(dbase => dbase.Name == dataBase.Name);
        int index = QuestionDataBaseNames.FindIndex(name => name == dataBaseToEdit.Name);

        if (dataBaseToEdit.Questions.Exists(q => q.QuestionName == newQuestion.QuestionName))
        {
            int existingQuestionIndex = dataBaseToEdit.Questions.FindIndex(q => q.QuestionName == newQuestion.QuestionName);
            dataBaseToEdit.Questions[existingQuestionIndex] = newQuestion;
        }
        else
        {
            dataBaseToEdit.Questions.Add(newQuestion);
        }

        PlayerPrefsManager.SaveQuestionState(index, newQuestion);
        LocalDataManager.SaveQuestion(dataBaseToEdit, newQuestion);
    }
コード例 #23
0
    private void UpdateQuestionDataBases()
    {
        QuestionDataBases.Clear();
        for (var index = 0; index < QuestionDataBaseNames.Count; index++)
        {
            string           questionDataBaseName = QuestionDataBaseNames[index];
            QuestionDataBase newBase = new QuestionDataBase();
            newBase.Name      = questionDataBaseName;
            newBase.Path      = PlayerPrefsManager.GetQuestionDataBasePath(index);
            newBase.TimeSpent = PlayerPrefsManager.GetQuestionDataBaseTimeSpent(index);
            newBase.Questions = LocalDataManager.GetQuestionsFromFolder(newBase.Path);
            foreach (Question question in newBase.Questions)
            {
                question.IsAnswered = PlayerPrefsManager.GetQuestionState(index, question);
            }

            QuestionDataBases.Add(newBase);
        }
    }
コード例 #24
0
ファイル: Game.cs プロジェクト: LukCore95/Testoquest
 public void SetQuestionBase(QuestionDataBase selectedQuestionDataBase)
 {
     _answeredQuestionsNumber = 0;
     _questionRepeats.Clear();
     _selectedQuestionDataBase = selectedQuestionDataBase;
     _allQuestionRepeats       = OptionsManager.Instance.StartingRepeatsPerQuestionsNumber * this._selectedQuestionDataBase.Questions.Count;
     _goodAnswersNumber        = _selectedQuestionDataBase.Questions.FindAll(question => question.IsAnswered).ToList().Count;
     foreach (Question question in this._selectedQuestionDataBase.Questions)
     {
         if (!question.IsAnswered)
         {
             _questionRepeats.Add(new QuestionRepeatsStruct(question, OptionsManager.Instance.StartingRepeatsPerQuestionsNumber));
         }
         else
         {
             _answeredQuestionsNumber++;
         }
     }
     _timeSpent         = this._selectedQuestionDataBase.TimeSpent;
     _timer             = _timeSpent.TotalSeconds;
     TimeSpentText.text = _timeSpent.ToString();
     UpdateProgress();
 }
コード例 #25
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         String userName = (String)Session["userName"];
         user = new User(userName);
         user.startTestWrong("c1_1Questions");
         questionData = user.getTest().getQuestionDataInstance();
         questionNum  = questionData.getSize();
         if (questionNum == 0)
         {
             Response.Write("<script language = javascript>alert('你还没有做错过题!');</script>");
             Response.Write("<script language='javascript'>window.location='ChooseTestModel.aspx'</script>");
         }
         else
         {
             yourAnswer    = new int[questionNum];
             questionScore = new Boolean[questionNum];
             showQuestion();
             showQuestionInfo();
             ASPxLabelPeopleInfo1.Text = "考生姓名:" + userName;
         }
     }
 }
コード例 #26
0
    private void RefreshDataBases(int iterations)
    {
        int index = 0;

        for (var i = 0; i < iterations; i++)
        {
            if (PlayerPrefsManager.CheckQuestionDataBaseNameFromPlayerPrefs(i))
            {
                index++;
                PlayerPrefsManager.DeleteQuestionDataBaseName(i);
                PlayerPrefsManager.DeleteQuestionDataBasePath(i);
            }
        }

        for (var i = 0; i < QuestionDataBaseNames.Count; i++)
        {
            string           dataBaseName = QuestionDataBaseNames[i];
            QuestionDataBase database     = QuestionDataBases.Find(_database => _database.Name == dataBaseName);
            PlayerPrefsManager.SaveQuestionDataBaseNameToPlayerPrefs(i, dataBaseName);
            PlayerPrefsManager.SaveQuestionDataBasePath(database.Path, i);
        }

        UpdateQuestionDataBases();
    }
コード例 #27
0
 private void LoadQuestions()
 {
     m_qDb = QuestionDataBase.Load(Path.Combine(Application.dataPath, m_questionDataBasePath));
 }
コード例 #28
0
 public void SetQuestionToEdit(QuestionDataBase baseToEdit, Question question)
 {
     _dataBase     = baseToEdit;
     _questionName = question.QuestionName;
 }
コード例 #29
0
 public void SetEditBase(QuestionDataBase questionDataBase)
 {
     _baseToEdit        = questionDataBase;
     _baseNameText.text = _baseToEdit.Name;
 }
コード例 #30
0
ファイル: QuestionPanel.cs プロジェクト: zuojiashun/src
    void SetContent(QuestionTab type)
    {
        m_UIXmlRichText.Clear();
        QuestionDataBase db = GameTableManager.Instance.GetTableItem <QuestionDataBase>((uint)type);

        if (db == null)
        {
            Engine.Utility.Log.Error("问卷表格id{0}的数据为空", (uint)type);
            return;
        }

        switch (type)
        {
        case QuestionTab.GongGao:
            m_trans_GongGao.gameObject.SetActive(true);
            m_trans_WenJuan.gameObject.SetActive(false);
            m_trans_FanKui.gameObject.SetActive(false);
            m_label_title.text = db.title;
            string content = db.descr;
            m_UIXmlRichText.AddXml(RichXmlHelper.RichXmlAdapt(content));
            break;

        case QuestionTab.WenJuan_1:
            m_trans_GongGao.gameObject.SetActive(false);
            m_trans_WenJuan.gameObject.SetActive(true);
            m_trans_FanKui.gameObject.SetActive(false);
            m_label_WenJuanText.text = db.descr;
            H5Address = db.H5Address;
            CreateRewardObj(m_trans_WJRewardGrid, db);
            SetWenJuanBtn();
            break;

        case QuestionTab.WenJuan_2:
            m_trans_GongGao.gameObject.SetActive(false);
            m_trans_WenJuan.gameObject.SetActive(true);
            m_trans_FanKui.gameObject.SetActive(false);
            m_label_WenJuanText.text = db.descr;
            H5Address = db.H5Address;
            CreateRewardObj(m_trans_WJRewardGrid, db);
            SetWenJuanBtn();
            break;

        case QuestionTab.WenJuan_3:
            m_trans_GongGao.gameObject.SetActive(false);
            m_trans_WenJuan.gameObject.SetActive(true);
            m_trans_FanKui.gameObject.SetActive(false);
            m_label_WenJuanText.text = db.descr;
            H5Address = db.H5Address;
            CreateRewardObj(m_trans_WJRewardGrid, db);
            SetWenJuanBtn();
            break;

        case QuestionTab.FanKui:
            m_trans_GongGao.gameObject.SetActive(false);
            m_trans_WenJuan.gameObject.SetActive(false);
            m_trans_FanKui.gameObject.SetActive(true);
            m_label_FanKuiText.text = db.descr;
            CreateRewardObj(m_trans_FKRewardGrid, db);
            SetFanKuiBtn();
            break;
        }
    }