use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypeDAO method createDefaultTypes.
protected void createDefaultTypes() {
List<QItemType> types = getItemTypes();
Set<String> typeKeys = new HashSet<String>();
for (QItemType type : types) {
typeKeys.add(type.getType().toLowerCase());
}
for (QuestionType defaultType : QuestionType.values()) {
if (!typeKeys.contains(defaultType.name().toLowerCase())) {
create(defaultType.name(), false);
}
}
dbInstance.commitAndCloseSession();
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method processItemMetadata.
private void processItemMetadata(QuestionItemImpl poolItem, ItemAndMetadata metadata) {
// non heuristic set of question type
int questionType = metadata.getQuestionType();
if (questionType >= 0) {
String typeStr;
switch(questionType) {
case Question.TYPE_MC:
typeStr = QuestionType.MC.name();
break;
case Question.TYPE_SC:
typeStr = QuestionType.SC.name();
break;
case Question.TYPE_FIB:
typeStr = QuestionType.FIB.name();
break;
case Question.TYPE_ESSAY:
typeStr = QuestionType.ESSAY.name();
break;
default:
typeStr = null;
}
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);
}
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);
}
int numOfAnswerAlternatives = metadata.getNumOfAnswerAlternatives();
if (numOfAnswerAlternatives > 0) {
poolItem.setNumOfAnswerAlternatives(numOfAnswerAlternatives);
}
poolItem.setDifficulty(metadata.getDifficulty());
poolItem.setDifferentiation(metadata.getDifferentiation());
poolItem.setStdevDifficulty(metadata.getStdevDifficulty());
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method processItem.
protected QuestionItemImpl processItem(Element itemEl, String comment, String originalItemFilename, String editor, String editorVersion, DocInfos docInfos, ItemAndMetadata metadata) {
// filename
String filename;
String ident = getAttributeValue(itemEl, "ident");
if (originalItemFilename != null) {
filename = originalItemFilename;
} else if (StringHelper.containsNonWhitespace(ident)) {
filename = StringHelper.transformDisplayNameToFileSystemName(ident) + ".xml";
} else {
filename = "item.xml";
}
String dir = qpoolFileStorage.generateDir();
// title
String title = getAttributeValue(itemEl, "title");
if (!StringHelper.containsNonWhitespace(title)) {
title = ident;
}
if (!StringHelper.containsNonWhitespace(title)) {
title = importedFilename;
}
QuestionItemImpl poolItem = questionItemDao.create(title, QTIConstants.QTI_12_FORMAT, dir, filename);
// description
poolItem.setDescription(comment);
// language from default
poolItem.setLanguage(defaultLocale.getLanguage());
// question type first
boolean ooFormat = processItemQuestionType(poolItem, ident, itemEl);
if (StringHelper.containsNonWhitespace(editor)) {
poolItem.setEditor(editor);
poolItem.setEditorVersion(editorVersion);
} else if (ooFormat) {
poolItem.setEditor("OpenOLAT");
}
// if question type not found, can be overridden by the metadatas
processItemMetadata(poolItem, itemEl);
if (poolItem.getType() == null) {
QItemType defType = qItemTypeDao.loadByType(QuestionType.UNKOWN.name());
poolItem.setType(defType);
}
if (docInfos != null) {
processSidecarMetadata(poolItem, docInfos);
}
if (metadata != null) {
processItemMetadata(poolItem, metadata);
createLicense(poolItem, metadata);
}
questionItemDao.persist(owner, poolItem);
return poolItem;
}
use of org.olat.modules.qpool.model.QItemType in project OpenOLAT by OpenOLAT.
the class QItemTypesAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == createType) {
doEdit(ureq, null);
} else if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete-type".equals(se.getCommand())) {
QItemType row = model.getObject(se.getIndex());
doConfirmDelete(ureq, row);
} else if ("translate".equals(se.getCommand())) {
QItemType row = model.getObject(se.getIndex());
doOpenTranslationTool(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.qpool.model.QItemType in project openolat by klemens.
the class QItemTypesAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == createType) {
doEdit(ureq, null);
} else if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete-type".equals(se.getCommand())) {
QItemType row = model.getObject(se.getIndex());
doConfirmDelete(ureq, row);
} else if ("translate".equals(se.getCommand())) {
QItemType row = model.getObject(se.getIndex());
doOpenTranslationTool(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations