use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.
the class AssessmentItemDisplayController method enterSession.
private ItemSessionController enterSession(UserRequest ureq) /*, final UserTestSession candidateSession */
{
/* Set up listener to record any notifications */
final NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
/* Create fresh JQTI+ state Object and try to create controller */
itemSessionController = createNewItemSessionStateAndController(notificationRecorder);
if (itemSessionController == null) {
logError("Cannot create item session controller for:" + itemFileRef, null);
return null;
}
/* Try to Initialise JQTI+ state */
final ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
try {
final Date timestamp = ureq.getRequestTimestamp();
itemSessionController.initialize(timestamp);
itemSessionController.performTemplateProcessing(timestamp);
itemSessionController.enterItem(timestamp);
} catch (final RuntimeException e) {
logError("", e);
return null;
}
/* Record and log entry event */
final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.ENTER, itemSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent);
lastEvent = candidateEvent;
/* Record current result state */
final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
/* Handle immediate end of session */
if (itemSessionState.isEnded()) {
qtiService.finishItemSession(candidateSession, assessmentResult, ureq.getRequestTimestamp());
}
return itemSessionController;
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.
the class AssessmentItemDisplayController method exitSession.
public void exitSession(UserRequest ureq) {
ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
/* Are we terminating a session that hasn't already been ended? If so end the session and record final result. */
final Date currentTimestamp = ureq.getRequestTimestamp();
if (!itemSessionState.isEnded()) {
try {
itemSessionController.endItem(currentTimestamp);
} catch (final RuntimeException e) {
logError("", e);
// handleExplosion(e, candidateSession);
return;
}
final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
qtiService.finishItemSession(candidateSession, assessmentResult, currentTimestamp);
}
/* Update session entity */
candidateSession.setTerminationTime(currentTimestamp);
candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
/* Record and log event */
final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.EXIT, itemSessionState);
lastEvent = candidateEvent;
candidateAuditLogger.logCandidateEvent(candidateEvent);
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.
the class AssessmentItemDisplayController method endSession.
public void endSession(UserRequest ureq) {
NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
// final ItemSessionController itemSessionController = candidateDataService.createItemSessionController(mostRecentEvent, notificationRecorder);
ItemSessionState itemSessionState = itemSessionController.getItemSessionState();
if (itemSessionState.isEnded()) {
logError("END_SESSION_WHEN_ALREADY_ENDED", null);
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED, null);
return;
}
/* else if (!itemDeliverySettings.isAllowEnd()) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN);
return null;
}*/
/* Update state */
final Date timestamp = ureq.getRequestTimestamp();
try {
itemSessionController.endItem(timestamp);
} catch (QtiCandidateStateException e) {
String msg = itemSessionState.isEnded() ? "END_SESSION_WHEN_ALREADY_ENDED" : "END_SESSION_WHEN_INTERACTING_FORBIDDEN";
logError(msg, e);
candidateAuditLogger.logAndThrowCandidateException(candidateSession, itemSessionState.isEnded() ? CandidateExceptionReason.END_SESSION_WHEN_ALREADY_ENDED : CandidateExceptionReason.END_SESSION_WHEN_INTERACTING_FORBIDDEN, null);
return;
} catch (final RuntimeException e) {
logError("", e);
// handleExplosion(e, candidateSession);
return;
}
/* Record current result state */
final AssessmentResult assessmentResult = computeAndRecordItemAssessmentResult(ureq);
/* Record and log event */
final CandidateEvent candidateEvent = qtiService.recordCandidateItemEvent(candidateSession, null, entry, CandidateItemEventType.END, itemSessionState, notificationRecorder);
candidateAuditLogger.logCandidateEvent(candidateEvent);
lastEvent = candidateEvent;
/* Close session */
qtiService.finishItemSession(candidateSession, assessmentResult, timestamp);
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.
the class AssessmentTestDisplayController method immediateEndTestSession.
private void immediateEndTestSession(UserRequest ureq) {
AssessmentResult assessmentResult = qtiService.getAssessmentResult(candidateSession);
if (assessmentResult == null) {
candidateSession.setTerminationTime(ureq.getRequestTimestamp());
candidateSession.setExploded(true);
candidateSession = qtiService.updateAssessmentTestSession(candidateSession);
} else {
candidateSession = qtiService.finishTestSession(candidateSession, testSessionController.getTestSessionState(), assessmentResult, currentRequestTimestamp, getDigitalSignatureOptions(), getIdentity());
}
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project openolat by klemens.
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 (RuntimeException e) {
candidateAuditLogger.logAndThrowCandidateException(candidateSession, CandidateExceptionReason.CANNOT_FINISH_LINEAR_TEST_ITEM, e);
logError("CANNOT_FINISH_LINEAR_TEST_ITEM", e);
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, terminated);
/* If we ended the testPart and there are now no more available testParts, then finish the session now */
if (terminated) {
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);
}
Aggregations