use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBEditorController method doGapEntry.
private void doGapEntry(UserRequest ureq, String responseIdentifier, String selectedText, String emptySolution, String type, boolean newEntry) {
if (textEntrySettingsCtrl != null || numericalEntrySettingsCtrl != null)
return;
AbstractEntry interaction = itemBuilder.getEntry(responseIdentifier);
if (interaction == null) {
interaction = createEntry(responseIdentifier, selectedText, type, newEntry);
} else if (StringHelper.containsNonWhitespace(selectedText)) {
updateSolution(interaction, selectedText, emptySolution);
}
if (interaction instanceof TextEntry) {
textEntrySettingsCtrl = new FIBTextEntrySettingsController(ureq, getWindowControl(), (TextEntry) interaction, restrictedEdit, readOnly);
listenTo(textEntrySettingsCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), textEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
cmc.activate();
listenTo(cmc);
} else if (interaction instanceof NumericalEntry) {
numericalEntrySettingsCtrl = new FIBNumericalEntrySettingsController(ureq, getWindowControl(), (NumericalEntry) interaction, restrictedEdit, readOnly);
listenTo(numericalEntrySettingsCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), numericalEntrySettingsCtrl.getInitialComponent(), true, translate("title.add"));
cmc.activate();
listenTo(cmc);
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBScoreController method sync.
@Override
public void sync(UserRequest ureq, AssessmentItemBuilder assessmentItemBuilder) {
if (itemBuilder == assessmentItemBuilder) {
List<AbstractEntry> entries = itemBuilder.getOrderedTextEntries();
for (AbstractEntry entry : entries) {
FIBEntryWrapper wrapper = getTextEntryWrapper(entry);
if (wrapper == null) {
wrappers.add(createTextEntryWrapper(entry));
}
}
// remove removed entry
for (Iterator<FIBEntryWrapper> wrapperIt = wrappers.iterator(); wrapperIt.hasNext(); ) {
Identifier responseIdentifier = wrapperIt.next().getEntry().getResponseIdentifier();
if (itemBuilder.getTextEntry(responseIdentifier.toString()) == null) {
wrapperIt.remove();
}
}
// reorder the wrappers
Map<AbstractEntry, FIBEntryWrapper> wrapperMap = new HashMap<>();
for (FIBEntryWrapper wrapper : wrappers) {
wrapperMap.put(wrapper.getEntry(), wrapper);
}
List<FIBEntryWrapper> reorderedWrappers = new ArrayList<>();
for (AbstractEntry entry : entries) {
FIBEntryWrapper wrapper = wrapperMap.get(entry);
if (wrapper != null) {
reorderedWrappers.add(wrapper);
wrapperMap.remove(entry);
}
}
if (wrapperMap.size() > 0) {
// paranoid security
for (FIBEntryWrapper wrapper : wrapperMap.values()) {
if (!reorderedWrappers.contains(wrapper)) {
reorderedWrappers.add(wrapper);
}
}
}
wrappers.clear();
wrappers.addAll(reorderedWrappers);
}
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBScoreController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
super.initForm(formLayout, listener, ureq);
minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, "0.0", formLayout);
minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
minScoreEl.setEnabled(false);
ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
} else {
assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
}
String scorePage = velocity_root + "/fib_score.html";
scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
formLayout.add(scoreCont);
scoreCont.setLabel(null, null);
for (AbstractEntry entry : itemBuilder.getOrderedTextEntries()) {
wrappers.add(createTextEntryWrapper(entry));
}
scoreCont.contextPut("choices", wrappers);
scoreCont.setVisible(assessmentModeEl.isSelected(1));
// Submit Button
FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsContainer.setRootForm(mainForm);
buttonsContainer.setVisible(!readOnly);
formLayout.add(buttonsContainer);
uifactory.addFormSubmitButton("submit", buttonsContainer);
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBAssessmentItemBuilder method getOrderedTextEntries.
public List<AbstractEntry> getOrderedTextEntries() {
List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
List<AbstractEntry> entries = getTextEntries();
List<AbstractEntry> orderedEntries = new ArrayList<>();
for (Interaction interaction : interactions) {
AbstractEntry entry = getTextEntry(interaction.getResponseIdentifier().toString());
if (entry != null) {
orderedEntries.add(entry);
entries.remove(entry);
}
}
if (entries.size() > 0) {
// security
orderedEntries.addAll(entries);
}
return orderedEntries;
}
use of org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.AbstractEntry in project OpenOLAT by OpenOLAT.
the class FIBAssessmentItemBuilder method buildItemBody.
@Override
protected void buildItemBody() {
// remove current blocks
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
blocks.clear();
// add question
getHtmlHelper().appendHtml(assessmentItem.getItemBody(), question);
// transfer text entry to the interactions
List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
List<String> usedResponseIdentifiers = new ArrayList<>(interactions.size());
for (Interaction interaction : interactions) {
if (interaction instanceof TextEntryInteraction && interaction.getResponseIdentifier() != null) {
TextEntryInteraction textEntryInteraction = (TextEntryInteraction) interaction;
String responseIdentifier = interaction.getResponseIdentifier().toString();
AbstractEntry entry = responseIdentifierToTextEntry.get(responseIdentifier);
if (entry != null) {
textEntryInteraction.setPlaceholderText(entry.getPlaceholder());
textEntryInteraction.setExpectedLength(entry.getExpectedLength());
}
usedResponseIdentifiers.add(responseIdentifier);
}
}
List<String> mappedResponseIdentifiers = new ArrayList<>(responseIdentifierToTextEntry.keySet());
mappedResponseIdentifiers.removeAll(usedResponseIdentifiers);
for (String mappedResponseIdentifier : mappedResponseIdentifiers) {
responseIdentifierToTextEntry.remove(mappedResponseIdentifier);
}
}
Aggregations