Ejemplo n.º 1
0
    ///<summary>
    ///Create rows for the list of questions and answers created
    ///</summary>
    public async Task Read()
    {
        count = 0;
        for (int i = 0; i < itemParent.transform.childCount; i++)
        {
            Destroy(itemParent.transform.GetChild(i).gameObject);
        }
        DatabaseQAHandler.GetCourseLvlQn(key, courseLvlQn =>
        {
            courseLvlQnCreate = courseLvlQn;
            int number        = 1;
            for (int i = 0; i < (courseLvlQn.qns).Count; i++) // Loop through List
            {
                GameObject tmp_item = Instantiate(item, itemParent.transform);
                tmp_item.name       = i.ToString();
                Debug.Log("here item name: " + tmp_item.name);
                tmp_item.transform.GetChild(0).GetComponent <Text>().text = number.ToString();
                tmp_item.transform.GetChild(1).GetComponent <Text>().text = courseLvlQn.qns[i];
                tmp_item.transform.GetChild(2).GetComponent <Text>().text = (courseLvlQn.ans[i]).ToString();
                number++;
                count++;
            }
        });
        Stopwatch sw    = Stopwatch.StartNew();
        var       delay = Task.Delay(1000).ContinueWith(_ =>
        {
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        });
        await delay;
        int   sec = (int)delay.Result;

        Debug.Log("Read elapsed milliseconds: {0}" + sec + "Count:" + count);
    }
Ejemplo n.º 2
0
    ///<summary>
    ///Check for existing question
    ///</summary>
    ///<param name = "qn">Question Input</param>
    public async Task <bool> CheckQnExist(string qn)
    {
        DatabaseQAHandler.GetCourseLvlQn(key, courseLvlQn =>
        {
            //courseLvlQnCreate = courseLvlQn;
            for (int i = 0; i < (courseLvlQn.qns).Count; i++) // Loop through List
            {
                if (qn == courseLvlQn.qns[i])
                {
                    chk = true;
                }
            }
        });
        Stopwatch sw    = Stopwatch.StartNew();
        var       delay = Task.Delay(500).ContinueWith(_ =>
        {
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        });
        await delay;
        int   sec = (int)delay.Result;

        Debug.Log("check qn exist elapsed milliseconds: {0}" + sec + ", Chk is " + chk);
        return(chk);
    }