Search in sources :

Example 6 with QTI21DeliveryOptions

use of org.olat.ims.qti21.QTI21DeliveryOptions in project OpenOLAT by OpenOLAT.

the class QTI21DeliveryOptionsController method applyDeliveryOptions.

private void applyDeliveryOptions(QTI21DeliveryOptions options) {
    String maxAttemptsValue = "";
    int maxAttempts = options.getMaxAttempts();
    if (maxAttempts > 0) {
        limitAttemptsEl.select(onKeys[0], true);
        maxAttemptsValue = Integer.toString(maxAttempts);
    } else {
        limitAttemptsEl.uncheckAll();
    }
    maxAttemptsEl.setValue(maxAttemptsValue);
    maxAttemptsEl.setVisible(maxAttempts > 0);
    applyMultipleSelection(blockAfterSuccessEl, options.isBlockAfterSuccess());
    applyMultipleSelection(allowAnonymEl, options.isAllowAnonym());
    applyMultipleSelection(hideLmsEl, options.isHideLms());
    applyMultipleSelection(showTitlesEl, options.isShowTitles());
    applyMultipleSelection(showMenuEl, options.isShowMenu());
    applyMultipleSelection(personalNotesEl, options.isPersonalNotes());
    applyMultipleSelection(displayQuestionProgressEl, options.isDisplayQuestionProgress());
    applyMultipleSelection(displayScoreProgressEl, options.isDisplayScoreProgress());
    applyMultipleSelection(displayMaxScoreItemEl, options.isDisplayMaxScoreItem());
    applyMultipleSelection(enableSuspendEl, options.isEnableSuspend());
    applyMultipleSelection(enableCancelEl, options.isEnableCancel());
    applyMultipleSelection(showFeedbacksEl, !options.isHideFeedbacks());
    if (options.isShowAssessmentResultsOnFinish()) {
        showResultsOnFinishEl.select(onKeys[0], true);
    }
    QTI21AssessmentResultsOptions resultsOptions = options.getAssessmentResultsOptions();
    if (!resultsOptions.none()) {
        assessmentResultsOnFinishEl.uncheckAll();
        if (resultsOptions.isMetadata()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[0], true);
        }
        if (resultsOptions.isSectionSummary()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[1], true);
        }
        if (resultsOptions.isQuestionSummary()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[2], true);
        }
        if (resultsOptions.isUserSolutions()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[3], true);
        }
        if (resultsOptions.isCorrectSolutions()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[4], true);
        }
    } else {
        assessmentResultsOnFinishEl.uncheckAll();
    }
    assessmentResultsOnFinishEl.setVisible(showResultsOnFinishEl.isAtLeastSelected(1));
    boolean digitalSignature = options.isDigitalSignature();
    applyMultipleSelection(digitalSignatureEl, digitalSignature);
    boolean digitalSignatureSendMail = options.isDigitalSignatureMail();
    applyMultipleSelection(digitalSignatureMailEl, digitalSignatureSendMail);
    digitalSignatureMailEl.setVisible(qtiModule.isDigitalSignatureEnabled() && digitalSignatureEl.isAtLeastSelected(1));
}
Also used : QTI21AssessmentResultsOptions(org.olat.ims.qti21.QTI21AssessmentResultsOptions)

Example 7 with QTI21DeliveryOptions

use of org.olat.ims.qti21.QTI21DeliveryOptions 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 8 with QTI21DeliveryOptions

use of org.olat.ims.qti21.QTI21DeliveryOptions 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 9 with QTI21DeliveryOptions

use of org.olat.ims.qti21.QTI21DeliveryOptions in project openolat by klemens.

the class QTI21ServiceImpl method getDeliveryOptions.

@Override
public QTI21DeliveryOptions getDeliveryOptions(RepositoryEntry testEntry) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(testEntry.getOlatResource());
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    QTI21DeliveryOptions config;
    if (configXml.exists()) {
        config = (QTI21DeliveryOptions) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = QTI21DeliveryOptions.defaultSettings();
        setDeliveryOptions(testEntry, config);
    }
    return config;
}
Also used : QTI21DeliveryOptions(org.olat.ims.qti21.QTI21DeliveryOptions) FileResourceManager(org.olat.fileresource.FileResourceManager) File(java.io.File)

Example 10 with QTI21DeliveryOptions

use of org.olat.ims.qti21.QTI21DeliveryOptions in project openolat by klemens.

the class QTI21DeliveryOptionsController method applyDeliveryOptions.

private void applyDeliveryOptions(QTI21DeliveryOptions options) {
    String maxAttemptsValue = "";
    int maxAttempts = options.getMaxAttempts();
    if (maxAttempts > 0) {
        limitAttemptsEl.select(onKeys[0], true);
        maxAttemptsValue = Integer.toString(maxAttempts);
    } else {
        limitAttemptsEl.uncheckAll();
    }
    maxAttemptsEl.setValue(maxAttemptsValue);
    maxAttemptsEl.setVisible(maxAttempts > 0);
    applyMultipleSelection(blockAfterSuccessEl, options.isBlockAfterSuccess());
    applyMultipleSelection(allowAnonymEl, options.isAllowAnonym());
    applyMultipleSelection(hideLmsEl, options.isHideLms());
    applyMultipleSelection(showTitlesEl, options.isShowTitles());
    applyMultipleSelection(showMenuEl, options.isShowMenu());
    applyMultipleSelection(personalNotesEl, options.isPersonalNotes());
    applyMultipleSelection(displayQuestionProgressEl, options.isDisplayQuestionProgress());
    applyMultipleSelection(displayScoreProgressEl, options.isDisplayScoreProgress());
    applyMultipleSelection(displayMaxScoreItemEl, options.isDisplayMaxScoreItem());
    applyMultipleSelection(enableSuspendEl, options.isEnableSuspend());
    applyMultipleSelection(enableCancelEl, options.isEnableCancel());
    applyMultipleSelection(showFeedbacksEl, !options.isHideFeedbacks());
    if (options.isShowAssessmentResultsOnFinish()) {
        showResultsOnFinishEl.select(onKeys[0], true);
    }
    QTI21AssessmentResultsOptions resultsOptions = options.getAssessmentResultsOptions();
    if (!resultsOptions.none()) {
        assessmentResultsOnFinishEl.uncheckAll();
        if (resultsOptions.isMetadata()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[0], true);
        }
        if (resultsOptions.isSectionSummary()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[1], true);
        }
        if (resultsOptions.isQuestionSummary()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[2], true);
        }
        if (resultsOptions.isUserSolutions()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[3], true);
        }
        if (resultsOptions.isCorrectSolutions()) {
            assessmentResultsOnFinishEl.select(resultsOptionsKeys[4], true);
        }
    } else {
        assessmentResultsOnFinishEl.uncheckAll();
    }
    assessmentResultsOnFinishEl.setVisible(showResultsOnFinishEl.isAtLeastSelected(1));
    boolean digitalSignature = options.isDigitalSignature();
    applyMultipleSelection(digitalSignatureEl, digitalSignature);
    boolean digitalSignatureSendMail = options.isDigitalSignatureMail();
    applyMultipleSelection(digitalSignatureMailEl, digitalSignatureSendMail);
    digitalSignatureMailEl.setVisible(qtiModule.isDigitalSignatureEnabled() && digitalSignatureEl.isAtLeastSelected(1));
}
Also used : QTI21AssessmentResultsOptions(org.olat.ims.qti21.QTI21AssessmentResultsOptions)

Aggregations

QTI21DeliveryOptions (org.olat.ims.qti21.QTI21DeliveryOptions)22 RepositoryEntry (org.olat.repository.RepositoryEntry)14 File (java.io.File)6 ModuleConfiguration (org.olat.modules.ModuleConfiguration)6 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)4 QTI21Service (org.olat.ims.qti21.QTI21Service)4 DigitalSignatureOptions (org.olat.ims.qti21.model.DigitalSignatureOptions)4 OLATResource (org.olat.resource.OLATResource)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 NodeEditController (org.olat.course.editor.NodeEditController)2 FileResourceManager (org.olat.fileresource.FileResourceManager)2 ImsQTI21Resource (org.olat.fileresource.types.ImsQTI21Resource)2 QTIEditorPackage (org.olat.ims.qti.editor.QTIEditorPackage)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2