use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos in project openolat by klemens.
the class QTIImportProcessorTest method testImport_SC.
/**
* This test check every methods of the import process in details
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void testImport_SC() throws IOException, URISyntaxException {
URL itemUrl = QTIImportProcessorTest.class.getResource("mchc_i_002.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<DocInfos> docInfoList = proc.getDocInfos();
Assert.assertNotNull(docInfoList);
Assert.assertEquals(1, docInfoList.size());
DocInfos docInfos = docInfoList.get(0);
Assert.assertNotNull(docInfos);
Assert.assertNotNull(docInfos.getFilename());
Assert.assertNotNull(docInfos.getDocument());
Assert.assertEquals("mchc_i_002.xml", docInfos.getFilename());
// get the question DOM's
List<ItemInfos> itemInfos = proc.getItemList(docInfos);
Assert.assertNotNull(itemInfos);
Assert.assertEquals(1, itemInfos.size());
// process item, files...
QuestionItemImpl item = proc.processItem(docInfos, itemInfos.get(0), null);
Assert.assertNotNull(item);
dbInstance.commitAndCloseSession();
proc.processFiles(item, itemInfos.get(0), null);
// reload and check what is saved
QuestionItemFull reloadItem = questionItemDao.loadById(item.getKey());
Assert.assertNotNull(reloadItem);
Assert.assertNotNull(reloadItem.getCreationDate());
Assert.assertNotNull(reloadItem.getLastModified());
Assert.assertEquals(QuestionStatus.draft, reloadItem.getQuestionStatus());
Assert.assertEquals(QTIConstants.QTI_12_FORMAT, reloadItem.getFormat());
// title
Assert.assertEquals("Standard Multiple Choice with Images Item", reloadItem.getTitle());
// description -> qticomment
Assert.assertEquals("This is a multiple-choice example with image content. The rendering is a standard radio button style. No response processing is incorporated.", reloadItem.getDescription());
// question type
Assert.assertNotNull(reloadItem.getType());
Assert.assertEquals(QuestionType.SC.name().toLowerCase(), reloadItem.getType().getType());
// check that the file is storead
VFSContainer itemDir = qpoolFileStorage.getContainer(reloadItem.getDirectory());
Assert.assertNotNull(itemDir);
VFSItem qtiLeaf = itemDir.resolve(reloadItem.getRootFilename());
Assert.assertNotNull(qtiLeaf);
Assert.assertTrue(qtiLeaf instanceof VFSLeaf);
Assert.assertTrue(qtiLeaf.exists());
Assert.assertEquals(itemFile.length(), ((VFSLeaf) qtiLeaf).getSize());
}
Aggregations