コード例 #1
0
  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;
  }
コード例 #2
0
 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);
 }
コード例 #3
0
  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;
  }
コード例 #4
0
  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);
    }
  }
コード例 #5
0
  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;
  }
コード例 #6
0
 /**
  * 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);
 }
コード例 #7
0
 /**
  * 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);
 }