Search in sources :

Example 1 with ItemInfos

use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos 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());
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) DocInfos(org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) ItemInfos(org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 2 with ItemInfos

use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos 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());
}
Also used : DocInfos(org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos) ItemInfos(org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 3 with ItemInfos

use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos 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());
}
Also used : DocInfos(org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos) ItemInfos(org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 4 with ItemInfos

use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos 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));
}
Also used : DocInfos(org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos) Element(org.dom4j.Element) ItemInfos(org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem) URL(java.net.URL) Test(org.junit.Test)

Example 5 with ItemInfos

use of org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos 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));
}
Also used : DocInfos(org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos) Element(org.dom4j.Element) ItemInfos(org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem) URL(java.net.URL) Test(org.junit.Test)

Aggregations

File (java.io.File)6 URL (java.net.URL)6 Test (org.junit.Test)6 DocInfos (org.olat.ims.qti.qpool.QTIImportProcessor.DocInfos)6 ItemInfos (org.olat.ims.qti.qpool.QTIImportProcessor.ItemInfos)6 Element (org.dom4j.Element)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 QuestionItem (org.olat.modules.qpool.QuestionItem)2 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)2 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)2