Search in sources :

Example 26 with TestPlanNode

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNode in project openolat by klemens.

the class AssessmentTestDisplayController method processNextItem.

private void processNextItem(UserRequest ureq) {
    if (checkConcurrentExit(ureq)) {
        return;
    }
    Date requestTimestamp = ureq.getRequestTimestamp();
    if (testSessionController.hasFollowingNonLinearItem()) {
        TestPlanNode selectedNode = testSessionController.selectFollowingItemNonLinear(requestTimestamp);
        TestPlanNodeKey selectedNodeKey = (selectedNode == null ? null : selectedNode.getKey());
        NotificationRecorder notificationRecorder = new NotificationRecorder(NotificationLevel.INFO);
        TestSessionState testSessionState = testSessionController.getTestSessionState();
        CandidateEvent candidateEvent = qtiService.recordCandidateTestEvent(candidateSession, testEntry, entry, CandidateTestEventType.NEXT_ITEM, null, selectedNodeKey, testSessionState, notificationRecorder);
        candidateAuditLogger.logCandidateEvent(candidateEvent);
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) NotificationRecorder(uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder) Date(java.util.Date) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 27 with TestPlanNode

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNode 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 28 with TestPlanNode

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNode in project openolat by klemens.

the class QTI21ServiceImpl method resumeItem.

private void resumeItem(TestPlanNodeKey lastEntryItemKey, TestSessionState testSessionState) {
    TestPlan plan = testSessionState.getTestPlan();
    Date now = new Date();
    for (TestPlanNode currentNode = plan.getNode(lastEntryItemKey); currentNode != null; currentNode = currentNode.getParent()) {
        TestNodeType type = currentNode.getTestNodeType();
        TestPlanNodeKey currentNodeKey = currentNode.getKey();
        switch(type) {
            case TEST_PART:
                {
                    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;
                }
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestPlan(uk.ac.ed.ph.jqtiplus.state.TestPlan) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) TestPartSessionState(uk.ac.ed.ph.jqtiplus.state.TestPartSessionState) AssessmentSectionSessionState(uk.ac.ed.ph.jqtiplus.state.AssessmentSectionSessionState) Date(java.util.Date) TestNodeType(uk.ac.ed.ph.jqtiplus.state.TestPlanNode.TestNodeType) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Example 29 with TestPlanNode

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNode in project openolat by klemens.

the class AssessmentTestComponentRenderer method renderTestItem.

private void renderTestItem(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNodeKey itemRefKey, URLBuilder ubu, Translator translator, RenderingRequest options) {
    final TestSessionController testSessionController = component.getTestSessionController();
    final TestSessionState testSessionState = testSessionController.getTestSessionState();
    String key = itemRefKey.toString();
    /* We finally do the transform on the _item_ (NB!) */
    sb.append("<div class='qtiworks o_assessmentitem o_assessmenttest'>");
    // test part feedback 'during'
    // test feedback 'during'
    TestPlanNode itemRefNode = testSessionState.getTestPlan().getNode(itemRefKey);
    final EffectiveItemSessionControl effectiveItemSessionControl = itemRefNode.getEffectiveItemSessionControl();
    final boolean allowComments = effectiveItemSessionControl.isAllowComment() && component.isPersonalNotes();
    renderer.setCandidateCommentAllowed(allowComments);
    // write section rubric
    renderSectionRubrics(renderer, sb, component, itemRefNode, ubu, translator);
    // test part -> section -> item
    renderTestItemBody(renderer, sb, component, itemRefNode, ubu, translator, options);
    // controls
    sb.append("<div class='o_button_group o_assessmentitem_controls'>");
    // submit button
    final ItemSessionState itemSessionState = component.getItemSessionState(itemRefNode.getKey());
    if (component.isItemSessionOpen(itemSessionState, options.isSolutionMode())) {
        Component submit = component.getQtiItem().getSubmitButton().getComponent();
        submit.getHTMLRendererSingleton().render(renderer.getRenderer(), sb, submit, ubu, translator, new RenderResult(), null);
    }
    // advanceTestItemAllowed /* && testSessionState.getCurrentItemKey() != null && testSessionController.mayAdvanceItemLinear() */
    if (options.isAdvanceTestItemAllowed()) {
        // TODO need to find if there is a next question
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.finishItem.name()));
    }
    // nextItem
    if (options.isNextItemAllowed() && testSessionController.hasFollowingNonLinearItem()) {
        String title = translator.translate("assessment.test.nextQuestion");
        renderControl(sb, component, title, false, "o_sel_next_question", new NameValuePair("cid", Event.nextItem.name()));
    }
    // testPartNavigationAllowed"
    if (options.isTestPartNavigationAllowed() && component.isRenderNavigation()) {
        String title = translator.translate("assessment.test.questionMenu");
        renderControl(sb, component, title, false, "o_sel_question_menu", new NameValuePair("cid", Event.testPartNavigation.name()));
    }
    // endTestPartAllowed
    if (options.isEndTestPartAllowed()) {
        String title = component.hasMultipleTestParts() ? translator.translate("assessment.test.end.testPart") : translator.translate("assessment.test.end.test");
        renderControl(sb, component, title, false, "o_sel_end_testpart", new NameValuePair("cid", Event.endTestPart.name()));
    }
    // reviewMode
    if (options.isReviewMode()) {
        String title = translator.translate("assessment.test.backToTestFeedback");
        renderControl(sb, component, title, false, "o_sel_back_test_feedback", new NameValuePair("cid", Event.reviewTestPart.name()));
    }
    // <xsl:variable name="provideItemSolutionButton" as="xs:boolean" select="$reviewMode and $showSolution and not($solutionMode)"/>
    if (options.isReviewMode() && effectiveItemSessionControl.isShowSolution() && !options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.show");
        renderControl(sb, component, title, false, "o_sel_show_solution", new NameValuePair("cid", Event.itemSolution.name()), new NameValuePair("item", key));
    }
    if (options.isReviewMode() && options.isSolutionMode()) {
        String title = translator.translate("assessment.solution.hide");
        renderControl(sb, component, title, false, "o_sel_solution_hide", new NameValuePair("cid", Event.reviewItem.name()), new NameValuePair("item", key));
    }
    // end controls
    sb.append("</div>");
    // end assessmentItem
    sb.append("</div>");
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) RenderResult(org.olat.core.gui.render.RenderResult) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) Component(org.olat.core.gui.components.Component) EffectiveItemSessionControl(uk.ac.ed.ph.jqtiplus.state.EffectiveItemSessionControl)

Example 30 with TestPlanNode

use of uk.ac.ed.ph.jqtiplus.state.TestPlanNode in project openolat by klemens.

the class CorrectionIdentityAssessmentItemListController method loadModel.

private void loadModel(boolean reset) {
    ResolvedAssessmentTest resolvedAssessmentTest = model.getResolvedAssessmentTest();
    Map<Identifier, AssessmentItemRef> identifierToRefs = new HashMap<>();
    for (AssessmentItemRef itemRef : resolvedAssessmentTest.getAssessmentItemRefs()) {
        identifierToRefs.put(itemRef.getIdentifier(), itemRef);
    }
    List<AssessmentItemSession> allItemSessions = qtiService.getAssessmentItemSessions(candidateSession);
    Map<String, AssessmentItemSession> identifierToItemSessions = new HashMap<>();
    for (AssessmentItemSession itemSession : allItemSessions) {
        identifierToItemSessions.put(itemSession.getAssessmentItemIdentifier(), itemSession);
    }
    // reorder to match the list of assessment items
    List<CorrectionIdentityAssessmentItemRow> rows = new ArrayList<>();
    TestSessionState testSessionState = model.getTestSessionStates().get(assessedIdentity);
    List<TestPlanNode> nodes = testSessionState.getTestPlan().getTestPlanNodeList();
    for (TestPlanNode node : nodes) {
        if (node.getTestNodeType() == TestNodeType.ASSESSMENT_ITEM_REF) {
            TestPlanNodeKey key = node.getKey();
            AssessmentItemRef itemRef = identifierToRefs.get(key.getIdentifier());
            AssessmentItemSession itemSession = identifierToItemSessions.get(key.getIdentifier().toString());
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            ManifestMetadataBuilder metadata = model.getMetadata(itemRef);
            AssessmentItem item = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            ItemSessionState itemSessionState = testSessionState.getItemSessionStates().get(key);
            boolean manualCorrection = model.isManualCorrection(itemRef);
            CorrectionIdentityAssessmentItemRow row = new CorrectionIdentityAssessmentItemRow(assessedIdentity, item, itemRef, metadata, candidateSession, itemSession, itemSessionState, manualCorrection);
            row.setTitle(title);
            row.setTitleCssClass("o_icon_user");
            rows.add(row);
        }
    }
    tableModel.setObjects(rows);
    tableEl.reset(reset, reset, true);
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestSessionState(uk.ac.ed.ph.jqtiplus.state.TestSessionState) HashMap(java.util.HashMap) CorrectionIdentityAssessmentItemRow(org.olat.ims.qti21.ui.assessment.model.CorrectionIdentityAssessmentItemRow) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ArrayList(java.util.ArrayList) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) ManifestMetadataBuilder(org.olat.ims.qti21.model.xml.ManifestMetadataBuilder) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItemSession(org.olat.ims.qti21.AssessmentItemSession) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) TestPlanNodeKey(uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)

Aggregations

TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)54 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)32 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)26 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 Date (java.util.Date)16 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)16 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)14 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 AssessmentItemSession (org.olat.ims.qti21.AssessmentItemSession)10 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)10 TestPlan (uk.ac.ed.ph.jqtiplus.state.TestPlan)10 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)8 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 QtiCandidateStateException (uk.ac.ed.ph.jqtiplus.exception.QtiCandidateStateException)7 OLATResourceable (org.olat.core.id.OLATResourceable)6 ParentPartItemRefs (org.olat.ims.qti21.model.ParentPartItemRefs)6 CandidateTestEventType (org.olat.ims.qti21.model.audit.CandidateTestEventType)6