use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.
the class AssessmentTestDisplayController method processSelectItem.
private void processSelectItem(UserRequest ureq, String key) {
if (checkConcurrentExit(ureq)) {
return;
}
TestPlanNodeKey nodeKey = TestPlanNodeKey.fromString(key);
Date requestTimestamp = ureq.getRequestTimestamp();
TestPlanNode selectedNode = testSessionController.selectItemNonlinear(requestTimestamp, nodeKey);
/* Record and log event */
TestPlanNodeKey selectedNodeKey = (selectedNode == null ? null : selectedNode.getKey());
NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
TestSessionState testSessionState = testSessionController.getTestSessionState();
CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.SELECT_MENU, null, selectedNodeKey, testSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent);
}
use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.
the class AssessmentTestDisplayController method enterSession.
// private CandidateSession enterCandidateSession(final CandidateSession candidateSession)
private TestSessionController enterSession(UserRequest ureq) {
/* Set up listener to record any notifications */
final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
/* Create fresh JQTI+ state & controller for it */
testSessionController = createNewTestSessionStateAndController(notificationRecorder);
if (testSessionController == null) {
return null;
}
/* Initialise test state and enter test */
final TestSessionState testSessionState = testSessionController.getTestSessionState();
final Date timestamp = ureq.getRequestTimestamp();
try {
testSessionController.initialize(timestamp);
final int testPartCount = testSessionController.enterTest(timestamp);
if (testPartCount == 1) {
/* If there is only testPart, then enter this (if possible).
* (Note that this may cause the test to exit immediately if there is a failed
* preCondition on this part.)
*/
testSessionController.enterNextAvailableTestPart(timestamp);
} else {
/* Don't enter first testPart yet - we shall tell candidate that
* there are multiple parts and let them enter manually.
*/
}
} catch (final RuntimeException e) {
logError("", e);
return null;
}
/* Record and log event */
final CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.ENTER_TEST, testSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent);
this.lastEvent = candidateEvent;
boolean ended = testSessionState.isEnded();
/* Record current result state */
final AssessmentResult assessmentResult = computeAndRecordTestAssessmentResult(timestamp, testSessionState, ended);
/* Handle immediate end of test session */
if (ended) {
candidateSession = qtiService.finishTestSession(candidateSession, testSessionState, assessmentResult, timestamp, getDigitalSignatureOptions(), getIdentity());
} else {
TestPart currentTestPart = testSessionController.getCurrentTestPart();
if (currentTestPart != null && currentTestPart.getNavigationMode() == NavigationMode.NONLINEAR) {
// go to the first assessment item
if (testSessionController.hasFollowingNonLinearItem()) {
testSessionController.selectFollowingItemNonLinear(currentRequestTimestamp);
}
}
}
return testSessionController;
}
use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.
the class AssessmentTestDisplayController method timeLimitBarrier.
private boolean timeLimitBarrier(UserRequest ureq) {
Long assessmentTestMaxTimeLimits = getAssessmentTestMaxTimeLimit();
if (assessmentTestMaxTimeLimits != null) {
// convert in milliseconds
long maximumAssessmentTestDuration = assessmentTestMaxTimeLimits.longValue() * 1000;
TestSessionState testSessionState = testSessionController.getTestSessionState();
if (!testSessionState.isEnded() && !testSessionState.isExited()) {
long durationMillis = testSessionState.getDurationAccumulated();
durationMillis += getRequestTimeStampDifferenceToNow();
if (durationMillis > maximumAssessmentTestDuration) {
currentRequestTimestamp = ureq.getRequestTimestamp();
processExitTestAfterTimeLimit(ureq);
return true;
}
}
/*
ItemProcessingContext ctx = testSessionController.getItemProcessingContext(null);
ItemSessionState itemSessionState = ctx.getItemSessionState();
itemSessionState.getDurationAccumulated();
double itemDuration = ctx.getItemSessionState().computeDuration();
*/
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.state.TestSessionState in project openolat by klemens.
the class AssessmentTestDisplayController method processItemSolution.
private void processItemSolution(UserRequest ureq, String key) {
TestPlanNodeKey itemKey = TestPlanNodeKey.fromString(key);
NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
TestSessionState testSessionState = testSessionController.getTestSessionState();
// assertSessionNotTerminated(candidateSession);
try {
if (!testSessionController.mayAccessItemSolution(itemKey)) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, null);
logError("CANNOT_SOLUTION_TEST_ITEM", null);
return;
}
} catch (final QtiCandidateStateException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, e);
logError("CANNOT_SOLUTION_TEST_ITEM", e);
return;
} catch (final RuntimeException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_SOLUTION_TEST_ITEM, e);
logError("Exploded", e);
// handleExplosion(e, candidateSession);
return;
}
/* Record current result state */
computeAndRecordTestAssessmentResult(ureq.getRequestTimestamp(), testSessionState, false);
/* Record and log event */
CandidateEvent candidateTestEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.SOLUTION_ITEM, null, itemKey, testSessionState, notificationRecorder);
this.lastEvent = candidateTestEvent;
candidateAuditLogger.logCandidateEvent(candidateTestEvent);
}
use of uk.ac.ed.ph.jqtiplus.state.TestSessionState 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