use of org.olat.ims.qti.export.QTIExportManager in project OpenOLAT by OpenOLAT.
the class IQEditReplaceWizard method doStep2.
private void doStep2(UserRequest ureq) {
String nodeTitle = courseNode.getShortTitle();
if (results != null && !results.isEmpty()) {
exportDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
UserManager um = UserManager.getInstance();
String charset = um.getUserCharset(ureq.getIdentity());
QTIExportManager qem = QTIExportManager.getInstance();
Long repositoryRef = results.get(0).getResultSet().getRepositoryRef();
List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(repositoryRef);
QTIExportFormatter formatter;
if (courseNode instanceof IQTESTCourseNode) {
formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
} else if (courseNode instanceof IQSELFCourseNode) {
formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
((QTIExportFormatterCSVType1) formatter).setAnonymous(true);
} else {
formatter = new QTIExportFormatterCSVType3(ureq.getLocale(), null, "\t", "\"", "\r\n", false);
}
Map<Class<?>, QTIExportItemFormatConfig> qtiItemConfigs = getQTIItemConfigs(qtiItemObjectList);
formatter.setMapWithExportItemConfigs(qtiItemConfigs);
resultExportFile = qem.exportResults(formatter, results, qtiItemObjectList, courseNode.getShortTitle(), exportDir, charset, ".xls");
vcStep2 = createVelocityContainer("replacewizard_step2");
String[] args1 = new String[] { Integer.toString(learners.size()) };
vcStep2.contextPut("information", translate("replace.wizard.information.paragraph1", args1));
String[] args2 = new String[] { exportDir.getName(), resultExportFile };
vcStep2.contextPut("information_par2", translate("replace.wizard.information.paragraph2", args2));
vcStep2.contextPut("nodetitle", nodeTitle);
showFileButton = LinkFactory.createButton("replace.wizard.showfile", vcStep2, this);
} else {
// it exists no result
String[] args = new String[] { Integer.toString(numberOfQtiSerEntries) };
vcStep2 = createVelocityContainer("replacewizard_step2");
vcStep2.contextPut("information", translate("replace.wizard.information.empty.results", args));
vcStep2.contextPut("nodetitle", nodeTitle);
}
nextBtn = LinkFactory.createButton("replace.wizard.next", vcStep2, this);
setNextWizardStep(translate("replace.wizard.title.step2"), vcStep2);
}
use of org.olat.ims.qti.export.QTIExportManager in project OpenOLAT by OpenOLAT.
the class IQSELFCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
try {
if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
qaf.exportCourseElement(exportStream);
return true;
} else {
QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatterCSVType1 qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
qef.setAnonymous(true);
if (options != null && options.getExportFormat() != null) {
Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
for (Class<?> itemClass : itemTypes) {
itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
}
qef.setMapWithExportItemConfigs(itemConfigs);
}
return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
}
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti.export.QTIExportManager in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long courseResourceableId = course.getResourceableId();
// 1) prepare result export
CourseEnvironment courseEnv = course.getCourseEnvironment();
try {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
if (onyx) {
return true;
} else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
// 2a) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
// excel results
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
qaf.exportCourseElement(exportStream);
return true;
} else {
// 2b) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
// excel results
String shortTitle = getShortTitle();
QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
if (options != null && options.getExportFormat() != null) {
Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
for (Class<?> itemClass : itemTypes) {
itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
}
qef.setMapWithExportItemConfigs(itemConfigs);
}
return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
}
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti.export.QTIExportManager in project OpenOLAT by OpenOLAT.
the class IQSURVCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
QTIExportManager qem = QTIExportManager.getInstance();
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
QTIExportFormatter qef = new QTIExportFormatterCSVType3(locale, null, "\t", "\"", "\r\n", false);
try {
return qem.selectAndExportResults(qef, course.getResourceableId(), getShortTitle(), getIdent(), re, exportStream, locale, ".xls");
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.ims.qti.export.QTIExportManager in project openolat by klemens.
the class IQEditReplaceWizard method doStep2.
private void doStep2(UserRequest ureq) {
String nodeTitle = courseNode.getShortTitle();
if (results != null && !results.isEmpty()) {
exportDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
UserManager um = UserManager.getInstance();
String charset = um.getUserCharset(ureq.getIdentity());
QTIExportManager qem = QTIExportManager.getInstance();
Long repositoryRef = results.get(0).getResultSet().getRepositoryRef();
List<QTIItemObject> qtiItemObjectList = new QTIObjectTreeBuilder().getQTIItemObjectList(repositoryRef);
QTIExportFormatter formatter;
if (courseNode instanceof IQTESTCourseNode) {
formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
} else if (courseNode instanceof IQSELFCourseNode) {
formatter = new QTIExportFormatterCSVType1(ureq.getLocale(), "\t", "\"", "\r\n", false);
((QTIExportFormatterCSVType1) formatter).setAnonymous(true);
} else {
formatter = new QTIExportFormatterCSVType3(ureq.getLocale(), null, "\t", "\"", "\r\n", false);
}
Map<Class<?>, QTIExportItemFormatConfig> qtiItemConfigs = getQTIItemConfigs(qtiItemObjectList);
formatter.setMapWithExportItemConfigs(qtiItemConfigs);
resultExportFile = qem.exportResults(formatter, results, qtiItemObjectList, courseNode.getShortTitle(), exportDir, charset, ".xls");
vcStep2 = createVelocityContainer("replacewizard_step2");
String[] args1 = new String[] { Integer.toString(learners.size()) };
vcStep2.contextPut("information", translate("replace.wizard.information.paragraph1", args1));
String[] args2 = new String[] { exportDir.getName(), resultExportFile };
vcStep2.contextPut("information_par2", translate("replace.wizard.information.paragraph2", args2));
vcStep2.contextPut("nodetitle", nodeTitle);
showFileButton = LinkFactory.createButton("replace.wizard.showfile", vcStep2, this);
} else {
// it exists no result
String[] args = new String[] { Integer.toString(numberOfQtiSerEntries) };
vcStep2 = createVelocityContainer("replacewizard_step2");
vcStep2.contextPut("information", translate("replace.wizard.information.empty.results", args));
vcStep2.contextPut("nodetitle", nodeTitle);
}
nextBtn = LinkFactory.createButton("replace.wizard.next", vcStep2, this);
setNextWizardStep(translate("replace.wizard.title.step2"), vcStep2);
}
Aggregations