use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project OpenOLAT by OpenOLAT.
the class QTIWordExport method renderItem.
public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
Element el = DocumentFactory.getInstance().createElement("dummy");
item.addToElement(el);
Element itemEl = (Element) el.elements().get(0);
org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
RenderInstructions renderInstructions = new RenderInstructions();
renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
if (item.getQuestion() != null) {
Map<String, String> iinput = new HashMap<String, String>();
String questionType = null;
String questionScore = null;
Question question = item.getQuestion();
if (question instanceof ChoiceQuestion) {
ChoiceQuestion choice = (ChoiceQuestion) question;
if (question.getType() == Question.TYPE_SC) {
questionType = translator.translate("item.type.sc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_MC) {
questionType = translator.translate("item.type.mc");
fetchPointsOfMultipleChoices(itemEl, choice, iinput);
} else if (question.getType() == Question.TYPE_KPRIM) {
questionType = translator.translate("item.type.kprim");
fetchPointsOfKPrim(itemEl, choice, iinput);
}
} else if (question instanceof FIBQuestion) {
questionType = translator.translate("item.type.sc");
for (Response response : question.getResponses()) {
FIBResponse fibResponse = (FIBResponse) response;
if ("BLANK".equals(fibResponse.getType())) {
iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
}
}
} else if (question instanceof EssayQuestion) {
questionType = translator.translate("item.type.essay");
}
if (question != null && question.getMaxValue() > 0.0f) {
questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
questionScore = translator.translate("item.score.long", new String[] { questionScore });
}
renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
}
foo.renderOpenXML(document, renderInstructions);
}
use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project openolat by klemens.
the class QTI12To21Converter method convertEssay.
private AssessmentItemBuilder convertEssay(Item item) {
EssayAssessmentItemBuilder itemBuilder = new EssayAssessmentItemBuilder("Essay", qtiSerializer);
convertItemBasics(item, itemBuilder);
EssayQuestion question = (EssayQuestion) item.getQuestion();
EssayResponse response = question.getEssayResponse();
int cols = response.getColumns();
int rows = response.getRows();
itemBuilder.setExpectedLength(cols * rows);
itemBuilder.setExpectedLines(rows);
double score = question.getMaxValue();
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(score);
return itemBuilder;
}
use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion 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.EssayQuestion in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convertEssay.
private AssessmentItemBuilder convertEssay(Item item) {
EssayAssessmentItemBuilder itemBuilder = new EssayAssessmentItemBuilder("Essay", qtiSerializer);
convertItemBasics(item, itemBuilder);
EssayQuestion question = (EssayQuestion) item.getQuestion();
EssayResponse response = question.getEssayResponse();
int cols = response.getColumns();
int rows = response.getRows();
itemBuilder.setExpectedLength(cols * rows);
itemBuilder.setExpectedLines(rows);
double score = question.getMaxValue();
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(score);
return itemBuilder;
}
use of org.olat.ims.qti.editor.beecom.objects.EssayQuestion in project openolat by klemens.
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;
}
Aggregations