Search in sources :

Example 31 with ChoiceInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction in project OpenOLAT by OpenOLAT.

the class SingleChoiceEditorController method doAddSimpleChoice.

private void doAddSimpleChoice(UserRequest ureq) {
    ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
    SimpleChoice newChoice = AssessmentItemFactory.createSimpleChoice(interaction, translate("new.answer"), "sc");
    wrapAnswer(ureq, newChoice);
    flc.setDirty(true);
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)

Example 32 with ChoiceInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentItemStatisticsController method interactionControllerFactory.

private Component interactionControllerFactory(UserRequest ureq, Interaction interaction, StatisticsItem itemStats) {
    Controller interactionCtrl = null;
    if (interaction instanceof ChoiceInteraction) {
        interactionCtrl = new SimpleChoiceInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (ChoiceInteraction) interaction, itemStats, resourceResult);
    } else if (interaction instanceof MatchInteraction) {
        String responseIdentifier = interaction.getResponseIdentifier().toString();
        if (responseIdentifier.startsWith("KPRIM_") || QTI21QuestionType.hasClass(interaction, QTI21Constants.CSS_MATCH_KPRIM)) {
            interactionCtrl = new KPrimStatisticsController(ureq, getWindowControl(), itemRef, item, (MatchInteraction) interaction, resourceResult);
        } else {
            interactionCtrl = new MatchStatisticsController(ureq, getWindowControl(), itemRef, item, (MatchInteraction) interaction, resourceResult);
        }
    } else if (interaction instanceof HotspotInteraction) {
        interactionCtrl = new HotspotInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (HotspotInteraction) interaction, itemStats, resourceResult);
    } else if (interaction instanceof HottextInteraction) {
        interactionCtrl = new HottextInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (HottextInteraction) interaction, itemStats, resourceResult);
    }
    if (interactionCtrl == null) {
        interactionCtrl = new UnsupportedInteractionController(ureq, getWindowControl(), interaction);
    }
    listenTo(interactionCtrl);
    return interactionCtrl.getInitialComponent();
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) KPrimStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.KPrimStatisticsController) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HottextInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HottextInteractionStatisticsController) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) SimpleChoiceInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.SimpleChoiceInteractionStatisticsController) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) MatchStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.MatchStatisticsController) UnsupportedInteractionController(org.olat.ims.qti21.ui.statistics.interactions.UnsupportedInteractionController) 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) HotspotInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HotspotInteractionStatisticsController)

Example 33 with ChoiceInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction in project OpenOLAT by OpenOLAT.

the class SimpleChoiceAssessmentItemBuilder method extractChoiceInteraction.

private void extractChoiceInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof ChoiceInteraction) {
                choiceInteraction = (ChoiceInteraction) block;
                responseIdentifier = choiceInteraction.getResponseIdentifier();
                shuffle = choiceInteraction.getShuffle();
                break;
            } else if (block != null) {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
    choices = new ArrayList<>();
    if (choiceInteraction != null) {
        choices.addAll(choiceInteraction.getSimpleChoices());
        orientation = choiceInteraction.getOrientation();
        cssClass = choiceInteraction.getClassAttr();
        maxChoices = choiceInteraction.getMaxChoices();
        minChoices = choiceInteraction.getMinChoices();
    }
}
Also used : Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 34 with ChoiceInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction in project OpenOLAT by OpenOLAT.

the class QTI12To21Converter method convertSingleChoice.

private AssessmentItemBuilder convertSingleChoice(Item item) {
    SingleChoiceAssessmentItemBuilder itemBuilder = new SingleChoiceAssessmentItemBuilder("Single choice", "New answer", qtiSerializer);
    convertItemBasics(item, itemBuilder);
    itemBuilder.clearMapping();
    itemBuilder.clearSimpleChoices();
    itemBuilder.setScoreEvaluationMode(ScoreEvaluation.allCorrectAnswers);
    ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
    Question question = item.getQuestion();
    itemBuilder.setShuffle(question.isShuffle());
    convertOrientation(question, itemBuilder);
    List<Response> responses = question.getResponses();
    Map<String, Identifier> identToIdentifier = new HashMap<>();
    for (Response response : responses) {
        String responseText = response.getContent().renderAsHtmlForEditor();
        responseText = blockedHtml(responseText);
        SimpleChoice newChoice;
        if (StringHelper.isHtml(responseText)) {
            newChoice = AssessmentItemFactory.createSimpleChoice(interaction, "", itemBuilder.getQuestionType().getPrefix());
            htmlBuilder.appendHtml(newChoice, responseText);
        } else {
            newChoice = AssessmentItemFactory.createSimpleChoice(interaction, responseText, itemBuilder.getQuestionType().getPrefix());
        }
        itemBuilder.addSimpleChoice(newChoice);
        identToIdentifier.put(response.getIdent(), newChoice.getIdentifier());
        if (response.isCorrect()) {
            itemBuilder.setCorrectAnswer(newChoice.getIdentifier());
        }
    }
    convertFeedbackPerAnswers(item, itemBuilder, identToIdentifier);
    double correctScore = question.getSingleCorrectScore();
    if (correctScore >= 0.0d) {
        itemBuilder.setMinScore(0.0d);
        itemBuilder.setMaxScore(correctScore);
    }
    return itemBuilder;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) HashMap(java.util.HashMap) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question)

Example 35 with ChoiceInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createSingleChoice.

public static AssessmentItem createSingleChoice(String title, String defaultAnswer) {
    AssessmentItem assessmentItem = createAssessmentItem(QTI21QuestionType.sc, title);
    // define correct answer
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("sc");
    ResponseDeclaration responseDeclaration = createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    // the single choice interaction
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 1, true);
    appendSimpleChoice(choiceInteraction, defaultAnswer, 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) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Aggregations

ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)54 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)30 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)20 Test (org.junit.Test)16 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)16 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)16 MultipleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder)14 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)14 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)14 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12 URL (java.net.URL)10 SingleChoiceAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder)10 AssessmentItemFactory.appendChoiceInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendChoiceInteraction)8 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)8 EndAttemptInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.EndAttemptInteraction)8 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)8 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)8 HashMap (java.util.HashMap)6 PromptGroup (uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)6 SimpleChoiceGroup (uk.ac.ed.ph.jqtiplus.group.item.interaction.choice.SimpleChoiceGroup)6