use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestComposerController method doCopy.
private void doCopy(UserRequest ureq) {
TreeNode selectedNode = menuTree.getSelectedNode();
if (selectedNode == null || !(selectedNode.getUserObject() instanceof AssessmentItemRef))
return;
AssessmentItemRef itemRefToCopy = (AssessmentItemRef) selectedNode.getUserObject();
AssessmentSection section = itemRefToCopy.getParentSection();
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRefToCopy);
AssessmentItem originalAssessmentItem = resolvedAssessmentItem.getItemLookup().extractIfSuccessful();
if (originalAssessmentItem == null) {
showError("error.assessment.item");
return;
}
QTI21QuestionType type = QTI21QuestionType.getType(originalAssessmentItem);
File itemFile = null;
try {
AssessmentItemRef itemRef = new AssessmentItemRef(section);
String itemId = IdentifierGenerator.newAsString(getTypePrefix(type));
itemRef.setIdentifier(Identifier.parseString(itemId));
itemFile = new File(unzippedDirRoot, itemId + ".xml");
itemRef.setHref(new URI(itemFile.getName()));
try (OutputStream out = new FileOutputStream(itemFile)) {
// make the copy
qtiService.qtiSerializer().serializeJqtiObject(originalAssessmentItem, out);
// change identifier and title
ResolvedAssessmentItem resolvedCopyItem = qtiService.loadAndResolveAssessmentItemForCopy(itemFile.toURI(), unzippedDirRoot);
AssessmentItem copiedAssessmentItem = resolvedCopyItem.getRootNodeLookup().extractIfSuccessful();
copiedAssessmentItem.setIdentifier(IdentifierGenerator.newAsString(getTypePrefix(type)));
copiedAssessmentItem.setTitle(originalAssessmentItem.getTitle() + " (Copy)");
qtiService.updateAssesmentObject(itemFile, resolvedCopyItem);
// add to section
section.getSectionParts().add(itemRef);
Map<AssessmentItemRef, AssessmentItem> flyingObjects = Collections.singletonMap(itemRef, copiedAssessmentItem);
doSaveAssessmentTest(ureq, flyingObjects);
manifestBuilder.appendAssessmentItem(itemFile.getName());
doSaveManifest();
} catch (Exception e) {
logError("", e);
}
updateTreeModel(false);
TreeNode newItemNode = menuTree.getTreeModel().getNodeById(itemId);
menuTree.setSelectedNode(newItemNode);
menuTree.open(newItemNode);
partEditorFactory(ureq, newItemNode);
} catch (URISyntaxException e) {
logError("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponent method willShowFeedbacks.
/**
* Check if the assessment item will show some
* form of feedback like feedbackElement, modalFeedback
* or message as invalid or bad response.
*
* @param itemNode
* @return
*/
public boolean willShowFeedbacks(TestPlanNode itemNode) {
if (isHideFeedbacks()) {
return false;
}
try {
URI itemSystemId = itemNode.getItemSystemId();
ResolvedAssessmentItem resolvedAssessmentItem = getResolvedAssessmentTest().getResolvedAssessmentItemBySystemIdMap().get(itemSystemId);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
if (assessmentItem.getAdaptive()) {
return true;
}
ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
if (!itemSessionState.isResponded()) {
return true;
}
ItemProcessingContext itemContext = getTestSessionController().getItemProcessingContext(itemNode);
if (itemContext instanceof ItemSessionController) {
ItemSessionController itemSessionController = (ItemSessionController) itemContext;
List<Interaction> interactions = itemSessionController.getInteractions();
for (Interaction interaction : interactions) {
if (AssessmentRenderFunctions.isBadResponse(itemSessionState, interaction.getResponseIdentifier())) {
return true;
}
if (AssessmentRenderFunctions.isInvalidResponse(itemSessionState, interaction.getResponseIdentifier())) {
return true;
}
}
}
if (assessmentItem.getItemBody().willShowFeedback(itemContext)) {
return true;
}
List<ModalFeedback> modalFeedbacks = assessmentItem.getModalFeedbacks();
for (ModalFeedback modalFeedback : modalFeedbacks) {
if (isFeedback(modalFeedback, itemSessionState)) {
return true;
}
}
} catch (Exception e) {
log.error("", e);
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
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.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class QTI21StatisticResourceResult method createAssessmentItemController.
private Controller createAssessmentItemController(UserRequest ureq, WindowControl wControl, AssessmentItemRef assessmentItemRef, String sectionTitle, boolean printMode) {
ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(assessmentItemRef);
Controller ctrl = new QTI21AssessmentItemStatisticsController(ureq, wControl, assessmentItemRef, resolvedAssessmentItem, sectionTitle, this, withFilter, printMode);
String iconCssClass = "o_mi_qtisc";
if (courseNode != null) {
ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, courseNode, iconCssClass);
}
return ctrl;
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project OpenOLAT by OpenOLAT.
the class ItemBodyResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
ItemBodyResultComponent cmp = (ItemBodyResultComponent) source;
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
if (cmp.isShowSolution()) {
assessmentRenderer.setSolutionAllowed(true);
assessmentRenderer.setSolutionMode(true);
} else {
assessmentRenderer.setReviewMode(true);
}
assessmentItem.getItemBody().getBlocks().forEach((block) -> renderBlock(assessmentRenderer, sb, cmp, resolvedAssessmentItem, itemSessionState, block, ubu, translator));
}
Aggregations