use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QuestionItemDAO method removeAuthors.
public void removeAuthors(List<Identity> authors, QuestionItemShort item) {
QuestionItemImpl lockedItem = loadForUpdate(item);
SecurityGroup secGroup = lockedItem.getOwnerGroup();
for (Identity author : authors) {
if (securityManager.isIdentityInSecurityGroup(author, secGroup)) {
securityManager.removeIdentityFromSecurityGroup(author, secGroup);
}
}
dbInstance.commit();
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QuestionItemDAO method addAuthors.
public void addAuthors(List<Identity> authors, QuestionItemShort item) {
QuestionItemImpl lockedItem = loadForUpdate(item);
SecurityGroup secGroup = lockedItem.getOwnerGroup();
for (Identity author : authors) {
if (!securityManager.isIdentityInSecurityGroup(author, secGroup)) {
securityManager.addIdentityToSecurityGroup(author, secGroup);
}
}
dbInstance.commit();
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class CollectionDAO method addItemToCollection.
/**
* Add an item to a collection
* @param itemKey
* @param collection
* @return true if the item is in the collection after the call
*/
public boolean addItemToCollection(QuestionItemShort item, List<QuestionItemCollection> collections) {
QuestionItemImpl lockedItem = questionItemDao.loadForUpdate(item);
if (lockedItem == null) {
return false;
}
Set<QuestionItemCollection> uniqueCollections = new HashSet<>(collections);
for (QuestionItemCollection collection : uniqueCollections) {
if (!isInCollection(collection, lockedItem)) {
CollectionToItem coll2Item = new CollectionToItem();
coll2Item.setCreationDate(new Date());
coll2Item.setCollection(collection);
coll2Item.setItem(lockedItem);
dbInstance.getCurrentEntityManager().persist(coll2Item);
}
}
dbInstance.commit();
return true;
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class QuestionMetadataEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
builder.withBefore(itemImpl);
int day = learningTimeDayElement.getIntValue();
int hour = learningTimeHourElement.getIntValue();
int minute = learningTimeMinuteElement.getIntValue();
int seconds = learningTimeSecondElement.getIntValue();
String timeStr = MetadataConverterHelper.convertDuration(day, hour, minute, seconds);
itemImpl.setEducationalLearningTime(timeStr);
BigDecimal difficulty = toBigDecimal(difficultyEl.getValue());
itemImpl.setDifficulty(difficulty);
BigDecimal stdevDifficulty = toBigDecimal(stdevDifficultyEl.getValue());
itemImpl.setStdevDifficulty(stdevDifficulty);
BigDecimal differentiation = toBigDecimal(differentiationEl.getValue());
itemImpl.setDifferentiation(differentiation);
int numOfAnswerAlternatives = toInt(numAnswerAltEl.getValue());
itemImpl.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
int numUsage = toInt(usageEl.getValue());
itemImpl.setUsage(numUsage);
item = qpoolService.updateItem(itemImpl);
builder.withAfter(item);
qpoolService.persist(builder.create());
fireEvent(ureq, new QItemEdited(item));
}
}
use of org.olat.modules.qpool.model.QuestionItemImpl in project OpenOLAT by OpenOLAT.
the class RightsMetadataEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (item instanceof QuestionItemImpl) {
QuestionItemImpl itemImpl = (QuestionItemImpl) item;
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(getIdentity(), Action.UPDATE_QUESTION_ITEM_METADATA);
builder.withBefore(itemImpl);
if (licenseModule.isEnabled(licenseHandler)) {
if (licenseEl != null && licenseEl.isOneSelected()) {
String licenseTypeKey = licenseEl.getSelectedKey();
LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
license.setLicenseType(licneseType);
}
String licensor = null;
String freetext = null;
if (licensorEl != null && licensorEl.isVisible()) {
licensor = StringHelper.containsNonWhitespace(licensorEl.getValue()) ? licensorEl.getValue() : null;
}
if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
}
license.setLicensor(licensor);
license.setFreetext(freetext);
license = licenseService.update(license);
licensorEl.setValue(license.getLicensor());
licenseFreetextEl.setValue(license.getFreetext());
}
item = qpoolService.updateItem(item);
builder.withAfter(itemImpl);
qpoolService.persist(builder.create());
fireEvent(ureq, new QItemEdited(item));
}
}
Aggregations