Search in sources :

Example 11 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.

the class MatchScoreController method sync.

private List<MatchWrapper> sync(SimpleMatchSet matchSet, List<MatchWrapper> wrappers) {
    Map<Identifier, MatchWrapper> currentMapping = wrappers.stream().collect(Collectors.toMap(w -> w.getChoiceIdentifier(), w -> w));
    List<MatchWrapper> newWrappers = new ArrayList<>();
    List<SimpleAssociableChoice> choices = matchSet.getSimpleAssociableChoices();
    for (SimpleAssociableChoice choice : choices) {
        if (currentMapping.containsKey(choice.getIdentifier())) {
            newWrappers.add(currentMapping.get(choice.getIdentifier()));
        } else {
            newWrappers.add(createMatchWrapper(choice));
        }
    }
    return newWrappers;
}
Also used : Util(org.olat.core.util.Util) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) Map(java.util.Map) StringHelper(org.olat.core.util.StringHelper) URI(java.net.URI) AssessmentTestEditorController(org.olat.ims.qti21.ui.editor.AssessmentTestEditorController) WindowControl(org.olat.core.gui.control.WindowControl) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) CodeHelper(org.olat.core.util.CodeHelper) File(java.io.File) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) AssessmentHtmlBuilder(org.olat.ims.qti21.model.xml.AssessmentHtmlBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) List(java.util.List) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) AssessmentHelper(org.olat.course.assessment.AssessmentHelper) SyncAssessmentItem(org.olat.ims.qti21.ui.editor.SyncAssessmentItem) UserRequest(org.olat.core.gui.UserRequest) ScoreEvaluation(org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ArrayList(java.util.ArrayList)

Example 12 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.

the class SingleChoiceEditorController method updateCorrectAnswer.

private void updateCorrectAnswer(UserRequest ureq) {
    String correctAnswer = ureq.getParameter("correct");
    if (StringHelper.containsNonWhitespace(correctAnswer)) {
        Identifier correctAnswerIdentifier = Identifier.parseString(correctAnswer);
        itemBuilder.setCorrectAnswer(correctAnswerIdentifier);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier)

Example 13 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.

the class AssessmentItemComponentRenderer method renderPrintedVariable.

@Override
protected void renderPrintedVariable(AssessmentRenderer renderer, StringOutput sb, AssessmentObjectComponent component, ResolvedAssessmentItem resolvedAssessmentItem, ItemSessionState itemSessionState, PrintedVariable printedVar) {
    Identifier identifier = printedVar.getIdentifier();
    Value templateValue = itemSessionState.getTemplateValues().get(identifier);
    Value outcomeValue = itemSessionState.getOutcomeValues().get(identifier);
    sb.append("<span class='printedVariable'>");
    if (outcomeValue != null) {
        OutcomeDeclaration outcomeDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getOutcomeDeclaration(identifier);
        renderPrintedVariable(renderer, sb, printedVar, outcomeDeclaration, outcomeValue);
    } else if (templateValue != null) {
        TemplateDeclaration templateDeclaration = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful().getTemplateDeclaration(identifier);
        renderPrintedVariable(renderer, sb, printedVar, templateDeclaration, templateValue);
    } else {
        sb.append("(variable ").append(identifier.toString()).append(" was not found)");
    }
    sb.append("</span>");
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Value(uk.ac.ed.ph.jqtiplus.value.Value) TemplateDeclaration(uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 14 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.

the class AssessmentObjectComponent method isFeedback.

public boolean isFeedback(ModalFeedback feedbackElement, ItemSessionState itemSessionState) {
    Identifier outcomeIdentifier = feedbackElement.getOutcomeIdentifier();
    Identifier identifier = feedbackElement.getIdentifier();
    Value outcomeValue = itemSessionState.getOutcomeValues().get(outcomeIdentifier);
    boolean identifierMatch = valueContains(outcomeValue, identifier);
    return (identifierMatch && feedbackElement.getVisibilityMode() == VisibilityMode.SHOW_IF_MATCH) || (!identifierMatch && feedbackElement.getVisibilityMode() == VisibilityMode.HIDE_IF_MATCH);
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) Value(uk.ac.ed.ph.jqtiplus.value.Value)

Example 15 with Identifier

use of uk.ac.ed.ph.jqtiplus.types.Identifier in project OpenOLAT by OpenOLAT.

the class HotspotAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hotspot, title);
    // define the response
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newNumberAsIdentifier("hc");
    ResponseDeclaration responseDeclaration = createHotspotEntryResponseDeclarationSingle(assessmentItem, responseDeclarationId, correctResponseId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    appendHotspotInteraction(itemBody, responseDeclarationId, correctResponseId);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentItemFactory.createResponseProcessing(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Aggregations

Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)208 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)62 ArrayList (java.util.ArrayList)53 HashMap (java.util.HashMap)52 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)46 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)42 Value (uk.ac.ed.ph.jqtiplus.value.Value)42 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)40 Map (java.util.Map)32 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)24 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)24 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)24 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)22 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)22 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)22 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)22 List (java.util.List)20 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)20 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)20 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)20