Search in sources :

Example 1 with TransientIdentity

use of org.olat.admin.user.imp.TransientIdentity in project OpenOLAT by OpenOLAT.

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;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestFileResource(org.olat.ims.qti.fileresource.TestFileResource) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 2 with TransientIdentity

use of org.olat.admin.user.imp.TransientIdentity 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;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestFileResource(org.olat.ims.qti.fileresource.TestFileResource) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 3 with TransientIdentity

use of org.olat.admin.user.imp.TransientIdentity in project OpenOLAT by OpenOLAT.

the class CertificatesManagerImpl method getPreviewIdentity.

private Identity getPreviewIdentity() {
    TransientIdentity identity = new TransientIdentity();
    identity.setName("username");
    List<UserPropertyHandler> userPropertyHandlers = userManager.getAllUserPropertyHandlers();
    for (UserPropertyHandler handler : userPropertyHandlers) {
        if (handler instanceof DatePropertyHandler) {
            identity.getUser().setProperty(handler.getName(), Formatter.formatDatetime(new Date()));
        } else {
            identity.getUser().setProperty(handler.getName(), handler.getName());
        }
    }
    return identity;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) DatePropertyHandler(org.olat.user.propertyhandlers.DatePropertyHandler) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Date(java.util.Date)

Example 4 with TransientIdentity

use of org.olat.admin.user.imp.TransientIdentity in project openolat by klemens.

the class CertificatesManagerImpl method getPreviewIdentity.

private Identity getPreviewIdentity() {
    TransientIdentity identity = new TransientIdentity();
    identity.setName("username");
    List<UserPropertyHandler> userPropertyHandlers = userManager.getAllUserPropertyHandlers();
    for (UserPropertyHandler handler : userPropertyHandlers) {
        if (handler instanceof DatePropertyHandler) {
            identity.getUser().setProperty(handler.getName(), Formatter.formatDatetime(new Date()));
        } else {
            identity.getUser().setProperty(handler.getName(), handler.getName());
        }
    }
    return identity;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) DatePropertyHandler(org.olat.user.propertyhandlers.DatePropertyHandler) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Date(java.util.Date)

Aggregations

TransientIdentity (org.olat.admin.user.imp.TransientIdentity)4 Date (java.util.Date)2 Translator (org.olat.core.gui.translator.Translator)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 QTIEditorPackage (org.olat.ims.qti.editor.QTIEditorPackage)2 QTIEditorPackageImpl (org.olat.ims.qti.editor.QTIEditorPackageImpl)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 TestFileResource (org.olat.ims.qti.fileresource.TestFileResource)2 DatePropertyHandler (org.olat.user.propertyhandlers.DatePropertyHandler)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2