Example #1
0
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            string[] sentence_separator = new string[3];
            sentence_separator[0] = "I like Rat.";
            sentence_separator[1] = "I will eat Rat.";
            sentence_separator[2] = "I am Cat.";

            correct_answer.Value = "I am Cat.I like Rat.I will eat Rat.";
            int     n     = sentence_separator.Length;
            Label[] Label = new Label[n];
            for (int i = 0; i < sentence_separator.Length; i++)
            {
                Label[i]      = new Label();
                Label[i].Text = sentence_separator[i];
                HtmlGenericControl li = new HtmlGenericControl("li");
                li.Attributes.Add("class", "ui-state-default");
                li.Attributes.Add("id", "LI" + i);
                sortable.Controls.Add(li);
                li.Controls.Add(Label[i]);
            }
        }
        catch { }
    }
Example #2
0
 protected void ASPxCallbackPanelcont_Callback(object sender, CallbackEventArgsBase e)
 {
     ASPxCallbackPanel cbPanel = (ASPxCallbackPanel)sender;
     int         upId          = Convert.ToInt32(e.Parameter.ToString());
     clsUserInfo obj           = clsUserInfo.getData(upId);
     ASPxMemo    ASPxMemoCont  = (ASPxMemo)cbPanel.FindControl("ASPxMemoCont"); ASPxMemoCont.Text = obj.Address;
 }
Example #3
0
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }


            string    sql     = string.Format("SELECT [UID], [GE], [Sentence], [Correct_Answer], [option1],[option2],[option3],[option4],[Sound_FileName] FROM [dbo].[practice] WHERE UID NOT IN (SELECT practiceId from practiceresult where child_id={0})", userInfo.ChildId);
            DataTable dt1     = new DataTable();
            bool      isFound = con.GetData(sql, ref dt1);
            if (isFound)
            {
                UID.Value           = dt1.Rows[0][0].ToString();
                Corret_Answer.Value = dt1.Rows[0][3].ToString();
                // lblquestion.Text = dt1.Rows[0][2].ToString();
                radiovalue[0] = dt1.Rows[0][4].ToString();
                radiovalue[1] = dt1.Rows[0][5].ToString();
                radiovalue[2] = dt1.Rows[0][6].ToString();
                radiovalue[3] = dt1.Rows[0][7].ToString();
                m_FileName    = dt1.Rows[0][8].ToString();
            }
            else
            {
                divcontrol.Visible = false;
                Label1.Text        = "Good Work! You have completed the Test.";
            }
        }
        catch (Exception e)
        {
        }
    }
Example #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int         isansewrcorrect = 0;
        clsUserInfo userInfo        = Session["UserInfo"] as clsUserInfo;
        string      selectedanswer  = selected_answer.Value;
        int         childid         = userInfo.ChildId;

        if (Corret_Answer.Value == selectedanswer)
        {
            isansewrcorrect = 1;
        }
        con.getCon();
        String s = "insert into practiceresult(Child_ID,Selected_Answer,IsAnswerCorrect,practiceId) values (@Child_ID,@Selected_Answer,@IsAnswerCorrect,@practiceId)";

        con.cmd = new SqlCommand(s, con.con);
        con.cmd.Parameters.Add("@Child_ID", SqlDbType.VarChar).Value        = childid;
        con.cmd.Parameters.Add("@Selected_Answer", SqlDbType.VarChar).Value = selectedanswer;
        con.cmd.Parameters.Add("@IsAnswerCorrect", SqlDbType.VarChar).Value = isansewrcorrect;
        con.cmd.Parameters.Add("@practiceId", SqlDbType.VarChar).Value      = UID.Value;
        con.cmd.ExecuteNonQuery();
        System.Threading.Thread.Sleep(1000);

        con.cmd.Dispose();
        con.disCon();
        Response.Redirect("~/practice.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        con.getCon();
        String s = "select * from child where UserName=@user AND Password=@pass";

        con.cmd = new SqlCommand(s, con.con);
        con.cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = UserName.Text;
        con.cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value = Password.Text;
        con.dr = con.cmd.ExecuteReader();
        if (con.dr.HasRows)
        {
            con.dr.Read();
            string      sql      = string.Format("INSERT INTO Student_Session (Child_ID, StartTime, EndTime) VALUES ({0}, GetDate(), NULL)", con.dr["UID"].ToString());
            int         uid      = con.GetIDFromInsert(sql);
            clsUserInfo userInfo = new clsUserInfo();
            userInfo.SessionId = uid;
            userInfo.ChildId   = Convert.ToInt32(con.dr["UID"].ToString());
            userInfo.Grade     = Convert.ToInt32(con.dr["Grade"].ToString());

            userInfo.UserName = UserName.Text;

            Session["UserInfo"] = userInfo;
            Session["username"] = UserName.Text;
            UserName.Text       = "";
            Response.Redirect("default.aspx");
        }
        else
        {
            UserName.Text = "";
            lblMsg.Text   = "Invalid Username or Password";
        }
        con.disCon();
    }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Session["AppID"] = Convert.ToInt64(Request.QueryString["AppID"]); ;
                if (Session["SocietyName"] != null)
                {
                    var txtSocName = FindControl("txtSocietyName") as TextBox;
                    txtSocName.Text = Session["SocietyName"].ToString();
                }



                if (Session["UserID"] != null)
                {
                    //    Session["AppID"] = Convert.ToInt64(DataAccess.ExecSqlScalar("select ApplicationID from Applications where UserId=" + Session["UserID"]));
                    int AppStep = Convert.ToInt16(Session["AppStep"]);// Convert.ToInt16(DataAccess.ExecSqlScalar("select AppStep from Applications where UserId=" + Session["UserID"]));
                    control(AppStep);
                    if (AppStep == 0)
                    {
                        gvUser.ClientSideEvents.Init =
                            "function(s,e)" +
                            "{" +
                            "  grid.AddNewRow();" +
                            "  }";
                    }
                    else
                    {
                        gvUser.FilterExpression = "";
                        gvUser.StartEdit(gvUser.VisibleStartIndex);
                    }
                    pc.ActiveTabIndex = AppStep;

                    if (AppStep >= 2)
                    {
                        int?conMemID  = DataAccess.RunSqlMaxNL("select MemberID from CommitteeMembers where MemberRoleID=4 and ApplicationID=" + Convert.ToInt64(Session["AppID"]));
                        int?presMemID = DataAccess.RunSqlMaxNL("select MemberID from CommitteeMembers where MemberRoleID=5 and ApplicationID=" + Convert.ToInt64(Session["AppID"]));
                        int nom       = Convert.ToInt16(DataAccess.RunSqlMaxNL("select isnull(CommitteeMembers,6) from Applications where ApplicationID=" + Convert.ToInt64(Session["AppID"])));
                        RadioButton6.Checked  = (6 == nom);
                        RadioButton9.Checked  = (9 == nom);
                        RadioButton12.Checked = (12 == nom);
                        if (conMemID != null)
                        {
                            clsUserInfo obj = clsUserInfo.getData(Convert.ToInt16(conMemID));
                            ASPxMemoCont.Text = obj.Address; cbocontactID.Value = conMemID;
                        }
                        if (presMemID != null)
                        {
                            clsUserInfo obj2 = clsUserInfo.getData(Convert.ToInt16(presMemID));
                            ASPxMemoPres.Text = obj2.Address;
                            txtPhone.Text     = obj2.PhoneNo; cbopres.Value = presMemID;
                        }
                    }
                }
                else
                {
                    Response.Redirect("frmLogin.aspx");
                }
            }
        }
    protected void Button1_Click(object sender, EventArgs e)
    {
        con.getCon();
        String s = "select * from child where UserName=@user AND Password=@pass";
        con.cmd = new SqlCommand(s, con.con);
        con.cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = UserName.Text;
        con.cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value = Password.Text;
        con.dr = con.cmd.ExecuteReader();
        if (con.dr.HasRows)
        {
            con.dr.Read();
            string sql =string.Format("INSERT INTO Student_Session (Child_ID, StartTime, EndTime) VALUES ({0}, GetDate(), NULL)", con.dr["UID"].ToString());
            int uid = con.GetIDFromInsert(sql);
            clsUserInfo userInfo = new clsUserInfo();
            userInfo.SessionId = uid;
            userInfo.ChildId = Convert.ToInt32(con.dr["UID"].ToString());
            userInfo.Grade = Convert.ToInt32(con.dr["Grade"].ToString());

            userInfo.UserName = UserName.Text;

            Session["UserInfo"] = userInfo;
            Session["username"] = UserName.Text;
            UserName.Text = "";
            Response.Redirect("default.aspx");
        }
        else
        {
            UserName.Text = "";
            lblMsg.Text = "Invalid Username or Password";
        }
        con.disCon();

    }
        /// <summary>
        /// 部分修改保存
        /// </summary>
        /// <param name="model">对象clsUserInfo的一个实例参数</param>
        /// <returns></returns>
        public int UpdatePart(clsUserInfo model, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn = 0;

            try
            {
                string updateSql = "update tUserInfo set "
                                   + "LoginID='" + model.LoginID + "',"
                                   + "[Name]='" + model.Name + "',"
                                   + "[PassWord]='" + model.PassWord + "',"
                                   + "UnitCode='" + model.UnitCode + "',"
                                   //+ "WebLoginID='" + model.WebLoginID + "',"
                                   //+ "WebPassWord='******',"
                                   + "IsAdmin=" + model.IsAdmin + ","
                                   + "IsLock=" + model.IsLock + ","
                                   + "Remark='" + model.Remark + "'"
                                   + " where UserCode='" + model.UserCode + "' ";
                DataBase.ExecuteCommand(updateSql, out errMsg);

                rtn = 1;
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }

            return(rtn);
        }
        /// <summary>
        /// 插入一条明细记录
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public int Insert(clsUserInfo userModel, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn = 0;

            try
            {
                //WebLoginID,WebPassWord,
                //+ userModel.WebLoginID + "','"
                //+ userModel.WebPassWord + "',"
                string insertSql = "INSERT INTO tUserInfo(UserCode,[LoginID],[Name],[PassWord],UnitCode,IsAdmin,IsLock,[Remark])"
                                   + " VALUES('"
                                   + userModel.UserCode + "','"
                                   + userModel.LoginID + "','"
                                   + userModel.Name + "','"
                                   + userModel.PassWord + "','"
                                   + userModel.UnitCode + "',"
                                   + userModel.IsAdmin + ","
                                   + userModel.IsLock + ",'"
                                   + userModel.Remark + "')";
                DataBase.ExecuteCommand(insertSql, out errMsg);

                rtn = 1;
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }

            return(rtn);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btnPrevTest.Visible = true;
            if (Session["username"] == null)
            {
                Response.Redirect("/login.aspx");
            }

            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo != null)
            {
                string    sql = string.Format("SELECT UID, [SessionState] FROM [Student_log] WHERE [Child_ID]={0} ORDER BY UID DESC", userInfo.ChildId);
                DataTable dt  = new DataTable();

                bool IsFound = conn.GetData(sql, ref dt);
                if (IsFound)
                {
                    int state = Convert.ToInt32(dt.Rows[0][1].ToString());
                    if (state == 0)
                    {
                        btnPrevTest.Visible = true;
                        userInfo.LogId      = Convert.ToInt32(dt.Rows[0][0].ToString());
                    }
                }
                else
                {
                    btnPrevTest.Visible = false;
                }
            }
        }
    }
Example #11
0
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            int ge = 0;
            int lastAnswerCorrect = 0;
            int questionType      = 0;

            string    sql     = string.Format("SELECT [UID], [currentQuestionType], [currentQuestionNo], [currentGE], [last_answer_correct] FROM [dbo].[Student_log] WHERE UID={0}", userInfo.LogId);
            DataTable dt1     = new DataTable();
            bool      isFound = con.GetData(sql, ref dt1);
            if (isFound)
            {
                lastAnswerCorrect = Convert.ToInt32(dt1.Rows[0][4].ToString().Trim());
                ge           = Convert.ToInt32(dt1.Rows[0][3].ToString().Trim());
                questionType = Convert.ToInt32(dt1.Rows[0][1].ToString().Trim());
            }

            QuestionType.Value = questionType.ToString();

            if (lastAnswerCorrect == 1)
            {
                sql = string.Format("select UID, GE, option1, option2, option3, option4, option5, option6, option7, Correct_Answer, audioFileName FROM mcq_decodable_words_audio where GE>={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE", ge, userInfo.ChildId, questionType);
            }
            else
            {
                sql = string.Format("select UID, GE, option1, option2, option3, option4, option5, option6, option7, Correct_Answer, audioFileName FROM mcq_decodable_words_audio where GE<={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE DESC", ge, userInfo.ChildId, questionType);
            }
            DataTable dt = new DataTable();

            bool IsFound = con.GetData(sql, ref dt);
            if (IsFound)
            {
                start_time.Value = DateTime.Now.ToString();
                UID.Value        = dt.Rows[0][0].ToString();

                radiovalue[0] = dt.Rows[0][2].ToString();
                radiovalue[1] = dt.Rows[0][3].ToString();
                radiovalue[2] = dt.Rows[0][4].ToString();
                radiovalue[3] = dt.Rows[0][5].ToString();
                radiovalue[4] = dt.Rows[0][6].ToString();
                radiovalue[5] = dt.Rows[0][7].ToString();
                radiovalue[6] = dt.Rows[0][8].ToString();
                m_FileName    = dt.Rows[0][10].ToString();
                // lblCorrectAnswer.Text = dt.Rows[0][9].ToString();
            }
        }
        catch (Exception e)
        {
        }
    }
Example #12
0
        protected void ASPxCallbackcon_Callback(object sender, CallbackEventArgsBase e)
        {
            ASPxCallbackPanel cbPanel = (ASPxCallbackPanel)sender;
            int         upId          = Convert.ToInt32(e.Parameter.ToString());
            clsUserInfo obj2          = clsUserInfo.getData(upId);
            ASPxTextBox txtPhone      = (ASPxTextBox)cbPanel.FindControl("txtPhone");
            ASPxMemo    ASPxMemoPres  = (ASPxMemo)cbPanel.FindControl("ASPxMemoPres");

            txtPhone.Text = obj2.PhoneNo; ASPxMemoPres.Text = obj2.Address;
        }
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            int ge = 0;
            int lastAnswerCorrect = 0;
            int questionType      = 0;

            string    sql     = string.Format("SELECT [UID], [currentQuestionType], [currentQuestionNo], [currentGE], [last_answer_correct] FROM [dbo].[Student_log] WHERE UID={0}", userInfo.LogId);
            DataTable dt1     = new DataTable();
            bool      isFound = con.GetData(sql, ref dt1);
            if (isFound)
            {
                lastAnswerCorrect = Convert.ToInt32(dt1.Rows[0][4].ToString().Trim());
                ge           = Convert.ToInt32(dt1.Rows[0][3].ToString().Trim());
                questionType = Convert.ToInt32(dt1.Rows[0][1].ToString().Trim());
            }

            QuestionType.Value = questionType.ToString();

            if (lastAnswerCorrect == 1)
            {
                sql = string.Format("select UID, GE, Sentences, Correct_Answer,Sound_FileName FROM word_scramble where GE>={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE", ge, userInfo.ChildId, questionType);
            }
            else
            {
                sql = string.Format("select UID, GE, Sentences, Correct_Answer,Sound_FileName FROM word_scramble where GE<={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE DESC", ge, userInfo.ChildId, questionType);
            }
            DataTable dt      = new DataTable();
            string    word    = "";
            bool      IsFound = con.GetData(sql, ref dt);
            if (IsFound)
            {
                word             = dt.Rows[0][2].ToString();
                start_time.Value = DateTime.Now.ToString();
                UID.Value        = dt.Rows[0][0].ToString();
                m_FileName       = dt.Rows[0][4].ToString();
                string answer = dt.Rows[0][3].ToString();
                answerlength.Value = answer.Length.ToString();
                anslength          = answer.Length * 50 + "px";
                LoadEmptyBox(answer);
            }
            LoadWord(word);
        }
        catch (Exception e)
        {
        }
    }
    private int GetGEFromType(int quetionType)
    {
        int         ge        = 0;
        clsUserInfo userInfo  = Session["UserInfo"] as clsUserInfo;
        string      fieldName = "";

        if (userInfo != null)
        {
            switch (quetionType)
            {
            case 1:
                fieldName = "Letter_GE";
                break;

            case 2:
                fieldName = "Sound_GE";
                break;

            case 3:
                fieldName = "mcq_decodable_words_audio_GE";
                break;

            case 4:
                fieldName = "mcq_nondecodable_words_audio_GE";
                break;

            case 5:
                fieldName = "word_scramble_GE";
                break;

            case 6:
                fieldName = "sentence_GE";
                break;

            case 7:
                fieldName = "m_sentences_GE";
                break;

            default:
                break;
            }

            string    sql = string.Format("SELECT {0} FROM Difficulty_level_Grade WHERE Grade={1}", fieldName, userInfo.Grade);
            DataTable dt  = new DataTable();

            bool IsFound = conn.GetData(sql, ref dt);
            if (IsFound)
            {
                ge = Convert.ToInt32(dt.Rows[0][0].ToString());
            }
        }
        return(ge);
    }
        /// <summary>
        /// 获取用户实例
        /// </summary>
        /// <param name="whereSql"></param>
        /// <returns></returns>
        public clsUserInfo GetInfo(string whereSql)
        {
            string      errMsg   = string.Empty;
            DataTable   dt       = null;
            clsUserInfo userInfo = null;

            try
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("SELECT UserCode,LoginID,Name,PassWord,UnitCode,WebLoginID,WebPassWord,IsLock,IsAdmin,Remark FROM tUserInfo");
                //string selectSql = "select UserCode,LoginID,Name,PassWord,UnitCode,WebLoginID,WebPassWord,IsLock,IsAdmin,Remark"
                //        + " from tUserInfo";

                if (!whereSql.Equals(""))
                {
                    sb.Append(" WHERE ");
                    sb.Append(whereSql);
                    // selectSql += " where " + whereSql;
                }

                string[] cmd = new string[1] {
                    sb.ToString()
                };
                //sCmd[0] = selectSql;
                string[] names = new string[1] {
                    "UserInfo"
                };
                // sNames[0] = "UserInfo";
                dt = DataBase.GetDataSet(cmd, names, out errMsg).Tables["UserInfo"];
                if (dt.Rows.Count > 0)
                {
                    userInfo             = new clsUserInfo();
                    userInfo.UserCode    = dt.Rows[0]["UserCode"].ToString();
                    userInfo.LoginID     = dt.Rows[0]["LoginID"].ToString();
                    userInfo.Name        = dt.Rows[0]["Name"].ToString();
                    userInfo.PassWord    = dt.Rows[0]["PassWord"].ToString();
                    userInfo.UnitCode    = dt.Rows[0]["UnitCode"].ToString();
                    userInfo.WebLoginID  = dt.Rows[0]["WebLoginID"].ToString();
                    userInfo.WebPassWord = dt.Rows[0]["WebPassWord"].ToString();
                    userInfo.Remark      = dt.Rows[0]["Remark"].ToString();
                    userInfo.IsLock      = Convert.ToBoolean(dt.Rows[0]["IsLock"]);
                    userInfo.IsAdmin     = Convert.ToBoolean(dt.Rows[0]["IsAdmin"]);
                }
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }

            return(userInfo);
        }
Example #16
0
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            char[] letterArray = new char[3];

            letterArray[0] = 'o';
            letterArray[1] = 'd';
            letterArray[2] = 'g';


            string answer = "dog";

            LoadEmptyBox(answer);
            correct_answer.Value = answer;
            answerlength.Value   = answer.Length.ToString();
            anslength            = answer.Length * 50 + "px";
            int     n     = letterArray.Length;
            Label[] Label = new Label[n];

            for (int i = 0; i < letterArray.Length; i++)
            {
                Label[i]      = new Label();
                Label[i].Text = "" + letterArray[i];
                HtmlGenericControl li = new HtmlGenericControl("li");
                li.Attributes.Add("class", "ui-state-default");
                li.Attributes.Add("id", "LI" + i);

                drop.Controls.Add(li);
                li.Controls.Add(Label[i]);
            }
        }
        catch (Exception e)
        {
        }
    }
Example #17
0
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            radiovalue[0] = "A";
            radiovalue[1] = "B";
            radiovalue[2] = "C";
            radiovalue[3] = "D";
            radiovalue[4] = "E";

            // lblCorrectAnswer.Text = "B";
            correct_answer.Value = "C";
        }
        catch { }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;

            DateTime starttime = Convert.ToDateTime(start_time.Value);
            DateTime endTime   = DateTime.Now;
            TimeSpan span      = endTime.Subtract(starttime);
            int      timeTaken = span.Seconds + (span.Minutes * 60);

            string selectedanswer = selected_answer.Value;
            int    uid            = Convert.ToInt32(UID.Value);
            int    questionType   = Convert.ToInt32(QuestionType.Value);
            Utils.UpdateViewLog(userInfo.ChildId, questionType, uid);

            string pageName = string.Format("/UpdateQuestion.aspx?QuestionType={0}&QuestionId={1}&selectedAnswer={2}&timeTaken={3}", questionType, uid, selectedanswer, timeTaken);
            Response.Redirect(pageName);
        }
        catch { }
    }
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            string[] letterArray = new string[3];
            letterArray[0]       = "am";
            letterArray[1]       = "happy";
            letterArray[2]       = "I";
            correct_answer.Value = "I am happy";


            int     n     = letterArray.Length;
            Label[] Label = new Label[n];

            for (int i = 0; i < letterArray.Length; i++)
            {
                if (letterArray[i] != "")
                {
                    Label[i]      = new Label();
                    Label[i].Text = "" + letterArray[i];
                    HtmlGenericControl li = new HtmlGenericControl("li");
                    li.Attributes.Add("class", "ui-state-default");
                    li.Attributes.Add("id", "LI" + i);

                    sortable.Controls.Add(li);
                    li.Controls.Add(Label[i]);
                }
                // Here you can modify the value of the label which is at labels[i]
            }
        }
        catch (Exception e)
        {
        }
    }
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }
            radiovalue[0] = "Pird";
            radiovalue[1] = "Durb";
            radiovalue[2] = "Bird";
            radiovalue[3] = "Lerd";
            radiovalue[4] = "Brid";
            radiovalue[5] = "Bidd";
            radiovalue[6] = "Fly";

            //lblCorrectAnswer.Text = "T";
            correct_answer.Value = "Bird";
        }
        catch { }
    }
    protected void btnNewTest_Click(object sender, EventArgs e)
    {
        clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;

        if (userInfo != null)
        {
            string    sql1     = "select top 1 session_id from student_log  order by Session_ID desc ";
            DataTable dt1      = new DataTable();
            string    sql      = "SELECT Sound_GE FROM  [Difficulty_level_Grade] Where Grade='" + userInfo.Grade + "'";
            DataTable dt       = new DataTable();
            bool      IsFound1 = conn.GetData(sql1, ref dt1);
            if (IsFound1)
            {
                try
                {
                    int sessionId = Convert.ToInt32(dt1.Rows[0][0].ToString());
                    if (userInfo.SessionId > sessionId)
                    {
                        sql1 = " delete from student_viewlog";
                        conn.ExecuteQuery(sql1);
                    }
                }
                catch { }
            }

            int  ge      = 0;
            bool IsFound = conn.GetData(sql, ref dt);
            if (IsFound)
            {
                ge  = Convert.ToInt32(dt.Rows[0][0].ToString());
                sql = string.Format("INSERT INTO Student_log (Session_ID, Child_ID, TestStartTime, SessionState, currentQuestionType, currentQuestionNo, currentGE, last_answer_correct) VALUES({0},{1},GETDATE(),0, {2}, {3}, {4}, 1)", userInfo.SessionId, userInfo.ChildId, 1, 1, ge);
                int logId = conn.GetIDFromInsert(sql);
                userInfo.LogId = logId;
                Response.Redirect("~/letter_id_training1.aspx");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] == null)
        {
            Response.Redirect("/login.aspx");
        }

        try
        {
            int    quetionType    = Convert.ToInt32(Request.QueryString["QuestionType"]);
            int    questionId     = Convert.ToInt32(Request.QueryString["QuestionId"]);
            string selectedAnswer = Request.QueryString["SelectedAnswer"].ToString();
            int    timeTaken      = Convert.ToInt32(Request.QueryString["timeTaken"].ToString());


            clsUserInfo userInfo  = Session["UserInfo"] as clsUserInfo;
            string      tableName = "";
            string      pageName  = "";
            if (userInfo != null)
            {
                switch (quetionType)
                {
                case 1:
                    tableName = "Letter_ID";
                    break;

                case 2:
                    tableName = "Sound_ID";
                    break;

                case 3:
                    tableName = "mcq_decodable_words_audio";
                    break;

                case 4:
                    tableName = "mcq_nondecodable_words_audio";
                    break;

                case 5:
                    tableName = "word_scramble";
                    break;

                case 6:
                    tableName = "sentence";
                    break;

                case 7:
                    tableName = "m_sentences";

                    break;

                //case 1:
                //    tableName = "Sound_ID";
                //    break;
                //case 2:
                //    tableName = "Letter_ID";
                //    break;
                //case 3:
                //    tableName = "m_sentences";
                //    break;
                //case 4:
                //    tableName = "sentence";
                //    break;
                //case 5:
                //    tableName = "word_scramble";
                //    break;
                //case 6:
                //    tableName = "mcq_decodable_words_audio";
                //    break;
                //case 7:
                //    tableName = "mcq_nondecodable_words_audio";
                //    break;
                default:
                    break;
                }


                string    sql       = string.Format("SELECT UID, GE, Correct_Answer FROM {0} WHERE UID={1}", tableName, questionId);
                DataTable dt        = new DataTable();
                int       ge        = 0;
                int       IsCorrect = 0;
                bool      IsFound   = conn.GetData(sql, ref dt);
                if (IsFound)
                {
                    int       positivejump = 0;
                    int       negativejump = 0;
                    DataTable dt1          = new DataTable();
                    string    sql1         = string.Format("SELECT Positivejump, NegativeJump FROM GradeJump WHERE Grade={0} and QuestionType={1}", userInfo.Grade, quetionType);
                    bool      IsFound1     = conn.GetData(sql1, ref dt1);
                    if (IsFound1)
                    {
                        positivejump = Convert.ToInt32(dt1.Rows[0][0].ToString());
                        negativejump = Convert.ToInt32(dt1.Rows[0][1].ToString());
                    }
                    ge = Convert.ToInt32(dt.Rows[0][1].ToString());
                    string correctanswer = dt.Rows[0][2].ToString();

                    if (quetionType == 6 || quetionType == 7)
                    {
                        string x = string.Join(" ", Regex.Split(correctanswer, @"(?:\r\n|\n|\r)"));
                        string correctanswer1  = x.Replace(" ", "");
                        string selectedAnswer1 = selectedAnswer.Replace(" ", "");
                        if (correctanswer1 == selectedAnswer1)
                        {
                            IsCorrect = 1;
                            ge        = ge + positivejump;
                        }
                        else
                        {
                            IsCorrect = 0;
                            ge        = ge - negativejump;
                        }
                    }
                    else
                    {
                        if (correctanswer == selectedAnswer)
                        {
                            IsCorrect = 1;
                            ge        = ge + positivejump;
                        }
                        else
                        {
                            IsCorrect = 0;
                            ge        = ge - negativejump;
                        }
                    }
                }


                sql = "select currentQuestionType, currentQuestionNo, currentGE from Student_log where UID=" + userInfo.LogId;
                dt  = new DataTable();

                int currentQuestionType = 0;
                int currentQuestionNo   = 0;
                IsFound = conn.GetData(sql, ref dt);
                if (IsFound)
                {
                    currentQuestionNo   = Convert.ToInt32(dt.Rows[0][1].ToString());
                    currentQuestionType = Convert.ToInt32(dt.Rows[0][0].ToString());
                }

                sql = string.Format("UPDATE Student_log SET  {0}_question_{1}_uid={2}, {0}_question_{1}_selected_answer='{3}', {0}_question_{1}_answer_correct={4}, {0}_question_{1}_total_time={5} WHERE UID={6}", tableName, currentQuestionNo, questionId, selectedAnswer, IsCorrect, timeTaken, userInfo.LogId);
                conn.ExecuteQuery(sql);

                currentQuestionNo++;
                if (currentQuestionNo > 7)
                {
                    currentQuestionNo = 1;
                    currentQuestionType++;
                    ge = GetGEFromType(currentQuestionType);
                }



                sql = string.Format("UPDATE Student_log SET currentQuestionType={0}, currentQuestionNo={1}, currentGE={2},last_answer_correct={4} WHERE UID={3}", currentQuestionType, currentQuestionNo, ge, userInfo.LogId, IsCorrect);
                conn.ExecuteQuery(sql);

                //----Check next question-------
                int lastAnswerCorrect = 0;
                int questionType      = 0;

                string    sql2    = string.Format("SELECT [UID], [currentQuestionType], [currentQuestionNo], [currentGE], [last_answer_correct] FROM [dbo].[Student_log] WHERE UID={0}", userInfo.LogId);
                DataTable dt2     = new DataTable();
                bool      isFound = conn.GetData(sql2, ref dt2);
                if (isFound)
                {
                    lastAnswerCorrect = Convert.ToInt32(dt2.Rows[0][4].ToString().Trim());
                    ge           = Convert.ToInt32(dt2.Rows[0][3].ToString().Trim());
                    questionType = Convert.ToInt32(dt2.Rows[0][1].ToString().Trim());
                }

                if (lastAnswerCorrect == 1)
                {
                    sql = string.Format("select GE, UID from {3} where GE>={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE", ge, userInfo.ChildId, questionType, tableName);
                }
                else
                {
                    sql = string.Format("select GE, UID from {3} where GE<={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE DESC", ge, userInfo.ChildId, questionType, tableName);
                }
                DataTable dt3 = new DataTable();

                bool IsFound2 = conn.GetData(sql, ref dt3);
                if (!IsFound2)
                {
                    currentQuestionNo = 1;
                    currentQuestionType++;
                    ge  = GetGEFromType(currentQuestionType);
                    sql = string.Format("UPDATE Student_log SET currentQuestionType={0}, currentQuestionNo={1}, currentGE={2},last_answer_correct={4} WHERE UID={3}", currentQuestionType, currentQuestionNo, ge, userInfo.LogId, IsCorrect);
                    conn.ExecuteQuery(sql);
                    pageName = GetPageName(currentQuestionType);
                }
                else
                {
                    if (currentQuestionNo != 1)
                    {
                        switch (currentQuestionType)
                        {
                        case 1:
                            pageName = "letter_id.aspx";
                            break;

                        case 2:
                            pageName = "sound_id.aspx";
                            break;

                        case 3:
                            pageName = "test_mcq_audio.aspx";
                            break;

                        case 4:
                            pageName = "test_mcq_non-decodable.aspx";
                            break;

                        case 5:
                            pageName = "final_ls.aspx";
                            break;

                        case 6:
                            pageName = "Sentence.aspx";
                            break;

                        case 7:
                            pageName = "m_sentences.aspx";
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        pageName = GetPageName(currentQuestionType);
                    }
                }
                if (pageName == "")
                {
                    lblend.Text = "Good Work!   You have completed the Letters2Meaning game. ";
                }
                else
                {
                    Response.Redirect(pageName);
                }
            }
        }
        catch (Exception)
        {
        }
    }
    private void LoadQuestion()
    {
        try
        {
            clsUserInfo userInfo = Session["UserInfo"] as clsUserInfo;
            if (userInfo == null)
            {
                Response.Redirect("/login.aspx");
            }

            int ge = 0;
            int lastAnswerCorrect = 0;
            int questionType      = 0;

            string    sql     = string.Format("SELECT [UID], [currentQuestionType], [currentQuestionNo], [currentGE], [last_answer_correct] FROM [dbo].[Student_log] WHERE UID={0}", userInfo.LogId);
            DataTable dt1     = new DataTable();
            bool      isFound = con.GetData(sql, ref dt1);
            if (isFound)
            {
                lastAnswerCorrect = Convert.ToInt32(dt1.Rows[0][4].ToString().Trim());
                ge           = Convert.ToInt32(dt1.Rows[0][3].ToString().Trim());
                questionType = Convert.ToInt32(dt1.Rows[0][1].ToString().Trim());
            }

            QuestionType.Value = questionType.ToString();

            if (lastAnswerCorrect == 1)
            {
                sql = string.Format("select GE,Correct_Answer,Sound_FileName, UID from Letter_ID where GE>={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE", ge, userInfo.ChildId, questionType);
            }
            else
            {
                sql = string.Format("select GE,Correct_Answer,Sound_FileName, UID from Letter_ID where GE<={0} and uid NOT IN (Select QuestionId From Student_ViewLog Where Child_Id={1} AND QuestionType={2}) ORDER BY GE DESC", ge, userInfo.ChildId, questionType);
            }
            DataTable dt = new DataTable();

            bool IsFound = con.GetData(sql, ref dt);
            if (IsFound)
            {
                sound_id.Value   = dt.Rows[0][0].ToString();
                start_time.Value = DateTime.Now.ToString();
                str        = dt.Rows[0][1].ToString().ToCharArray(); // myReader["Correct_Answer"].ToString().ToCharArray();
                m_FileName = dt.Rows[0][2].ToString();
                //lblCorrectAnswer.Text = str[0].ToString();
                UID.Value = dt.Rows[0][3].ToString();
            }
        }
        catch (Exception e)
        {
        }
        try
        {
            char[] a = RandomString(str[0]).ToCharArray();
            m_Question = new List <string>();
            foreach (var item in a)
            {
                m_Question.Add(item.ToString());
            }
        }
        catch { }
    }