use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method createFIBItem.
/**
* Creates a new FIB item
* @param trans
* @return New fib item.
*/
public static Item createFIBItem(Translator trans) {
// create item
Item newItem = new Item();
newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_FIB + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
newItem.setTitle(trans.translate("editor.newquestion"));
newItem.setLabel("");
// conrols
Control control = new Control();
List<Control> controls = new ArrayList<Control>();
controls.add(control);
newItem.setItemcontrols(controls);
QTIEditHelper.setFeedbackMastery(newItem, "");
QTIEditHelper.setFeedbackFail(newItem, "");
FIBQuestion fibquestion = new FIBQuestion();
fibquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
fibquestion.setSingleCorrect(true);
fibquestion.setSingleCorrectScore(1);
FIBResponse response = new FIBResponse();
response.setType(FIBResponse.TYPE_CONTENT);
Material mat = new Material();
mat.add(new Mattext(trans.translate("editor.newtextelement")));
response.setContent(mat);
fibquestion.getResponses().add(response);
newItem.setQuestion(fibquestion);
return newItem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method createEssayItem.
/**
* Creates a new essay item
* @param trans
* @return New essay item.
*/
public static Item createEssayItem(Translator trans) {
// create item
Item newItem = new Item();
newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_ESSAY + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
newItem.setTitle(trans.translate("editor.newquestion"));
newItem.setLabel("");
// conrols
Control control = new Control();
List<Control> controls = new ArrayList<Control>();
controls.add(control);
newItem.setItemcontrols(controls);
QTIEditHelper.setFeedbackMastery(newItem, "");
QTIEditHelper.setFeedbackFail(newItem, "");
EssayQuestion essayquestion = new EssayQuestion();
essayquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
essayquestion.setSingleCorrect(true);
essayquestion.setSingleCorrectScore(1);
EssayResponse response = new EssayResponse();
Material mat = new Material();
mat.add(new Mattext(trans.translate("editor.newtextelement")));
response.setContent(mat);
essayquestion.getResponses().add(response);
newItem.setQuestion(essayquestion);
return newItem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method createMCItem.
/**
* Creates a new Multiple Choice item.
* @param trans
* @return New Multiple Choice item.
*/
public static Item createMCItem(Translator trans) {
// create item
Item newItem = new Item();
newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_MC + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
newItem.setTitle(trans.translate("editor.newquestion"));
newItem.setLabel("");
// conrols
Control control = new Control();
List<Control> controls = new ArrayList<Control>();
controls.add(control);
newItem.setItemcontrols(controls);
// pepare question
ChoiceQuestion question = new ChoiceQuestion();
question.setLable(trans.translate("editor.newquestion"));
question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
question.setType(Question.TYPE_MC);
question.setSingleCorrect(true);
question.setSingleCorrectScore(1);
ChoiceResponse newChoice = new ChoiceResponse();
newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
newChoice.setCorrect(true);
newChoice.setPoints(1);
question.getResponses().add(newChoice);
newItem.setQuestion(question);
QTIEditHelper.setFeedbackMastery(newItem, "");
QTIEditHelper.setFeedbackFail(newItem, "");
return newItem;
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class ItemPreviewController method getQuestionPreview.
private String getQuestionPreview(Item theItem) {
try {
Element el = DocumentFactory.getInstance().createElement("dummy");
theItem.addToElement(el);
StringBuilder sb = new StringBuilder();
org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item((Element) el.elements().get(0));
foo.render(sb, renderInstructions);
return FilterFactory.getBaseURLToMediaRelativeURLFilter(mediaBaseUrl).filter(sb.toString());
} catch (Exception e) {
log.warn("Cannot render preview of an QTI 1.2 item: " + theItem);
return "ERROR";
}
}
use of org.olat.ims.qti.editor.beecom.objects.Item in project OpenOLAT by OpenOLAT.
the class QTIWordExport method exportTest.
private void exportTest(String header, OutputStream out, boolean withResponses) {
ZipOutputStream zout = null;
try {
OpenXMLDocument document = new OpenXMLDocument();
document.setMediaContainer(mediaContainer);
document.setDocumentHeader(header);
Translator translator = Util.createPackageTranslator(QTIWordExport.class, locale, Util.createPackageTranslator(QTIEditorMainController.class, locale));
Assessment assessment = rootNode.getAssessment();
renderAssessment(assessment, document, translator);
for (Section section : assessment.getSections()) {
renderSection(section, document);
List<Item> items = section.getItems();
for (Iterator<Item> itemIt = items.iterator(); itemIt.hasNext(); ) {
Item item = itemIt.next();
if (item.isAlient()) {
renderAlienItem(item, document, translator);
} else {
renderItem(item, document, withResponses, translator);
}
if (itemIt.hasNext()) {
document.appendPageBreak();
}
}
}
zout = new ZipOutputStream(out);
zout.setLevel(9);
OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
writer.createDocument(zout, document);
} catch (Exception e) {
log.error("", e);
} finally {
if (zout != null) {
try {
zout.finish();
} catch (IOException e) {
log.error("", e);
}
}
}
}
Aggregations