public CandidateEvent recordCandidateItemEvent( final CandidateSession candidateSession, final CandidateItemEventType itemEventType, final ItemSessionState itemSessionState, final NotificationRecorder notificationRecorder) { /* Create event */ final CandidateEvent event = new CandidateEvent(); event.setCandidateSession(candidateSession); event.setItemEventType(itemEventType); event.setTimestamp(requestTimestampContext.getCurrentRequestTimestamp()); /* Store event */ candidateEventDao.persist(event); /* Save current ItemSessionState */ storeItemSessionState(event, itemSessionState); /* Now store processing notifications */ if (notificationRecorder != null) { for (final Notification notification : notificationRecorder.getNotifications()) { recordNotification(event, notification); } } return event; }
private File getSessionStateFile(final CandidateEvent candidateEvent) { final CandidateSession candidateSession = candidateEvent.getCandidateSession(); final AssessmentObjectType assessmentType = candidateSession.getDelivery().getAssessment().getAssessmentType(); final String stateFileBaseName = assessmentType == AssessmentObjectType.ASSESSMENT_ITEM ? "itemSessionState" : "testSessionState"; final File sessionFolder = filespaceManager.obtainCandidateSessionStateStore(candidateSession); final String stateFileName = stateFileBaseName + candidateEvent.getId() + ".xml"; return new File(sessionFolder, stateFileName); }
public CandidateEventNotification recordNotification( final CandidateEvent candidateEvent, final Notification notification) { final CandidateEventNotification record = new CandidateEventNotification(); record.setCandidateEvent(candidateEvent); record.setMessage(notification.getMessage()); record.setNotificationLevel(notification.getNotificationLevel()); record.setNotificationType(notification.getNotificationType()); final QtiNode qtiNode = notification.getQtiNode(); if (qtiNode != null) { record.setNodeQtiClassName(qtiNode.getQtiClassName()); final XmlSourceLocationInformation sourceLocation = qtiNode.getSourceLocation(); if (sourceLocation != null) { record.setSystemId(sourceLocation.getSystemId()); record.setLineNumber(sourceLocation.getLineNumber()); record.setColumnNumber(sourceLocation.getColumnNumber()); } } final Attribute<?> attribute = notification.getAttribute(); if (attribute != null) { record.setAttributeLocalName(attribute.getLocalName()); record.setAttributeNamespaceUri(attribute.getNamespaceUri()); } candidateEvent.getNotifications().add(record); candidateEventNotificationDao.persist(record); return record; }
public AssessmentResult computeAssessmentResult(final CandidateEvent candidateEvent) { final AssessmentObjectType assessmentType = candidateEvent.getCandidateSession().getDelivery().getAssessment().getAssessmentType(); switch (assessmentType) { case ASSESSMENT_ITEM: final ItemSessionController itemSessionController = createItemSessionController(candidateEvent, null); return computeItemAssessmentResult( candidateEvent.getCandidateSession(), itemSessionController); case ASSESSMENT_TEST: final TestSessionController testSessionController = createTestSessionController(candidateEvent, null); return computeTestAssessmentResult( candidateEvent.getCandidateSession(), testSessionController); default: throw new QtiWorksLogicException("Unexpected switch case " + assessmentType); } }
public CandidateEvent recordCandidateTestEvent( final CandidateSession candidateSession, final CandidateTestEventType testEventType, final CandidateItemEventType itemEventType, final TestPlanNodeKey itemKey, final TestSessionState testSessionState, final NotificationRecorder notificationRecorder) { Assert.notNull(candidateSession, "candidateSession"); Assert.notNull(testEventType, "testEventType"); Assert.notNull(testSessionState, "testSessionState"); /* Create event */ final CandidateEvent event = new CandidateEvent(); event.setCandidateSession(candidateSession); event.setTestEventType(testEventType); event.setItemEventType(itemEventType); if (itemKey != null) { event.setTestItemKey(itemKey.toString()); } event.setTimestamp(requestTimestampContext.getCurrentRequestTimestamp()); /* Store event */ candidateEventDao.persist(event); /* Store test session state */ storeTestSessionState(event, testSessionState); /* Now store processing notifications */ if (notificationRecorder != null) { for (final Notification notification : notificationRecorder.getNotifications()) { recordNotification(event, notification); } } return event; }
/** * Extracts the {@link TestSessionState} corresponding to the given {@link CandidateEvent} and * wraps it in a {@link TestSessionController}. * * <p>It is assumed that the test was runnable, so this will never return null. */ public TestSessionController createTestSessionController( final CandidateEvent candidateEvent, final NotificationRecorder notificationRecorder) { final TestSessionState testSessionState = loadTestSessionState(candidateEvent); return createTestSessionController( candidateEvent.getCandidateSession(), testSessionState, notificationRecorder); }
/** * Extracts the {@link ItemSessionState} corresponding to the given {@link CandidateEvent} and * wraps it in a {@link ItemSessionController}. * * <p>It is assumed that the item was runnable, so this will never return null. */ public ItemSessionController createItemSessionController( final CandidateEvent candidateEvent, final NotificationRecorder notificationRecorder) { final ItemSessionState itemSessionState = loadItemSessionState(candidateEvent); return createItemSessionController( candidateEvent.getCandidateSession(), itemSessionState, notificationRecorder); }