From 7eeb6efdfc6336d047565c86d4c5736380a110b3 Mon Sep 17 00:00:00 2001 From: Christophe GARCIA Date: Wed, 7 Jun 2017 16:41:13 +0200 Subject: [PATCH 1/5] remove tests subdirectory --- manifest.php | 2 +- models/classes/export/class.QtiTestExporter.php | 13 +++++++------ scripts/update/Updater.php | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest.php b/manifest.php index d7b822fdfc..fd84856c67 100755 --- a/manifest.php +++ b/manifest.php @@ -28,7 +28,7 @@ 'label' => 'QTI test model', 'description' => 'TAO QTI test implementation', 'license' => 'GPL-2.0', - 'version' => '9.10.2', + 'version' => '9.10.3', 'author' => 'Open Assessment Technologies', 'requires' => array( 'taoTests' => '>=6.2.0', diff --git a/models/classes/export/class.QtiTestExporter.php b/models/classes/export/class.QtiTestExporter.php index 91e5db1213..b9a0e2a5a2 100644 --- a/models/classes/export/class.QtiTestExporter.php +++ b/models/classes/export/class.QtiTestExporter.php @@ -230,7 +230,7 @@ protected function exportItems() } // Modify the reference to the item in the test definition. - $newQtiItemXmlPath = $extraReversePath . '../../items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; + $newQtiItemXmlPath = $extraReversePath . 'items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; $itemRef = $this->getTestDocument()->getDocumentComponent()->getComponentByIdentifier($refIdentifier); $itemRef->setHref($newQtiItemXmlPath); @@ -260,10 +260,8 @@ protected function exportTest(array $itemIdentifiers) $newTestDir = 'tests/' . tao_helpers_Uri::getUniqueId($this->getItem()->getUri()).'/'; $testRootDir = $this->getTestService()->getQtiTestDir($this->getItem()); - $file = $this->getTestService()->getQtiTestFile($this->getItem()); - // revert backslashes introduced by dirname on windows - $relPath = trim(str_replace('\\', '/',dirname($testRootDir->getRelPath($file))), '/'); - $testHref = $newTestDir . (empty($relPath) ? '' : $relPath.'/') . 'test.xml'; + + $testHref = $newTestDir . 'test.xml'; common_Logger::t('TEST DEFINITION AT: ' . $testHref); $this->getZip()->addFromString($testHref, $testXmlDocument); @@ -271,12 +269,15 @@ protected function exportTest(array $itemIdentifiers) $iterator = $testRootDir->getFlyIterator(Directory::ITERATOR_RECURSIVE|Directory::ITERATOR_FILE); $indexFile = pathinfo(taoQtiTest_models_classes_QtiTestService::QTI_TEST_DEFINITION_INDEX , PATHINFO_BASENAME); + /** + * @var oat\oatbox\filesystem\File $f + */ foreach ($iterator as $f) { // Only add dependency files... if ($f->getBasename() !== taoQtiTest_models_classes_QtiTestService::TAOQTITEST_FILENAME && $f->getBasename() !== $indexFile) { // Add the file to the archive. - $fileHref = $newTestDir . ltrim($testRootDir->getRelPath($f), '/'); + $fileHref = $newTestDir . ltrim($f->getBasename(), '/'); common_Logger::t('AUXILIARY FILE AT: ' . $fileHref); $this->getZip()->addFromString($fileHref, $f->read()); $this->referenceAuxiliaryFile($fileHref); diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index 464cb25c0f..a4b2fb1335 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -1254,6 +1254,6 @@ public function update($initialVersion) { $this->setVersion('9.10.0'); } - $this->skip('9.10.0', '9.10.2'); + $this->skip('9.10.0', '9.10.3'); } } From de707f13a29a1ecc590808279c666575b7060cc4 Mon Sep 17 00:00:00 2001 From: Christophe GARCIA Date: Mon, 12 Jun 2017 16:32:55 +0200 Subject: [PATCH 2/5] revert item path reduction --- models/classes/export/class.QtiTestExporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/classes/export/class.QtiTestExporter.php b/models/classes/export/class.QtiTestExporter.php index b9a0e2a5a2..9400ad0f37 100644 --- a/models/classes/export/class.QtiTestExporter.php +++ b/models/classes/export/class.QtiTestExporter.php @@ -230,7 +230,7 @@ protected function exportItems() } // Modify the reference to the item in the test definition. - $newQtiItemXmlPath = $extraReversePath . 'items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; + $newQtiItemXmlPath = $extraReversePath . '../../items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; $itemRef = $this->getTestDocument()->getDocumentComponent()->getComponentByIdentifier($refIdentifier); $itemRef->setHref($newQtiItemXmlPath); From 2915587ac899a54c2635bc6c46e1695a84b9948e Mon Sep 17 00:00:00 2001 From: Christophe GARCIA Date: Mon, 12 Jun 2017 17:58:03 +0200 Subject: [PATCH 3/5] fix first export path --- models/classes/export/class.QtiTestExporter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/models/classes/export/class.QtiTestExporter.php b/models/classes/export/class.QtiTestExporter.php index 9400ad0f37..8b91634798 100644 --- a/models/classes/export/class.QtiTestExporter.php +++ b/models/classes/export/class.QtiTestExporter.php @@ -209,7 +209,7 @@ protected function exportItems() $file = $this->getTestService()->getQtiTestFile($this->getItem()); $extraPath = str_replace('\\', '/', dirname($rootDir->getRelPath($file))); $extraPath = trim($extraPath, '/'); - + \common_Logger::w($extraPath . ' ' . $rootDir->getRelPath($file)); $extraReversePath = ''; if (empty($extraPath) === false) { $n = count(explode('/', $extraPath)); @@ -220,6 +220,9 @@ protected function exportItems() } $extraReversePath = implode('/', $parts) . '/'; + \common_Logger::w($n . ' ' . $extraReversePath); + } else { + $extraReversePath = '../../'; } foreach ($this->getItems() as $refIdentifier => $item) { @@ -230,7 +233,7 @@ protected function exportItems() } // Modify the reference to the item in the test definition. - $newQtiItemXmlPath = $extraReversePath . '../../items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; + $newQtiItemXmlPath = $extraReversePath . 'items/' . tao_helpers_Uri::getUniqueId($item->getUri()) . '/qti.xml'; $itemRef = $this->getTestDocument()->getDocumentComponent()->getComponentByIdentifier($refIdentifier); $itemRef->setHref($newQtiItemXmlPath); From ec623ffe349ea90fce34986dc8640760de5c9b9c Mon Sep 17 00:00:00 2001 From: Christophe GARCIA Date: Mon, 12 Jun 2017 17:59:40 +0200 Subject: [PATCH 4/5] remove debug --- models/classes/export/class.QtiTestExporter.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/models/classes/export/class.QtiTestExporter.php b/models/classes/export/class.QtiTestExporter.php index 8b91634798..12f7e39442 100644 --- a/models/classes/export/class.QtiTestExporter.php +++ b/models/classes/export/class.QtiTestExporter.php @@ -209,8 +209,7 @@ protected function exportItems() $file = $this->getTestService()->getQtiTestFile($this->getItem()); $extraPath = str_replace('\\', '/', dirname($rootDir->getRelPath($file))); $extraPath = trim($extraPath, '/'); - \common_Logger::w($extraPath . ' ' . $rootDir->getRelPath($file)); - $extraReversePath = ''; + $extraReversePath = '../../'; if (empty($extraPath) === false) { $n = count(explode('/', $extraPath)); $parts = array(); @@ -220,9 +219,6 @@ protected function exportItems() } $extraReversePath = implode('/', $parts) . '/'; - \common_Logger::w($n . ' ' . $extraReversePath); - } else { - $extraReversePath = '../../'; } foreach ($this->getItems() as $refIdentifier => $item) { From f1eaab4343d5eba18221b8b68259e3ce86b55aef Mon Sep 17 00:00:00 2001 From: Christophe GARCIA Date: Mon, 19 Jun 2017 14:51:58 +0200 Subject: [PATCH 5/5] fix tests elements subdirectory --- models/classes/export/class.QtiTestExporter.php | 9 ++++++++- scripts/update/Updater.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/models/classes/export/class.QtiTestExporter.php b/models/classes/export/class.QtiTestExporter.php index 12f7e39442..a280ffa989 100644 --- a/models/classes/export/class.QtiTestExporter.php +++ b/models/classes/export/class.QtiTestExporter.php @@ -271,12 +271,19 @@ protected function exportTest(array $itemIdentifiers) /** * @var oat\oatbox\filesystem\File $f */ + $file = $this->getTestService()->getQtiTestFile($this->getItem()); + // revert backslashes introduced by dirname on windows + $relPath = trim(str_replace('\\', '/',dirname($testRootDir->getRelPath($file))), '/'); + $basePath = $testRootDir->getPrefix(); + foreach ($iterator as $f) { + // Only add dependency files... if ($f->getBasename() !== taoQtiTest_models_classes_QtiTestService::TAOQTITEST_FILENAME && $f->getBasename() !== $indexFile) { + $data = $f->getMetadata(); // Add the file to the archive. - $fileHref = $newTestDir . ltrim($f->getBasename(), '/'); + $fileHref = $newTestDir . ltrim(str_replace($basePath , '' , $data['path']), '/'); common_Logger::t('AUXILIARY FILE AT: ' . $fileHref); $this->getZip()->addFromString($fileHref, $f->read()); $this->referenceAuxiliaryFile($fileHref); diff --git a/scripts/update/Updater.php b/scripts/update/Updater.php index 4a0b15d469..479b5fd1d5 100644 --- a/scripts/update/Updater.php +++ b/scripts/update/Updater.php @@ -1270,6 +1270,6 @@ public function update($initialVersion) { $this->setVersion('9.12.0'); } - $this->skip('9.12.0', '9.14.1'); + $this->skip('9.12.0', '9.14.2'); } }