Search in sources :

Example 1 with RetrieveAssessmentTestSessionEvent

use of org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method reopenAssessmentTestSession.

/*
	@Override
	public AssessmentTestSession reopenAssessmentTestSession(AssessmentTestSession session, Identity actor) {
		// update test session on the database
		AssessmentTestSession reloadedSession = testSessionDao.loadByKey(session.getKey());

		//update the XMl test session state
		TestSessionState testSessionState = loadTestSessionState(reloadedSession);
		testSessionState.setEndTime(null);
		testSessionState.setExitTime(null);
		for(TestPartSessionState testPartSessionState:testSessionState.getTestPartSessionStates().values()) {
			testPartSessionState.setEndTime(null);
			testPartSessionState.setExitTime(null);
		}
		for(AssessmentSectionSessionState sessionState:testSessionState.getAssessmentSectionSessionStates().values()) {
			sessionState.setEndTime(null);
			sessionState.setExitTime(null);
		}
		
		TestPlanNodeKey lastEntryItemKey = null;
		ItemSessionState lastEntryItemSessionState = null;
		for(Map.Entry<TestPlanNodeKey, ItemSessionState> entry:testSessionState.getItemSessionStates().entrySet()) {
			ItemSessionState itemSessionState = entry.getValue();
			itemSessionState.setEndTime(null);
			itemSessionState.setExitTime(null);
			if(itemSessionState.getEntryTime() != null &&
					(lastEntryItemSessionState == null || itemSessionState.getEntryTime().after(lastEntryItemSessionState.getEntryTime()))) {
				lastEntryItemKey = entry.getKey();
				lastEntryItemSessionState = itemSessionState;
			}
		}
		
		if(lastEntryItemKey != null) {
			Date now = new Date();
			TestPlan plan = testSessionState.getTestPlan();
			TestPlanNodeKey currentTestPartKey = null;
			for(TestPlanNode currentNode = plan.getNode(lastEntryItemKey); currentNode != null; currentNode = currentNode.getParent()) {
				TestNodeType type = currentNode.getTestNodeType();
				TestPlanNodeKey currentNodeKey = currentNode.getKey();
				switch(type) {
					case TEST_PART: {
						currentTestPartKey = currentNodeKey;
						TestPartSessionState state = testSessionState.getTestPartSessionStates().get(currentNodeKey);
						if(state != null) {
							state.setDurationIntervalStartTime(now);
						}
						break;
					}
					case ASSESSMENT_SECTION: {
						AssessmentSectionSessionState sessionState = testSessionState.getAssessmentSectionSessionStates().get(currentNodeKey);
						if(sessionState != null) {
							sessionState.setDurationIntervalStartTime(now);
						}
						break;
					}
					case ASSESSMENT_ITEM_REF: {
						ItemSessionState itemState = testSessionState.getItemSessionStates().get(currentNodeKey);
						if(itemState != null) {
							itemState.setDurationIntervalStartTime(now);
						}
						break;
					}
					default: {
						//root doesn't match any session state
						break;
					}
				}
			}
			
			//if all the elements are started again, allow to reopen the test
			if(currentTestPartKey != null) {
				testSessionState.setCurrentTestPartKey(currentTestPartKey);
				testSessionState.setCurrentItemKey(lastEntryItemKey);
				storeTestSessionState(reloadedSession, testSessionState);
				
				reloadedSession.setFinishTime(null);
				reloadedSession.setTerminationTime(null);
				reloadedSession = testSessionDao.update(reloadedSession);
				
				AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
				candidateAuditLogger.logTestReopen(session, actor);
				
				RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
				OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
				coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
				return reloadedSession;
			}
		}
		return null;
	}*/
@Override
public AssessmentTestSession reopenAssessmentTestSession(AssessmentTestSession session, Identity actor) {
    AssessmentTestSession reloadedSession = testSessionDao.loadByKey(session.getKey());
    // update the XMl test session state
    TestSessionState testSessionState = loadTestSessionState(reloadedSession);
    testSessionState.setEndTime(null);
    testSessionState.setExitTime(null);
    TestPlanNodeKey lastEntryItemKey = null;
    ItemSessionState lastEntryItemSessionState = null;
    for (Map.Entry<TestPlanNodeKey, ItemSessionState> entry : testSessionState.getItemSessionStates().entrySet()) {
        ItemSessionState itemSessionState = entry.getValue();
        if (itemSessionState.getEntryTime() != null && (lastEntryItemSessionState == null || itemSessionState.getEntryTime().after(lastEntryItemSessionState.getEntryTime()))) {
            lastEntryItemKey = entry.getKey();
            lastEntryItemSessionState = itemSessionState;
        }
    }
    if (lastEntryItemKey != null) {
        TestPlan plan = testSessionState.getTestPlan();
        TestPlanNode lastItem = plan.getNode(lastEntryItemKey);
        TestPlanNodeKey partKey = reopenTestPart(lastItem, testSessionState);
        resumeItem(lastEntryItemKey, testSessionState);
        // if all the elements are started again, allow to reopen the test
        if (partKey != null) {
            testSessionState.setCurrentTestPartKey(partKey);
            testSessionState.setCurrentItemKey(lastEntryItemKey);
            storeTestSessionState(reloadedSession, testSessionState);
            reloadedSession.setFinishTime(null);
            reloadedSession.setTerminationTime(null);
            reloadedSession = testSessionDao.update(reloadedSession);
            AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
            candidateAuditLogger.logTestReopen(session, actor);
            RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
            OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
            coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
            return reloadedSession;
        }
    }
    return null;
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) OLATResourceable(org.olat.core.id.OLATResourceable) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 2 with RetrieveAssessmentTestSessionEvent

use of org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent in project openolat by klemens.

the class QTI21ServiceImpl method pullSession.

@Override
public AssessmentTestSession pullSession(AssessmentTestSession session, DigitalSignatureOptions signatureOptions, Identity actor) {
    session = getAssessmentTestSession(session.getKey());
    if (session.getFinishTime() == null) {
        if (qtiModule.isDigitalSignatureEnabled()) {
            signAssessmentResult(session, signatureOptions, session.getIdentity());
        }
        session.setFinishTime(new Date());
    }
    session.setTerminationTime(new Date());
    session = updateAssessmentTestSession(session);
    // make sure that the changes committed before sending the event
    dbInstance.commit();
    AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
    candidateAuditLogger.logTestRetrieved(session, actor);
    OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new RetrieveAssessmentTestSessionEvent(session.getKey()), sessionOres);
    return session;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent) Date(java.util.Date)

Example 3 with RetrieveAssessmentTestSessionEvent

use of org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent in project openolat by klemens.

the class QTI21ServiceImpl method reopenAssessmentTestSession.

/*
	@Override
	public AssessmentTestSession reopenAssessmentTestSession(AssessmentTestSession session, Identity actor) {
		// update test session on the database
		AssessmentTestSession reloadedSession = testSessionDao.loadByKey(session.getKey());

		//update the XMl test session state
		TestSessionState testSessionState = loadTestSessionState(reloadedSession);
		testSessionState.setEndTime(null);
		testSessionState.setExitTime(null);
		for(TestPartSessionState testPartSessionState:testSessionState.getTestPartSessionStates().values()) {
			testPartSessionState.setEndTime(null);
			testPartSessionState.setExitTime(null);
		}
		for(AssessmentSectionSessionState sessionState:testSessionState.getAssessmentSectionSessionStates().values()) {
			sessionState.setEndTime(null);
			sessionState.setExitTime(null);
		}
		
		TestPlanNodeKey lastEntryItemKey = null;
		ItemSessionState lastEntryItemSessionState = null;
		for(Map.Entry<TestPlanNodeKey, ItemSessionState> entry:testSessionState.getItemSessionStates().entrySet()) {
			ItemSessionState itemSessionState = entry.getValue();
			itemSessionState.setEndTime(null);
			itemSessionState.setExitTime(null);
			if(itemSessionState.getEntryTime() != null &&
					(lastEntryItemSessionState == null || itemSessionState.getEntryTime().after(lastEntryItemSessionState.getEntryTime()))) {
				lastEntryItemKey = entry.getKey();
				lastEntryItemSessionState = itemSessionState;
			}
		}
		
		if(lastEntryItemKey != null) {
			Date now = new Date();
			TestPlan plan = testSessionState.getTestPlan();
			TestPlanNodeKey currentTestPartKey = null;
			for(TestPlanNode currentNode = plan.getNode(lastEntryItemKey); currentNode != null; currentNode = currentNode.getParent()) {
				TestNodeType type = currentNode.getTestNodeType();
				TestPlanNodeKey currentNodeKey = currentNode.getKey();
				switch(type) {
					case TEST_PART: {
						currentTestPartKey = currentNodeKey;
						TestPartSessionState state = testSessionState.getTestPartSessionStates().get(currentNodeKey);
						if(state != null) {
							state.setDurationIntervalStartTime(now);
						}
						break;
					}
					case ASSESSMENT_SECTION: {
						AssessmentSectionSessionState sessionState = testSessionState.getAssessmentSectionSessionStates().get(currentNodeKey);
						if(sessionState != null) {
							sessionState.setDurationIntervalStartTime(now);
						}
						break;
					}
					case ASSESSMENT_ITEM_REF: {
						ItemSessionState itemState = testSessionState.getItemSessionStates().get(currentNodeKey);
						if(itemState != null) {
							itemState.setDurationIntervalStartTime(now);
						}
						break;
					}
					default: {
						//root doesn't match any session state
						break;
					}
				}
			}
			
			//if all the elements are started again, allow to reopen the test
			if(currentTestPartKey != null) {
				testSessionState.setCurrentTestPartKey(currentTestPartKey);
				testSessionState.setCurrentItemKey(lastEntryItemKey);
				storeTestSessionState(reloadedSession, testSessionState);
				
				reloadedSession.setFinishTime(null);
				reloadedSession.setTerminationTime(null);
				reloadedSession = testSessionDao.update(reloadedSession);
				
				AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
				candidateAuditLogger.logTestReopen(session, actor);
				
				RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
				OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
				coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
				return reloadedSession;
			}
		}
		return null;
	}*/
@Override
public AssessmentTestSession reopenAssessmentTestSession(AssessmentTestSession session, Identity actor) {
    AssessmentTestSession reloadedSession = testSessionDao.loadByKey(session.getKey());
    // update the XMl test session state
    TestSessionState testSessionState = loadTestSessionState(reloadedSession);
    testSessionState.setEndTime(null);
    testSessionState.setExitTime(null);
    TestPlanNodeKey lastEntryItemKey = null;
    ItemSessionState lastEntryItemSessionState = null;
    for (Map.Entry<TestPlanNodeKey, ItemSessionState> entry : testSessionState.getItemSessionStates().entrySet()) {
        ItemSessionState itemSessionState = entry.getValue();
        if (itemSessionState.getEntryTime() != null && (lastEntryItemSessionState == null || itemSessionState.getEntryTime().after(lastEntryItemSessionState.getEntryTime()))) {
            lastEntryItemKey = entry.getKey();
            lastEntryItemSessionState = itemSessionState;
        }
    }
    if (lastEntryItemKey != null) {
        TestPlan plan = testSessionState.getTestPlan();
        TestPlanNode lastItem = plan.getNode(lastEntryItemKey);
        TestPlanNodeKey partKey = reopenTestPart(lastItem, testSessionState);
        resumeItem(lastEntryItemKey, testSessionState);
        // if all the elements are started again, allow to reopen the test
        if (partKey != null) {
            testSessionState.setCurrentTestPartKey(partKey);
            testSessionState.setCurrentItemKey(lastEntryItemKey);
            storeTestSessionState(reloadedSession, testSessionState);
            reloadedSession.setFinishTime(null);
            reloadedSession.setTerminationTime(null);
            reloadedSession = testSessionDao.update(reloadedSession);
            AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
            candidateAuditLogger.logTestReopen(session, actor);
            RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
            OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
            coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
            return reloadedSession;
        }
    }
    return null;
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) OLATResourceable(org.olat.core.id.OLATResourceable) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 4 with RetrieveAssessmentTestSessionEvent

use of org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method extraTimeAssessmentTestSession.

@Override
public void extraTimeAssessmentTestSession(AssessmentTestSession session, int extraTime, Identity actor) {
    testSessionDao.extraTime(session, extraTime);
    // commit before event
    dbInstance.commit();
    AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
    candidateAuditLogger.logTestExtend(session, extraTime, actor);
    RetrieveAssessmentTestSessionEvent event = new RetrieveAssessmentTestSessionEvent(session.getKey());
    OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(event, sessionOres);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent)

Example 5 with RetrieveAssessmentTestSessionEvent

use of org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method pullSession.

@Override
public AssessmentTestSession pullSession(AssessmentTestSession session, DigitalSignatureOptions signatureOptions, Identity actor) {
    session = getAssessmentTestSession(session.getKey());
    if (session.getFinishTime() == null) {
        if (qtiModule.isDigitalSignatureEnabled()) {
            signAssessmentResult(session, signatureOptions, session.getIdentity());
        }
        session.setFinishTime(new Date());
    }
    session.setTerminationTime(new Date());
    session = updateAssessmentTestSession(session);
    // make sure that the changes committed before sending the event
    dbInstance.commit();
    AssessmentSessionAuditLogger candidateAuditLogger = getAssessmentSessionAuditLogger(session, false);
    candidateAuditLogger.logTestRetrieved(session, actor);
    OLATResourceable sessionOres = OresHelper.createOLATResourceableInstance(AssessmentTestSession.class, session.getKey());
    coordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(new RetrieveAssessmentTestSessionEvent(session.getKey()), sessionOres);
    return session;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentSessionAuditLogger(org.olat.ims.qti21.AssessmentSessionAuditLogger) RetrieveAssessmentTestSessionEvent(org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent) Date(java.util.Date)

Aggregations

RetrieveAssessmentTestSessionEvent (org.olat.ims.qti21.ui.event.RetrieveAssessmentTestSessionEvent)8 OLATResourceable (org.olat.core.id.OLATResourceable)6 AssessmentSessionAuditLogger (org.olat.ims.qti21.AssessmentSessionAuditLogger)6 Date (java.util.Date)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)2 InMemoryAssessmentTestSession (org.olat.ims.qti21.model.InMemoryAssessmentTestSession)2 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)2 TestPlan (uk.ac.ed.ph.jqtiplus.state.TestPlan)2 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)2 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)2 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)2