String[] yesnoKeys = { "y", "n" };
String[] yesnoValues = { translate("yes"), translate("no") };
String configKeyType = (String)modConfig.get(IQEditController.CONFIG_KEY_TYPE);
TitleElement testTitle = new TitleElement("qti.form.test.title");
if(configKeyType != null && AssessmentInstance.QMD_ENTRY_TYPE_SURVEY.equals(configKeyType)) {
testTitle = new TitleElement("qti.form.questionnaire.title");
} else if(configKeyType != null && AssessmentInstance.QMD_ENTRY_TYPE_SELF.equals(configKeyType)) {
testTitle = new TitleElement("qti.form.selftest.title");
}
addFormElement("testTitle", testTitle);
// enable menu
Boolean bEnableMenu = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_ENABLEMENU);
boolean confEnableMenu = (bEnableMenu != null) ? bEnableMenu.booleanValue() : true;
enableMenu = new RadioButtonGroupElement(false, "qti.form.menuenable", yesnoKeys, yesnoValues);
enableMenu.select(confEnableMenu ? "y" : "n", true);
addFormElement("qti_enableMenu", enableMenu);
// display menu
Boolean bDisplayMenu = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_DISPLAYMENU);
boolean confDisplayMenu = (bDisplayMenu != null) ? bDisplayMenu.booleanValue() : true;
displayMenu = new RadioButtonGroupElement(false, "qti.form.menudisplay", yesnoKeys, yesnoValues);
displayMenu.select(confDisplayMenu ? "y" : "n", true);
addFormElement("qti_displayMenu", displayMenu);
// render menu options depend on disabled menu link!
String[] menuRenderOptKeys = new String[] {Boolean.FALSE.toString(), Boolean.TRUE.toString()};
String[] menuRenderOptValues = new String[] {
translate("qti.form.menurender.allquestions"),
translate("qti.form.menurender.sectionsonly")
};
menuRenderOptions = new StaticSingleSelectionElement("qti.form.menurender",menuRenderOptKeys,menuRenderOptValues);
Boolean renderSectionsOnly;
if (modConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION) == null) {
// migration
modConfig.set(IQEditController.CONFIG_KEY_RENDERMENUOPTION, Boolean.FALSE);
renderSectionsOnly = Boolean.FALSE;
} else {
renderSectionsOnly = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION);
}
menuRenderOptions.select(renderSectionsOnly.toString(), true);
addFormElement("qti_form_menurenderoption", menuRenderOptions);
// sequence type
String[] sequenceKeys = new String[] {AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM, AssessmentInstance.QMD_ENTRY_SEQUENCE_SECTION};
String[] sequenceValues = new String[] {
translate("qti.form.sequence.item"),
translate("qti.form.sequence.section")};
sequence = new StaticSingleSelectionElement("qti.form.sequence", sequenceKeys, sequenceValues);
String confSequence = (String)modConfig.get(IQEditController.CONFIG_KEY_SEQUENCE);
if (confSequence == null) confSequence = AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM;
sequence.select(confSequence, true);
addFormElement("qti_form_sequence", sequence);
// question progress
Boolean bEnableQuestionProgress = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_QUESTIONPROGRESS);
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);