Package org.olat.core.gui.formelements

Examples of org.olat.core.gui.formelements.VisibilityDependsOnSelectionRule


  private void renderElementVisibilityDependencyRules(Form f, StringOutput sb) {
    List rules = f.getVisibilityDependsOnSelectionRules();
    Iterator iter = rules.iterator();
    while (iter.hasNext()) {
      VisibilityDependsOnSelectionRule rule = (VisibilityDependsOnSelectionRule) iter.next();
      FormElement dependentElement = rule.getDependentElement();
      SelectionElement selection = rule.getSelectionElement();
      String resetValueOrig = rule.getResetValue();
      String resetValue = null;
      if (resetValueOrig != null) {
        // quote return caracters to fill into js variable
        resetValue = resetValueOrig.replaceAll("\n", "\\\\n");
        resetValue = resetValue.replaceAll("\r", "\\\\n");
      }
      sb.append("b_form_updateFormElementVisibility('")
      .append(f.getComponentName())
      .append("','")
      .append(selection.getName())
      .append("','")
      .append(dependentElement.getName())
      .append("','")
      .append(rule.getVisibilityRuleValue())
      .append("',")
      .append(String.valueOf(rule.isVisibilityRuleResult()))
      .append(",\"")
      .append(resetValue)
      .append("\",")
      .append(String.valueOf(rule.isHideDisabledElements()))
      .append(",")
      .append(String.valueOf(rule.isPreventOppositeAction()))
      .append(");\n");
    }
  }
View Full Code Here


    bodyElem = new TextAreaElement("mailtemplateform.body", 15, 60, template.getBodyTemplate());
    bodyElem.setMandatory(true);
    addFormElement("bodyElem", bodyElem);

    // rules
    VisibilityDependsOnSelectionRule rule;
    rule = new VisibilityDependsOnSelectionRule(sendMailSwitchElem, ccSender, Boolean.TRUE.toString(), true, template.getCpfrom().toString(), true);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(sendMailSwitchElem, subjectElem, Boolean.TRUE.toString(), true, template.getSubjectTemplate(), true);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(sendMailSwitchElem, bodyElem, Boolean.TRUE.toString(), true, template.getBodyTemplate(), true);
    addVisibilityDependsOnSelectionRule(rule);

    if (useCancel) {
      setCancelButton();
    }
View Full Code Here

   
    SpacerElement s3 = new SpacerElement(true, false);
    addFormElement("s3", s3);
   
    // rules
    VisibilityDependsOnSelectionRule rule;

    rule = new VisibilityDependsOnSelectionRule(toogleVisibility, onlineTimeSwitch, Boolean.FALSE.toString(), false, Boolean.FALSE
        .toString(), true);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(toogleVisibility, courseNameSwitch, Boolean.FALSE.toString(), false, Boolean.FALSE
        .toString(), true);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(toogleVisibility, s1, Boolean.FALSE.toString(), false, null, true);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(toogleVisibility, s2, Boolean.FALSE.toString(), false, null, true);
    addVisibilityDependsOnSelectionRule(rule);
    addVisibilityDependsOnSelectionRule(rule);
    rule = new VisibilityDependsOnSelectionRule(toogleVisibility, s3, Boolean.FALSE.toString(), false, null, true);
    addVisibilityDependsOnSelectionRule(rule);
   
    addSubmitKey("save", "save");
    setCancelButton();
  }
View Full Code Here

    spacer = new SpacerElement(true, false);
    addFormElement("spacer1", spacer);
    // recurrence
    String currentRecur = CalendarUtils.getRecurrence(event.getRecurrenceRule());
    VisibilityDependsOnSelectionRule rule;
    String[] keysRecurrence = new String[] {
        RECURRENCE_NONE,
        KalendarEvent.DAILY,
        KalendarEvent.WORKDAILY,
        KalendarEvent.WEEKLY,
        KalendarEvent.BIWEEKLY,
        KalendarEvent.MONTHLY,
        KalendarEvent.YEARLY
    };
    String[] valuesRecurrence = new String[] {
        translate("cal.form.recurrence.none"),
        translate("cal.form.recurrence.daily"),
        translate("cal.form.recurrence.workdaily"),
        translate("cal.form.recurrence.weekly"),
        translate("cal.form.recurrence.biweekly"),
        translate("cal.form.recurrence.monthly"),
        translate("cal.form.recurrence.yearly")
    };
    chooseRecurrence = new StaticSingleSelectionElement("cal.form.recurrence", keysRecurrence, valuesRecurrence);
    if(currentRecur != null && !currentRecur.equals("")) {
      chooseRecurrence.select(currentRecur, true);
    } else {
      chooseRecurrence.select(RECURRENCE_NONE, true);
    }
    addFormElement("cal.form.recurrence", chooseRecurrence);
    // recurrence end date
    recurrenceEnd = new DateElement("cal.form.recurrence.end", null, "dd.MM.yyyy");
    recurrenceEnd.setDateChooserDateFormat("%d.%m.%Y");
    recurrenceEnd.setExample(translate("cal.form.recurrence.end.example"));
    Date recurEnd = CalendarUtils.getRecurrenceEndDate(event.getRecurrenceRule());
    if(recurEnd != null) recurrenceEnd.setDate(recurEnd);
    addFormElement("cal.form.recurrence.end", recurrenceEnd);
    rule = new VisibilityDependsOnSelectionRule(chooseRecurrence, recurrenceEnd, RECURRENCE_NONE, false, "", true);
    addVisibilityDependsOnSelectionRule(rule);
    addFormElement("spacer2", spacer);

    // classification
    String[] keys = new String[] {"0", "1", "2"};
View Full Code Here

     * Rules for:
     * - show username and password field if option 1 or 2 is chosen
     * - hide username and password field if option 3 or 4 is chosen
     * - hide startbutton field if option 4 is chosen
     */
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tuser, OPTION_TUNNEL_THROUGH_OLAT_INLINE, true,  tuser.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tuser, OPTION_TUNNEL_THROUGH_OLAT_IFRAME, true,  tuser.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tuser, OPTION_SHOW_IN_OLAT_IN_AN_IFRAME,  false, tuser.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tuser, OPTION_SHOW_IN_NEW_BROWSER_WINDOW, false, tuser.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tpass, OPTION_TUNNEL_THROUGH_OLAT_INLINE, true,  tpass.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tpass, OPTION_TUNNEL_THROUGH_OLAT_IFRAME, true,  tpass.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tpass, OPTION_SHOW_IN_OLAT_IN_AN_IFRAME,  false, tpass.getValue(), true, true));
    addVisibilityDependsOnSelectionRule(new VisibilityDependsOnSelectionRule(selectables, tpass, OPTION_SHOW_IN_NEW_BROWSER_WINDOW, false, tpass.getValue(), true, true));
   
    addSubmitKey("TUConfigForm.save");
    if (withCancel) setCancelKey("search.form.cancel");
  }
View Full Code Here

    passedNodeIdents = initNodeSelectionElement("scform.passedNodeIndents", scoreCalculator, (scoreCalculator == null ? null
        : scoreCalculator.getPassedNodes()), nodeIdentList);
    addFormElement("passedNodeIdents", passedNodeIdents);

    // rules
    VisibilityDependsOnSelectionRule rule = new VisibilityDependsOnSelectionRule(hasScore, scoreNodeIdents, Boolean.TRUE.toString(), true,
        "false", true);
    addVisibilityDependsOnSelectionRule(rule);

    rule = new VisibilityDependsOnSelectionRule(passedType, passedNodeIdents, ScoreCalculator.PASSED_TYPE_INHERIT, true, "false", true);
    addVisibilityDependsOnSelectionRule(rule);

    rule = new VisibilityDependsOnSelectionRule(passedType, passedCutValue, ScoreCalculator.PASSED_TYPE_CUTVALUE, true, "0", true);
    addVisibilityDependsOnSelectionRule(rule);

    setSubmitKey("submit");
    setCancelButton();
  }
View Full Code Here

    String[] statusValues = { translate("rightsForm.status.activ"), translate("rightsForm.status.permanent"), translate("rightsForm.status.login_denied") };
    return new StaticSingleSelectionElement("rightsForm.status", statusKeys, statusValues);
  }

  public void finishInitialization() {
    VisibilityDependsOnSelectionRule disableWhenGuestRule;
   
    SpacerElement spacer = new SpacerElement(true, false);

    if (isAnonymous != null) {
      addFormElement("isAnonymous", isAnonymous);
      addFormElement("spacer1", spacer);
      disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, spacer, "true", false, "", true);
      addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
    }
    if (isUsermanager != null) {
      addFormElement("isUsermanager", isUsermanager);
      if (isAnonymous != null) {
        disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, isUsermanager, "true", false, "", true);
        addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
      }
    }
    if (isGroupmanager != null) {
      addFormElement("isGroupmanager", isGroupmanager);
      if (isAnonymous != null) {
        disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, isGroupmanager, "true", false, "", true);
        addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
      }
    }
    if (isAuthor != null){
      addFormElement("isAuthor", isAuthor);
      if (isAnonymous != null) {
        disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, isAuthor, "true", false, "", true);
        addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
      }
    }
    if (isAdmin != null){
      addFormElement("isAdmin", isAdmin);
      if (isAnonymous != null) {
        disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, isAdmin, "true", false, "", true);
        addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
      }
    }
    if (isInstitutionalResourceManager!= null) {
      addFormElement("isInstitutionalResourceManager", isInstitutionalResourceManager);
      if (isAnonymous != null) {
        disableWhenGuestRule = new VisibilityDependsOnSelectionRule(isAnonymous, isInstitutionalResourceManager, "true", false, "", true);
        addVisibilityDependsOnSelectionRule(disableWhenGuestRule);
      }
    }
    addFormElement("status", statusSelectionElement)
View Full Code Here

    this.showChooseOwners = bgpm.showOwners();
    this.showChoosePartips = bgpm.showPartips();
    this.isAdmin = isAdmin;
   
    Manager scrtMngr = ManagerFactory.getManager();
    VisibilityDependsOnSelectionRule rule;
   
    if (!isRightGroup()) {
      if (isMultiSelectionOwnerKeys()) {
        String[] radioKeysOwners = { NLS_RADIO_ALL, NLS_RADIO_NOTHING, NLS_RADIO_CHOOSE };
        String[] radioValuesOwners = { translator.translate("sendtochooser.form.radio.owners.all"),
            translator.translate("sendtochooser.form.radio.owners.nothing"), translator.translate("sendtochooser.form.radio.owners.choose") };
        radioButtonOwner = new RadioButtonGroupElement(true, "sendtochooser.form.radio.owners", radioKeysOwners, radioValuesOwners);
        radioButtonOwner.select(NLS_RADIO_ALL, true);

        // Owner MultiSelection
        SecurityGroup owners = businessGroup.getOwnerGroup();
        List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
        String[] keysOwner = new String[ownerList.size()];
        String[] valuesOwner = new String[ownerList.size()];
        for (int i = 0; i < ownerList.size(); i++) {
          keysOwner[i] = ownerList.get(i).getKey().toString();
          valuesOwner[i] = ownerList.get(i).getName().toString();
        }
        multiSelectionOwnerKeys = new StaticMultipleSelectionElement(null, keysOwner, valuesOwner, ownerList.size() > 0 ? true : false);

        addFormElement("radioButtonOwner", radioButtonOwner);
        addFormElement("multiSelectionOwnerKeys", multiSelectionOwnerKeys);

        // rule owner
        rule = new VisibilityDependsOnSelectionRule(radioButtonOwner, multiSelectionOwnerKeys, "choose", true, null, true);
        addVisibilityDependsOnSelectionRule(rule);
      } else {
        String[] radioKeysOwners = { NLS_RADIO_ALL, NLS_RADIO_NOTHING };
        String[] radioValuesOwners = { translator.translate("sendtochooser.form.radio.owners.all"),
            translator.translate("sendtochooser.form.radio.owners.nothing") };
        radioButtonOwner = new RadioButtonGroupElement(true, "sendtochooser.form.radio.owners", radioKeysOwners, radioValuesOwners);
        radioButtonOwner.select(NLS_RADIO_ALL, true);

        addFormElement("radioButtonOwner", radioButtonOwner);
      }
    }
    if (isMultiSelectionPartipKeys()) {
      if (isRightGroup()) {
        String[] radioKeysPartip = { NLS_RADIO_ALL, NLS_RADIO_CHOOSE };
        String[] radioValuesPartip = { translator.translate("sendtochooser.form.radio.partip.rightgroup.all"), translator.translate("sendtochooser.form.radio.partip.rightgroup.choose") };
        radioButtonPartip = new RadioButtonGroupElement(true, "sendtochooser.form.radio.rightgroup", radioKeysPartip, radioValuesPartip);
        radioButtonPartip.select(NLS_RADIO_ALL, true);
        // Participator MultiSelection
        SecurityGroup participants = businessGroup.getPartipiciantGroup();
        List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
        String[] keysPartip = new String[participantsList.size()];
        String[] valuesPartip = new String[participantsList.size()];
        for (int i = 0; i < participantsList.size(); i++) {
          keysPartip[i] = participantsList.get(i).getKey().toString();
          valuesPartip[i] = participantsList.get(i).getName().toString();
        }
        multiSelectionPartipKeys = new StaticMultipleSelectionElement(null, keysPartip, valuesPartip, participantsList.size() > 0 ? true
            : false);
        addFormElement("radioButtonPartip", radioButtonPartip);
        addFormElement("multiSelectionPartipKeys", multiSelectionPartipKeys);
        // rule partips
        rule = new VisibilityDependsOnSelectionRule(radioButtonPartip, multiSelectionPartipKeys, "choose", true, null, true);
        addVisibilityDependsOnSelectionRule(rule);
      } else {
        String[] radioKeysPartip = { NLS_RADIO_ALL, NLS_RADIO_NOTHING, NLS_RADIO_CHOOSE };
        String[] radioValuesPartip = { translator.translate("sendtochooser.form.radio.partip.all"),
            translator.translate("sendtochooser.form.radio.partip.nothing"), translator.translate("sendtochooser.form.radio.partip.choose") };
        radioButtonPartip = new RadioButtonGroupElement(true, "sendtochooser.form.radio.partip", radioKeysPartip, radioValuesPartip);
        radioButtonPartip.select(NLS_RADIO_ALL, true);
        // Participator MultiSelection
        SecurityGroup participants = businessGroup.getPartipiciantGroup();
        List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
        String[] keysPartip = new String[participantsList.size()];
        String[] valuesPartip = new String[participantsList.size()];
        for (int i = 0; i < participantsList.size(); i++) {
          keysPartip[i] = participantsList.get(i).getKey().toString();
          valuesPartip[i] = participantsList.get(i).getName().toString();
        }
        multiSelectionPartipKeys = new StaticMultipleSelectionElement(null, keysPartip, valuesPartip, participantsList.size() > 0 ? true
            : false);
        addFormElement("radioButtonPartip", radioButtonPartip);
        addFormElement("multiSelectionPartipKeys", multiSelectionPartipKeys);
        // rule partips
        rule = new VisibilityDependsOnSelectionRule(radioButtonPartip, multiSelectionPartipKeys, "choose", true, null, true);
        addVisibilityDependsOnSelectionRule(rule);
      }
    } else {
      if (isRightGroup()) {
        String[] radioKeysPartip = { NLS_RADIO_ALL };
        String[] radioValuesPartip = { translator.translate("sendtochooser.form.radio.partip.all.rightgroup") };
        radioButtonPartip = new RadioButtonGroupElement(true, "sendtochooser.form.radio.partip.rightgroup", radioKeysPartip, radioValuesPartip);
        radioButtonPartip.select(NLS_RADIO_ALL, true);
        addFormElement("radioButtonPartip", radioButtonPartip);
      } else {
        String[] radioKeysPartip = { NLS_RADIO_ALL, NLS_RADIO_NOTHING };
        String[] radioValuesPartip = { translator.translate("sendtochooser.form.radio.partip.all"),
            translator.translate("sendtochooser.form.radio.partip.nothing") };
        radioButtonPartip = new RadioButtonGroupElement(true, "sendtochooser.form.radio.partip", radioKeysPartip, radioValuesPartip);
        radioButtonPartip.select(NLS_RADIO_ALL, true);
        addFormElement("radioButtonPartip", radioButtonPartip);
      }
    }   

    if ( isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
      String[] radioKeysWaitings = { NLS_RADIO_ALL, NLS_RADIO_NOTHING, NLS_RADIO_CHOOSE };
      String[] radioValuesWaitings = {translator.translate("sendtochooser.form.radio.waitings.all"), translator.translate("sendtochooser.form.radio.waitings.nothing"), translator.translate("sendtochooser.form.radio.waitings.choose")};
      radioButtonWaiting = new RadioButtonGroupElement(true, "sendtochooser.form.radio.waitings", radioKeysWaitings, radioValuesWaitings);
      radioButtonWaiting.select(NLS_RADIO_ALL, true);
     
      // Waitings MultiSelection
      SecurityGroup waitingList = businessGroup.getWaitingGroup();
      List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
      String[] keysWaiting = new String[waitingListIdentities.size()];
      String[] valuesWaiting = new String[waitingListIdentities.size()];
      for (int i = 0; i < waitingListIdentities.size(); i++) {
        keysWaiting[i] = waitingListIdentities.get(i).getKey().toString();
        valuesWaiting[i] = waitingListIdentities.get(i).getName().toString();
      }
      multiSelectionWaitingKeys = new StaticMultipleSelectionElement(null, keysWaiting, valuesWaiting, waitingListIdentities.size()>0?true:false);
      // WaitingList is enabled => show checkbox
      addFormElement("radioButtonWaiting", radioButtonWaiting);
      addFormElement("multiSelectionWaitingKeys", multiSelectionWaitingKeys);
     
      // rule waitings
      rule = new VisibilityDependsOnSelectionRule(radioButtonWaiting, multiSelectionWaitingKeys, "choose", true, null, true);
      addVisibilityDependsOnSelectionRule(rule);
    }
    setCancelButton();
    addSubmitKey("sendtochooser.form.submit");
  }
View Full Code Here

    statefulMicroWeb = new StaticSingleSelectionElement(NLS_DISPLAY_CONFIG_STATEFUL, statefulKeys, statefulValues);
    statefulMicroWeb.select(stateful, true);
    addFormElement("microWeb", statefulMicroWeb);
   
    // enable statefulMicroWeb only if the page is not displayed in an iframe.
    VisibilityDependsOnSelectionRule rule = new VisibilityDependsOnSelectionRule(iframeE, statefulMicroWeb, Boolean.FALSE.toString(), true, Boolean.FALSE.toString(), false);
    addVisibilityDependsOnSelectionRule(rule);
   
  }
View Full Code Here

    boolean confEnableQuestionProgress = (bEnableQuestionProgress != null) ? bEnableQuestionProgress.booleanValue() : true;
    displayQuestionProgress = new RadioButtonGroupElement(false, "qti.form.questionprogress", yesnoKeys, yesnoValues);
    displayQuestionProgress.select(confEnableQuestionProgress ? "y" : "n", true);
    addFormElement("qti_enableQuestionProgress", displayQuestionProgress);

    VisibilityDependsOnSelectionRule displayMenuVisibilityRule = new VisibilityDependsOnSelectionRule(
        enableMenu, displayMenu, "n", true, "y", true);
    addVisibilityDependsOnSelectionRule(displayMenuVisibilityRule);
   
    VisibilityDependsOnSelectionRule displayMenuRenderOptionRule = new VisibilityDependsOnSelectionRule(
        enableMenu, menuRenderOptions, "y", true, Boolean.FALSE.toString(), true);
    addVisibilityDependsOnSelectionRule(displayMenuRenderOptionRule);
   
    VisibilityDependsOnSelectionRule displayQuestionVisibilityRule = new VisibilityDependsOnSelectionRule(
        enableMenu, displayQuestionProgress, "n", true, "n", true);
    addVisibilityDependsOnSelectionRule(displayQuestionVisibilityRule);
   
    // question title
    Boolean bDisplayQuestionTitle = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_QUESTIONTITLE);
    boolean confDisplayQuestionTitle = (bDisplayQuestionTitle != null) ? bDisplayQuestionTitle.booleanValue() : true;
    displayQuestionTitle = new RadioButtonGroupElement(false, "qti.form.questiontitle", yesnoKeys, yesnoValues);
    displayQuestionTitle.select(confDisplayQuestionTitle ? "y" : "n", true);
    addFormElement("qti_displayQuestionTitle", displayQuestionTitle);   
       
    // enable cancel
    Boolean bEnableCancel = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_ENABLECANCEL);
    boolean confEnableCancel = true;
    if (bEnableCancel != null) {
      // if defined use config value
      confEnableCancel = bEnableCancel.booleanValue();
    } else {
      // undefined... migrate according to old behaviour
      if (configKeyType != null && configKeyType.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS))
        confEnableCancel = false;
    }
    enableCancel = new RadioButtonGroupElement(false, "qti.form.enablecancel", yesnoKeys, yesnoValues);
    enableCancel.select(confEnableCancel ? "y" : "n", true);
    addFormElement("qti_enableCancel", enableCancel);

    // enable suspend
    Boolean bEnableSuspend = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_ENABLESUSPEND);
    boolean confEnableSuspend = (bEnableSuspend != null) ? bEnableSuspend.booleanValue() : false;
    enableSuspend = new RadioButtonGroupElement(false, "qti.form.enablesuspend", yesnoKeys, yesnoValues);
    enableSuspend.select(confEnableSuspend ? "y" : "n", true);
    addFormElement("qti_enableSuspend", enableSuspend);
   
    // Only tests have a limitation on number of attempts
    if (configKeyType != null && configKeyType.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS) ) {
      String[] attemptsKeys = new String[21];
        attemptsKeys[0] = "0"; // position 0 means no restriction
        for (int i = 1; i < 21; i++) {
                attemptsKeys[i] = (String.valueOf(i));
            }
      String[] attemptsValues = new String[21];
      attemptsValues[0] = translate("qti.form.attempts.noLimit");
        for (int i = 1; i < 21; i++) {
                attemptsValues[i] = (String.valueOf(i) + " x");
            }
      attempts = new StaticSingleSelectionElement("qti.form.attempts", attemptsKeys, attemptsValues);
      Integer confAttempts = (Integer) modConfig.get(IQEditController.CONFIG_KEY_ATTEMPTS);
      if (confAttempts == null) confAttempts = new Integer(0);
      attempts.select(confAttempts.toString(), true);
      addFormElement("qti_form_attempts", attempts);
    }
           
    // score progress
    if (configKeyType != null && !configKeyType.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) {
      //results options section
      TitleElement resultTitle = new TitleElement("qti.form.result.title");
      addFormElement("resultTitle", resultTitle);
     
      Boolean bEnableScoreProgress = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_SCOREPROGRESS);
      boolean confEnableScoreProgress = (bEnableScoreProgress != null) ? bEnableScoreProgress.booleanValue() : true;
      displayScoreProgress = new RadioButtonGroupElement(false, "qti.form.scoreprogress", yesnoKeys, yesnoValues);
      displayScoreProgress.select(confEnableScoreProgress ? "y" : "n", true);
      addFormElement("qti_enableScoreProgress", displayScoreProgress);
       
      //Show score infos on start page
      Boolean bEnableScoreInfos = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
      boolean enableScoreInfos = (bEnableScoreInfos != null) ? bEnableScoreInfos.booleanValue() : true;
      scoreInfo = new RadioButtonGroupElement(false, "qti.form.scoreinfo", yesnoKeys, yesnoValues);
      scoreInfo.select(enableScoreInfos ? "y" : "n", true);
      addFormElement("qti_scoreInfo", scoreInfo);
     
      //migration: check if old tests have no summary
      String configuredSummary = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
      boolean noSummary = configuredSummary!=null && configuredSummary.equals(AssessmentInstance.QMD_ENTRY_SUMMARY_NONE) ? true : false;
   
      //show results after finish (submit) test     
      Boolean showResultOnFinish = (Boolean) modConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_FINISH);
      boolean confEnableShowResultOnFinish = (showResultOnFinish != null) ? showResultOnFinish.booleanValue() : true;
      confEnableShowResultOnFinish = !noSummary && confEnableShowResultOnFinish;
      showResultsAfterFinishTest = new RadioButtonGroupElement(false, "qti.form.results.onfinish", yesnoKeys, yesnoValues);
      showResultsAfterFinishTest.select(confEnableShowResultOnFinish ? "y" : "n", true);
      addFormElement("qti_enableResultsOnFinish", showResultsAfterFinishTest);

      // show results on test home page
      Boolean showResultOnHomePage = (Boolean) modConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
      boolean confEnableShowResultOnHomePage = (showResultOnHomePage != null) ? showResultOnHomePage.booleanValue() : false;
      confEnableShowResultOnHomePage = !noSummary && confEnableShowResultOnHomePage;
      showResultsOnHomePage = new RadioButtonGroupElement(false, "qti.form.results.onhomepage", yesnoKeys, yesnoValues);
      showResultsOnHomePage.select(confEnableShowResultOnHomePage ? "y" : "n", true);
      addFormElement("qti_enableResultsOnHomePage", showResultsOnHomePage);

      // enable show results depending on date only the "show results on test
      // home page" is true
      Boolean showResultsActive = (Boolean) modConfig.get(IQEditController.CONFIG_KEY_DATE_DEPENDENT_RESULTS);
      boolean showResultsDateDependent = false; // default false
      if (showResultsActive != null) {
        // if defined use config value
        showResultsDateDependent = showResultsActive.booleanValue();
      }
      showResultsDateDependentButton = new RadioButtonGroupElement(false, "qti.form.show.results", yesnoKeys, yesnoValues);
      showResultsDateDependentButton.select(showResultsDateDependent ? "y" : "n", true);
      addFormElement("qti_showresult", showResultsDateDependentButton);

      // start date
      Date startDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
      startDateElement = new DateElement("qti.form.date.start", startDate, "dd.MM.yyyy HH:mm");
      startDateElement.setMandatory(showResultsDateDependent);
      startDateElement.setDateChooserTimeEnabled(true);
      startDateElement.setDateChooserDateFormat("%d.%m.%Y %H:%M");
      startDateElement.setExample(startDateElement.getExample());
      addFormElement("qti.form.date.start", startDateElement);

      // end date
      Date endDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
      endDateElement = new DateElement("qti.form.date.end", endDate, "dd.MM.yyyy HH:mm");
      // endDateElement.setMandatory(showResultsDateDependent);
      endDateElement.setDateChooserTimeEnabled(true);
      endDateElement.setDateChooserDateFormat("%d.%m.%Y %H:%M");
      endDateElement.setExample(endDateElement.getExample());
      addFormElement("qti.form.date.end", endDateElement);

      // hide showResultsOnHomePage if the results must not be shown on the test
      // home page
      VisibilityDependsOnSelectionRule showResultOnHomePageVisibilityRule1 = new VisibilityDependsOnSelectionRule(showResultsOnHomePage,
          showResultsDateDependentButton, "n", false, "n", true);
      addVisibilityDependsOnSelectionRule(showResultOnHomePageVisibilityRule1);
      VisibilityDependsOnSelectionRule showResultOnHomePageVisibilityRule2 = new VisibilityDependsOnSelectionRule(showResultsOnHomePage,
          startDateElement, "n", false, "", true);
      addVisibilityDependsOnSelectionRule(showResultOnHomePageVisibilityRule2);
      VisibilityDependsOnSelectionRule showResultOnHomePageVisibilityRule3 = new VisibilityDependsOnSelectionRule(showResultsOnHomePage,
          endDateElement, "n", false, "", true);
      addVisibilityDependsOnSelectionRule(showResultOnHomePageVisibilityRule3);

      // hide start/end date element if show results is not date dependent
      VisibilityDependsOnSelectionRule startDateVisibilityRule = new VisibilityDependsOnSelectionRule(showResultsDateDependentButton,
          startDateElement, "n", false, "", true);
      addVisibilityDependsOnSelectionRule(startDateVisibilityRule);
      VisibilityDependsOnSelectionRule endDateVisibilityRule = new VisibilityDependsOnSelectionRule(showResultsDateDependentButton,
          endDateElement, "n", false, "", true);
      addVisibilityDependsOnSelectionRule(endDateVisibilityRule);

      //TODO: LD: hide summary if no results are shown neither on finish test nor on test home page
      // Only tests and selftests have summaries     
View Full Code Here

TOP

Related Classes of org.olat.core.gui.formelements.VisibilityDependsOnSelectionRule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.