///<summary>
    ///Delete course in database
    ///</summary>
    public async void DeleteCourse()
    {
        loader.SetActive(true);
        Debug.Log("DELETE name: " + courseKey);
        DatabaseQAHandler.DeleteCourse(courseKey, () => { });
        DatabaseQAHandler.GetCourseLvlQns(courseLvlQns =>
        {
            foreach (var courseLvlQn in courseLvlQns)
            {
                //Debug.Log($"{course.Key} {course.Value.userName}");
                if (courseLvlQn.Value.courseName == courseKey) //Find course created by you
                {
                    DatabaseQAHandler.DeleteCourseLvlQn(courseLvlQn.Key, () => { });
                }
            }
        });
        Stopwatch sw    = Stopwatch.StartNew();
        var       delay = Task.Delay(1000).ContinueWith(_ =>
        {
            sw.Stop();
            return(sw.ElapsedMilliseconds);
        });
        await delay;
        int   sec = (int)delay.Result;

        Debug.Log("Delete elapsed milliseconds: {0}" + sec);
        await Read();

        loader.SetActive(false);
        messageBox.SetActive(true);
        messageBox.transform.GetChild(1).GetComponent <Text>().text = courseKey + " deleted successfully.";
        courseKey = null;
    }
    public async Task <bool> CheckLvlExist(int lvlNo)
    {
        DatabaseQAHandler.GetCourseLvlQns(courseLvlQns =>
        {
            foreach (var courseLvlQn in courseLvlQns)
            {
                Debug.Log($"{courseLvlQn.Key} {courseLvlQn.Value.courseName} {courseLvlQn.Value.level}");
                if (/*courseLvlQn.Value.userName == userName &&*/ courseLvlQn.Value.courseName == courseName)
                {
                    if (courseLvlQn.Value.level == lvlNo)
                    {
                        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 level exist elapsed milliseconds: {0}" + sec);
        return(chk);
    }
    ///<summary>
    ///Creating buttons for levels
    ///</summary>
    public async Task Read()
    {
        Debug.Log("READ ");
        int count = itemParent.transform.childCount;

        if (count != null)
        {
            for (int i = 0; i < count; i++)
            {
                Debug.Log("itemparent");
                Destroy(itemParent.transform.GetChild(i).gameObject);
            }
        }
        //Retrieve Courses Created by the Teacher
        DatabaseQAHandler.GetCourseLvlQns(courseLvlQns =>
        {
            foreach (var courseLvlQn in courseLvlQns)
            {
                Debug.Log($"{courseLvlQn.Key} {courseLvlQn.Value.courseName} {courseLvlQn.Value.level}");
                if (courseLvlQn.Value.courseName == courseName)//&& courseLvlQn.Value.userName == userName)
                {
                    GameObject tmp_btn = Instantiate(item, itemParent.transform);
                    tmp_btn.name       = courseLvlQn.Key;
                    Debug.Log("item name: " + tmp_btn.name);
                    Debug.Log("lvl name: " + (courseLvlQn.Value.level).ToString());
                    tmp_btn.transform.GetChild(1).GetComponent <Text>().text = (courseLvlQn.Value.level).ToString();
                }
            }
        });
        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);
    }