Search in sources :

Example 26 with Block

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

the class MatchAssessmentItemBuilder 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 MatchInteraction) {
            break;
        } else {
            questionBlocks.add(block);
        }
    }
    return questionBlocks;
}
Also used : AssessmentItemFactory.appendMatchInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendMatchInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 27 with Block

use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block 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 28 with Block

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

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 29 with Block

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

the class UploadAssessmentItemBuilder 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 UploadInteraction) {
            break;
        } else {
            questionBlocks.add(block);
        }
    }
    return questionBlocks;
}
Also used : AssessmentItemFactory.appendUploadInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendUploadInteraction) UploadInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.UploadInteraction) ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 30 with Block

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

the class HottextAssessmentItemBuilder method extractHottextInteraction.

private void extractHottextInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof HottextInteraction) {
                hottextInteraction = (HottextInteraction) block;
                for (BlockStatic innerBlock : hottextInteraction.getBlockStatics()) {
                    serializeJqtiObject(innerBlock, sb);
                }
                responseIdentifier = hottextInteraction.getResponseIdentifier();
                break;
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : BlockStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.BlockStatic) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) AssessmentItemFactory.appendHottextInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHottextInteraction) 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