Exemplo n.º 1
0
  public void init(Object context) {

    // load data into various data structures

    // TODO: load results from a data file instead of static list
    results = new Vector();
    Hashtable h = new Hashtable();
    h.put("date", "08/09/2015");
    h.put("topics", "White-Green Kicks, Punches, Strikes");
    h.put("score", "95%");
    results.addElement(h);

    h = new Hashtable();
    h.put("date", "07/15/2015");
    h.put("topics", "Green Concepts, Punches, Strikes");
    h.put("score", "100%");
    results.addElement(h);

    h = new Hashtable();
    h.put("date", "07/15/2015");
    h.put("topics", "Green Concepts, Punches, Strikes");
    h.put("score", "100%");
    results.addElement(h);

    h = new Hashtable();
    h.put("date", "07/15/2015");
    h.put("topics", "Green Concepts, Punches, Strikes");
    h.put("score", "100%");
    results.addElement(h);

    h = new Hashtable();
    h.put("date", "07/15/2015");
    h.put("topics", "Green Concepts, Punches, Strikes");
    h.put("score", "100%");
    results.addElement(h);

    // manually load some test data for now
    moduleSet = new ModuleSet();

    Category c;
    Testable t;
    Learnable l;
    Vector<Testable> qList;

    Module m =
        new Module(
            "white_to_yellow",
            "white_to_yellow.png",
            "White to Yellow",
            "Requirements for White Belts to earn their Yellow Belt",
            false);

    c = new Category("blocks", "blocks.png", "Blocks");

    m.addCategory(c);

    t = new Testable("Which block is an outwards middle block?", null);
    t.addAnswer(true, "Soto-uke");
    t.addAnswer(false, "Ucki-uke");
    t.addAnswer(false, "Soto-uchi");
    t.addAnswer(false, "Gedan-barai");

    qList = new Vector<Testable>();
    qList.addElement(t);

    l =
        new Learnable(
            true,
            true,
            "Soto-uke",
            "white_to_yellow",
            "blocks",
            new String[0],
            "",
            "An outwards Middle Block.  The hand crosses horizontally in front of the body then swings up to a vertical position in front of the shoulder.  The elbow should finish one fist away from the body",
            qList);

    c.addLearnable(l);
    moduleSet.addModule(m);

    String categoryID = "kicks",
        categoryIcon = "kicks.png",
        categoryName = "Kicks",
        question = "which kick strikes with the heel?",
        CorrectAnswer = "Yoko-Keage",
        answer2 = "O-uchi-mawashi-geri",
        answer3 = "Ushiro-geri",
        answer4 = "Fumi-komi",
        lName = "O-uchi-mawashi-geri",
        lModule = "white_to_yellow",
        mIcon = lModule + ".png",
        mName = "White to Yellow",
        lCategory = "blocks",
        lDescription =
            "A side-kick thrusting with the heel outwards.  The kick starts from sagi-aski-dachi then the the hips must rotate thrusting the heel outwards as the foot rotates to horizontal.";

    boolean lTestable = true, lTrainable = true;

    String[] lImages = new String[0];

    t = new Testable(question, null);
    t.addAnswer(true, CorrectAnswer);
    t.addAnswer(false, answer2);
    t.addAnswer(false, answer3);
    t.addAnswer(false, answer4);
    qList = new Vector<Testable>();
    qList.add(t);

    Module modCheck = moduleSet.getModule(lModule);

    if (modCheck == null) {
      modCheck = new Module(lModule, mIcon, mName, "Module Description", false);
      moduleSet.addModule(modCheck);
    }

    if (!modCheck.hasCategory(categoryID)) {
      moduleSet
          .getModule(lModule)
          .addCategory(new Category(categoryID, categoryIcon, categoryName));
    }

    moduleSet
        .getModule(lModule)
        .getCategory(categoryID)
        .addLearnable(
            new Learnable(
                lTrainable,
                lTestable,
                lName,
                lModule,
                lCategory,
                lImages,
                null,
                lDescription,
                qList));

    // TODO: load all categories, modules and data from files

  }