Skip to content

Commit

Permalink
Merge pull request #94 from oat-sa/release_3.10.0
Browse files Browse the repository at this point in the history
Release 3.10.0
  • Loading branch information
ionutpad authored Jul 27, 2018
2 parents 5a13dd7 + 765ba34 commit 75798bb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 36 deletions.
25 changes: 0 additions & 25 deletions actions/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,4 @@ protected function getValidators()
GenerisRdf::PROPERTY_USER_LOGIN => [tao_helpers_form_FormFactory::getValidator('Unique')],
];
}

/**
* @param core_kernel_classes_Resource $resource
* @return array
* @throws \core_kernel_persistence_Exception
* @throws \common_ext_ExtensionException
*/
protected function getProperties($resource)
{
/** @var \common_ext_ExtensionsManager $extManager */
$extManager = $this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID);
$taoTestTaker = $extManager->getExtensionById('taoTestTaker');
$config = $taoTestTaker->getConfig('csvImporterCallbacks');

if ((bool)$config['use_properties_for_event']) {
return [
'hashForKey' => UserHashForEncryption::hash(TestTakerSavePasswordInMemory::getPassword()),
GenerisRdf::PROPERTY_USER_PASSWORD => $resource->getOnePropertyValue(
new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD)
)->literal
];
}

return [];
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
}
},
"require" : {
"oat-sa/oatbox-extension-installer" : "dev-master"
"oat-sa/oatbox-extension-installer" : "~1.1||dev-master"
}
}
3 changes: 1 addition & 2 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'label' => 'Test-taker core extension',
'description' => 'TAO TestTaker extension',
'license' => 'GPL-2.0',
'version' => '3.9.0',
'version' => '3.10.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(
'tao' => '>=19.11.0',
Expand All @@ -50,7 +50,6 @@
\oat\taoTestTaker\scripts\install\SetupConfig::class,
\oat\taoTestTaker\scripts\install\SetupTesttakerCsvImporter::class,
]

),
'update' => "oat\\taoTestTaker\\scripts\\update\\Updater",
'managementRole' => 'http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole',
Expand Down
63 changes: 56 additions & 7 deletions models/CsvImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
*
*/
namespace oat\taoTestTaker\models;
use common_Logger;
use common_report_Report;
use core_kernel_classes_Resource;
use oat\generis\Helper\UserHashForEncryption;
use oat\oatbox\service\ServiceManager;
use oat\tao\model\TaoOntology;
use oat\generis\model\GenerisRdf;
use oat\taoTestTaker\models\events\TestTakerImportedEvent;

/**
* A custom subject CSV importer
Expand All @@ -33,19 +38,63 @@
*/
class CsvImporter extends \tao_models_classes_import_CsvImporter
{
public function import($class, $form)
{
$report = parent::import($class, $form);

/** @var common_report_Report $success */
foreach ($report->getSuccesses() as $success) {
$resource = $success->getData();
try {
$this->getEventManager()->trigger(
new TestTakerImportedEvent($resource->getUri(), $this->getProperties($resource))
);
} catch (\Exception $e) {
common_Logger::e($e->getMessage());
}
}

return $report;
}

/**
* @param core_kernel_classes_Resource $resource
* @return array
* @throws \core_kernel_persistence_Exception
* @throws \common_ext_ExtensionException
*/
protected function getProperties($resource)
{
/** @var \common_ext_ExtensionsManager $extManager */
$extManager = ServiceManager::getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID);
$taoTestTaker = $extManager->getExtensionById('taoTestTaker');
$config = $taoTestTaker->getConfig('csvImporterCallbacks');

if ((bool)$config['use_properties_for_event']) {
return [
'hashForKey' => UserHashForEncryption::hash(TestTakerSavePasswordInMemory::getPassword()),
GenerisRdf::PROPERTY_USER_PASSWORD => $resource->getOnePropertyValue(
new \core_kernel_classes_Property(GenerisRdf::PROPERTY_USER_PASSWORD)
)->literal
];
}

return [];
}

/**
* (non-PHPdoc)
* @see tao_models_classes_import_CsvImporter::getExludedProperties()
*/
protected function getExludedProperties()
{
return array_merge(parent::getExludedProperties(), array(
GenerisRdf::PROPERTY_USER_DEFLG,
GenerisRdf::PROPERTY_USER_ROLES,
TaoOntology::PROPERTY_USER_LAST_EXTENSION,
TaoOntology::PROPERTY_USER_FIRST_TIME,
GenerisRdf::PROPERTY_USER_TIMEZONE
));
return array_merge(parent::getExludedProperties(), array(
GenerisRdf::PROPERTY_USER_DEFLG,
GenerisRdf::PROPERTY_USER_ROLES,
TaoOntology::PROPERTY_USER_LAST_EXTENSION,
TaoOntology::PROPERTY_USER_FIRST_TIME,
GenerisRdf::PROPERTY_USER_TIMEZONE
));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ public function update($initialVersion)

$this->setVersion('3.7.0');
}
$this->skip('3.7.0', '3.9.0');
$this->skip('3.7.0', '3.10.0');
}
}

0 comments on commit 75798bb

Please sign in to comment.