use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QuestionDAOTest method shareItems_countSharedItemByResource_format.
@Test
public void shareItems_countSharedItemByResource_format() {
// create a group to share 2 items
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
BusinessGroup group = businessGroupDao.createAndPersist(null, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
QuestionItem item1 = questionDao.createAndPersist(null, "Count-shared-Item-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item2 = questionDao.createAndPersist(null, "Count-shared-Item-2", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
QuestionItem item3 = questionDao.createAndPersist(null, "Count-shared-Item-3", QTIConstants.QTI_12_FORMAT, Locale.FRENCH.getLanguage(), null, null, null, fibType);
dbInstance.commit();
// share them
questionDao.share(item1, group.getResource());
questionDao.share(item2, group.getResource());
questionDao.share(item3, group.getResource());
dbInstance.commitAndCloseSession();
// retrieve them
int sharedItems = questionDao.countSharedItemByResource(group.getResource(), QTI21Constants.QTI_21_FORMAT);
Assert.assertEquals(1, sharedItems);
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QuestionDAOTest method removeFromShare.
@Test
public void removeFromShare() {
// create a group to share 2 items
QItemType mcType = qItemTypeDao.loadByType(QuestionType.MC.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Share-rm-" + UUID.randomUUID().toString());
BusinessGroup group = businessGroupDao.createAndPersist(id, "gdrm", "gdrm-desc", -1, -1, false, false, false, false, false);
QuestionItem item = questionDao.createAndPersist(id, "Share-item-rm-1", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, mcType);
dbInstance.commit();
// share them
questionDao.share(item, group.getResource());
// retrieve them as a check
List<QuestionItemView> shared = qItemQueriesDao.getSharedItemByResource(id, group.getResource(), null, null, 0, -1);
Assert.assertEquals(1, shared.size());
// and remove the items
List<QuestionItemShort> toDelete = Collections.<QuestionItemShort>singletonList(shared.get(0));
int count = questionDao.removeFromShares(toDelete);
Assert.assertEquals(1, count);
// make sure that changes are committed
dbInstance.commit();
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QTI21ImportProcessor method processItemMetadata.
// additionalInformations, assessmentType
protected void processItemMetadata(QuestionItemImpl poolItem, AssessmentItemMetadata metadata) {
// non heuristic set of question type
String typeStr = null;
QTI21QuestionType questionType = metadata.getQuestionType();
if (questionType != null && questionType.getPoolQuestionType() != null) {
typeStr = questionType.getPoolQuestionType().name();
}
if (typeStr != null) {
QItemType type = qItemTypeDao.loadByType(typeStr);
if (type != null) {
poolItem.setType(type);
}
}
String coverage = metadata.getCoverage();
if (StringHelper.containsNonWhitespace(coverage)) {
poolItem.setCoverage(coverage);
}
String language = metadata.getLanguage();
if (StringHelper.containsNonWhitespace(language)) {
poolItem.setLanguage(language);
}
String keywords = metadata.getKeywords();
if (StringHelper.containsNonWhitespace(keywords)) {
poolItem.setKeywords(keywords);
}
String taxonomyPath = metadata.getTaxonomyPath();
if (StringHelper.containsNonWhitespace(taxonomyPath)) {
QTIMetadataConverter converter = new QTIMetadataConverter(qItemTypeDao, qEduContextDao, qpoolService);
TaxonomyLevel taxonomyLevel = converter.toTaxonomy(taxonomyPath);
poolItem.setTaxonomyLevel(taxonomyLevel);
}
// educational
String level = metadata.getLevel();
if (StringHelper.containsNonWhitespace(level)) {
QTIMetadataConverter converter = new QTIMetadataConverter(qItemTypeDao, qEduContextDao, qpoolService);
QEducationalContext educationalContext = converter.toEducationalContext(level);
poolItem.setEducationalContext(educationalContext);
}
String time = metadata.getTypicalLearningTime();
if (StringHelper.containsNonWhitespace(time)) {
poolItem.setEducationalLearningTime(time);
}
String editor = metadata.getEditor();
if (StringHelper.containsNonWhitespace(editor)) {
poolItem.setEditor(editor);
}
String editorVersion = metadata.getEditorVersion();
if (StringHelper.containsNonWhitespace(editorVersion)) {
poolItem.setEditorVersion(editorVersion);
}
// OpenOLAT
poolItem.setDifficulty(metadata.getDifficulty());
poolItem.setDifferentiation(metadata.getDifferentiation());
poolItem.setStdevDifficulty(metadata.getStdevDifficulty());
int numOfAnswerAlternatives = metadata.getNumOfAnswerAlternatives();
if (numOfAnswerAlternatives > 0) {
poolItem.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
}
poolItem.setTopic(metadata.getTopic());
poolItem.setAssessmentType(metadata.getAssessmentType());
poolItem.setAdditionalInformations(metadata.getAdditionalInformations());
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QTI21ImportProcessor method processItem.
protected QuestionItemImpl processItem(AssessmentItem assessmentItem, String comment, String originalItemFilename, String editor, String editorVersion, String dir, AssessmentItemMetadata metadata) {
// filename
String filename;
String ident = assessmentItem.getIdentifier();
if (originalItemFilename != null) {
filename = originalItemFilename;
} else if (StringHelper.containsNonWhitespace(ident)) {
filename = StringHelper.transformDisplayNameToFileSystemName(ident) + ".xml";
} else {
filename = "item.xml";
}
// title
String title = assessmentItem.getTitle();
if (!StringHelper.containsNonWhitespace(title)) {
title = assessmentItem.getLabel();
}
if (!StringHelper.containsNonWhitespace(title)) {
title = ident;
}
QuestionItemImpl poolItem = questionItemDao.create(title, QTI21Constants.QTI_21_FORMAT, dir, filename);
// description
poolItem.setDescription(comment);
// language from default
poolItem.setLanguage(defaultLocale.getLanguage());
// question type first
if (StringHelper.containsNonWhitespace(editor)) {
poolItem.setEditor(editor);
poolItem.setEditorVersion(editorVersion);
}
// if question type not found, can be overridden by the metadatas
processItemMetadata(poolItem, metadata);
if (poolItem.getType() == null) {
QItemType defType = convertType(assessmentItem);
poolItem.setType(defType);
}
questionItemDao.persist(owner, poolItem);
createLicense(poolItem, metadata);
return poolItem;
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QTI21ImportProcessor method processItem.
protected QuestionItemImpl processItem(AssessmentItem assessmentItem, String comment, String originalItemFilename, String editor, String editorVersion, String dir, AssessmentItemMetadata metadata) {
// filename
String filename;
String ident = assessmentItem.getIdentifier();
if (originalItemFilename != null) {
filename = originalItemFilename;
} else if (StringHelper.containsNonWhitespace(ident)) {
filename = StringHelper.transformDisplayNameToFileSystemName(ident) + ".xml";
} else {
filename = "item.xml";
}
// title
String title = assessmentItem.getTitle();
if (!StringHelper.containsNonWhitespace(title)) {
title = assessmentItem.getLabel();
}
if (!StringHelper.containsNonWhitespace(title)) {
title = ident;
}
QuestionItemImpl poolItem = questionItemDao.create(title, QTI21Constants.QTI_21_FORMAT, dir, filename);
// description
poolItem.setDescription(comment);
// language from default
poolItem.setLanguage(defaultLocale.getLanguage());
// question type first
if (StringHelper.containsNonWhitespace(editor)) {
poolItem.setEditor(editor);
poolItem.setEditorVersion(editorVersion);
}
// if question type not found, can be overridden by the metadatas
processItemMetadata(poolItem, metadata);
if (poolItem.getType() == null) {
QItemType defType = convertType(assessmentItem);
poolItem.setType(defType);
}
questionItemDao.persist(owner, poolItem);
createLicense(poolItem, metadata);
return poolItem;
}
Aggregations