use of org.olat.ims.qti.editor.beecom.objects.Assessment in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method doExportQItem.
private void doExportQItem() {
GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
if (selectedNode instanceof ItemNode) {
ItemNode itemNode = (ItemNode) selectedNode;
QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
if (qtiObject instanceof Item) {
ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
VFSContainer editorContainer = qtiPackage.getBaseDir();
qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
showInfo("export.qpool.successful", "1");
}
} else if (selectedNode instanceof SectionNode) {
SectionNode sectionNode = (SectionNode) selectedNode;
QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
if (qtiObject instanceof Section) {
int count = doExportSection((Section) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
} else if (selectedNode instanceof AssessmentNode) {
AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
if (qtiObject instanceof Assessment) {
int count = doExportAssessment((Assessment) qtiObject);
showInfo("export.qpool.successful", Integer.toString(count));
}
}
}
use of org.olat.ims.qti.editor.beecom.objects.Assessment 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.Assessment in project OpenOLAT by OpenOLAT.
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.Assessment in project OpenOLAT by OpenOLAT.
the class QTIEditHelper method createAssessment.
/**
* Creates an empty assessment
* @param title
* @param type
* @return Assessment
*/
public static Assessment createAssessment(String title, String type) {
Assessment assessment = new Assessment();
assessment.setIdent(CodeHelper.getGlobalForeverUniqueID());
assessment.setTitle(title);
Metadata meta = new Metadata();
meta.setField(AssessmentInstance.QMD_LABEL_TYPE, type);
assessment.setMetadata(meta);
return assessment;
}
use of org.olat.ims.qti.editor.beecom.objects.Assessment in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method checkEssay.
private boolean checkEssay(RepositoryEntry testEntry) {
if (qtiEssayMap.containsKey(testEntry.getKey())) {
return qtiEssayMap.get(testEntry.getKey()).booleanValue();
}
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
TransientIdentity pseudoIdentity = new TransientIdentity();
pseudoIdentity.setName("transient");
Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
try {
QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
Assessment ass = qtiPackage.getQTIDocument().getAssessment();
// Sections with their Items
List<Section> sections = ass.getSections();
for (Section section : sections) {
List<Item> items = section.getItems();
for (Item item : items) {
String ident = item.getIdent();
if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
return true;
}
}
}
}
} catch (OLATRuntimeException e) {
log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
}
qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
return false;
}
Aggregations