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));
}
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();
}
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);
}
}
}
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()));
}
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);
}
}
Aggregations