use of org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos in project OpenOLAT by OpenOLAT.
the class QTIImportProcessorTest method testImport_OpenOLATTest_extractItems.
/**
* This test check every methods of the import process in details
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void testImport_OpenOLATTest_extractItems() throws IOException, URISyntaxException {
URL testUrl = QTIImportProcessorTest.class.getResource("oo_test_qti.xml");
Assert.assertNotNull(testUrl);
File testFile = new File(testUrl.toURI());
// get the document informations
QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, testFile.getName(), testFile);
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("oo_test_qti.xml", docInfos.getFilename());
// get the question DOM's
List<ItemInfos> itemElements = proc.getItemList(docInfos);
Assert.assertNotNull(itemElements);
Assert.assertEquals(4, itemElements.size());
}
use of org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos in project openolat by klemens.
the class QTIImportProcessorTest method testImport_OpenOLATTest_extractItems.
/**
* This test check every methods of the import process in details
* @throws IOException
* @throws URISyntaxException
*/
@Test
public void testImport_OpenOLATTest_extractItems() throws IOException, URISyntaxException {
URL testUrl = QTIImportProcessorTest.class.getResource("oo_test_qti.xml");
Assert.assertNotNull(testUrl);
File testFile = new File(testUrl.toURI());
// get the document informations
QTIImportProcessor proc = new QTIImportProcessor(owner, Locale.ENGLISH, testFile.getName(), testFile);
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("oo_test_qti.xml", docInfos.getFilename());
// get the question DOM's
List<ItemInfos> itemElements = proc.getItemList(docInfos);
Assert.assertNotNull(itemElements);
Assert.assertEquals(4, itemElements.size());
}
use of org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos in project openolat by klemens.
the class QTIImportProcessorTest method testImport_QTI12_film.
@Test
public void testImport_QTI12_film() throws IOException, URISyntaxException {
URL itemUrl = QTIImportProcessorTest.class.getResource("sc_with_film.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);
List<DocInfos> docInfoList = proc.getDocInfos();
Assert.assertNotNull(docInfoList);
Assert.assertEquals(1, docInfoList.size());
DocInfos docInfos = docInfoList.get(0);
List<ItemInfos> itemInfos = proc.getItemList(docInfos);
Assert.assertNotNull(itemInfos);
Assert.assertEquals(1, itemInfos.size());
Element el = itemInfos.get(0).getItemEl();
List<String> materials = proc.getMaterials(el);
Assert.assertNotNull(materials);
Assert.assertEquals(1, materials.size());
Assert.assertEquals("media/filmH264.mp4", materials.get(0));
}
use of org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos in project OpenOLAT by OpenOLAT.
the class QTIImportProcessorTest method testImport_QTI12_film.
@Test
public void testImport_QTI12_film() throws IOException, URISyntaxException {
URL itemUrl = QTIImportProcessorTest.class.getResource("sc_with_film.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);
List<DocInfos> docInfoList = proc.getDocInfos();
Assert.assertNotNull(docInfoList);
Assert.assertEquals(1, docInfoList.size());
DocInfos docInfos = docInfoList.get(0);
List<ItemInfos> itemInfos = proc.getItemList(docInfos);
Assert.assertNotNull(itemInfos);
Assert.assertEquals(1, itemInfos.size());
Element el = itemInfos.get(0).getItemEl();
List<String> materials = proc.getMaterials(el);
Assert.assertNotNull(materials);
Assert.assertEquals(1, materials.size());
Assert.assertEquals("media/filmH264.mp4", materials.get(0));
}
Aggregations