use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class EssayAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.essay, title);
// define the response
Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
ResponseDeclaration responseDeclaration = createExtendedTextResponseDeclaration(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
// outcomes
appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
appendExtendedTextInteraction(itemBody, responseDeclarationId);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class QTI21ArchiveFormat method collectElementInfos.
private void collectElementInfos(AssessmentSection section) {
numOfSections++;
SectionInfos sectionInfos = new SectionInfos(section);
elementInfos.add(sectionInfos);
List<SectionPart> parts = section.getChildAbstractParts();
for (SectionPart part : parts) {
if (part instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) part;
ResolvedAssessmentItem resolvedItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem item = resolvedItem.getRootNodeLookup().extractIfSuccessful();
if (item != null) {
ItemInfos itemInfo = new ItemInfos(itemRef, item, item.getItemBody().findInteractions());
elementInfos.add(itemInfo);
sectionInfos.getItemInfos().add(itemInfo);
}
} else if (part instanceof AssessmentSection) {
collectElementInfos((AssessmentSection) part);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class QTI21WordExport method renderAssessmentSection.
public void renderAssessmentSection(AssessmentSection assessmentSection, OpenXMLDocument document, boolean withResponses, Translator translator) {
String title = assessmentSection.getTitle();
document.appendHeading1(title, null);
List<RubricBlock> rubricBlocks = assessmentSection.getRubricBlocks();
for (RubricBlock rubricBlock : rubricBlocks) {
String htmlRubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
document.appendHtmlText(htmlRubric, true);
}
for (SectionPart sectionPart : assessmentSection.getChildAbstractParts()) {
if (sectionPart instanceof AssessmentSection) {
renderAssessmentSection((AssessmentSection) sectionPart, document, withResponses, translator);
} else if (sectionPart instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
renderAssessmentItem(assessmentItem, new File(itemUri), mediaDir, document, withResponses, translator, htmlBuilder);
document.appendPageBreak();
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class AssessmentItemBuilderTest method buildAssessmentItem_gap.
@Test
public void buildAssessmentItem_gap() throws IOException, URISyntaxException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
FIBAssessmentItemBuilder itemBuilder = new FIBAssessmentItemBuilder("Gap text", EntryType.text, qtiSerializer);
if (build.booleanValue()) {
itemBuilder.build();
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
ItemValidationResult itemResult = serializeAndReload(assessmentItem);
AssessmentItem reloadedItem = itemResult.getResolvedAssessmentItem().getItemLookup().extractIfSuccessful();
List<Interaction> interactions = reloadedItem.getItemBody().findInteractions();
Assert.assertNotNull(interactions);
Assert.assertEquals(1, interactions.size());
Assert.assertTrue(interactions.get(0) instanceof TextEntryInteraction);
TextEntryInteraction interaction = (TextEntryInteraction) interactions.get(0);
Assert.assertNotNull(interaction.getResponseIdentifier());
ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
Assert.assertNotNull(responseDeclaration);
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class AssessmentItemBuilderTest method buildAssessmentItem_hotspot.
@Test
public void buildAssessmentItem_hotspot() throws IOException, URISyntaxException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
HotspotAssessmentItemBuilder itemBuilder = new HotspotAssessmentItemBuilder("Hotspot", qtiSerializer);
if (build.booleanValue()) {
itemBuilder.build();
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
ItemValidationResult itemResult = serializeAndReload(assessmentItem);
AssessmentItem reloadedItem = itemResult.getResolvedAssessmentItem().getItemLookup().extractIfSuccessful();
List<Interaction> interactions = reloadedItem.getItemBody().findInteractions();
Assert.assertNotNull(interactions);
Assert.assertEquals(1, interactions.size());
Assert.assertTrue(interactions.get(0) instanceof HotspotInteraction);
HotspotInteraction interaction = (HotspotInteraction) interactions.get(0);
Assert.assertNotNull(interaction.getResponseIdentifier());
ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
Assert.assertNotNull(responseDeclaration);
}
Aggregations