Search in sources :

Example 1 with QItemList

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;
}
Also used : QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) QTIQPoolServiceProvider(org.olat.ims.qti.qpool.QTIQPoolServiceProvider) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) RepositoryService(org.olat.repository.RepositoryService) QItemList(org.olat.modules.qpool.model.QItemList)

Example 2 with QItemList

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();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) QItemList(org.olat.modules.qpool.model.QItemList)

Example 3 with QItemList

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;
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) ImsQTI21Resource(org.olat.fileresource.types.ImsQTI21Resource) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) QItemList(org.olat.modules.qpool.model.QItemList) RepositoryService(org.olat.repository.RepositoryService)

Example 4 with QItemList

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;
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) ImsQTI21Resource(org.olat.fileresource.types.ImsQTI21Resource) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) QItemList(org.olat.modules.qpool.model.QItemList) RepositoryService(org.olat.repository.RepositoryService)

Example 5 with QItemList

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();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) QItemList(org.olat.modules.qpool.model.QItemList)

Aggregations

QItemList (org.olat.modules.qpool.model.QItemList)6 File (java.io.File)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 RepositoryService (org.olat.repository.RepositoryService)4 OLATResource (org.olat.resource.OLATResource)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ImsQTI21Resource (org.olat.fileresource.types.ImsQTI21Resource)2 QTIEditorPackage (org.olat.ims.qti.editor.QTIEditorPackage)2 QTIEditorPackageImpl (org.olat.ims.qti.editor.QTIEditorPackageImpl)2 QTIQPoolServiceProvider (org.olat.ims.qti.qpool.QTIQPoolServiceProvider)2 QTI21DeliveryOptions (org.olat.ims.qti21.QTI21DeliveryOptions)2 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)2