use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.
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);
}
}
use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.
the class KPrimAssessmentItemBuilder method extractMatchInteraction.
private void extractMatchInteraction() {
try (StringOutput sb = new StringOutput()) {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
for (Block block : blocks) {
if (block instanceof MatchInteraction) {
matchInteraction = (MatchInteraction) block;
responseIdentifier = matchInteraction.getResponseIdentifier();
shuffle = matchInteraction.getShuffle();
cssClass = matchInteraction.getClassAttr();
break;
} else {
serializeJqtiObject(block, sb);
}
}
question = sb.toString();
} catch (IOException e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.
the class MultipleChoiceAssessmentItemBuilder 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.createMultipleChoiceInteraction(assessmentItem, responseIdentifier, orientation, cssClass);
singleChoiceInteraction.setShuffle(isShuffle());
blocks.add(singleChoiceInteraction);
List<SimpleChoice> choiceList = getChoices();
singleChoiceInteraction.getSimpleChoices().addAll(choiceList);
int finalMaxChoices = 0;
if (maxChoices >= 0 && maxChoices <= choiceList.size()) {
finalMaxChoices = maxChoices;
}
singleChoiceInteraction.setMaxChoices(finalMaxChoices);
int finalMinChoices = 0;
if (minChoices >= 0 && minChoices <= choiceList.size()) {
finalMinChoices = minChoices;
}
singleChoiceInteraction.setMinChoices(finalMinChoices);
}
use of uk.ac.ed.ph.jqtiplus.node.content.basic.Block in project openolat by klemens.
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();
}
}
Aggregations