Search in sources :

Example 11 with EndAttemptInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction in project openolat by klemens.

the class AbstractQtiWorksController method processResponse.

protected void processResponse(UserRequest ureq, FormItem source) {
    Map<Identifier, ResponseInput> stringResponseMap = extractStringResponseData();
    Map<Identifier, ResponseInput> fileResponseMap;
    if (mainForm.isMultipartEnabled()) {
        fileResponseMap = extractFileResponseData();
    } else {
        fileResponseMap = Collections.emptyMap();
    }
    if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        String cmd = button.getCmd();
        if (cmd != null && cmd.startsWith("qtiworks_response_")) {
            String responseIdentifierString = cmd.substring("qtiworks_response_".length());
            String presentedFlag = "qtiworks_presented_".concat(responseIdentifierString);
            if (mainForm.getRequestParameterSet().contains(presentedFlag)) {
                Identifier responseIdentifier;
                try {
                    responseIdentifier = getResponseIdentifierFromUniqueId(responseIdentifierString);
                // Identifier.parseString(responseIdentifierString);
                } catch (final QtiParseException e) {
                    throw new RuntimeException("Bad response identifier encoded in parameter " + cmd, e);
                }
                String[] responseValues;
                if (button.getUserObject() instanceof EndAttemptInteraction) {
                    responseValues = new String[] { ((EndAttemptInteraction) button.getUserObject()).getTitle() };
                } else {
                    responseValues = new String[] { "submit" };
                }
                StringInput stringResponseData = new StringInput(responseValues);
                stringResponseMap.put(responseIdentifier, stringResponseData);
            }
        }
    }
    String candidateComment = extractComment();
    fireResponse(ureq, source, stringResponseMap, fileResponseMap, candidateComment);
}
Also used : StringInput(org.olat.ims.qti21.ui.ResponseInput.StringInput) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) QtiParseException(uk.ac.ed.ph.jqtiplus.exception.QtiParseException)

Example 12 with EndAttemptInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction in project openolat by klemens.

the class QTI21AssessmentItemStatisticsController method initInteractionControllers.

private List<String> initInteractionControllers(UserRequest ureq, StatisticsItem itemStats) {
    List<Interaction> interactions = item.getItemBody().findInteractions();
    List<String> interactionIds = new ArrayList<>(interactions.size());
    int counter = 0;
    List<TextEntryInteraction> textEntryInteractions = new ArrayList<>();
    for (Interaction interaction : interactions) {
        if (interaction instanceof TextEntryInteraction) {
            textEntryInteractions.add((TextEntryInteraction) interaction);
        } else if (interaction instanceof EndAttemptInteraction) {
            continue;
        } else {
            Component cmp = interactionControllerFactory(ureq, interaction, itemStats);
            String componentId = "interaction" + counter++;
            mainVC.put(componentId, cmp);
            interactionIds.add(componentId);
        }
    }
    if (textEntryInteractions.size() > 0) {
        Controller interactionCtrl = new TextEntryInteractionsStatisticsController(ureq, getWindowControl(), itemRef, item, textEntryInteractions, resourceResult);
        listenTo(interactionCtrl);
        String componentId = "interaction" + counter++;
        mainVC.put(componentId, interactionCtrl.getInitialComponent());
        interactionIds.add(componentId);
    }
    return interactionIds;
}
Also used : TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) TextEntryInteractionsStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.TextEntryInteractionsStatisticsController) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) EndAttemptInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) ArrayList(java.util.ArrayList) StatisticsComponent(org.olat.core.gui.components.chart.StatisticsComponent) Component(org.olat.core.gui.components.Component) TextEntryInteractionsStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.TextEntryInteractionsStatisticsController) HotspotInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HotspotInteractionStatisticsController) MatchStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.MatchStatisticsController) UserFilterController(org.olat.modules.assessment.ui.UserFilterController) SimpleChoiceInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.SimpleChoiceInteractionStatisticsController) KPrimStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.KPrimStatisticsController) HottextInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HottextInteractionStatisticsController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) UnsupportedInteractionController(org.olat.ims.qti21.ui.statistics.interactions.UnsupportedInteractionController)

Aggregations

EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)12 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)8 URL (java.net.URL)6 Test (org.junit.Test)6 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)6 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)4 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)4 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)4 ArrayList (java.util.ArrayList)2 Component (org.olat.core.gui.components.Component)2 StatisticsComponent (org.olat.core.gui.components.chart.StatisticsComponent)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 HottextAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder)2 StringInput (org.olat.ims.qti21.ui.ResponseInput.StringInput)2