示例#1
0
    public static ProblemPart CreateProblemPart(Senseix.Message.Atom.Atom newAtom)
    {
        ProblemPart newProblemPart = new TextProblemPart(newAtom);

        bool actuallyConstructed = false;

        if (newAtom.type == Senseix.Message.Atom.Atom.Type.IMAGE)
        {
            newProblemPart      = new ImageProblemPart(newAtom);
            actuallyConstructed = true;
        }
        if (newAtom.type == Senseix.Message.Atom.Atom.Type.TEXT)
        {
            newProblemPart      = new TextProblemPart(newAtom);
            actuallyConstructed = true;
        }
        if (newAtom.type == Senseix.Message.Atom.Atom.Type.NUMBER)
        {
            newProblemPart      = new NumberProblemPart(newAtom);
            actuallyConstructed = true;
        }
        if (!actuallyConstructed)
        {
            throw new Exception("I encountered an atom of an unimplemented type.");
        }

        return(newProblemPart);
    }
    /// <summary>
    /// Gets distractors.
    /// These are wrong answers which can be presented as options to the player.
    /// </summary>
    /// <returns>The distractors.</returns>
    /// <param name="howManyDistractors">How many random distractors to return.</param>
    public ProblemPart[] GetDistractors(int howManyDistractors)
    {
        int availableDistractors = protobufsProblemData.distractor.distractors.Count;

        if (availableDistractors < howManyDistractors)
        {
            throw new Exception("There aren't enough distractors!  There are only "
                                + availableDistractors + " distractors.");
        }

        ArrayList allDistractors = new ArrayList();

        for (int i = 0; i < availableDistractors; i++)
        {
            Senseix.Message.Atom.Atom distractorAtom = protobufsProblemData.distractor.distractors[i];
            ProblemPart distractor = ProblemPart.CreateProblemPart(distractorAtom);
            allDistractors.Add(distractor);
        }         //find all the distractors

        ProblemPart[] resultDistractors = new ProblemPart[howManyDistractors];
        for (int i = 0; i < howManyDistractors; i++)
        {
            int randomDistractorIndex = UnityEngine.Random.Range(0, allDistractors.Count);
            resultDistractors[i] = (ProblemPart)allDistractors[randomDistractorIndex];
            allDistractors.RemoveAt(randomDistractorIndex);
        }         //take random ones

        return(resultDistractors);
    }
 private string GetImageFilename()
 {
     Senseix.Message.Atom.Atom atom = GetAtom();
     if (atom.filename == "")
     {
         return("dog");
     }
     return(atom.filename);
 }
示例#4
0
 public static ProblemPart CreateProblemPart(string text)
 {
     Senseix.Message.Atom.Atom atom = new Senseix.Message.Atom.Atom();
     atom.data        = BitConverter.GetBytes(404);
     atom.type        = Senseix.Message.Atom.Atom.Type.TEXT;
     atom.text        = text;
     atom.description = "unity-side generated text";
     atom.uuid        = "unity-side generated text";
     atom.required    = false;
     return(CreateProblemPart(atom));
 }
示例#5
0
 public static ProblemPart CreateProblemPart(int number)
 {
     Senseix.Message.Atom.Atom atom = new Senseix.Message.Atom.Atom();
     atom.data        = BitConverter.GetBytes(404);
     atom.type        = Senseix.Message.Atom.Atom.Type.NUMBER;
     atom.numberValue = number;
     atom.description = "unity-side generated number";
     atom.uuid        = "unity-side generated number";
     atom.required    = false;
     return(CreateProblemPart(atom));
 }
    /// <summary>
    /// This will build a text ProblemPart.  Hot tip: numbers are actually text
    /// ProblemParts.  If the text happens to be numbers, it will be treated
    /// as such.
    /// </summary>
    public ProblemPart(string textContent)
    {
        Senseix.Message.Atom.Atom newAtom = new Senseix.Message.Atom.Atom ();

        //forced my hand
        newAtom.uuid = "Developer-side generated problem part";
        newAtom.required = false;

        //text
        newAtom.type = Senseix.Message.Atom.Atom.Type.TEXT;
        newAtom.data = Encoding.ASCII.GetBytes (textContent);
    }
 public ProblemPart GetLearningActionPartByName(string name)
 {
     for (int i = 0; i < GetProto().atoms.Count; i++)
     {
         Senseix.Message.Atom.Atom atom = GetProto().atoms[i];
         if (atom.description.Equals(name))
         {
             return(GetLearningActionPartByIndex(i));
         }
     }
     throw new Exception("There is no problem part by that name in this learning action.");
 }
示例#8
0
    /// <summary>
    /// This will build a text ProblemPart.  Hot tip: numbers are actually text
    /// ProblemParts.  If the text happens to be numbers, it will be treated
    /// as such.
    /// </summary>
    public ProblemPart(string textContent)
    {
        Senseix.Message.Atom.Atom newAtom = new Senseix.Message.Atom.Atom();

        //forced my hand
        newAtom.uuid     = "Developer-side generated problem part";
        newAtom.required = false;

        //text
        newAtom.type = Senseix.Message.Atom.Atom.Type.TEXT;
        newAtom.data = Encoding.ASCII.GetBytes(textContent);
    }
    /// <summary>
    /// This will build an image ProblemPart.  The filename references only
    /// Sprites from resources.
    /// </summary>
    public ProblemPart(string filename, bool isPretty)
    {
        Senseix.Message.Atom.Atom newAtom = new Senseix.Message.Atom.Atom ();

        //forced my hand
        newAtom.uuid = "Developer-side generated problem part";
        newAtom.required = false;
        newAtom.data = new byte[0];

        //text
        newAtom.type = Senseix.Message.Atom.Atom.Type.IMAGE;
        newAtom.filename = filename;
    }
示例#10
0
    /// <summary>
    /// This will build an image ProblemPart.  The filename references only
    /// Sprites from resources.
    /// </summary>
    public ProblemPart(string filename, bool isPretty)
    {
        Senseix.Message.Atom.Atom newAtom = new Senseix.Message.Atom.Atom();

        //forced my hand
        newAtom.uuid     = "Developer-side generated problem part";
        newAtom.required = false;
        newAtom.data     = new byte[0];

        //text
        newAtom.type     = Senseix.Message.Atom.Atom.Type.IMAGE;
        newAtom.filename = filename;
    }
 public ImageProblemPart(Senseix.Message.Atom.Atom atom) : base(atom)
 {
 }
 public static ProblemPart CreateProblemPart(int number)
 {
     Senseix.Message.Atom.Atom atom = new Senseix.Message.Atom.Atom ();
     atom.data = BitConverter.GetBytes (404);
     atom.type = Senseix.Message.Atom.Atom.Type.NUMBER;
     atom.numberValue = number;
     atom.description = "unity-side generated number";
     atom.uuid = "unity-side generated number";
     atom.required = false;
     return CreateProblemPart (atom);
 }
 public ProblemPart(Senseix.Message.Atom.Atom newAtom)
 {
     atom = newAtom;
 }
 public static ProblemPart CreateProblemPart(string text)
 {
     Senseix.Message.Atom.Atom atom = new Senseix.Message.Atom.Atom ();
     atom.data = BitConverter.GetBytes (404);
     atom.type = Senseix.Message.Atom.Atom.Type.TEXT;
     atom.text = text;
     atom.description = "unity-side generated text";
     atom.uuid = "unity-side generated text";
     atom.required = false;
     return CreateProblemPart (atom);
 }
示例#15
0
 public NumberProblemPart(Senseix.Message.Atom.Atom atom) : base(atom)
 {
 }
示例#16
0
 public ProblemPart(Senseix.Message.Atom.Atom newAtom)
 {
     atom = newAtom;
 }