Exemplo n.º 1
0
 /**
  * Adds a user defined tool to the exercise as well as the view
  *
  * @param macro the user defined tool which should be added to the exercise as well as the view
  */
 void addAssignment(Macro macro) {
   if (!exercise.usesMacro(macro)) {
     Assignment a = exercise.addAssignment(macro);
     appendAssignmentRow(a);
   }
   userAddModes.setVisible(false);
 }
Exemplo n.º 2
0
  /**
   * Brings up a new ExerciseBuilderDialog
   *
   * @param app application
   */
  public ExerciseBuilderDialog(App app) {
    super(false, false, null, ((AppW) app).getPanel());

    this.app = (AppW) app;
    // exerciseBuilderHandler = new ExerciseBuilderDOMHandler();
    exercise = app.getKernel().getExercise();
    if (exercise.isEmpty()) {
      exercise.initStandardExercise();
    }
    createGUI();
  }
Exemplo n.º 3
0
  private void createGUI() {

    getCaption().setText(app.getMenu("Exercise.CreateNew"));

    setWidget(mainWidget = new VerticalPanel());
    addDomHandlers(mainWidget);
    assignmentsTable = new FlexTable();
    FlexCellFormatter cellFormatter = assignmentsTable.getFlexCellFormatter();
    cellFormatter.setColSpan(0, 1, 2);

    assignmentsTable.setWidget(0, 1, new Label(app.getPlain("Tool")));
    assignmentsTable.setWidget(0, 2, new Label(app.getPlain("HintForCorrect")));
    assignmentsTable.setWidget(0, 3, new Label(app.getPlain("Fraction")));

    createAssignmentsTable();
    checkAssignmentsTable = new FlexTable();
    checkAssignmentsTable.setVisible(false);

    mainWidget.add(assignmentsTable);
    mainWidget.add(checkAssignmentsTable);

    addList = new UnorderedList();
    addDomHandlers(addList);
    // addIcon = new ListItem();
    Image addIcon = new Image(GuiResources.INSTANCE.menu_icon_file_new());
    ListItem addListItem = new ListItem();
    addListItem.addStyleName("toolbar_item");
    addListItem.add(addIcon);
    addList.add(addListItem);

    userAddModes = new ToolbarSubemuW(app, 1);
    userAddModes.addStyleName("toolbar_item");
    userAddModes.setVisible(false);
    for (int i = 0; i < app.getKernel().getMacroNumber(); i++) {
      if (!exercise.usesMacro(i)) {
        ListItem item = userAddModes.addItem(i + EuclidianConstants.MACRO_MODE_ID_OFFSET);
        addDomHandlers(item);
      }
    }
    addList.add(userAddModes);
    mainWidget.add(addList);

    mainWidget.add(bottomWidget = new FlowPanel());
    bottomWidget.setStyleName("DialogButtonPanel");

    btApply = new Button(app.getPlain("OK"));
    btApply.addClickHandler(this);
    btApply.getElement().getStyle().setMargin(3, Style.Unit.PX);

    addCancelButton();

    btTest = new Button(app.getPlain("Test"));
    btTest.addClickHandler(this);
    btTest.getElement().getStyle().setMargin(3, Style.Unit.PX);

    bottomWidget.add(btTest);
    bottomWidget.add(btApply);
    // bottomWidget.add(btCancel);

  }
Exemplo n.º 4
0
 /**
  * If add symbol is clicked, <br>
  * a ToolCreationDialog will be created, if there are no (more) Macros which can be used for the
  * Exercise <br>
  * or a SubMenu like chooser of the tools which can be used for the Exercise will be shown.
  */
 void handleAddClick() {
   if (app.getKernel().getMacroNumber() == 0
       || app.getKernel().getMacroNumber() <= exercise.getParts().size()) {
     newTool();
   } else {
     userAddModes.setVisible(true);
   }
 }
Exemplo n.º 5
0
 /**
  * Handles the remove of an Assignment from the Exercise
  *
  * @param event the original event to determine which row should be removed from Table
  * @param assignment the assignment to remove from the Exercise
  */
 void handleAssignmentDeleteClick(ClickEvent event, Assignment assignment) {
   ListItem item =
       userAddModes.addItem(
           app.getKernel().getMacroID(assignment.getTool())
               + EuclidianConstants.MACRO_MODE_ID_OFFSET);
   addDomHandlers(item);
   exercise.remove(assignment);
   assignmentsTable.removeRow(assignmentsTable.getCellForEvent(event).getRowIndex());
 }
Exemplo n.º 6
0
  private void check() {
    exercise.checkExercise();

    int k = 1;
    int i = 0; // keep track of the row we're in
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getMenu("Tool")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("Result")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("HintForResult")));
    checkAssignmentsTable.setWidget(i, k++, new Label(app.getPlain("Fraction")));
    i++;

    ArrayList<Assignment> parts = exercise.getParts();
    for (int j = 0; j < parts.size(); j++, i++) {
      final Assignment assignment = parts.get(j);
      Image icon = new Image();
      icon.setUrl(getIconFile(assignment.getIconFileName()));
      k = 0;
      checkAssignmentsTable.setWidget(i, k++, icon);
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getToolName()));
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getResult().name()));
      checkAssignmentsTable.setWidget(i, k++, new Label(assignment.getHint()));
      checkAssignmentsTable.setWidget(
          i,
          k++,
          new Label(
              app.getKernel()
                  .format(assignment.getFraction() * 100, StringTemplate.defaultTemplate)));
    }

    checkAssignmentsTable.setWidget(i, k = 0, new Label(app.getPlain("FractionTotal")));
    checkAssignmentsTable.setWidget(
        i,
        k++,
        new Label(
            app.getKernel().format(exercise.getFraction() * 100, StringTemplate.defaultTemplate)));
  }
Exemplo n.º 7
0
 private void createAssignmentsTable() {
   for (Assignment assignment : exercise.getParts()) {
     appendAssignmentRow(assignment);
   }
 }