use of org.olat.modules.qpool.model.QItemList in project OpenOLAT by OpenOLAT.
the class QTIHandler method createResource.
protected RepositoryEntry createResource(String type, FileResource ores, Identity initialAuthor, String displayname, String description, Object object, Locale locale) {
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(ores);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
DBFactory.getInstance().commit();
File fRepositoryQTI = new File(FileResourceManager.getInstance().getFileResourceRoot(re.getOlatResource()), "qti.zip");
QTIEditorPackageImpl qtiPackage = new QTIEditorPackageImpl(displayname, type, locale);
if (object instanceof QItemList) {
QItemList itemToImport = (QItemList) object;
QTIQPoolServiceProvider provider = (QTIQPoolServiceProvider) CoreSpringFactory.getBean("qtiPoolServiceProvider");
provider.exportToEditorPackage(qtiPackage, itemToImport.getItems(), true);
}
qtiPackage.savePackageTo(fRepositoryQTI);
return re;
}
use of org.olat.modules.qpool.model.QItemList in project OpenOLAT by OpenOLAT.
the class QuestionListController method doOpenCreateRepositoryTest.
private void doOpenCreateRepositoryTest(UserRequest ureq, List<QuestionItemShort> items, String type) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(addController);
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(type);
addController = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
addController.setCreateObject(new QItemList(items));
listenTo(addController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addController.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
use of org.olat.modules.qpool.model.QItemList in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentTestHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
ImsQTI21Resource ores = new ImsQTI21Resource();
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(ores);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
dbInstance.commit();
File repositoryDir = new File(FileResourceManager.getInstance().getFileResourceRoot(re.getOlatResource()), FileResourceManager.ZIPDIR);
if (!repositoryDir.exists()) {
repositoryDir.mkdirs();
}
if (createObject instanceof QItemList) {
QItemList itemToImport = (QItemList) createObject;
qpoolServiceProvider.exportToEditorPackage(repositoryDir, itemToImport.getItems(), locale);
} else if (createObject instanceof QTIEditorPackage) {
QTIEditorPackage testToConvert = (QTIEditorPackage) createObject;
QTI21DeliveryOptions options = qtiService.getDeliveryOptions(re);
qpoolServiceProvider.convertFromEditorPackage(testToConvert, repositoryDir, locale, options);
qtiService.setDeliveryOptions(re, options);
} else if (createObject instanceof OLATResource) {
// convert a Onyx test in QTI 2.1
OLATResource onyxResource = (OLATResource) createObject;
RepositoryEntry onyxRe = CoreSpringFactory.getImpl(RepositoryService.class).loadByResourceKey(onyxResource.getKey());
if (OnyxModule.isOnyxTest((OLATResource) createObject)) {
copyOnyxResources(onyxResource, repositoryDir);
} else {
QTI21DeliveryOptions options = qtiService.getDeliveryOptions(re);
QTIEditorPackage testToConvert = TestFileResource.getQTIEditorPackageReader(onyxResource);
qpoolServiceProvider.convertFromEditorPackage(testToConvert, repositoryDir, locale, options);
qtiService.setDeliveryOptions(re, options);
}
copyMetadata(onyxRe, re, repositoryDir);
} else {
createMinimalAssessmentTest(displayname, repositoryDir, locale);
}
return re;
}
use of org.olat.modules.qpool.model.QItemList in project openolat by klemens.
the class QTI21AssessmentTestHandler method createResource.
@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
ImsQTI21Resource ores = new ImsQTI21Resource();
OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(ores);
RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
dbInstance.commit();
File repositoryDir = new File(FileResourceManager.getInstance().getFileResourceRoot(re.getOlatResource()), FileResourceManager.ZIPDIR);
if (!repositoryDir.exists()) {
repositoryDir.mkdirs();
}
if (createObject instanceof QItemList) {
QItemList itemToImport = (QItemList) createObject;
qpoolServiceProvider.exportToEditorPackage(repositoryDir, itemToImport.getItems(), locale);
} else if (createObject instanceof QTIEditorPackage) {
QTIEditorPackage testToConvert = (QTIEditorPackage) createObject;
QTI21DeliveryOptions options = qtiService.getDeliveryOptions(re);
qpoolServiceProvider.convertFromEditorPackage(testToConvert, repositoryDir, locale, options);
qtiService.setDeliveryOptions(re, options);
} else if (createObject instanceof OLATResource) {
// convert a Onyx test in QTI 2.1
OLATResource onyxResource = (OLATResource) createObject;
RepositoryEntry onyxRe = CoreSpringFactory.getImpl(RepositoryService.class).loadByResourceKey(onyxResource.getKey());
if (OnyxModule.isOnyxTest((OLATResource) createObject)) {
copyOnyxResources(onyxResource, repositoryDir);
} else {
QTI21DeliveryOptions options = qtiService.getDeliveryOptions(re);
QTIEditorPackage testToConvert = TestFileResource.getQTIEditorPackageReader(onyxResource);
qpoolServiceProvider.convertFromEditorPackage(testToConvert, repositoryDir, locale, options);
qtiService.setDeliveryOptions(re, options);
}
copyMetadata(onyxRe, re, repositoryDir);
} else {
createMinimalAssessmentTest(displayname, repositoryDir, locale);
}
return re;
}
use of org.olat.modules.qpool.model.QItemList in project openolat by klemens.
the class QuestionListController method doOpenCreateRepositoryTest.
private void doOpenCreateRepositoryTest(UserRequest ureq, List<QuestionItemShort> items, String type) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(addController);
RepositoryHandler handler = repositoryHandlerFactory.getRepositoryHandler(type);
addController = handler.createCreateRepositoryEntryController(ureq, getWindowControl());
addController.setCreateObject(new QItemList(items));
listenTo(addController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addController.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
Aggregations