use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState 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.state.ItemSessionState 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.state.ItemSessionState 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));
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class UnkownItemEditorController method createNewItemSessionStateAndController.
private ItemSessionController createNewItemSessionStateAndController() {
/* Resolve the underlying JQTI+ object */
final ItemProcessingMap itemProcessingMap = new ItemProcessingInitializer(resolvedAssessmentItem, true).initialize();
/* Create fresh state for session */
final ItemSessionState itemSessionState = new ItemSessionState();
final ItemSessionControllerSettings itemSessionControllerSettings = new ItemSessionControllerSettings();
itemSessionControllerSettings.setTemplateProcessingLimit(25);
itemSessionControllerSettings.setMaxAttempts(10);
/* Create controller and wire up notification recorder */
final ItemSessionController sessionController = new ItemSessionController(qtiService.jqtiExtensionManager(), itemSessionControllerSettings, itemProcessingMap, itemSessionState);
sessionController.addNotificationListener(new NotificationRecorder(NotificationLevel.ERROR));
Long randomSeed = new Random().nextLong();
sessionController.setRandomSeed(randomSeed);
sessionController.initialize(new Date());
sessionController.performTemplateProcessing(new Date());
return sessionController;
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project openolat by klemens.
the class RunningItemHelper method run.
public static ItemSessionController run(URI inputUri, Map<Identifier, ResponseData> responseMap, ResourceLocator inputResourceLocator) {
SimpleJqtiFacade simpleJqtiFacade = new SimpleJqtiFacade();
ResolvedAssessmentItem resolvedAssessmentItem = simpleJqtiFacade.loadAndResolveAssessmentItem(inputResourceLocator, inputUri);
ItemProcessingMap itemProcessingMap = new ItemProcessingInitializer(resolvedAssessmentItem, false).initialize();
ItemSessionState itemSessionState = new ItemSessionState();
ItemSessionControllerSettings itemSessionControllerSettings = new ItemSessionControllerSettings();
ItemSessionController itemSessionController = simpleJqtiFacade.createItemSessionController(itemSessionControllerSettings, itemProcessingMap, itemSessionState);
itemSessionController.initialize(new Date());
itemSessionController.performTemplateProcessing(new Date());
itemSessionController.enterItem(new Date());
itemSessionController.bindResponses(new Date(), responseMap);
itemSessionController.commitResponses(new Date());
itemSessionController.performResponseProcessing(new Date());
AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
assessmentItem.getItemBody().willShowFeedback(itemSessionController);
itemSessionController.endItem(new Date());
itemSessionController.exitItem(new Date());
return itemSessionController;
}
Aggregations