Esempio n. 1
0
    protected void btnKnee_Click(object sender, EventArgs e)
    {
        //get the parameters in URL and store there value in global var.
        retrieveURLParameters();



        //Get The Question Number of organs  picked by instructor ( from AITypeQuestion XML file)
        ////Get The Question Number of organs  picked by instructor//////////
        //read in the XML files that contains all organs of a certain body part. e.g., Knee
        XMLHandler xmlHandler = new XMLHandler(Server.MapPath(IPC_QuestionXMLFolder + questionXMLPath + ".xml"));

        //get the number of the Organs whose Question tag are marked "Yes".
        int[] pickedQuestions = xmlHandler.getPickedQuestionNumber();



        //if it's in exam mode.
        if (examMode == "Yes")
        {
            //store the randomized question number to be sending to 3DBuilder.
            string strRandomQuestionNo = "";


            //get the "NameOrNumberAnsweringMode_Session" of the  AITypeQuestion from the AITypeQuestion XML file
            NameOrNumberAnsweringMode_Session = xmlHandler.getValueOfSpecificNonNestedTag("NameOrNumberAnsweringMode");


            //if the AITypeQuestion is set as Number Answering Mode AITypeQuestion
            if (NameOrNumberAnsweringMode_Session == "Number Answering Mode")
            {
                //We Create an array called ‘arr_OrganRearrangedNumber' whose content is "1~number of organs" in the AITypeQuestion XML file, and store the rearranged organ number into the array.
                int[] arr_OrganRearrangedNumber = createArr_OrganRearrangedNumber();

                //Step 2-1 We randomly rearrange all the organ numbers in the AITypeQuestion xml file.
                //shuffle the array of organ number
                shuffleOrganNumber(ref arr_OrganRearrangedNumber);

                //assign an array to RandomQuestionNoSession
                int[] arr_RearrangedPickedOrganNumber = new int[pickedQuestions.Length];


                //Step 2-3 Store the randomly rearranged organ numbers of the organs that are picked as question to ‘RandomQuestionNoSession’.
                for (int i = 0; i < pickedQuestions.Length; i++)
                {
                    //arr_RearrangedPickedOrganNumber[i] = arr_OrganRearrangedNumber[pickedQuestions[i] - 1];
                    arr_RearrangedPickedOrganNumber[i] = pickedQuestions[i];
                }

                //Store the randomly rearranged organ numbers of the organs that are picked as question to ‘RandomQuestionNoSession’.
                RandomQuestionNoSession = arr_RearrangedPickedOrganNumber;

                //When the AITypeQuestion is of 'Number Answering Mode',
                //we need to store the whole randomized organ number for creating a  mapping of organ number and the randomized organ name
                NumberAnsweringMode_WholeRandOrganNo_Session = arr_OrganRearrangedNumber;


                // Step 2-2 Send the randomly rearranged organ numbers result to the 3DBuilder.
                //create randomized  Question Numbers picked by instructor, and change its format for 3DBuilder to read.
                intArray2AString(NumberAnsweringMode_WholeRandOrganNo_Session, ref strRandomQuestionNo);
            }



            //if the AITypeQuestion is set as Name Answering Mode AITypeQuestion
            else if (NameOrNumberAnsweringMode_Session == "Name Answering Mode")
            {
                //randomize the  Question Numbers picked by instructor using student's ID as seed.
                int[] randomQuestionNo = RandomQuestionNo.rand(randomizeSeed, pickedQuestions);


                //send randomized  Question Numbers picked by instructor to IPC.aspx through Session
                RandomQuestionNoSession = randomQuestionNo;


                //create randomized  Question Numbers picked by instructor, and change its format for 3DBuilder to read.
                intArray2AString(randomQuestionNo, ref strRandomQuestionNo);
            }



            //use JS alert() in C#
            //ScriptManager.RegisterStartupScript(this,
            // typeof(Page),
            //"Alert",
            //"<script>alert('" + "3 " + XMLFolder + questionXMLPath+ ".xml" +" "+ strRandomQuestionNo + "');</script>",
            //false);

            //make 3DBuilder load the target Organ XML file and display it
            //and send the random question number to the organs displayed in 3DBuilder
            loadOrganXMLIn3DBuilderForExamMode(strRandomQuestionNo);


            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            Response.Redirect("IPC.aspx?examMode=" + examMode + "&strQID=" + questionXMLPath + "&strUserID=" + strUserID + "&cActivityID=" + cActivityID);
        }

        else//if it's not in exam mode
        {
            //make 3DBuilder load the target Organ XML file and display it
            //because it's not of Exam Mode, so we don't need to send the randomized organ question number to 3DBuilder.
            loadOrganXMLIn3DBuilderFor_Non_ExamMode();

            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            Response.Redirect("IPC.aspx&strQID=" + questionXMLPath + "&strUserID=" + strUserID);
        }
    }
    //originating from Item.aspx btnKnee_Click()
    private void randomizeQuestionOrganNo()
    {
        //These 2 variables will set by URL parameter or data retrieve from DB in the near future.
        ///////////////////////////////////////////////////////////////////////////////

        bool ExamMode = false;//ExamMode的中控

        //2019/4/9 Ben commented for using default URL value if no paras provided.
        //if (Request["examMode"] == "Yes")
        if (examMode == "Yes")
        {
            ExamMode = true;   //ExamMode的中控
        }
        string ID_Num = "234"; //The last 3 digits of student's ID will be retrieved from DB in the near future.

        //int[] pickedQuestions = { 1, 3, 5 }; //The Question Number of organs  picked by instructor will be retrieved from DB in the near future.


        //////////////////////////////////////////////////////////////////////////

        //Get The Question Number of organs  picked by instructor ( from Question XML file)
        int[] pickedQuestions = getPickedQuestionNumber();



        //if it's in exam mode.
        if (ExamMode)
        {
            //randomize the  Question Numbers picked by instructor using student's ID as seed.
            int[] randomQuestionNo = RandomQuestionNo.rand(ID_Num, pickedQuestions);


            //send randomized  Question Numbers picked by instructor to IPC.aspx through Session
            RandomQuestionNoSession = randomQuestionNo;



            //send randomized  Question Numbers picked by instructor to 3DBuilder .
            string strRandomQuestionNo = "";
            intArray2AString(randomQuestionNo, ref strRandomQuestionNo);

            /*
             * //use JS alert() in C#
             * ScriptManager.RegisterStartupScript(this,
             * typeof(Page),
             * "Alert",
             * "<script>alert('" + "3 " + XMLFolder + questionXMLPath +" "+ strRandomQuestionNo + "');</script>",
             * false);
             */


            /*
             * StreamWriter wr = (StreamWriter)Session["Writer"];
             * wr.WriteLine("3 " + absoluteKneeXMLFolder + QuestionFileName + "_" + strRandomQuestionNo);//send protocol,Data to 3DBuilder.
             */

            NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + QuestionFileName + "_" + strRandomQuestionNo);

            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            //Response.Redirect("IPC.aspx?examMode=Yes");
        }

        else//if it's not in exam mode
        {
            NamedPipe_IPC_Connection.sendMsg23DBuilder("3 " + absoluteKneeXMLFolder + QuestionFileName);

            /*
             * StreamWriter wr = (StreamWriter)Session["Writer"];
             * wr.WriteLine("3 " + absoluteKneeXMLFolder + QuestionFileName);//send protocol,Data to 3DBuilder.
             */
            //!!!!//如何將上方兩個參數傳送到3DBuilder那裏的IPCInterface呢? 上行的WriteLine會寫到哪裡呢?

            //head to IPC.aspx
            //Response.Redirect("IPC.aspx");

            ////head to IPC.aspx in exam mode
            //Response.Redirect("IPC.aspx");
        }
    }