use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class AssessmentTestComposerController method doInsert.
private void doInsert(UserRequest ureq, AssessmentItemsPackage importPackage) {
TreeNode selectedNode = menuTree.getSelectedNode();
TreeNode sectionNode = getNearestSection(selectedNode);
String firstItemId = null;
boolean errorOnImport = false;
Map<AssessmentItemRef, AssessmentItem> flyingObjects = new HashMap<>();
try {
AssessmentSection section = (AssessmentSection) sectionNode.getUserObject();
List<AssessmentItemAndMetadata> itemsAndMetadata = importPackage.getItems();
for (AssessmentItemAndMetadata itemAndMetadata : itemsAndMetadata) {
if (itemAndMetadata.isHasError()) {
errorOnImport = true;
continue;
}
AssessmentItemBuilder itemBuilder = itemAndMetadata.getItemBuilder();
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
AssessmentItemRef itemRef = doInsert(section, assessmentItem);
ManifestMetadataBuilder metadata = manifestBuilder.getResourceBuilderByHref(itemRef.getHref().toString());
metadata.setQtiMetadataInteractionTypes(itemBuilder.getInteractionNames());
itemAndMetadata.toBuilder(metadata, getLocale());
if (firstItemId == null) {
firstItemId = itemRef.getIdentifier().toString();
}
flyingObjects.put(itemRef, assessmentItem);
}
} catch (URISyntaxException e) {
errorOnImport = true;
logError("", e);
}
if (errorOnImport) {
showError("error.import.question");
}
if (firstItemId != null) {
// persist metadata
doSaveAssessmentTest(ureq, flyingObjects);
doSaveManifest();
updateTreeModel(false);
TreeNode newItemNode = menuTree.getTreeModel().getNodeById(firstItemId);
menuTree.setSelectedNode(newItemNode);
menuTree.open(newItemNode);
partEditorFactory(ureq, newItemNode);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class AssessmentTestComposerController method recalculateMaxScoreAssessmentTest.
private void recalculateMaxScoreAssessmentTest(Map<AssessmentItemRef, AssessmentItem> flyingObjects) {
DoubleAdder atomicMaxScore = new DoubleAdder();
AssessmentTest assessmentTest = (AssessmentTest) menuTree.getTreeModel().getRootNode().getUserObject();
AssessmentTestHelper.visit(assessmentTest, new AssessmentTestVisitor() {
@Override
public void visit(TestPart testPart) {
/* */
}
@Override
public void visit(SectionPart sectionPart) {
if (sectionPart instanceof AssessmentItemRef) {
AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
checkAndFixAbsolutePath(itemRef);
AssessmentItem assessmentItem = null;
if (resolvedAssessmentItem != null) {
assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
}
if (assessmentItem == null && flyingObjects != null && flyingObjects.containsKey(itemRef)) {
assessmentItem = flyingObjects.get(itemRef);
}
if (assessmentItem != null) {
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
if (maxScore != null) {
atomicMaxScore.add(maxScore.doubleValue());
}
}
}
}
});
double sumMaxScore = atomicMaxScore.sum();
if (sumMaxScore > 0.0d) {
assessmentTestBuilder.setMaxScore(sumMaxScore);
} else {
assessmentTestBuilder.setMaxScore(null);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class FeedbackResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
FeedbackResultComponent cmp = (FeedbackResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
sb.append("<div class='modalFeedback'>");
renderAssessmentItemCorrectSolutionModalFeedback(assessmentRenderer, sb, modalFeedback, cmp, resolvedAssessmentItem, itemSessionState, ubu, translator);
sb.append("</div>");
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project openolat by klemens.
the class CorrectionOverviewModel method isManualCorrection.
public boolean isManualCorrection(AssessmentItemRef itemRef) {
String identifier = itemRef.getIdentifier().toString();
return manualCorrections.computeIfAbsent(identifier, id -> {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
List<Interaction> interactions = item.getItemBody().findInteractions();
for (Interaction interaction : interactions) {
if (interaction instanceof UploadInteraction || interaction instanceof DrawingInteraction || interaction instanceof ExtendedTextInteraction) {
return true;
}
}
return false;
});
}
use of uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentItemCheckerTest method checkAndCorrect_notTemplateDeclaration.
@Test
public void checkAndCorrect_notTemplateDeclaration() throws URISyntaxException {
URL itemUrl = OnyxToAssessmentItemBuilderTest.class.getResource("resources/ims/template_image.xml");
AssessmentItem assessmentItem = loadAssessmentItem(itemUrl);
boolean ok = AssessmentItemChecker.checkAndCorrect(assessmentItem);
Assert.assertTrue(ok);
TemplateDeclaration templateDeclaration = assessmentItem.getTemplateDeclaration(Identifier.assumedLegal("SOLUTION1"));
Assert.assertNull(templateDeclaration);
}
Aggregations