Search in sources :

Example 36 with Question

use of org.olat.ims.qti.editor.beecom.objects.Question in project openolat by klemens.

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)

Aggregations

Question (org.olat.ims.qti.editor.beecom.objects.Question)36 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)32 Response (org.olat.ims.qti.editor.beecom.objects.Response)22 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)18 EssayQuestion (org.olat.ims.qti.editor.beecom.objects.EssayQuestion)16 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)14 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)14 ArrayList (java.util.ArrayList)12 Material (org.olat.ims.qti.editor.beecom.objects.Material)12 HashMap (java.util.HashMap)10 Control (org.olat.ims.qti.editor.beecom.objects.Control)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 WindowControl (org.olat.core.gui.control.WindowControl)8 Item (org.olat.ims.qti.editor.beecom.objects.Item)8 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)8 List (java.util.List)4 Element (org.dom4j.Element)4 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)4 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)4 ModalFeedbackBuilder (org.olat.ims.qti21.model.xml.ModalFeedbackBuilder)4