use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class QuestionPoolUserDataDeletable method deleteUserData.
@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
if (!qpoolModule.isDeleteQuestionsWithoutAuthor())
return;
List<QuestionItem> itemsWithOneAuthor = questionItemDao.getItemsWithOneAuthor(identity);
qpoolService.deleteItems(itemsWithOneAuthor);
for (QuestionItem item : itemsWithOneAuthor) {
QuestionItemAuditLogBuilder builder = qpoolService.createAuditLogBuilder(null, Action.DELETE_QUESTION_ITEM);
builder.withBefore(item);
builder.withMessage("Author deleted");
qpoolService.persist(builder.create());
}
String logMessage = getLogMessage(identity, itemsWithOneAuthor);
log.info(logMessage);
}
use of org.olat.modules.qpool.QuestionItem 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.QuestionItem in project OpenOLAT by OpenOLAT.
the class QTIImportProcessorTest method testImport_QTI12_multipleItems.
@Test
public void testImport_QTI12_multipleItems() throws IOException, URISyntaxException {
URL itemsUrl = QTIImportProcessorTest.class.getResource("multiple_items.zip");
Assert.assertNotNull(itemsUrl);
File itemFile = new File(itemsUrl.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(2, items.size());
dbInstance.commitAndCloseSession();
// check the files
for (QuestionItem item : items) {
QuestionItemFull itemFull = (QuestionItemFull) item;
String dir = itemFull.getDirectory();
String file = itemFull.getRootFilename();
VFSContainer itemContainer = qpoolFileStorage.getContainer(dir);
Assert.assertNotNull(itemContainer);
VFSItem itemLeaf = itemContainer.resolve(file);
Assert.assertNotNull(itemLeaf);
Assert.assertTrue(itemLeaf instanceof VFSLeaf);
// try to parse it
InputStream is = ((VFSLeaf) itemLeaf).getInputStream();
XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
Document doc = xmlParser.parse(is, false);
Node itemNode = doc.selectSingleNode("questestinterop/item");
Assert.assertNotNull(itemNode);
// check the attachments
if ("Export (blue)".equals(itemFull.getTitle())) {
Assert.assertTrue(exists(itemFull, "media/blue.png"));
Assert.assertFalse(exists(itemFull, "media/purple.png"));
} else if ("Export (purple)".equals(itemFull.getTitle())) {
Assert.assertFalse(exists(itemFull, "media/blue.png"));
Assert.assertTrue(exists(itemFull, "media/purple.png"));
} else {
Assert.fail();
}
}
}
use of org.olat.modules.qpool.QuestionItem 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());
}
use of org.olat.modules.qpool.QuestionItem in project OpenOLAT by OpenOLAT.
the class CollectionDAOTest method addItemToCollectionById.
@Test
public void addItemToCollectionById() {
QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("Coll-Onwer-2-" + UUID.randomUUID().toString());
QuestionItemCollection coll = collectionDao.createCollection("NGC collection 2", id);
QuestionItem item = questionDao.createAndPersist(null, "NGC 89", QTIConstants.QTI_12_FORMAT, Locale.GERMAN.getLanguage(), null, null, null, fibType);
dbInstance.commitAndCloseSession();
// add the item to the collection
collectionDao.addItemToCollection(item, singletonList(coll));
// check if it's alright
dbInstance.commit();
}
Aggregations