use of org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder in project openolat by klemens.
the class HottextAssessmentItemBuilderTest method createHottextAssessmentItem_allCorrectAnswers.
/**
* A basic hottextInteraction with three choices. If all answers
* are correct, the SCORE is 3.0.
*
* @throws IOException
*/
@Test
public void createHottextAssessmentItem_allCorrectAnswers() throws IOException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
HottextAssessmentItemBuilder itemBuilder = new HottextAssessmentItemBuilder("Hot texts", "This is a hot ", "text", qtiSerializer);
itemBuilder.setQuestion("<p>This is <hottext identifier=\"RESPONSE_HOT_1\">hot</hottext>, <hottext identifier=\"RESPONSE_HOT_2\">cold</hottext> or <hottext identifier=\"RESPONSE_HOT_3\">freezing</hottext></p>");
itemBuilder.addCorrectAnswer(Identifier.parseString("RESPONSE_HOT_2"));
itemBuilder.addCorrectAnswer(Identifier.parseString("RESPONSE_HOT_3"));
itemBuilder.setMaxScore(3.0d);
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
itemBuilder.build();
File itemFile = new File(WebappHelper.getTmpDir(), "hottextAssessmentItem" + UUID.randomUUID() + ".xml");
try (FileOutputStream out = new FileOutputStream(itemFile)) {
qtiSerializer.serializeJqtiObject(itemBuilder.getAssessmentItem(), out);
} catch (Exception e) {
log.error("", e);
}
{
// correct answers
Map<Identifier, ResponseData> responseMap = new HashMap<>();
Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
responseMap.put(responseIdentifier, new StringResponseData("RESPONSE_HOT_2", "RESPONSE_HOT_3"));
ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
Assert.assertEquals(new FloatValue(3.0d), score);
}
{
// wrong answer
Map<Identifier, ResponseData> responseMap = new HashMap<>();
Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
responseMap.put(responseIdentifier, new StringResponseData("RESPONSE_HOT_1"));
ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
Assert.assertEquals(new FloatValue(0.0d), score);
}
FileUtils.deleteDirsAndFiles(itemFile.toPath());
}
use of org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder in project openolat by klemens.
the class AssessmentItemEditorController method initHottextEditors.
private AssessmentItemBuilder initHottextEditors(UserRequest ureq, AssessmentItem item) {
HottextAssessmentItemBuilder hottextItemBuilder = new HottextAssessmentItemBuilder(item, qtiService.qtiSerializer());
itemEditor = new HottextEditorController(ureq, getWindowControl(), hottextItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
listenTo(itemEditor);
scoreEditor = new ChoiceScoreController(ureq, getWindowControl(), hottextItemBuilder, itemRef, itemFile, restrictedEdit, readOnly, "Test editor QTI 2.1 in detail#details_testeditor_score");
listenTo(scoreEditor);
feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), hottextItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
listenTo(feedbackEditor);
tabbedPane.addTab(translate("form.hottext"), itemEditor);
tabbedPane.addTab(translate("form.score"), scoreEditor);
tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
return hottextItemBuilder;
}
use of org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class HottextAssessmentItemBuilderTest method createHottextAssessmentItem_allCorrectAnswers.
/**
* A basic hottextInteraction with three choices. If all answers
* are correct, the SCORE is 3.0.
*
* @throws IOException
*/
@Test
public void createHottextAssessmentItem_allCorrectAnswers() throws IOException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
HottextAssessmentItemBuilder itemBuilder = new HottextAssessmentItemBuilder("Hot texts", "This is a hot ", "text", qtiSerializer);
itemBuilder.setQuestion("<p>This is <hottext identifier=\"RESPONSE_HOT_1\">hot</hottext>, <hottext identifier=\"RESPONSE_HOT_2\">cold</hottext> or <hottext identifier=\"RESPONSE_HOT_3\">freezing</hottext></p>");
itemBuilder.addCorrectAnswer(Identifier.parseString("RESPONSE_HOT_2"));
itemBuilder.addCorrectAnswer(Identifier.parseString("RESPONSE_HOT_3"));
itemBuilder.setMaxScore(3.0d);
itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
itemBuilder.build();
File itemFile = new File(WebappHelper.getTmpDir(), "hottextAssessmentItem" + UUID.randomUUID() + ".xml");
try (FileOutputStream out = new FileOutputStream(itemFile)) {
qtiSerializer.serializeJqtiObject(itemBuilder.getAssessmentItem(), out);
} catch (Exception e) {
log.error("", e);
}
{
// correct answers
Map<Identifier, ResponseData> responseMap = new HashMap<>();
Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
responseMap.put(responseIdentifier, new StringResponseData("RESPONSE_HOT_2", "RESPONSE_HOT_3"));
ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
Assert.assertEquals(new FloatValue(3.0d), score);
}
{
// wrong answer
Map<Identifier, ResponseData> responseMap = new HashMap<>();
Identifier responseIdentifier = itemBuilder.getInteraction().getResponseIdentifier();
responseMap.put(responseIdentifier, new StringResponseData("RESPONSE_HOT_1"));
ItemSessionController itemSessionController = RunningItemHelper.run(itemFile, responseMap);
Value score = itemSessionController.getItemSessionState().getOutcomeValue(QTI21Constants.SCORE_IDENTIFIER);
Assert.assertEquals(new FloatValue(0.0d), score);
}
FileUtils.deleteDirsAndFiles(itemFile.toPath());
}
use of org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method event.
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (menuTree == source) {
if (event instanceof TreeEvent) {
TreeEvent te = (TreeEvent) event;
String cmd = te.getCommand();
if (MenuTree.COMMAND_TREENODE_CLICKED.equals(cmd)) {
TreeNode selectedNode = menuTree.getTreeModel().getNodeById(te.getNodeId());
partEditorFactory(ureq, selectedNode);
}
} else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
TreeDropEvent tde = (TreeDropEvent) event;
doDrop(ureq, tde.getDroppedNodeId(), tde.getTargetNodeId(), tde.isAsChild());
}
} else if (newSectionLink == source) {
doNewSection(ureq, menuTree.getSelectedNode());
} else if (newTestPartLink == source) {
doNewTestPart(ureq);
} else if (newSingleChoiceLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new SingleChoiceAssessmentItemBuilder(translate("new.sc"), translate("new.answer"), qtiService.qtiSerializer()));
} else if (newMultipleChoiceLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MultipleChoiceAssessmentItemBuilder(translate("new.mc"), translate("new.answer"), qtiService.qtiSerializer()));
} else if (newKPrimLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new KPrimAssessmentItemBuilder(translate("new.kprim"), translate("new.answer"), qtiService.qtiSerializer()));
} else if (newMatchLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer()));
} else if (newMatchDragAndDropLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchdraganddrop"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer()));
} else if (newMatchTrueFalseLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new MatchAssessmentItemBuilder(translate("new.matchtruefalse"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translate("match.unanswered"), translate("match.true"), translate("match.false"), qtiService.qtiSerializer()));
} else if (newFIBLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib"), EntryType.text, qtiService.qtiSerializer()));
} else if (newNumericalLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new FIBAssessmentItemBuilder(translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer()));
} else if (newHotspotLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HotspotAssessmentItemBuilder(translate("new.hotspot"), qtiService.qtiSerializer()));
} else if (newHottextLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new HottextAssessmentItemBuilder(translate("new.hottext"), translate("new.hottext.start"), translate("new.hottext.text"), qtiService.qtiSerializer()));
} else if (newEssayLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new EssayAssessmentItemBuilder(translate("new.essay"), qtiService.qtiSerializer()));
} else if (newUploadLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new UploadAssessmentItemBuilder(translate("new.upload"), qtiService.qtiSerializer()));
} else if (newDrawingLink == source) {
doNewAssessmentItem(ureq, menuTree.getSelectedNode(), new DrawingAssessmentItemBuilder(translate("new.drawing"), qtiService.qtiSerializer()));
} else if (importFromPoolLink == source) {
doSelectQItem(ureq);
} else if (importFromTableLink == source) {
doImportTable(ureq);
} else if (exportToPoolLink == source) {
doExportPool();
} else if (exportToDocxLink == source) {
doExportDocx(ureq);
} else if (deleteLink == source) {
doConfirmDelete(ureq);
} else if (copyLink == source) {
doCopy(ureq);
} else if (reloadInCacheLink == source) {
doForceReloadFiles(ureq);
}
}
use of org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder in project OpenOLAT by OpenOLAT.
the class AssessmentItemEditorController method initHottextEditors.
private AssessmentItemBuilder initHottextEditors(UserRequest ureq, AssessmentItem item) {
HottextAssessmentItemBuilder hottextItemBuilder = new HottextAssessmentItemBuilder(item, qtiService.qtiSerializer());
itemEditor = new HottextEditorController(ureq, getWindowControl(), hottextItemBuilder, rootDirectory, rootContainer, itemFile, restrictedEdit, readOnly);
listenTo(itemEditor);
scoreEditor = new ChoiceScoreController(ureq, getWindowControl(), hottextItemBuilder, itemRef, itemFile, restrictedEdit, readOnly, "Test editor QTI 2.1 in detail#details_testeditor_score");
listenTo(scoreEditor);
feedbackEditor = new FeedbacksEditorController(ureq, getWindowControl(), hottextItemBuilder, rootDirectory, rootContainer, itemFile, FeedbacksEnabler.standardFeedbacks(), restrictedEdit, readOnly);
listenTo(feedbackEditor);
tabbedPane.addTab(translate("form.hottext"), itemEditor);
tabbedPane.addTab(translate("form.score"), scoreEditor);
tabbedPane.addTab(translate("form.feedback"), feedbackEditor);
return hottextItemBuilder;
}
Aggregations