use of org.olat.ims.qti.editor.beecom.objects.Section in project openolat by klemens.
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;
}
use of org.olat.ims.qti.editor.beecom.objects.Section in project openolat by klemens.
the class IQConfigurationController method needManualCorrectionQTI12.
private boolean needManualCorrectionQTI12(RepositoryEntry re) {
boolean needManualCorrection = false;
QTIDocument doc = TestFileResource.getQTIDocument(re.getOlatResource());
if (doc != null && doc.getAssessment() != null) {
Assessment ass = doc.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")) {
needManualCorrection = true;
break;
}
}
}
}
return needManualCorrection;
}
use of org.olat.ims.qti.editor.beecom.objects.Section in project openolat by klemens.
the class QTIStatisticResourceResult method buildQTICourseNodeSubTree.
private void buildQTICourseNodeSubTree(QTIDocument qtiDoc, GenericTreeNode rootNode) {
for (Section section : qtiDoc.getAssessment().getSections()) {
GenericTreeNode sectionNode = new SectionNode(section, null);
sectionNode.setUserObject(section);
rootNode.addChild(sectionNode);
for (Item item : section.getItems()) {
GenericTreeNode itemNode = new ItemNode(item);
itemNode.setIdent(Long.toString(CodeHelper.getForeverUniqueID()));
if (sectionNode.getDelegate() == null) {
sectionNode.setDelegate(itemNode);
}
itemNode.setUserObject(item);
sectionNode.addChild(itemNode);
}
}
}
use of org.olat.ims.qti.editor.beecom.objects.Section in project openolat by klemens.
the class QTIWordExport method exportTest.
private void exportTest(String header, OutputStream out, boolean withResponses) {
ZipOutputStream zout = null;
try {
OpenXMLDocument document = new OpenXMLDocument();
document.setMediaContainer(mediaContainer);
document.setDocumentHeader(header);
Translator translator = Util.createPackageTranslator(QTIWordExport.class, locale, Util.createPackageTranslator(QTIEditorMainController.class, locale));
Assessment assessment = rootNode.getAssessment();
renderAssessment(assessment, document, translator);
for (Section section : assessment.getSections()) {
renderSection(section, document);
List<Item> items = section.getItems();
for (Iterator<Item> itemIt = items.iterator(); itemIt.hasNext(); ) {
Item item = itemIt.next();
if (item.isAlient()) {
renderAlienItem(item, document, translator);
} else {
renderItem(item, document, withResponses, translator);
}
if (itemIt.hasNext()) {
document.appendPageBreak();
}
}
}
zout = new ZipOutputStream(out);
zout.setLevel(9);
OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
writer.createDocument(zout, document);
} catch (Exception e) {
log.error("", e);
} finally {
if (zout != null) {
try {
zout.finish();
} catch (IOException e) {
log.error("", e);
}
}
}
}
use of org.olat.ims.qti.editor.beecom.objects.Section in project openolat by klemens.
the class QTIEditHelper method createSection.
/**
* Creates an empty section
* @param trans
* @return Section
*/
public static Section createSection(Translator trans) {
Section section = new Section();
section.setIdent(CodeHelper.getGlobalForeverUniqueID());
section.setTitle(trans.translate("editor.newsection"));
return section;
}
Aggregations