use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderMath.
protected void renderMath(AssessmentRenderer renderer, StringOutput out, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, QtiNode mathElement) {
if (mathElement instanceof ForeignElement) {
ForeignElement fElement = (ForeignElement) mathElement;
boolean mi = fElement.getQtiClassName().equals("mi");
boolean ci = fElement.getQtiClassName().equals("ci");
if (ci || mi) {
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
String text = contentAsString(fElement);
Identifier identifier = Identifier.assumedLegal(text);
Value templateValue = getTemplateValue(itemSessionState, text);
Value outcomeValue = getOutcomeValue(itemSessionState, text);
Value responseValue = getResponseValue(assessmentItem, itemSessionState, identifier, renderer.isSolutionMode());
if (templateValue != null && isTemplateDeclarationAMathVariable(assessmentItem, text)) {
if (ci) {
substituteCi(out, templateValue);
} else if (mi) {
substituteMi(out, templateValue);
}
} else if (outcomeValue != null) {
if (ci) {
substituteCi(out, outcomeValue);
} else if (mi) {
substituteMi(out, outcomeValue);
}
} else if (responseValue != null) {
if (ci) {
substituteCi(out, responseValue);
} else if (mi) {
substituteMi(out, responseValue);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else {
renderStartHtmlTag(out, component, resolvedAssessmentItem, fElement, null);
fElement.getChildren().forEach((child) -> renderMath(renderer, out, component, resolvedAssessmentItem, itemSessionState, child));
renderEndTag(out, fElement);
}
} else if (mathElement instanceof TextRun) {
out.append(((TextRun) mathElement).getTextContent());
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project openolat by klemens.
the class AssessmentObjectComponentRenderer method renderTestItemModalFeedback.
protected void renderTestItemModalFeedback(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, URLBuilder ubu, Translator translator) {
if (component.isHideFeedbacks())
return;
List<ModalFeedback> modalFeedbacks = new ArrayList<>();
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
for (ModalFeedback modalFeedback : assessmentItem.getModalFeedbacks()) {
if (component.isFeedback(modalFeedback, itemSessionState)) {
modalFeedbacks.add(modalFeedback);
}
}
if (modalFeedbacks.size() > 0) {
sb.append("<div class='modalFeedback'>");
for (ModalFeedback modalFeedback : modalFeedbacks) {
Identifier outcomeIdentifier = modalFeedback.getOutcomeIdentifier();
if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(outcomeIdentifier)) {
renderTestItemModalFeedback_feedbackModal(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
} else if (QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(outcomeIdentifier)) {
renderTestItemModalFeedback_correctSolution(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
} else {
renderTestItemModalFeedback_standard(renderer, sb, modalFeedback, component, resolvedAssessmentItem, itemSessionState, ubu, translator);
}
}
sb.append("</div>");
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project openolat by klemens.
the class CorrectionIdentityAssessmentItemListController method doSelect.
private void doSelect(UserRequest ureq, CorrectionIdentityAssessmentItemRow row) {
removeAsListenerAndDispose(identityItemCtrl);
doUnlock();
AssessmentItemRef itemRef = row.getItemRef();
TestSessionState testSessionState = qtiService.loadTestSessionState(candidateSession);
List<TestPlanNode> nodes = testSessionState.getTestPlan().getNodes(itemRef.getIdentifier());
AssessmentItemSession reloadItemSession = null;
if (nodes.size() == 1) {
TestPlanNode itemNode = nodes.get(0);
String stringuifiedIdentifier = itemNode.getKey().getIdentifier().toString();
ParentPartItemRefs parentParts = AssessmentTestHelper.getParentSection(itemNode.getKey(), testSessionState, model.getResolvedAssessmentTest());
reloadItemSession = qtiService.getOrCreateAssessmentItemSession(candidateSession, parentParts, stringuifiedIdentifier);
}
// lock on item, need to check the lock on identity / test
String lockSubKey = "item-" + reloadItemSession.getKey();
OLATResourceable testOres = OresHelper.clone(model.getTestEntry().getOlatResource());
lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(testOres, getIdentity(), lockSubKey);
if (lockResult.isSuccess()) {
if (nodes.size() == 1) {
TestPlanNode itemNode = nodes.get(0);
ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(itemNode.getKey());
AssessmentItemCorrection itemCorrection = new AssessmentItemCorrection(assessedIdentity, candidateSession, testSessionState, reloadItemSession, itemSessionState, itemRef, itemNode);
itemCorrection.setItemSession(reloadItemSession);
ResolvedAssessmentItem resolvedAssessmentItem = model.getResolvedAssessmentTest().getResolvedAssessmentItem(itemRef);
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
identityItemCtrl = new CorrectionIdentityAssessmentItemNavigationController(ureq, getWindowControl(), model.getTestEntry(), model.getResolvedAssessmentTest(), itemCorrection, row, tableModel.getObjects(), model);
listenTo(identityItemCtrl);
stackPanel.pushController(assessmentItem.getTitle(), identityItemCtrl);
updatePreviousNext();
}
} else {
String lockOwnerName = userManager.getUserDisplayName(lockResult.getOwner());
showWarning("warning.assessment.item.locked", new String[] { lockOwnerName });
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project openolat by klemens.
the class InteractionResultComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
InteractionResultComponent cmp = (InteractionResultComponent) source;
Interaction interaction = cmp.getInteraction();
ResolvedAssessmentItem resolvedAssessmentItem = cmp.getResolvedAssessmentItem();
ItemSessionState itemSessionState = cmp.getItemSessionState();
AssessmentRenderer assessmentRenderer = new AssessmentRenderer(renderer);
if (cmp.isShowSolution()) {
assessmentRenderer.setSolutionAllowed(true);
assessmentRenderer.setSolutionMode(true);
} else {
assessmentRenderer.setReviewMode(true);
}
if (interaction instanceof Block) {
renderBlock(assessmentRenderer, sb, cmp, resolvedAssessmentItem, itemSessionState, (Block) interaction, ubu, translator);
} else if (interaction instanceof Flow) {
renderFlow(assessmentRenderer, sb, cmp, resolvedAssessmentItem, itemSessionState, (Flow) interaction, ubu, translator);
}
}
use of uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem in project openolat by klemens.
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