use of org.olat.ims.qti.editor.beecom.objects.Control in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.ims.qti.editor.beecom.objects.Control 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.Control 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.Control 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.Control in project OpenOLAT by OpenOLAT.
the class AssessmentController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == main) {
if (event.getCommand().equals("sao")) {
// asessment options submitted
// Handle all data that is useless in survey mode
String newTitle = ureq.getParameter("title");
String oldTitle = assessment.getTitle();
boolean hasTitleChange = newTitle != null && !newTitle.equals(oldTitle);
String newObjectives = ureq.getParameter("objectives");
String oldObjectives = assessment.getObjectives();
boolean hasObjectivesChange = newObjectives != null && !newObjectives.equals(oldObjectives);
NodeBeforeChangeEvent nce = new NodeBeforeChangeEvent();
if (hasTitleChange) {
nce.setNewTitle(newTitle);
}
if (hasObjectivesChange) {
nce.setNewObjectives(newObjectives);
}
if (hasTitleChange || hasObjectivesChange) {
// create a memento first
fireEvent(ureq, nce);
// then apply changes
assessment.setTitle(newTitle);
assessment.setObjectives(newObjectives);
}
//
if (!surveyMode && !restrictedEdit) {
// ordering
assessment.getSelection_ordering().setOrderType(ureq.getParameter("order_type"));
assessment.getSelection_ordering().setSelectionNumber(ureq.getParameter("selection_number"));
main.contextPut("order_type", assessment.getSelection_ordering().getOrderType());
main.contextPut("selection_number", String.valueOf(assessment.getSelection_ordering().getSelectionNumber()));
Control tmpControl = QTIEditHelper.getControl(assessment);
boolean oldInheritControls = assessment.isInheritControls();
boolean newInheritControls = ureq.getParameter("inheritswitch").equals("Yes");
assessment.setInheritControls(newInheritControls);
String feedbackswitchTmp = ureq.getParameter("feedbackswitch");
String hintswitchTmp = ureq.getParameter("hintswitch");
String solutionswitchTmp = ureq.getParameter("solutionswitch");
tmpControl.setSwitches(feedbackswitchTmp, hintswitchTmp, solutionswitchTmp);
if (tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getSolution() != Control.CTRL_UNDEF)
assessment.setInheritControls(true);
if (oldInheritControls && !newInheritControls) {
tmpControl.setSwitches(Control.CTRL_UNDEF, Control.CTRL_UNDEF, Control.CTRL_UNDEF);
assessment.setInheritControls(false);
}
OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
if (outcomesProcessing == null) {
// Create outcomes processing object if it doesn't already exist.
// Happens
// when creating a new assessment
outcomesProcessing = new OutcomesProcessing();
assessment.setOutcomes_processing(outcomesProcessing);
}
String cutval = ureq.getParameter(OutcomesProcessing.CUTVALUE);
try {
Float.parseFloat(cutval);
} catch (NumberFormatException nfe) {
cutval = "0.0";
this.showWarning("error.cutval");
}
outcomesProcessing.setField(OutcomesProcessing.CUTVALUE, cutval);
main.contextPut(OutcomesProcessing.CUTVALUE, cutval);
if (ureq.getParameter("duration").equals("Yes")) {
String durationMin = ureq.getParameter("duration_min");
String durationSec = ureq.getParameter("duration_sec");
try {
Integer.parseInt(durationMin);
int sec = Integer.parseInt(durationSec);
if (sec > 60)
throw new NumberFormatException();
} catch (NumberFormatException nfe) {
durationMin = "0";
durationSec = "0";
this.showWarning("error.duration");
}
Duration d = new Duration(durationMin, durationSec);
assessment.setDuration(d);
main.contextPut("duration", assessment.getDuration());
} else {
assessment.setDuration(null);
main.contextRemove("duration");
}
}
qtiPackage.serializeQTIDocument();
// refresh for removing dirty marking of button even if nothing changed
main.setDirty(true);
}
}
}
Aggregations