Search in sources :

Example 16 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.

the class SimpleChoiceAssessmentItemBuilder method getQuestionBlocks.

/**
 * @return A copy of the list of blocks which make the question.
 * 		The list is a copy and modification will not be persisted.
 */
public List<Block> getQuestionBlocks() {
    List<Block> blocks = assessmentItem.getItemBody().getBlocks();
    List<Block> questionBlocks = new ArrayList<>(blocks.size());
    for (Block block : blocks) {
        if (block instanceof ChoiceInteraction) {
            break;
        } else if (block != null) {
            questionBlocks.add(block);
        }
    }
    return questionBlocks;
}
Also used : ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)

Example 17 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.

the class SingleChoiceAssessmentItemBuilder method buildItemBody.

@Override
protected void buildItemBody() {
    // remove current blocks
    List<Block> blocks = assessmentItem.getItemBody().getBlocks();
    blocks.clear();
    // add question
    getHtmlHelper().appendHtml(assessmentItem.getItemBody(), question);
    // add interaction
    ChoiceInteraction singleChoiceInteraction = AssessmentItemFactory.createSingleChoiceInteraction(assessmentItem, responseIdentifier, orientation, cssClass);
    singleChoiceInteraction.setShuffle(isShuffle());
    blocks.add(singleChoiceInteraction);
    List<SimpleChoice> choiceList = getChoices();
    singleChoiceInteraction.getSimpleChoices().addAll(choiceList);
}
Also used : AssessmentItemFactory.appendSimpleChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendSimpleChoice) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentItemFactory.appendChoiceInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendChoiceInteraction)

Example 18 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.

the class UploadAssessmentItemBuilder method extractExtendedTextInteraction.

private void extractExtendedTextInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof UploadInteraction) {
                uploadInteraction = (UploadInteraction) block;
                responseIdentifier = uploadInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : AssessmentItemFactory.appendUploadInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendUploadInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 19 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.

the class DrawingAssessmentItemBuilder method getQuestionBlocks.

/**
 * @return A copy of the list of blocks which make the question.
 * 		The list is a copy and modification will not be persisted.
 */
public List<Block> getQuestionBlocks() {
    List<Block> blocks = assessmentItem.getItemBody().getBlocks();
    List<Block> questionBlocks = new ArrayList<>(blocks.size());
    for (Block block : blocks) {
        if (block instanceof DrawingInteraction) {
            break;
        } else {
            questionBlocks.add(block);
        }
    }
    return questionBlocks;
}
Also used : ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) AssessmentItemFactory.appendDrawingInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDrawingInteraction) DrawingInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)

Example 20 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.

the class EssayAssessmentItemBuilder method extractExtendedTextInteraction.

private void extractExtendedTextInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof ExtendedTextInteraction) {
                extendedTextInteraction = (ExtendedTextInteraction) block;
                responseIdentifier = extendedTextInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) AssessmentItemFactory.appendExtendedTextInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendExtendedTextInteraction) IOException(java.io.IOException)

Aggregations

Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)50 StringOutput (org.olat.core.gui.render.StringOutput)24 IOException (java.io.IOException)20 ArrayList (java.util.ArrayList)18 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)12 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)10 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)8 StreamResult (javax.xml.transform.stream.StreamResult)6 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 DrawingInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.DrawingInteraction)6 ExtendedTextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction)6 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)6 UploadInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction)6 Test (org.junit.Test)4 AssessmentItemFactory.appendExtendedTextInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendExtendedTextInteraction)4 AssessmentItemFactory.appendHotspotInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction)4 Flow (uk.ac.ed.ph.jqtiplus.node.content.basic.Flow)4 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)4 ItemSessionState (uk.ac.ed.ph.jqtiplus.state.ItemSessionState)4