Return Question Numbers from QAGate Challenge

Oct 28, 2010 at 7:54 PM

Added the following public property to expose the array of "question numbers", synchronized with the "question text" populated by the GateQuestions property.  Without this, there is no way to issue a password reset when there are more questions defined on the server than the count of required answers for the challenge.

This coded was added to the QAGateData class:

public int[] GateQuestionNumbers
        byte[] encodedGateSettingsByteArray = Convert.FromBase64String(_encodedQAGateData);
        String gateSettings = System.Text.UnicodeEncoding.Unicode.GetString(encodedGateSettingsByteArray);
        String[] gateQuestionsWithNumbers = gateSettings.Split('\n');
        int[] gateNumbers = new int[gateQuestionsWithNumbers.Length / 2];
        int gateSettingsCounter = 0;
        for (int c = 0; c < gateQuestionsWithNumbers.Length; c += 2)
            gateNumbers[gateSettingsCounter] = int.Parse(gateQuestionsWithNumbers[c]);
        return gateNumbers;

This follows the same pattern of extraction as the GateQuestions property uses to read the elements from the encoded data.  This class should probably just expose a Dictionary<int, string> for managing the challenge questions.