use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.
the class QTIImportProcessor method processMetadataField.
/**
* <ul>
* <li>qmd_computerscored</li>
* <li>qmd_feedbackpermitted</li>
* <li>qmd_hintspermitted</li>
* <li>qmd_itemtype -> (check is made on the content of the item)</li>
* <li>qmd_levelofdifficulty -> educational context</li>
* <li>qmd_maximumscore</li>
* <li>qmd_renderingtype</li>
* <li>qmd_responsetype</li>
* <li>qmd_scoringpermitted</li>
* <li>qmd_solutionspermitted</li>
* <li>qmd_status</li>
* <li>qmd_timedependence</li>
* <li>qmd_timelimit</li>
* <li>qmd_toolvendor -> editor</li>
* <li>qmd_topic</li>
* <li>qmd_material</li>
* <li>qmd_typeofsolution</li>
* <li>qmd_weighting</li>
* </ul>
* @param poolItem
* @param labelEl
* @param entryEl
*/
private void processMetadataField(QuestionItemImpl poolItem, Element labelEl, Element entryEl) {
String label = labelEl.getText();
String entry = entryEl.getText();
if (QTIConstants.META_LEVEL_OF_DIFFICULTY.equals(label)) {
if (StringHelper.containsNonWhitespace(entry)) {
QEducationalContext context = qEduContextDao.loadByLevel(entry);
if (context == null) {
context = qEduContextDao.create(entry, true);
}
poolItem.setEducationalContext(context);
}
} else if (QTIConstants.META_ITEM_TYPE.equals(label)) {
if (poolItem.getType() == null && StringHelper.containsNonWhitespace(entry)) {
// some heuristic
String typeStr = entry;
if (typeStr.equalsIgnoreCase("MCQ") || typeStr.equalsIgnoreCase("Multiple choice")) {
typeStr = QuestionType.MC.name();
} else if (typeStr.equalsIgnoreCase("SCQ") || typeStr.equalsIgnoreCase("Single choice")) {
typeStr = QuestionType.SC.name();
} else if (typeStr.equalsIgnoreCase("fill-in") || typeStr.equals("Fill-in-the-Blank") || typeStr.equalsIgnoreCase("Fill-in-Blank") || typeStr.equalsIgnoreCase("Fill In the Blank")) {
typeStr = QuestionType.FIB.name();
} else if (typeStr.equalsIgnoreCase("Essay")) {
typeStr = QuestionType.ESSAY.name();
}
QItemType type = qItemTypeDao.loadByType(entry);
if (type == null) {
type = qItemTypeDao.create(entry, true);
}
poolItem.setType(type);
}
} else if (QTIConstants.META_TOOLVENDOR.equals(label)) {
poolItem.setEditor(entry);
}
}
use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formOKQuestion.
private void formOKQuestion(QuestionItemImpl itemImpl) {
if (isEnabled(contextEl)) {
if (contextEl.isOneSelected()) {
QEducationalContext context = qpoolService.getEducationlContextByLevel(contextEl.getSelectedKey());
itemImpl.setEducationalContext(context);
} else {
itemImpl.setEducationalContext(null);
}
}
if (isEnabled(learningTimeContainer)) {
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);
}
if (isEnabled(difficultyEl))
itemImpl.setDifficulty(toBigDecimal(difficultyEl.getValue()));
if (isEnabled(stdevDifficultyEl))
itemImpl.setStdevDifficulty(toBigDecimal(stdevDifficultyEl.getValue()));
if (isEnabled(differentiationEl))
itemImpl.setDifferentiation(toBigDecimal(differentiationEl.getValue()));
if (isEnabled(numAnswerAltEl))
itemImpl.setNumOfAnswerAlternatives(toInt(numAnswerAltEl.getValue()));
if (isEnabled(assessmentTypeEl)) {
String assessmentType = assessmentTypeEl.isOneSelected() ? assessmentTypeEl.getSelectedKey() : null;
itemImpl.setAssessmentType(assessmentType);
}
}
use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.
the class QEducationalContextDAO method create.
public QEducationalContext create(String level, boolean deletable) {
QEducationalContext itemLevel = new QEducationalContext();
itemLevel.setCreationDate(new Date());
itemLevel.setLevel(level);
itemLevel.setDeletable(deletable);
dbInstance.getCurrentEntityManager().persist(itemLevel);
return itemLevel;
}
use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.
the class QTIImportProcessorTest method testImport_QTI12_metadata.
@Test
public void testImport_QTI12_metadata() throws IOException, URISyntaxException {
URL itemUrl = QTIImportProcessorTest.class.getResource("mchc_i_001.xml");
Assert.assertNotNull(itemUrl);
File itemFile = new File(itemUrl.toURI());
// get the document informations
QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, itemFile.getName(), itemFile);
List<QuestionItem> items = proc.process();
Assert.assertNotNull(items);
Assert.assertEquals(1, items.size());
dbInstance.commitAndCloseSession();
// check metadata
QuestionItem item = items.get(0);
Assert.assertEquals("Standard Multiple Choice Item", item.getTitle());
// qmd_levelofdifficulty
QEducationalContext level = item.getEducationalContext();
Assert.assertNotNull(level);
Assert.assertEquals("basic", level.getLevel());
// qmd_toolvendor
Assert.assertEquals("QTITools", item.getEditor());
}
use of org.olat.modules.qpool.model.QEducationalContext in project OpenOLAT by OpenOLAT.
the class QTIImportProcessorTest method testImport_QTI12_sidecarMetadata.
@Test
public void testImport_QTI12_sidecarMetadata() throws IOException, URISyntaxException {
URL itemUrl = QTIImportProcessorTest.class.getResource("qitem_metadatas.zip");
Assert.assertNotNull(itemUrl);
File itemFile = new File(itemUrl.toURI());
// get the document informations
QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, itemFile.getName(), itemFile);
List<QuestionItem> items = proc.process();
Assert.assertNotNull(items);
Assert.assertEquals(1, items.size());
dbInstance.commitAndCloseSession();
// reload and check metadata
QuestionItem item = questionItemDao.loadById(items.get(0).getKey());
Assert.assertEquals("Une information en plus", item.getAdditionalInformations());
Assert.assertEquals("formative", item.getAssessmentType());
Assert.assertEquals("large", item.getCoverage());
Assert.assertEquals(0, new BigDecimal("-0.1").compareTo(item.getDifferentiation()));
Assert.assertEquals(0, new BigDecimal("0.45").compareTo(item.getDifficulty()));
Assert.assertEquals("OpenOLAT", item.getEditor());
Assert.assertEquals("9.4", item.getEditorVersion());
QEducationalContext level = item.getEducationalContext();
Assert.assertNotNull(level);
Assert.assertEquals("University", level.getLevel());
Assert.assertEquals("P5DT4H3M2S", item.getEducationalLearningTime());
Assert.assertEquals("IMS QTI 1.2", item.getFormat());
Assert.assertEquals("6bae65ac-f333-40ba-bdd0-13b54d016d59", item.getMasterIdentifier());
Assert.assertFalse("6bae65ac-f333-40ba-bdd0-13b54d016d59".equals(item.getIdentifier()));
Assert.assertEquals("sc", item.getItemType());
Assert.assertEquals("1.01", item.getItemVersion());
Assert.assertEquals("question export import Pluton", item.getKeywords());
Assert.assertEquals("de", item.getLanguage());
Assert.assertEquals(1, item.getNumOfAnswerAlternatives());
Assert.assertNotNull(item.getQuestionStatus());
Assert.assertEquals("review", item.getQuestionStatus().name());
Assert.assertEquals(0, new BigDecimal("0.56").compareTo(item.getStdevDifficulty()));
Assert.assertEquals("/Physique/Astronomie/Astrophysique/", item.getTaxonomicPath());
Assert.assertEquals("Une question sur Pluton", item.getTitle());
Assert.assertEquals(0, item.getUsage());
}
Aggregations