use of uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction in project OpenOLAT by OpenOLAT.
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);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction in project OpenOLAT by OpenOLAT.
the class AssessmentItemBuilderTest method buildAssessmentItem_kprim.
@Test
public void buildAssessmentItem_kprim() throws IOException, URISyntaxException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
KPrimAssessmentItemBuilder itemBuilder = new KPrimAssessmentItemBuilder("Kprim", "New answer", qtiSerializer);
if (build.booleanValue()) {
itemBuilder.build();
}
AssessmentItem singleChoiceItem = itemBuilder.getAssessmentItem();
ItemValidationResult itemResult = serializeAndReload(singleChoiceItem);
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 MatchInteraction);
MatchInteraction interaction = (MatchInteraction) interactions.get(0);
Assert.assertNotNull(interaction.getResponseIdentifier());
ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
Assert.assertNotNull(responseDeclaration);
Assert.assertEquals(2, interaction.getSimpleMatchSets().size());
SimpleMatchSet matchSet = interaction.getSimpleMatchSets().get(0);
Assert.assertEquals(4, matchSet.getSimpleAssociableChoices().size());
SimpleMatchSet correctWrongSet = interaction.getSimpleMatchSets().get(1);
Assert.assertEquals(2, correctWrongSet.getSimpleAssociableChoices().size());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction in project OpenOLAT by OpenOLAT.
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.interaction.Interaction in project OpenOLAT by OpenOLAT.
the class ManifestMetadataBuilder method appendMetadataFrom.
/**
* This method will add new metadata to the current ones.
*
* @param item
* @param locale
*/
public void appendMetadataFrom(QuestionItem item, AssessmentItem assessmentItem, Locale locale) {
String lang = item.getLanguage();
if (!StringHelper.containsNonWhitespace(lang)) {
lang = locale.getLanguage();
}
// LOM : General
if (StringHelper.containsNonWhitespace(item.getTitle())) {
setTitle(item.getTitle(), lang);
}
if (StringHelper.containsNonWhitespace(item.getCoverage())) {
setCoverage(item.getCoverage(), lang);
}
if (StringHelper.containsNonWhitespace(item.getKeywords())) {
setGeneralKeywords(item.getKeywords(), lang);
}
if (StringHelper.containsNonWhitespace(item.getDescription())) {
setDescription(item.getDescription(), lang);
}
// LOM : Technical
setTechnicalFormat(ManifestBuilder.ASSESSMENTITEM_MIMETYPE);
// LOM : Educational
if (StringHelper.containsNonWhitespace(item.getEducationalContextLevel())) {
setEducationalContext(item.getEducationalContextLevel(), lang);
}
if (StringHelper.containsNonWhitespace(item.getEducationalLearningTime())) {
setEducationalLearningTime(item.getEducationalLearningTime());
}
if (item.getLanguage() != null) {
setLanguage(item.getLanguage(), lang);
}
// LOM : Lifecycle
if (StringHelper.containsNonWhitespace(item.getItemVersion())) {
setLifecycleVersion(item.getItemVersion());
}
// LOM : Rights
LicenseService lService = CoreSpringFactory.getImpl(LicenseService.class);
ResourceLicense license = lService.loadLicense(item);
if (license != null) {
String licenseText = null;
LicenseType licenseType = license.getLicenseType();
if (lService.isFreetext(licenseType)) {
licenseText = license.getFreetext();
} else if (!lService.isNoLicense(licenseType)) {
licenseText = license.getLicenseType().getName();
}
if (StringHelper.containsNonWhitespace(licenseText)) {
setLicense(licenseText);
}
setOpenOLATMetadataCreator(license.getLicensor());
}
// LOM : classification
if (StringHelper.containsNonWhitespace(item.getTaxonomicPath())) {
setClassificationTaxonomy(item.getTaxonomicPath(), lang);
}
// QTI 2.1
setQtiMetadataTool(item.getEditor(), null, item.getEditorVersion());
if (assessmentItem != null) {
List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
List<String> interactionNames = new ArrayList<>(interactions.size());
for (Interaction interaction : interactions) {
interactionNames.add(interaction.getQtiClassName());
}
setQtiMetadataInteractionTypes(interactionNames);
}
// OpenOLAT
if (item.getType() != null) {
setOpenOLATMetadataQuestionType(item.getType().getType());
} else {
setOpenOLATMetadataQuestionType(null);
}
setOpenOLATMetadataIdentifier(item.getIdentifier());
setOpenOLATMetadataDifficulty(item.getDifficulty());
setOpenOLATMetadataDiscriminationIndex(item.getDifferentiation());
setOpenOLATMetadataDistractors(item.getNumOfAnswerAlternatives());
setOpenOLATMetadataStandardDeviation(item.getStdevDifficulty());
setOpenOLATMetadataUsage(item.getUsage());
setOpenOLATMetadataAssessmentType(item.getAssessmentType());
setOpenOLATMetadataTopic(item.getTopic());
setOpenOLATMetadataAdditionalInformations(item.getAdditionalInformations());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction in project OpenOLAT by OpenOLAT.
the class AssessmentItemBuilder method getInteractionNames.
public List<String> getInteractionNames() {
List<Interaction> interactions = assessmentItem.getItemBody().findInteractions();
List<String> interactionNames = new ArrayList<>(interactions.size());
for (Interaction interaction : interactions) {
String interactionName = interaction.getQtiClassName();
interactionNames.add(interactionName);
}
return interactionNames;
}
Aggregations