Exemple #1
0
  protected boolean isRight(int iAttempt) throws OmDeveloperException {
    /*
     *  reset all checkboxes to hidden
     */
    for (int i = 0; i < startOrder.length; i++) {
      String checkbox = startOrder[i] + "_cb";
      getComponent(checkbox).setDisplay(false);
    }

    int numberCorrect = 0;
    int numberAttempted = 0;

    for (int i = 0; i < startOrder.length; i++) {
      DropBoxComponent dbc = getDropBox(startOrder[i]);
      String dropped = dbc.getValue();
      if (!dropped.equals("")) {
        numberAttempted++;
        if (dropped.equals(correctOrder[i] + "1")) { // ids for the draggables are like a1, b1 etc.
          String checkbox = startOrder[i] + "_cb";
          getComponent(checkbox).setDisplay(true);
          numberCorrect++;
        }
      }
    }

    this.score = numberCorrect;

    String message =
        "You attempted "
            + numberAttempted
            + " part(s) of the question out of "
            + startOrder.length
            + "."
            + " "
            + numberCorrect
            + (numberCorrect == 1 ? " is" : " are")
            + " correct.";

    if (iAttempt < 3 && numberCorrect > 0) {
      message +=
          " When you click OK, your correct answer(s) will remain in position. Any incorrect ones will return to their starting positions.";
    }

    getText("feedback").setText(message);
    setFeedbackID("feedback");

    if (numberCorrect == startOrder.length) {
      return true;
    }

    return false;
  }
Exemple #2
0
  public void actionOK() throws OmException {
    // in here I want to put code to restore wrongly guessed dragged items
    // to their starting positions after the OK button in the feedback is clicked
    // calling the clear() method of the DropBoxComponent seems to achieve
    // this.
    for (int i = 0; i < startOrder.length; i++) {
      DropBoxComponent dbc = getDropBox(startOrder[i]);
      String dropped = dbc.getValue();
      if (!dropped.equals("")) {
        if (!dropped.equals(correctOrder[i] + "1")) { // ids for the draggables are like a1, b1 etc.
          dbc.clear();
        }
      }
    }

    super.actionOK();
  } // end of actionOK() method