use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method getAssessmentResult.
@Override
public AssessmentResult getAssessmentResult(AssessmentTestSession candidateSession) {
File assessmentResultFile = getAssessmentResultFile(candidateSession);
ResourceLocator fileResourceLocator = new PathResourceLocator(assessmentResultFile.getParentFile().toPath());
ResourceLocator inputResourceLocator = ImsQTI21Resource.createResolvingResourceLocator(fileResourceLocator);
URI assessmentResultUri = assessmentResultFile.toURI();
QtiObjectReader qtiObjectReader = qtiXmlReader().createQtiObjectReader(inputResourceLocator, false, false);
try {
QtiObjectReadResult<AssessmentResult> result = qtiObjectReader.lookupRootNode(assessmentResultUri, AssessmentResult.class);
return result.getRootNode();
} catch (XmlResourceNotFoundException | QtiXmlInterpretationException | ClassCastException e) {
log.error("", e);
return null;
}
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.
the class AssessmentItemDisplayController method computeAndRecordItemAssessmentResult.
public AssessmentResult computeAndRecordItemAssessmentResult(UserRequest ureq) {
final AssessmentResult assessmentResult = computeItemAssessmentResult(ureq);
qtiService.recordItemAssessmentResult(candidateSession, assessmentResult, candidateAuditLogger);
return assessmentResult;
}
use of uk.ac.ed.ph.jqtiplus.node.result.AssessmentResult in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
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;
}
Aggregations