use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.
the class AssessmentTestDisplayController method processFinishLinearItem.
// public CandidateSession finishLinearItem(final CandidateSessionContext candidateSessionContext)
// throws CandidateException {
private void processFinishLinearItem(UserRequest ureq) {
NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
TestSessionState testSessionState = testSessionController.getTestSessionState();
try {
if (!testSessionController.mayAdvanceItemLinear()) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, null);
logError("CANNOT_FINISH_LINEAR_TEST_ITEM", null);
return;
}
} catch (QtiCandidateStateException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
return;
} catch (RuntimeException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
// handleExplosion(e, candidateSession);
return;
}
// Update state
final Date requestTimestamp = ureq.getRequestTimestamp();
final TestPlanNode nextItemNode = testSessionController.advanceItemLinear(requestTimestamp);
// boolean terminated = nextItemNode == null && testSessionController.findNextEnterableTestPart() == null;
// Record current result state
final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(requestTimestamp, testSessionState, false);
/* If we ended the testPart and there are now no more available testParts, then finish the session now */
if (nextItemNode == null && testSessionController.findNextEnterableTestPart() == null) {
candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, requestTimestamp, getDigitalSignatureOptions(), getIdentity());
}
// Record and log event
final CandidateTestEventType eventType = nextItemNode != null ? CandidateTestEventType.FINISH_ITEM : CandidateTestEventType.FINISH_FINAL_ITEM;
final CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, eventType, null, null, testSessionState, notificationRecorder);
this.lastEvent = candidateTestEvent;
candidateAuditLogger.logCandidateEvent(candidateTestEvent);
}
use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
AssessmentTestComponent cmp = (AssessmentTestComponent) source;
TestSessionController testSessionController = cmp.getTestSessionController();
if (testSessionController.getTestSessionState().isEnded()) {
renderTerminated(sb, translator);
} else {
/* Create appropriate options that link back to this controller */
TestSessionState testSessionState = testSessionController.getTestSessionState();
CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
if (candidateSession.isExploded()) {
renderExploded(sb, translator);
} else if (candidateSessionContext.isTerminated()) {
renderTerminated(sb, translator);
} else {
/* Touch the session's duration state if appropriate */
if (testSessionState.isEntered() && !testSessionState.isEnded()) {
final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
testSessionController.touchDurations(timestamp);
}
/* Render event */
AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
renderTestEvent(testSessionController, renderHints, sb, cmp, ubu, translator);
}
}
}
use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.
the class AssessmentTestComponentRenderer method renderTestEvent.
private void renderTestEvent(TestSessionController testSessionController, AssessmentRenderer renderer, StringOutput target, AssessmentTestComponent component, URLBuilder ubu, Translator translator) {
CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
CandidateTestEventType testEventType = candidateEvent.getTestEventType();
/* If session has terminated, render appropriate state and exit */
final TestSessionState testSessionState = testSessionController.getTestSessionState();
if (candidateSessionContext.isTerminated() || testSessionState.isExited()) {
renderTerminated(target, translator);
} else if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
renderer.setReviewMode(true);
TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
RenderingRequest options = RenderingRequest.getItemReview();
renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
} else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
renderer.setSolutionMode(true);
TestPlanNodeKey itemKey = extractTargetItemKey(candidateEvent);
RenderingRequest options = RenderingRequest.getItemSolution();
renderTestItem(renderer, target, component, itemKey, ubu, translator, options);
} else {
/* Render current state */
final TestPlanNodeKey currentTestPartKey = testSessionState.getCurrentTestPartKey();
if (testSessionState.isEnded()) {
/* At end of test, so show overall test feedback */
renderTestPartFeedback(renderer, target, component, ubu, translator);
} else if (currentTestPartKey != null) {
final TestPartSessionState currentTestPartSessionState = testSessionState.getTestPartSessionStates().get(currentTestPartKey);
final TestPlanNodeKey currentItemKey = testSessionState.getCurrentItemKey();
if (currentItemKey != null) {
/* An item is selected, so render it in appropriate state */
RenderingRequest options = RenderingRequest.getItem(testSessionController);
renderTestItem(renderer, target, component, currentItemKey, ubu, translator, options);
} else {
/* No item selected */
if (currentTestPartSessionState.isEnded()) {
/* testPart has ended, so must be showing testPart feedback */
renderTestPartFeedback(renderer, target, component, ubu, translator);
} else {
/* testPart not ended, so we must be showing the navigation menu in nonlinear mode */
renderNavigation(renderer, target, component, ubu, translator);
}
}
} else {
/* No current testPart == start of multipart test */
renderTestEntry(target, component, translator);
}
}
}
use of org.olat.ims.qti21.ui.CandidateSessionContext in project OpenOLAT by OpenOLAT.
the class AssessmentTreeComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
AssessmentTreeComponent component = (AssessmentTreeComponent) source;
TestSessionController testSessionController = component.getTestSessionController();
if (!testSessionController.getTestSessionState().isEnded()) {
CandidateSessionContext candidateSessionContext = component.getCandidateSessionContext();
final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
if (!candidateSession.isExploded() && !candidateSessionContext.isTerminated()) {
CandidateEvent candidateEvent = candidateSessionContext.getLastEvent();
CandidateTestEventType testEventType = candidateEvent.getTestEventType();
RenderingRequest options;
if (testEventType == CandidateTestEventType.REVIEW_ITEM) {
options = RenderingRequest.getItemReview();
} else if (testEventType == CandidateTestEventType.SOLUTION_ITEM) {
options = RenderingRequest.getItemSolution();
} else {
options = RenderingRequest.getItem(testSessionController);
}
AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
renderTestEvent(testSessionController, renderHints, sb, component, ubu, translator, options);
}
}
}
use of org.olat.ims.qti21.ui.CandidateSessionContext in project openolat by klemens.
the class AssessmentTestComponentRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
AssessmentTestComponent cmp = (AssessmentTestComponent) source;
TestSessionController testSessionController = cmp.getTestSessionController();
if (testSessionController.getTestSessionState().isEnded()) {
renderTerminated(sb, translator);
} else {
/* Create appropriate options that link back to this controller */
TestSessionState testSessionState = testSessionController.getTestSessionState();
CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
if (candidateSession.isExploded()) {
renderExploded(sb, translator);
} else if (candidateSessionContext.isTerminated()) {
renderTerminated(sb, translator);
} else {
/* Touch the session's duration state if appropriate */
if (testSessionState.isEntered() && !testSessionState.isEnded()) {
final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
testSessionController.touchDurations(timestamp);
}
/* Render event */
AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
renderTestEvent(testSessionController, renderHints, sb, cmp, ubu, translator);
}
}
}
Aggregations