Search in sources :

Example 1 with QuestionItemAuditLog

use of org.olat.modules.qpool.QuestionItemAuditLog in project OpenOLAT by OpenOLAT.

the class QuestionItemAuditLogExport method addContent.

@SuppressWarnings("deprecation")
private void addContent(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    for (QuestionItemAuditLog logEntry : auditLog) {
        int pos = 0;
        Row row = exportSheet.newRow();
        Date creationDate = logEntry.getCreationDate();
        row.addCell(pos++, creationDate, workbook.getStyles().getDateTimeStyle());
        row.addCell(pos++, logEntry.getAction());
        QuestionItem item = null;
        if (logEntry.getQuestionItemKey() != null) {
            item = qpoolService.toAuditQuestionItem(logEntry.getAfter());
        }
        if (item != null) {
            row.addCell(pos++, item.getTitle());
            row.addCell(pos++, item.getTopic());
            if (qpoolModule.isTaxonomyEnabled()) {
                row.addCell(pos++, item.getTaxonomicPath());
            }
            if (qpoolModule.isEducationalContextEnabled()) {
                row.addCell(pos++, getTranslatedContext(item.getEducationalContext()));
            }
            row.addCell(pos++, item.getKeywords());
            row.addCell(pos++, item.getAdditionalInformations());
            row.addCell(pos++, item.getCoverage());
            row.addCell(pos++, item.getLanguage());
            row.addCell(pos++, getTranslatedAssessmentType(item.getAssessmentType()));
            row.addCell(pos++, getTranslatedItemType(item.getItemType()));
            row.addCell(pos++, item.getEducationalLearningTime());
            row.addCell(pos++, format(item.getDifficulty()));
            row.addCell(pos++, format(item.getStdevDifficulty()));
            row.addCell(pos++, format(item.getDifferentiation()));
            row.addCell(pos++, String.valueOf(item.getNumOfAnswerAlternatives()));
            row.addCell(pos++, String.valueOf(item.getUsage()));
            row.addCell(pos++, item.getItemVersion());
            row.addCell(pos++, getTranslatedStatus(item.getQuestionStatus()));
        } else {
            pos += 16;
            if (qpoolModule.isTaxonomyEnabled()) {
                pos++;
            }
            if (qpoolModule.isEducationalContextEnabled()) {
                pos++;
            }
        }
        if (licenseModule.isEnabled(licenseHandler)) {
            License license = licenseService.licenseFromXml(logEntry.getLicenseAfter());
            if (license != null) {
                row.addCell(pos++, license.getLicenseType() != null ? license.getLicenseType().getName() : null);
                row.addCell(pos++, license.getLicensor());
            } else if (item != null) {
                // Backward compatibility:
                // Before the introduction of the LicenseService the license was stored in the item itself.
                row.addCell(pos++, item.getLicense() != null ? item.getLicense().getLicenseKey() : null);
                row.addCell(pos++, item.getCreator());
            } else {
                pos += 2;
            }
        }
        Long authorKey = logEntry.getAuthorKey();
        if (authorKey != null) {
            String fullname = userManager.getUserDisplayName(authorKey);
            row.addCell(pos++, fullname);
        }
    }
}
Also used : License(org.olat.core.commons.services.license.License) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Date(java.util.Date)

Example 2 with QuestionItemAuditLog

use of org.olat.modules.qpool.QuestionItemAuditLog in project openolat by klemens.

the class QuestionItemAuditLogDAOTest method shouldFindAuditLogByQuestionItem.

@Test
public void shouldFindAuditLogByQuestionItem() {
    QItemType qItemType = qItemTypeDao.loadByType(QuestionType.MC.name());
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qitem-audit-log");
    QuestionItem item = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
    QuestionItemAuditLog auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.CREATE_QUESTION_ITEM_NEW).withBefore(item).create();
    sut.persist(auditLog);
    auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION).withBefore(item).create();
    sut.persist(auditLog);
    auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION_ITEM_METADATA).withBefore(item).create();
    sut.persist(auditLog);
    QuestionItem otherItem = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
    auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION_ITEM_METADATA).withBefore(otherItem).create();
    sut.persist(auditLog);
    dbInstance.commitAndCloseSession();
    List<QuestionItemAuditLog> auditLogs = sut.getAuditLogByQuestionItem(item);
    assertThat(auditLogs).hasSize(3);
}
Also used : Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 3 with QuestionItemAuditLog

use of org.olat.modules.qpool.QuestionItemAuditLog in project openolat by klemens.

the class QuestionItemAuditLogBuilderImplTest method shouldBuildMinimalAuditLog.

@Test
public void shouldBuildMinimalAuditLog() {
    QuestionItemAuditLog auditLog = new QuestionItemAuditLogBuilderImpl(qpoolServiceMock, licenseServiceMock, authorMock, ACTION).create();
    assertThat(auditLog.getAuthorKey()).isEqualTo(AUTHOR_KEY);
    assertThat(auditLog.getAction()).isEqualTo(ACTION.name());
    assertThat(auditLog.getQuestionItemKey()).isNull();
    assertThat(auditLog.getBefore()).isNull();
    assertThat(auditLog.getAfter()).isNull();
    assertThat(auditLog.getLicenseBefore()).isNull();
    assertThat(auditLog.getLicenseAfter()).isNull();
    assertThat(auditLog.getMessage()).isNull();
}
Also used : QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Test(org.junit.Test)

Example 4 with QuestionItemAuditLog

use of org.olat.modules.qpool.QuestionItemAuditLog in project openolat by klemens.

the class QuestionItemAuditLogExport method addContent.

@SuppressWarnings("deprecation")
private void addContent(OpenXMLWorksheet exportSheet, OpenXMLWorkbook workbook) {
    for (QuestionItemAuditLog logEntry : auditLog) {
        int pos = 0;
        Row row = exportSheet.newRow();
        Date creationDate = logEntry.getCreationDate();
        row.addCell(pos++, creationDate, workbook.getStyles().getDateTimeStyle());
        row.addCell(pos++, logEntry.getAction());
        QuestionItem item = null;
        if (logEntry.getQuestionItemKey() != null) {
            item = qpoolService.toAuditQuestionItem(logEntry.getAfter());
        }
        if (item != null) {
            row.addCell(pos++, item.getTitle());
            row.addCell(pos++, item.getTopic());
            if (qpoolModule.isTaxonomyEnabled()) {
                row.addCell(pos++, item.getTaxonomicPath());
            }
            if (qpoolModule.isEducationalContextEnabled()) {
                row.addCell(pos++, getTranslatedContext(item.getEducationalContext()));
            }
            row.addCell(pos++, item.getKeywords());
            row.addCell(pos++, item.getAdditionalInformations());
            row.addCell(pos++, item.getCoverage());
            row.addCell(pos++, item.getLanguage());
            row.addCell(pos++, getTranslatedAssessmentType(item.getAssessmentType()));
            row.addCell(pos++, getTranslatedItemType(item.getItemType()));
            row.addCell(pos++, item.getEducationalLearningTime());
            row.addCell(pos++, format(item.getDifficulty()));
            row.addCell(pos++, format(item.getStdevDifficulty()));
            row.addCell(pos++, format(item.getDifferentiation()));
            row.addCell(pos++, String.valueOf(item.getNumOfAnswerAlternatives()));
            row.addCell(pos++, String.valueOf(item.getUsage()));
            row.addCell(pos++, item.getItemVersion());
            row.addCell(pos++, getTranslatedStatus(item.getQuestionStatus()));
        } else {
            pos += 16;
            if (qpoolModule.isTaxonomyEnabled()) {
                pos++;
            }
            if (qpoolModule.isEducationalContextEnabled()) {
                pos++;
            }
        }
        if (licenseModule.isEnabled(licenseHandler)) {
            License license = licenseService.licenseFromXml(logEntry.getLicenseAfter());
            if (license != null) {
                row.addCell(pos++, license.getLicenseType() != null ? license.getLicenseType().getName() : null);
                row.addCell(pos++, license.getLicensor());
            } else if (item != null) {
                // Backward compatibility:
                // Before the introduction of the LicenseService the license was stored in the item itself.
                row.addCell(pos++, item.getLicense() != null ? item.getLicense().getLicenseKey() : null);
                row.addCell(pos++, item.getCreator());
            } else {
                pos += 2;
            }
        }
        Long authorKey = logEntry.getAuthorKey();
        if (authorKey != null) {
            String fullname = userManager.getUserDisplayName(authorKey);
            row.addCell(pos++, fullname);
        }
    }
}
Also used : License(org.olat.core.commons.services.license.License) Row(org.olat.core.util.openxml.OpenXMLWorksheet.Row) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Date(java.util.Date)

Example 5 with QuestionItemAuditLog

use of org.olat.modules.qpool.QuestionItemAuditLog in project OpenOLAT by OpenOLAT.

the class QuestionItemAuditLogBuilderImplTest method shouldBuildMinimalAuditLog.

@Test
public void shouldBuildMinimalAuditLog() {
    QuestionItemAuditLog auditLog = new QuestionItemAuditLogBuilderImpl(qpoolServiceMock, licenseServiceMock, authorMock, ACTION).create();
    assertThat(auditLog.getAuthorKey()).isEqualTo(AUTHOR_KEY);
    assertThat(auditLog.getAction()).isEqualTo(ACTION.name());
    assertThat(auditLog.getQuestionItemKey()).isNull();
    assertThat(auditLog.getBefore()).isNull();
    assertThat(auditLog.getAfter()).isNull();
    assertThat(auditLog.getLicenseBefore()).isNull();
    assertThat(auditLog.getLicenseAfter()).isNull();
    assertThat(auditLog.getMessage()).isNull();
}
Also used : QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Test(org.junit.Test)

Aggregations

QuestionItemAuditLog (org.olat.modules.qpool.QuestionItemAuditLog)10 Test (org.junit.Test)8 QuestionItem (org.olat.modules.qpool.QuestionItem)6 Identity (org.olat.core.id.Identity)4 QItemType (org.olat.modules.qpool.model.QItemType)4 Date (java.util.Date)2 License (org.olat.core.commons.services.license.License)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2