Search in sources :

Example 26 with QuestionItem

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

the class QItemQueriesDAOTest method shouldGetAllItems.

@Test
public void shouldGetAllItems() {
    Identity owner1 = createRandomIdentity();
    QuestionItem item11 = createRandomItem(owner1);
    QuestionItem item12 = createRandomItem(owner1);
    QuestionItem item13 = createRandomItem(owner1);
    Identity owner2 = createRandomIdentity();
    QuestionItem item21 = createRandomItem(owner2);
    QuestionItem item22 = createRandomItem(owner2);
    QuestionItem item23 = createRandomItem(owner2);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(loadedItems).hasSize(6);
    assertThat(keysOf(loadedItems)).containsOnlyElementsOf(keysOf(item11, item12, item13, item21, item22, item23));
}
Also used : Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 27 with QuestionItem

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

the class QItemQueriesDAOTest method shouldGetItemsIsEditableInAShare.

@Test
public void shouldGetItemsIsEditableInAShare() {
    Identity owner1 = createRandomIdentity();
    QuestionItem item11 = createRandomItem(owner1);
    QuestionItem item12 = createRandomItem(owner1);
    QuestionItem item13 = createRandomItem(owner1);
    BusinessGroup group = businessGroupDao.createAndPersist(owner1, "QPool", "QPool", -1, -1, false, false, false, false, false);
    List<OLATResource> groupResources = Arrays.asList(group.getResource());
    questionDao.share(item11, groupResources, true);
    questionDao.share(item12, groupResources, false);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(createRandomIdentity(), null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isEditableInShare()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isEditableInShare()).isFalse();
    assertThat(filterByKey(loadedItems, item13).isEditableInShare()).isFalse();
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem) Test(org.junit.Test)

Example 28 with QuestionItem

use of org.olat.modules.qpool.QuestionItem 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 29 with QuestionItem

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

the class QuestionItemDetailsController method doRate.

private void doRate(UserRequest ureq, float rating, String comment) {
    QuestionItem item = metadatasCtrl.getItem();
    qpoolService.rateItemInReview(item, getIdentity(), rating, comment);
    reloadData(ureq);
    setCommentsController(ureq);
    fireEvent(ureq, new QPoolEvent(QPoolEvent.ITEM_STATUS_CHANGED, item.getKey()));
}
Also used : QPoolEvent(org.olat.modules.qpool.ui.events.QPoolEvent) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 30 with QuestionItem

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

the class QuestionItemDetailsController method reloadData.

private void reloadData(UserRequest ureq) {
    Long itemKey = metadatasCtrl.getItem().getKey();
    QuestionItemView itemView = itemSource.getItemWithoutRestrictions(itemKey);
    if (itemView != null) {
        qItemSecurityCallback.setQuestionItemView(itemView);
        initTools();
        setCommentsController(ureq);
        QuestionItem reloadedItem = qpoolService.loadItemById(itemView.getKey());
        metadatasCtrl.setItem(reloadedItem, qItemSecurityCallback);
        reviewActionCtrl.setSecurityCallback(qItemSecurityCallback);
        setQuestionController(ureq, reloadedItem, qItemSecurityCallback);
    }
}
Also used : QuestionItemView(org.olat.modules.qpool.QuestionItemView) QuestionItem(org.olat.modules.qpool.QuestionItem)

Aggregations

QuestionItem (org.olat.modules.qpool.QuestionItem)260 Test (org.junit.Test)160 Identity (org.olat.core.id.Identity)122 QItemType (org.olat.modules.qpool.model.QItemType)82 QuestionItemView (org.olat.modules.qpool.QuestionItemView)76 SearchQuestionItemParams (org.olat.modules.qpool.model.SearchQuestionItemParams)54 ArrayList (java.util.ArrayList)42 File (java.io.File)32 BusinessGroup (org.olat.group.BusinessGroup)32 QuestionItemAuditLogBuilder (org.olat.modules.qpool.QuestionItemAuditLogBuilder)32 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)30 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)28 URL (java.net.URL)24 Pool (org.olat.modules.qpool.Pool)20 QuestionItem2Pool (org.olat.modules.qpool.QuestionItem2Pool)16 QuestionItemCollection (org.olat.modules.qpool.QuestionItemCollection)16 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)14 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 VFSItem (org.olat.core.util.vfs.VFSItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)12