public static bool CheckAnswer(Message.Problem.ProblemData answeredProblemData, Answer answer)
        {
            bool correct = true;
            //get correct answer IDs
            Message.Problem.AnswerIdentifier correctIDList = new Message.Problem.AnswerIdentifier ();
            foreach(Senseix.Message.Atom.Atom atom in answeredProblemData.answer.answers)
            {
                correctIDList.uuid.Add(atom.uuid);
            }

            //bail out if we have the wrong number of answers
            List<string> answerIDStrings = new List<string>(answer.GetAnswerIDs ());
            if (answerIDStrings.Count != correctIDList.uuid.Count)
                return false;

            //sort the lists to eliminate order discrepencies
            correctIDList.uuid.Sort ();
            answerIDStrings.Sort ();

            //check given answers against correct answers
            for (int i = 0; i < answerIDStrings.Count; i++)
            {
                correct = correct && (correctIDList.uuid[i] == (string)answerIDStrings[i]);
            }

            return correct;
        }
Beispiel #2
0
        static public bool CheckAnswer(Message.Problem.ProblemData answeredProblemData, Answer answer)
        {
            bool correct = true;

            //get correct answer IDs
            Message.Problem.AnswerIdentifier correctIDList = new Message.Problem.AnswerIdentifier();
            foreach (Senseix.Message.Atom.Atom atom in answeredProblemData.answer.answers)
            {
                correctIDList.uuid.Add(atom.uuid);
            }

            //bail out if we have the wrong number of answers
            List <string> answerIDStrings = new List <string>(answer.GetAnswerIDs());

            if (answerIDStrings.Count != correctIDList.uuid.Count)
            {
                return(false);
            }

            //sort the lists to eliminate order discrepencies
            correctIDList.uuid.Sort();
            answerIDStrings.Sort();

            //check given answers against correct answers
            for (int i = 0; i < answerIDStrings.Count; i++)
            {
                correct = correct && (correctIDList.uuid[i] == (string)answerIDStrings[i]);
            }

            return(correct);
        }