//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);
    }
Esempio n. 2
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>");
    }