use of org.olat.ims.qti.editor.beecom.objects.Control 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;
}
use of org.olat.ims.qti.editor.beecom.objects.Control in project openolat by klemens.
the class QTIEditHelper method getControl.
/**
* Get controls.
* @param object
* @return Controls.
*/
public static Control getControl(QTIObject object) {
Control control = null;
List controls = null;
if (Item.class.isAssignableFrom(object.getClass())) {
Item item = (Item) object;
controls = item.getItemcontrols();
} else if (Section.class.isAssignableFrom(object.getClass())) {
Section section = (Section) object;
controls = section.getSectioncontrols();
} else if (Assessment.class.isAssignableFrom(object.getClass())) {
Assessment assessment = (Assessment) object;
controls = assessment.getAssessmentcontrols();
}
for (Iterator i = controls.iterator(); i.hasNext(); ) {
Control tmp = (Control) i.next();
if (tmp.getView() != null) {
if (tmp.getView().equalsIgnoreCase("all")) {
control = tmp;
break;
}
} else {
control = tmp;
}
}
return control;
}
use of org.olat.ims.qti.editor.beecom.objects.Control in project openolat by klemens.
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.Control in project openolat by klemens.
the class QTIEditHelper method createKPRIMItem.
/**
* Creates a new Kprim item
* @param trans
* @return New Kprim item.
*/
public static Item createKPRIMItem(Translator trans) {
// create item
Item newItem = new Item();
newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_KPRIM + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
newItem.setTitle(trans.translate("editor.newquestion"));
newItem.setLabel("");
// controls
Control control = new Control();
List<Control> controls = new ArrayList<Control>();
controls.add(control);
newItem.setItemcontrols(controls);
// prepare question
float maxValue = 1;
ChoiceQuestion question = new ChoiceQuestion();
question.setLable(trans.translate("editor.newquestion"));
question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
question.setType(Question.TYPE_KPRIM);
question.setSingleCorrect(false);
// Kprim has always 4 answers, each of them score 1/4 of the maximum value
ChoiceResponse newChoice = new ChoiceResponse();
newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
newChoice.setCorrect(false);
newChoice.setPoints(maxValue / 4);
question.getResponses().add(newChoice);
ChoiceResponse newChoice2 = new ChoiceResponse();
newChoice2.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
newChoice2.setCorrect(false);
newChoice2.setPoints(maxValue / 4);
question.getResponses().add(newChoice2);
ChoiceResponse newChoice3 = new ChoiceResponse();
newChoice3.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
newChoice3.setCorrect(false);
newChoice3.setPoints(maxValue / 4);
question.getResponses().add(newChoice3);
ChoiceResponse newChoice4 = new ChoiceResponse();
newChoice4.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
newChoice4.setCorrect(false);
newChoice4.setPoints(maxValue / 4);
question.getResponses().add(newChoice4);
question.setMaxValue(maxValue);
newItem.setQuestion(question);
QTIEditHelper.setFeedbackMastery(newItem, "");
QTIEditHelper.setFeedbackFail(newItem, "");
return newItem;
}
use of org.olat.ims.qti.editor.beecom.objects.Control in project openolat by klemens.
the class QTIEditHelper method createSCItem.
/**
* Creates a new Single Choice item
* @param trans
* @return New Singe Choice item.
*/
public static Item createSCItem(Translator trans) {
Item newItem = new Item();
newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_SC + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
newItem.setTitle(trans.translate("editor.newquestion"));
newItem.setLabel("");
// controls
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_SC);
question.setSingleCorrect(true);
question.setSingleCorrectScore(1);
ChoiceResponse newChoice = new ChoiceResponse();
newChoice.setCorrect(true);
newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
question.getResponses().add(newChoice);
QTIEditHelper.setFeedbackMastery(newItem, "");
QTIEditHelper.setFeedbackFail(newItem, "");
newItem.setQuestion(question);
return newItem;
}
Aggregations