Search in sources :

Example 6 with ItemSessionState

use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentItemComponentRenderer method render.

@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    AssessmentItemComponent cmp = (AssessmentItemComponent) source;
    sb.append("<div class='qtiworks o_assessmentitem'>");
    ItemSessionController itemSessionController = cmp.getItemSessionController();
    CandidateSessionContext candidateSessionContext = cmp.getCandidateSessionContext();
    /* Create appropriate options that link back to this controller */
    final AssessmentTestSession candidateSession = candidateSessionContext.getCandidateSession();
    if (candidateSession != null && candidateSession.isExploded()) {
        renderExploded(sb, translator);
    } else if (candidateSessionContext.isTerminated()) {
        renderTerminated(sb, translator);
    } else {
        /* Look up most recent event */
        // assertSessionEntered(candidateSession);
        final CandidateEvent latestEvent = candidateSessionContext.getLastEvent();
        /* Load the ItemSessionState */
        // candidateDataService.loadItemSessionState(latestEvent);
        final ItemSessionState itemSessionState = cmp.getItemSessionController().getItemSessionState();
        /* Touch the session's duration state if appropriate */
        if (itemSessionState.isEntered() && !itemSessionState.isEnded() && !itemSessionState.isSuspended()) {
            final Date timestamp = candidateSessionContext.getCurrentRequestTimestamp();
            itemSessionController.touchDuration(timestamp);
        }
        /* Render event */
        AssessmentRenderer renderHints = new AssessmentRenderer(renderer);
        renderItemEvent(renderHints, sb, cmp, latestEvent, itemSessionState, ubu, translator);
    }
    sb.append("</div>");
}
Also used : CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ItemSessionController(uk.ac.ed.ph.jqtiplus.running.ItemSessionController) Date(java.util.Date) CandidateEvent(org.olat.ims.qti21.model.audit.CandidateEvent)

Example 7 with ItemSessionState

use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.

the class QTI21ServiceImpl method reopenTestPart.

private TestPlanNodeKey reopenTestPart(TestPlanNode lastItem, TestSessionState testSessionState) {
    TestPlan plan = testSessionState.getTestPlan();
    List<TestPlanNode> testPartNodes = lastItem.searchAncestors(TestNodeType.TEST_PART);
    if (testPartNodes.isEmpty()) {
        return null;
    }
    // reopen the test part of the selected item
    TestPlanNode partNode = testPartNodes.get(0);
    TestPlanNodeKey partKey = partNode.getKey();
    TestPartSessionState partState = testSessionState.getTestPartSessionStates().get(partKey);
    partState.setEndTime(null);
    partState.setExitTime(null);
    // reopen all sections the test part
    for (Map.Entry<TestPlanNodeKey, AssessmentSectionSessionState> sectionEntry : testSessionState.getAssessmentSectionSessionStates().entrySet()) {
        TestPlanNodeKey sectionKey = sectionEntry.getKey();
        TestPlanNode sectionNode = plan.getNode(sectionKey);
        if (sectionNode.hasAncestor(partNode)) {
            AssessmentSectionSessionState sectionState = sectionEntry.getValue();
            sectionState.setEndTime(null);
            sectionState.setExitTime(null);
        }
    }
    // reopen all items the test part
    for (Map.Entry<TestPlanNodeKey, ItemSessionState> itemEntry : testSessionState.getItemSessionStates().entrySet()) {
        TestPlanNodeKey itemKey = itemEntry.getKey();
        TestPlanNode itemNode = plan.getNode(itemKey);
        if (itemNode.hasAncestor(partNode)) {
            ItemSessionState itemState = itemEntry.getValue();
            itemState.setEndTime(null);
            itemState.setExitTime(null);
        }
    }
    return partKey;
}
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) 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 8 with ItemSessionState

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

use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponentRenderer method renderBlock.

public void renderBlock(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, Block block, URLBuilder ubu, Translator translator) {
    switch(block.getQtiClassName()) {
        case AssociateInteraction.QTI_CLASS_NAME:
        case ChoiceInteraction.QTI_CLASS_NAME:
        case DrawingInteraction.QTI_CLASS_NAME:
        case ExtendedTextInteraction.QTI_CLASS_NAME:
        case GapMatchInteraction.QTI_CLASS_NAME:
        case GraphicAssociateInteraction.QTI_CLASS_NAME:
        case GraphicGapMatchInteraction.QTI_CLASS_NAME:
        case GraphicOrderInteraction.QTI_CLASS_NAME:
        case HotspotInteraction.QTI_CLASS_NAME:
        case SelectPointInteraction.QTI_CLASS_NAME:
        case HottextInteraction.QTI_CLASS_NAME:
        case MatchInteraction.QTI_CLASS_NAME:
        case MediaInteraction.QTI_CLASS_NAME:
        case OrderInteraction.QTI_CLASS_NAME:
        case PositionObjectInteraction.QTI_CLASS_NAME:
        case SliderInteraction.QTI_CLASS_NAME:
        case UploadInteraction.QTI_CLASS_NAME:
            {
                renderInteraction(renderer, sb, (FlowInteraction) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case CustomInteraction.QTI_CLASS_NAME:
            {
                renderCustomInteraction(renderer, sb, (CustomInteraction<?>) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        case PositionObjectStage.QTI_CLASS_NAME:
            {
                renderPositionObjectStage(renderer, sb, (PositionObjectStage) block, resolvedAssessmentItem, itemSessionState, component, ubu, translator);
                break;
            }
        // never rendered
        case TemplateBlock.QTI_CLASS_NAME:
            break;
        case InfoControl.QTI_CLASS_NAME:
            {
                renderInfoControl(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (InfoControl) block, ubu, translator);
                break;
            }
        case FeedbackBlock.QTI_CLASS_NAME:
            {
                FeedbackBlock feedbackBlock = (FeedbackBlock) block;
                if (component.isFeedback(feedbackBlock, itemSessionState)) {
                    sb.append("<div class='o_info feedbackBlock '").append(getAtClass(feedbackBlock)).append(">");
                    feedbackBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                    sb.append("</div>");
                }
                break;
            }
        // never rendered automatically
        case RubricBlock.QTI_CLASS_NAME:
            break;
        case Math.QTI_CLASS_NAME:
            {
                renderMath(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Math) block);
                break;
            }
        case Div.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Div) block).getFlows().forEach((flow) -> renderFlow(renderer, sb, component, resolvedAssessmentItem, itemSessionState, flow, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ul.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ul) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Ol.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Ol) block).getLis().forEach((li) -> renderLi(renderer, sb, component, resolvedAssessmentItem, itemSessionState, li, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Dl.QTI_CLASS_NAME:
            renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
            ((Dl) block).getDlElements().forEach((dlElement) -> renderDlElement(renderer, sb, component, resolvedAssessmentItem, itemSessionState, dlElement, ubu, translator));
            renderEndTag(sb, block);
            break;
        case Table.QTI_CLASS_NAME:
            renderTable(renderer, sb, component, resolvedAssessmentItem, itemSessionState, (Table) block, ubu, translator);
            break;
        case Object.QTI_CLASS_NAME:
            System.out.println("1");
            break;
        default:
            {
                renderStartHtmlTag(sb, component, resolvedAssessmentItem, block, null);
                if (block instanceof AtomicBlock) {
                    AtomicBlock atomicBlock = (AtomicBlock) block;
                    atomicBlock.getInlines().forEach((child) -> renderInline(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                } else if (block instanceof SimpleBlock) {
                    SimpleBlock simpleBlock = (SimpleBlock) block;
                    simpleBlock.getBlocks().forEach((child) -> renderBlock(renderer, sb, component, resolvedAssessmentItem, itemSessionState, child, ubu, translator));
                }
                renderEndTag(sb, block);
            }
    }
}
Also used : Util(org.olat.core.util.Util) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) AssessmentRenderFunctions.extractMathsContentPmathml(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractMathsContentPmathml) Colgroup(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Colgroup) AssessmentRenderFunctions.getAtClass(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getAtClass) AssessmentRenderFunctions.getOutcomeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getOutcomeValue) StreamResult(javax.xml.transform.stream.StreamResult) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) CoreSpringFactory(org.olat.core.CoreSpringFactory) IntegerAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.IntegerAttribute) Context(org.apache.velocity.context.Context) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction) AssessmentRenderFunctions.isInvalidResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isInvalidResponse) QTI21Module(org.olat.ims.qti21.QTI21Module) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) TableCell(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.TableCell) OLog(org.olat.core.logging.OLog) AssessmentRenderFunctions.extractRecordFieldValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractRecordFieldValue) Translator(org.olat.core.gui.translator.Translator) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) Tfoot(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tfoot) AssessmentRenderFunctions.getCardinalitySize(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getCardinalitySize) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun) Reader(java.io.Reader) Value(uk.ac.ed.ph.jqtiplus.value.Value) VelocityContext(org.apache.velocity.VelocityContext) QTI21Service(org.olat.ims.qti21.QTI21Service) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) AssessmentRenderFunctions.getHtmlAttributeValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getHtmlAttributeValue) StringOutputPool(org.olat.core.gui.render.StringOutputPool) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) TemplateBlock(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateBlock) XsltStylesheetManager(uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager) ForeignAttribute(uk.ac.ed.ph.jqtiplus.attribute.ForeignAttribute) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Hottext(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Hottext) VariableDeclaration(uk.ac.ed.ph.jqtiplus.node.shared.VariableDeclaration) AssessmentRenderFunctions.checkJavaScript(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.checkJavaScript) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) AssessmentRenderFunctions.isTemplateDeclarationAMathVariable(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isTemplateDeclarationAMathVariable) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) QTI21Constants(org.olat.ims.qti21.QTI21Constants) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) MathEntryInteraction(uk.ac.ed.ph.qtiworks.mathassess.MathEntryInteraction) Attribute(uk.ac.ed.ph.jqtiplus.attribute.Attribute) Table(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Table) ArrayList(java.util.ArrayList) XMLReader(org.xml.sax.XMLReader) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) AssessmentRenderFunctions.renderOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderOrderedCardinalityValue) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) RenderResult(org.olat.core.gui.render.RenderResult) Img(uk.ac.ed.ph.jqtiplus.node.content.xhtml.image.Img) AssessmentRenderFunctions.isMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMultipleCardinalityValue) PrintedVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.PrintedVariable) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentRenderFunctions.isVisible(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isVisible) AssessmentRenderFunctions.renderSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderSingleCardinalityValue) Inline(uk.ac.ed.ph.jqtiplus.node.content.basic.Inline) Br(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Br) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) IOException(java.io.IOException) ForeignElement(uk.ac.ed.ph.jqtiplus.node.ForeignElement) CodeHelper(org.olat.core.util.CodeHelper) AssessmentRenderFunctions.renderMultipleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderMultipleCardinalityValue) StringReader(java.io.StringReader) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) AssessmentRenderFunctions.isBadResponse(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isBadResponse) NavigationMode(uk.ac.ed.ph.jqtiplus.node.test.NavigationMode) TransformerHandler(javax.xml.transform.sax.TransformerHandler) AssessmentRenderFunctions.exists(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.exists) AssessmentRenderFunctions.valueContains(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.valueContains) AssessmentRenderFunctions.extractSingleCardinalityResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractSingleCardinalityResponseInput) URLBuilder(org.olat.core.gui.render.URLBuilder) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) Form(org.olat.core.gui.components.form.flexible.impl.Form) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentRenderFunctions.extractResponseInputAt(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractResponseInputAt) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) XmlUtilities(org.olat.ims.qti21.XmlUtilities) A(uk.ac.ed.ph.jqtiplus.node.content.xhtml.hypertext.A) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) AssessmentRenderFunctions.getTemplateValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getTemplateValue) FormUIFactory(org.olat.core.gui.components.form.flexible.FormUIFactory) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) AssessmentRenderFunctions.extractIterableElement(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.extractIterableElement) Renderer(org.olat.core.gui.render.Renderer) SimpleInline(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleInline) URI(java.net.URI) AssessmentRenderFunctions.renderRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderRecordCardinalityValue) AssessmentItemFactory(org.olat.ims.qti21.model.xml.AssessmentItemFactory) Col(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Col) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) AssessmentRenderFunctions.getResponseValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseValue) AssessmentRenderFunctions.isNullValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isNullValue) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentRenderFunctions.isSingleCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isSingleCardinalityValue) FeedbackInline(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackInline) Thead(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Thead) List(java.util.List) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) DefaultComponentRenderer(org.olat.core.gui.components.DefaultComponentRenderer) Ol(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ol) ModalFeedback(uk.ac.ed.ph.jqtiplus.node.item.ModalFeedback) Settings(org.olat.core.helpers.Settings) TestSessionController(uk.ac.ed.ph.jqtiplus.running.TestSessionController) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) TemplateInline(uk.ac.ed.ph.jqtiplus.node.content.template.TemplateInline) AssessmentRenderFunctions.isRecordCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isRecordCardinalityValue) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) FormItem(org.olat.core.gui.components.form.flexible.FormItem) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) SelectPointInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SelectPointInteraction) Span(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Span) AssessmentRenderFunctions.isOrderedCardinalityValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isOrderedCardinalityValue) AssessmentRenderFunctions.isMathsContentValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.isMathsContentValue) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) DlElement(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.DlElement) VelocityHelper(org.olat.core.gui.render.velocity.VelocityHelper) Li(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Li) Tr(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tr) AssessmentRenderFunctions.getResponseDeclaration(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseDeclaration) InputSource(org.xml.sax.InputSource) Dd(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dd) Link(org.olat.core.gui.components.link.Link) PositionObjectInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.PositionObjectInteraction) Dl(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) AttributeList(uk.ac.ed.ph.jqtiplus.attribute.AttributeList) Div(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.Div) Dt(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Dt) Tbody(uk.ac.ed.ph.jqtiplus.node.content.xhtml.table.Tbody) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) MediaInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MediaInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) AssessmentRenderFunctions.getResponseInput(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.getResponseInput) Tracing(org.olat.core.logging.Tracing) Ul(uk.ac.ed.ph.jqtiplus.node.content.xhtml.list.Ul) StringEscapeUtils(org.apache.commons.lang.StringEscapeUtils) SimpleBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.SimpleBlock) InfoControl(uk.ac.ed.ph.jqtiplus.node.content.InfoControl) FeedbackBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.FeedbackBlock) AtomicBlock(uk.ac.ed.ph.jqtiplus.node.content.basic.AtomicBlock) CustomInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.CustomInteraction) FlowInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.FlowInteraction) Math(uk.ac.ed.ph.jqtiplus.node.content.mathml.Math) PositionObjectStage(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.PositionObjectStage)

Example 10 with ItemSessionState

use of uk.ac.ed.ph.jqtiplus.state.ItemSessionState in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.

/*
	  <xsl:function name="qw:get-visible-ordered-choices" as="element()*">
	    <xsl:param name="interaction" as="element()"/>
	    <xsl:param name="choices" as="element()*"/>
	    <xsl:variable name="orderedChoices" as="element()*">
	      <xsl:choose>
	        <xsl:when test="$interaction/@shuffle='true'">
	          <xsl:for-each select="qw:get-shuffled-choice-order($interaction)">
	            <xsl:sequence select="$choices[@identifier=current()]"/>
	          </xsl:for-each>
	        </xsl:when>
	        <xsl:otherwise>
	          <xsl:sequence select="$choices"/>
	        </xsl:otherwise>
	      </xsl:choose>
	    </xsl:variable>
	    <xsl:sequence select="qw:filter-visible($orderedChoices)"/>
	  </xsl:function>
	  */
public List<InlineChoice> getVisibleOrderedChoices(InlineChoiceInteraction interaction) {
    List<InlineChoice> choices;
    if (interaction.getShuffle()) {
        // <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
        // as="element(qw:shuffledInteractionChoiceOrder)*"/>
        // <xsl:variable name="choiceSequence" as="xs:string?"
        // select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
        List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
        choices = new ArrayList<>();
        for (Identifier choiceOrder : choiceOrders) {
            choices.add(interaction.getInlineChoice(choiceOrder));
        }
    } else {
        choices = interaction.getInlineChoices();
    }
    return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
Also used : URLBuilder(org.olat.core.gui.render.URLBuilder) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) GraphicAssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicAssociateInteraction) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) Map(java.util.Map) Flow(uk.ac.ed.ph.jqtiplus.node.content.basic.Flow) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) OLog(org.olat.core.logging.OLog) ListValue(uk.ac.ed.ph.jqtiplus.value.ListValue) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Translator(org.olat.core.gui.translator.Translator) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) FormJSHelper(org.olat.core.gui.components.form.flexible.impl.FormJSHelper) AssociateInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.AssociateInteraction) StringInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.StringInteraction) Value(uk.ac.ed.ph.jqtiplus.value.Value) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssociableHotspot(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.AssociableHotspot) Collectors(java.util.stream.Collectors) GapImg(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapImg) List(java.util.List) BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) AssessmentRenderFunctions.renderValue(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.renderValue) TextOrVariable(uk.ac.ed.ph.jqtiplus.node.content.variable.TextOrVariable) BaseType(uk.ac.ed.ph.jqtiplus.value.BaseType) VelocityRenderDecorator(org.olat.core.gui.render.velocity.VelocityRenderDecorator) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) GraphicOrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicOrderInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) Settings(org.olat.core.helpers.Settings) Orientation(uk.ac.ed.ph.jqtiplus.value.Orientation) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode) GapChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.GapChoice) QueryUtils(uk.ac.ed.ph.jqtiplus.utils.QueryUtils) CandidateSessionContext(org.olat.ims.qti21.ui.CandidateSessionContext) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) HashMap(java.util.HashMap) StringMultipleAttribute(uk.ac.ed.ph.jqtiplus.attribute.value.StringMultipleAttribute) Prompt(uk.ac.ed.ph.jqtiplus.node.item.interaction.Prompt) ItemSessionState(uk.ac.ed.ph.jqtiplus.state.ItemSessionState) ResponseData(uk.ac.ed.ph.jqtiplus.types.ResponseData) ArrayList(java.util.ArrayList) Gap(uk.ac.ed.ph.jqtiplus.node.item.interaction.content.Gap) SliderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.SliderInteraction) Cardinality(uk.ac.ed.ph.jqtiplus.value.Cardinality) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) OrderInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.OrderInteraction) StringHelper(org.olat.core.util.StringHelper) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) Iterator(java.util.Iterator) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) IOException(java.io.IOException) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Shape(uk.ac.ed.ph.jqtiplus.node.expression.operator.Shape) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) Tracing(org.olat.core.logging.Tracing) FileValue(uk.ac.ed.ph.jqtiplus.value.FileValue) BodyElement(uk.ac.ed.ph.jqtiplus.node.content.BodyElement) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) InlineChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.InlineChoice)

Aggregations

ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)88 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)30 Date (java.util.Date)28 HashMap (java.util.HashMap)28 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)28 TestPlanNodeKey (uk.ac.ed.ph.jqtiplus.state.TestPlanNodeKey)26 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)24 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)24 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)22 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)20 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)20 NotificationRecorder (uk.ac.ed.ph.jqtiplus.notification.NotificationRecorder)20 ItemSessionController (uk.ac.ed.ph.jqtiplus.running.ItemSessionController)20 ArrayList (java.util.ArrayList)18 Map (java.util.Map)18 ResponseData (uk.ac.ed.ph.jqtiplus.types.ResponseData)18 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)16 List (java.util.List)14 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)12 Flow (uk.ac.ed.ph.jqtiplus.node.content.basic.Flow)12