protected void Page_Load(object sender, EventArgs e)
        {
            ////insert a datum to ScoreDetailTB table
            //string ID = "112";
            //string grade = "\"100/2/50/50\"";
            //Response.Write("<script>console.log(" + CsDBOp.InsertScore(ID, grade) + ");</script>");


            //取得資料
            List <ScoreAnalysisM> ScoreAnalysisList = new List <ScoreAnalysisM>();


            //下方3個變數的值之後會由DB取得
            //get all the data from ScoreDetailTB table
            DataTable dt = CsDBOp.GetAllTBData();


            //get the retrieved data from each row of the retrieved data table.



            ////update a student's grade
            //string aID = "113";
            //string NewGrade = "\"78/5/0/20/20/20/18\"";
            //Response.Write("<script>console.log(" + CsDBOp.UpdateScore(aID, NewGrade) + ");</script>");
            ///////////////////////////////////////



            ////delete a student's grade
            //Response.Write("<script>console.log(" + CsDBOp.DeleteScore(ID) + ");</script>");
        }
示例#2
0
    private void storeAITypeQuestion2DB(string CA, string QBP, string CAO)
    {
        //create Or update required AITypeQuestion attributes in HintsDB
        createOrUpdateAITypeQuestionInHintsDB();


        //store correct answer of the AI type question to DB
        CsDBOp.InsertIPCExamHWCorrectAns(cQID, CA, QBP, CAO);
    }
    //set the remaining time to the timer and check whether time is already up.
    private void setUp_and_CheckCountdownTimer()
    {
        //2019/4/8 Ben commented for using default URL value if no paras provided.

        /*
         * strUserID = Request["strUserID"];
         * string questionXMLPath = Request["strQID"];
         *
         *
         * cActivityID = Request["cActivityID"];
         *
         */
        int remainingTimeSec = CsDBOp.getExamRemainingTime(cActivityID); //now I just hard code it to 15 sec


        if (remainingTimeSec < 0 && remainingTimeSec != -1)
        {
            //Response.Write("<script>alert('考試時間已結束')</script>");

            /*
             * Response.Write("<script>alert('考試時間已結束');location.href='ALHomePage.aspx?strQID=" + strQID + "&strUserID=" + strUserID + "&cActivityID=" + cActivityID + "'</script>");
             */
            //remind the student that the exam is over, and redirect back to Paper_DisplayForORCS.aspx to view the exam paper.
            Response.Write("<script>alert('The exam time is already over.');location.href='" + Previous_Page_URL_Session + "'</script>");
        }

        else if (remainingTimeSec == -1)
        {
            Response.Write("<script>alert('找不到資料');location.href='ALHomePage.aspx?strQID=" + strQID + "&strUserID=" + strUserID + "&cActivityID=" + cActivityID + "' </script>");
        }
        else
        {
            Double   examTimespan     = remainingTimeSec * 1.0;
            DateTime deadlineDateTime = DateTime.Now.AddSeconds(examTimespan); // return Datetime format

            /*psedo code:
             * store deadlineDateTime to DB
             * */
            /*This block should be implemented in the Hints set timer for the exam page
             * */



            /*psedo code
             * retrieve deadlineDateTime from DB,which is stored in the datetime format
             * */
            //check count down timer to decide whether time is already up.
            CheckCountdownTimer(deadlineDateTime);
        }
    }
    //for marking "Name Answering Mode" AITypeQuestion
    public ScoreAnalysisM(string id, string AnswerStr, string QuesOdrStr, List <string> xmlFile, Hashtable[] correctAnswerHT, string cQID, int questionTotalScore, string cActivityID)
    {
        //StuCouHWDe_ID is still used for displaying the result of the Hints program type question.
        //So, although we don't use it for AITypeQuestion, we still need to keep it.
        StuCouHWDe_ID = id;

        cUserID = id;
        string[] AnswerStr_Question  = AnswerStr.Remove(AnswerStr.Length - 1).Split(':');
        string[] QuesOdrStr_Question = QuesOdrStr.Remove(QuesOdrStr.Length - 1).Split(':');
        MemberQuestionNum = new int[AnswerStr_Question.Length];
        QuestionNum       = AnswerStr_Question.Length;
        for (int i = 0; i < AnswerStr_Question.Length; i++)
        {
            string[] AnswerStr_MemQuestion  = AnswerStr_Question[i].Split(',');
            string[] QuesOdrStr_MemQuestion = QuesOdrStr_Question[i].Split(',');
            if (xmlFile[i] != AnswerStr_MemQuestion[0])
            {
                XMLerror = true;
            }
            MemberQuestionNum[i] = QuesOdrStr_MemQuestion.Length - QueIndex_start;
            Grade.Add(new string[QuesOdrStr_MemQuestion.Length]);
            int grade_perQuestion = questionTotalScore / (QuesOdrStr_MemQuestion.Length - 1);
            int correct_num       = 0;
            for (int index = 1; index < QuesOdrStr_MemQuestion.Length; index++)
            {
                int    studentScore;
                string studentAnswer = AnswerStr_MemQuestion[index];
                string correctAnswer = correctAnswerHT[i][QuesOdrStr_MemQuestion[index]].ToString();
                studentScore = grade_perQuestion - CalculateDeductionPoint(correctAnswer.Length, CalculateLevenshteinDistance(correctAnswer, studentAnswer));
                if (studentScore <= 0)
                {
                    Grade[i][index] = "0";
                }
                else
                {
                    Grade[i][index] = studentScore.ToString();
                }
                correct_num++;
            }
            Grade[i][0] = (correct_num * grade_perQuestion).ToString();
        }


        ////In  博宇's implementation

        /*
         * CsDBOp.UpdateScore("StuCouHWDe_IPC", StuCouHWDe_ID, SQLGradeStr_Upgrade(Grade));
         * */
        CsDBOp.UpdateScore("AITypeQuestionStudentAnswer", cUserID, SQLGradeStr_Upgrade(Grade), cQID, cActivityID);
    }
示例#5
0
    //storing AI type question into NewVersionHintsDB QuestionIndex, QuestionMode datatable.
    private void storeAITypeQuestion2HintsDB(string strQID, string strQuestion, string strPaperID)
    {
        //get all the required parameter for storing AI type question into NewVersionHintsDB QuestionIndex, QuestionMode datatable.
        string strQuestionDivisionID = Request.QueryString["strQuestionDivisionID"];
        string strQuestionGroupID    = Request.QueryString["strQuestionGroupID"];
        string strQuestionMode       = Request.QueryString["strQuestionMode"];

        //All the questions need to store a record in QuestionIndex and QuestionMode table.
        //儲存一筆資料至QuestionIndex //
        CsDBOp.saveIntoQuestionIndex(strQID, strQuestion, null, 1);//set sLevel to 1 for the time being because although sLevel ranges from 0 to 12 ,only sLevel == 1 is used in the entire Hints system

        //儲存一筆資料至QuestionMode  //###with parameter "strQuestionType" set to 9 in AITypeQuestion,which is defined in Paper_QuestionTypeNew.aspx to represent the  QuestionType of  AITypeQuestion
        CsDBOp.saveIntoQuestionMode(strQID, strPaperID, strQuestionDivisionID, strQuestionGroupID, strQuestionMode, "9", null, null);

        //儲存一筆資料至Paper_Content //add the AI Type Question to the exam paper.
        CsDBOp.saveToPaper_Content(strPaperID, strQID, "9", strQuestionMode);
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.MaintainScrollPositionOnPostBack = true;



        if (!IsPostBack)
        {
            gvScore.AllowPaging         = false;
            gvScore.AllowSorting        = true;
            gvScore.AutoGenerateColumns = false;
            gvScore.Style.Add("width", "100%");
            gvScore.PageIndex = 0;

            DataSet ds = new DataSet();

            //decide which body part organ xml file should be loaded according to which body part is being used in this question
            decide_QuestionBodyPartOrganXML();

            ds.ReadXml(Server.MapPath(completeBodyPartOrgansXMLPath)); //must synchronized with the XML file in Items.aspx.cs:  wr.WriteLine("3 D:\\Mirac3DBuilder\\HintsAccounts\\Student\\Mirac\\1161-1450\\SceneFile13.xml");//send protocol,Data to 3DBuilder.
            //in Items.aspx.cs

            //DataRow dtRow = dtScore.NewRow();
            //dtRow["Seq"] = "1";
            //dtScore.Rows.Add(dtRow);
            gvScore.DataSource = ds.Tables["Organ"];
            //gvScore.DataMember =
            gvScore.DataBind();
            gvScore.HeaderRow.TableSection = TableRowSection.TableHeader;


            //if the instructor wants to check or modify the existing AITypeQuestion,
            //we retrieve the existing question description and display it for the instructor to modify.
            if (Request.QueryString["viewContent"] != null && Request.QueryString["viewContent"] == "Yes")
            {
                AITypeQuestionDescription.InnerText = CsDBOp.getAITypeQuestion_QuestionDescription(Request.QueryString["strQID"]);
            }



            //store the URL of the previous page to a session var.
            storePreviousPageURL();
        }
    }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //下方3個變數的值之後會由DB取得
            //get all the data from ScoreDetailTB table
            DataTable dt = CsDBOp.GetAllTBData();


            //Get the retrieved data from each row of the retrieved data table.
            foreach (DataRow dr in dt.Rows)
            {
                ScoreAnalysisM log = new ScoreAnalysisM();

                log.StuCouHWDe_ID = dr.Field <string>("StuCouHWDe_ID");
                log.Grade         = dr.Field <string>("Grade").Split(',').ToList <string>();
                log.QuestionNum   = Convert.ToInt16(log.Grade[1]);
                log.Grade.RemoveAt(1);
                ScoreAnalysisList.Add(log);
            }


            //Initalize the member variable

            table_cols  = FirstColDefault.Length + ScoreAnalysisList[0].Grade.Count - 1;
            table_rows  = ScoreAnalysisList.Count;
            studentNum  = table_rows;
            QuestionNum = ScoreAnalysisList[0].Grade.Count - 1;
            // Add a row named Avg
            AddRow("Avg");

            GenerateTable(table_cols, table_rows);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < QuestionNum; i++)
            {
                string temp2;
                temp2 = "['第" + (i + 1) + "題'," + QuestionAvg[i] + "],";
                sb.Append(temp2);
            }
            chart.InnerHtml = "<script>var chart = c3.generate({bindto: '#chart',data: {columns: [" + sb.ToString() + "],type : 'pie'}});</script>";
        }
示例#8
0
    //create Or update required AITypeQuestion attributes in HintsDB
    private void createOrUpdateAITypeQuestionInHintsDB()
    {
        //get all the required parameter for creating a new AITypeQuestion or modifying an existing AITypeQuestion in the NewVersionHintsDB  .
        string strQID      = Request.QueryString["strQID"];
        string strQuestion = AITypeQuestionDescription.InnerText;
        string strPaperID  = Request.QueryString["strPaperID"];

        //When creating a new AITypeQuestion, we must store the AITypeQuestion into NewVersionHintsDB QuestionIndex, QuestionMode,Paper_Content datatable
        //if Request.QueryString["viewContent"] == null means it is a new question rather than an existing one, which is opened again for modification.
        if (Request.QueryString["viewContent"] == null || Request.QueryString["viewContent"] != "Yes")
        {
            storeAITypeQuestion2HintsDB(strQID, strQuestion, strPaperID);
        }

        //When modifying an existing AITypeQuestion, we only need to update the content of the question description textarea.
        //Because the instructor can only modify its question description and the organs that are set as the questions.
        else
        {
            CsDBOp.updateAITypeQuestionDescription_QuestionIndex(strQID, strQuestion, null, 1);
        }
    }
示例#9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //insert a datum to ScoreDetailTB table
        string ID    = "112";
        string grade = "\"100/2/50/50\"";

        Response.Write("<script>console.log(" + CsDBOp.InsertScore(ID, grade) + ");</script>");



        //get all the data from ScoreDetailTB table
        DataTable dt = CsDBOp.GetAllTBData();

        //get the retrieved data from each row of the retrieved data table.
        foreach (DataRow dr in dt.Rows)
        {
            //get the value of field StuCouHWDe_ID from ScoreDetailTB table
            Response.Write("<script>console.log(" + dr.Field <string>("StuCouHWDe_ID") + ");</script> ");

            //get the value of field Grade from ScoreDetailTB table
            Response.Write("<script>console.log(" + dr.Field <string>("Grade") + ");</script> ");
        }



        //update a student's grade
        string aID      = "113";
        string NewGrade = "\"78/5/0/20/20/20/18\"";

        Response.Write("<script>console.log(" + CsDBOp.UpdateScore(aID, NewGrade) + ");</script>");
        /////////////////////////////////////



        //delete a student's grade
        Response.Write("<script>console.log(" + CsDBOp.DeleteScore(ID) + ");</script>");
    }
    private void FinishBtn_ClickEventHandler()
    {
        //commented it for Peter work on storing student's answer to DB
        //Break 3DBuilder connection

        /*
         * Process os = (Process)Session["Process"];
         * os.Kill();
         */
        //2019/4/8 Ben commented for using default URL value if no paras provided.

        /*
         * //get the strUserID and strQID from the URL parameters
         * strUserID = Request["strUserID"];
         * string questionXMLPath = Request["strQID"];
         */


        //Begin: The followings are  for temporary use ,and should be removed before push to github

        //get the Question Number of organs picked by instructor sent from the front end (These Question Numbers are passed by using a hidden field).
        string[] str_pickedQuestions = hidden_pickedQuestions.Value.ToString().Split(",".ToCharArray());
        int[]    pickedQuestions     = Array.ConvertAll <string, int>(str_pickedQuestions, int.Parse);

        string _QuesOrdering = "";

        /*
         * int[] pickedQuestions = { 1, 3, 5 }; //The Question Number of organs  picked by instructor
         * RandomQuestionNoSession = pickedQuestions;
         */
        //End: The followings are  for temporary use ,and should be removed before push to github

        /*
         * String[] values = new String[10];
         * values[0] = this.gvScore.Rows[0].Cells[0].Text.ToString();
         * values[1] = this.gvScore.Rows[0].Cells[1].Text.ToString();
         * values[2] = this.gvScore.Rows[0].Cells[2].Text.ToString();
         * values[3] = this.gvScore.Rows[0].Cells[3].Text.ToString();
         * values[4] = this.gvScore.Rows[0].Cells[4].Text.ToString();
         * values[5] = this.gvScore.Rows[1].Cells[0].Text.ToString();
         * values[6] = this.gvScore.Rows[1].Cells[1].Text.ToString();
         * values[7] = this.gvScore.Rows[1].Cells[2].Text.ToString();
         * values[8] = this.gvScore.Rows[1].Cells[3].Text.ToString();
         * values[9] = this.gvScore.Rows[1].Cells[4].Text.ToString();
         *
         * Session["values"] = values;
         */
        //store student's answer to DB
        if (examMode == "Yes")
        {
            StuAnsM StudentAnswer = new StuAnsM();
            int     RandomQuestionNum; //將題號一個一個取出來
            string  strTB1 = "";       //暫儲存學生每格答案

            /*
             * List<string> StudentAnswerList = new List<string>();//to store student's answer.
             */

            //trim space of QuestionFileName e.g., "   SceneFile_Q12.xml   "=>"SceneFile_Q12.xml"
            QuestionFileName              = QuestionFileName.Trim();
            StudentAnswer._QuesOrdering  += XMLFolder + QuestionFileName + ",";
            StudentAnswer._StudentAnswer += XMLFolder + QuestionFileName + ",";

            for (int i = 0; i < RandomQuestionNoSession.Length; i++)
            {
                RandomQuestionNum = RandomQuestionNoSession[i];

                if (NameOrNumberAnsweringMode_Session == "Name Answering Mode")
                {
                    TextBox tb = (TextBox)gvScore.Rows[RandomQuestionNum - 1].FindControl("TB_AnsweringField");
                    strTB1 = tb.Text.Trim();

                    if (i == (RandomQuestionNoSession.Length - 1))
                    {
                        _QuesOrdering = RandomQuestionNum.ToString();
                        StudentAnswer._StudentAnswer += strTB1;
                    }
                    else
                    {
                        _QuesOrdering = RandomQuestionNum + ",";
                        StudentAnswer._StudentAnswer += strTB1 + ",";
                    }
                }
                else if (NameOrNumberAnsweringMode_Session == "Number Answering Mode")
                {
                    TextBox tb = (TextBox)gvScore.Rows[RandomQuestionNoSession[i] - 1].FindControl("TB_AnsweringField");
                    strTB1 = tb.Text.Trim();



                    if (i == (RandomQuestionNoSession.Length - 1))
                    {
                        _QuesOrdering = NumberAnsweringMode_WholeRandOrganNo_Session[RandomQuestionNum - 1].ToString();
                        StudentAnswer._StudentAnswer += strTB1;
                    }
                    else
                    {
                        _QuesOrdering = NumberAnsweringMode_WholeRandOrganNo_Session[RandomQuestionNum - 1] + ",";
                        StudentAnswer._StudentAnswer += strTB1 + ",";
                    }
                }


                StudentAnswer._QuesOrdering += _QuesOrdering;
            }
            StudentAnswer._QuesOrdering  += ":";
            StudentAnswer._StudentAnswer += ":";



            //foreach (StuAnsM c in StudentAnswerList) //顯示list裡的資料
            //{

            //    Response.Write(c.StudentAnswer + ", " + c.QuesOrdering + " ");
            //}


            //2019/5/8 Ben commented to test Number Answering Mode

            //Insert the student's ID, student's answer, question order of this AITypeQuestion to the NewVestionDB/AITypeQuestionStudentAnswer datatable
            CsDBOp.InsertStuIPCAns(strUserID, strQID, StudentAnswer._QuesOrdering, StudentAnswer._StudentAnswer, cActivityID); //插入學生data至darabase



            //InsertStuIPCAns2DB(strUserID, questionXMLPath, StudentAnswer._QuesOrdering, StudentAnswer._StudentAnswer, Num_Of_Question_Submision_Session);//插入學生data至darabase
            ///////////////////////////////////////
            //DataTable dt = CsDBOp.GetStuIPCAns();
            //StuAnsM Stu_correct_papers = new StuAnsM();
            ////get the retrieved data from each row of the retrieved data table.
            //foreach (DataRow dr in dt.Rows)
            //{
            //    //get the value of field StuCouHWDe_ID from ScoreDetailTB table
            //    Response.Write("<script>console.log(" + dr.Field<string>("StuCouHWDe_ID") + ");</script> ");

            //    //get the value of field Grade from ScoreDetailTB table

            //    IList<string> names = dr.Field<string>("Grade").Split(',').ToList<string>();
            //    //Response.Write("<script>console.log(" + names + ");</script> ");

            //    Response.Write("<script>console.log(" + names[0] + ");</script> ");

            //    //
            //}
        }

        /* foreach (GridViewRow row in gvScore.Rows)
         * {
         *  // TextBox tb = (TextBox)row.FindControl("TextBox_Text");
         *
         * }
         */
        ///your code ......
        ///
        //Peter needs to get content of the first RandomQuestionNoSession.Length TH TextBoxes in the GridView called gvScore.
        //and store them to a List called StudentAnswerList
        //List<string> StudentAnswerList = new List<string>();//to store student's answer.
        //StudentAnswerList.Add(strTB1);

        //RandomQuestionNoSession.Length ==3
        //C# GridView gvScore
        //gvScore.Rows



        //Call all the required functions to clear resources before the user leaves the page, and redirect to the Exam paper page.
        leaveThePage();
    }