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