use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponent method isItemFeedbackAllowed.
// <xsl:if test="$itemFeedbackAllowed and $sessionStatus='final'">
// <xsl:variable name="itemFeedbackAllowed" as="xs:boolean"
// select="if ($reviewMode)
// then (/qti:assessentItem/@adaptive='true' or $showFeedback)
// else (not($solutionMode))"/>
public boolean isItemFeedbackAllowed(TestPlanNode itemNode, AssessmentItem assessmentItem, RenderingRequest options) {
ItemSessionState itemSessionState = getItemSessionState(itemNode.getKey());
boolean itemFeedbackAllowed = false;
if (itemSessionState.getSessionStatus() == SessionStatus.FINAL) {
if (options.isReviewMode()) {
if (assessmentItem.getAdaptive() || itemNode.getEffectiveItemSessionControl().isShowFeedback()) {
itemFeedbackAllowed = true;
}
} else if (!options.isSolutionMode()) {
itemFeedbackAllowed = true;
}
}
return itemFeedbackAllowed;
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class QTI21ItemBodyController 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));
sessionController.initialize(new Date());
return sessionController;
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTreeComponentRenderer method renderItemStatus.
private void renderItemStatus(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator, RenderingRequest options) {
ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
renderItemStatus(sb, itemSessionState, options, translator);
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
the class AssessmentTreeComponentRenderer method renderAssessmentItemAttempts.
private void renderAssessmentItemAttempts(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
ItemProcessingContext itemProcessingContext = component.getItemSessionState(itemNode);
ItemSessionState itemSessionState = itemProcessingContext.getItemSessionState();
// attempts
int numOfAttempts = itemSessionState.getNumAttempts();
int maxAttempts = 0;
if (itemProcessingContext instanceof ItemSessionController) {
ItemSessionController itemSessionController = (ItemSessionController) itemProcessingContext;
maxAttempts = itemSessionController.getItemSessionControllerSettings().getMaxAttempts();
}
sb.append("<span class='o_assessmentitem_attempts ");
if (maxAttempts > 0) {
if (maxAttempts - numOfAttempts > 0) {
sb.append("o_assessmentitem_attempts_limited");
} else {
sb.append("o_assessmentitem_attempts_nomore");
}
String title = translator.translate("attemptsleft", new String[] { Integer.toString((maxAttempts - numOfAttempts)) });
sb.append("' title=\"").append(StringHelper.escapeHtml(title)).append("\">");
sb.append(numOfAttempts).append(" / ").append(Integer.toString(maxAttempts));
} else {
sb.append("'>").append(numOfAttempts);
}
sb.append("</span>");
}
use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.
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);
}
}
Aggregations