use of org.olat.ims.qti.editor.beecom.objects.Feedback in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method getFeedbacks.
/**
* @param object
* @return
*/
private static List<Feedback> getFeedbacks(QTIObject object) {
List<Feedback> feedbacks = null;
if (Item.class.isAssignableFrom(object.getClass())) {
Item item = (Item) object;
feedbacks = item.getItemfeedbacks();
} else if (Section.class.isAssignableFrom(object.getClass())) {
Section section = (Section) object;
feedbacks = section.getSectionfeedbacks();
} else if (Assessment.class.isAssignableFrom(object.getClass())) {
Assessment assessment = (Assessment) object;
feedbacks = assessment.getAssessfeedbacks();
}
return feedbacks;
}
use of org.olat.ims.qti.editor.beecom.objects.Feedback in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method getFeedbackMaterial.
/**
* @param object
* @param sIdent
* @return
*/
public static Material getFeedbackMaterial(QTIObject object, String sIdent) {
Feedback feedback = getFeedback(object, sIdent);
Material mat = null;
try {
mat = (Material) feedback.getMaterials().get(0);
} catch (NullPointerException e) {
// feedback is null
}
return mat;
}
use of org.olat.ims.qti.editor.beecom.objects.Feedback in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method setFeedback.
/**
* Set feedback
* @param object
* @param feedbackString
* @param sIdent
*/
public static void setFeedback(QTIObject object, String feedbackString, String sIdent) {
List<Feedback> feedbacks = getFeedbacks(object);
Feedback feedback = getFeedback(sIdent, feedbacks);
if (feedbackString == null || feedbackString.trim().length() == 0) {
feedbacks.remove(feedback);
return;
}
if (feedback != null) {
feedbackString = feedbackString.trim();
List matList = feedback.getMaterials();
if (matList.size() > 0) {
Material mat = (Material) feedback.getMaterials().get(0);
if (mat == null) {
mat = new Material();
mat.getElements().add(new Mattext(feedbackString));
feedback.getMaterials().add(mat);
} else if (mat.getElements().size() > 0) {
mat.getElements().set(0, new Mattext(feedbackString));
} else {
mat.getElements().add(new Mattext(feedbackString));
}
} else {
Material mat = new Material();
mat.getElements().add(new Mattext(feedbackString));
feedback.getMaterials().add(mat);
}
} else {
Feedback newFeedback = new Feedback();
newFeedback.setIdent(sIdent);
newFeedback.setView("All");
Mattext newMattext = new Mattext(feedbackString);
List<QTIObject> newMattextL = new ArrayList<>();
newMattextL.add(newMattext);
Material material = new Material();
material.setElements(newMattextL);
List<Material> newMaterialL = new ArrayList<>();
newMaterialL.add(material);
newFeedback.setMaterials(newMaterialL);
feedbacks.add(newFeedback);
}
}
use of org.olat.ims.qti.editor.beecom.objects.Feedback in project openolat by klemens.
the class QTIEditHelper method setFeedback.
/**
* Set feedback
* @param object
* @param feedbackString
* @param sIdent
*/
public static void setFeedback(QTIObject object, String feedbackString, String sIdent) {
List<Feedback> feedbacks = getFeedbacks(object);
Feedback feedback = getFeedback(sIdent, feedbacks);
if (feedbackString == null || feedbackString.trim().length() == 0) {
feedbacks.remove(feedback);
return;
}
if (feedback != null) {
feedbackString = feedbackString.trim();
List matList = feedback.getMaterials();
if (matList.size() > 0) {
Material mat = (Material) feedback.getMaterials().get(0);
if (mat == null) {
mat = new Material();
mat.getElements().add(new Mattext(feedbackString));
feedback.getMaterials().add(mat);
} else if (mat.getElements().size() > 0) {
mat.getElements().set(0, new Mattext(feedbackString));
} else {
mat.getElements().add(new Mattext(feedbackString));
}
} else {
Material mat = new Material();
mat.getElements().add(new Mattext(feedbackString));
feedback.getMaterials().add(mat);
}
} else {
Feedback newFeedback = new Feedback();
newFeedback.setIdent(sIdent);
newFeedback.setView("All");
Mattext newMattext = new Mattext(feedbackString);
List<QTIObject> newMattextL = new ArrayList<>();
newMattextL.add(newMattext);
Material material = new Material();
material.setElements(newMattextL);
List<Material> newMaterialL = new ArrayList<>();
newMaterialL.add(material);
newFeedback.setMaterials(newMaterialL);
feedbacks.add(newFeedback);
}
}
use of org.olat.ims.qti.editor.beecom.objects.Feedback in project openolat by klemens.
the class QTIEditHelper method getFeedbackMaterial.
/**
* @param object
* @param sIdent
* @return
*/
public static Material getFeedbackMaterial(QTIObject object, String sIdent) {
Feedback feedback = getFeedback(object, sIdent);
Material mat = null;
try {
mat = (Material) feedback.getMaterials().get(0);
} catch (NullPointerException e) {
// feedback is null
}
return mat;
}
Aggregations