Skip to content

Commit

Permalink
Merge pull request #85 from oat-sa/release-3.6.0
Browse files Browse the repository at this point in the history
Release 3.6.0
  • Loading branch information
antoinerobin authored Mar 23, 2018
2 parents 3dc586a + 7998be9 commit 3fe5ac6
Show file tree
Hide file tree
Showing 15 changed files with 698 additions and 14 deletions.
30 changes: 29 additions & 1 deletion actions/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@

use common_report_Report;
use core_kernel_classes_Resource;
use oat\generis\Helper\UserHashForEncryption;
use oat\generis\model\GenerisRdf;
use oat\taoTestTaker\models\CsvImporter;
use oat\taoTestTaker\models\events\TestTakerImportedEvent;
use oat\taoTestTaker\models\TestTakerSavePasswordInMemory;
use tao_helpers_form_FormFactory;

/**
Expand Down Expand Up @@ -66,15 +68,41 @@ protected function getValidators(){

/**
* @param common_report_Report $report
* @throws \core_kernel_persistence_Exception
*/
protected function onAfterImport(common_report_Report $report)
{
/** @var common_report_Report $success */
foreach ($report->getSuccesses() as $success) {
$resource = $success->getData();
if ($resource instanceof core_kernel_classes_Resource) {
$this->getEventManager()->trigger(new TestTakerImportedEvent($resource->getUri()));
$this->getEventManager()->trigger(new TestTakerImportedEvent($resource->getUri(), $this->getProperties($resource)));
}
}
}

/**
* @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 [];
}
}
12 changes: 11 additions & 1 deletion actions/TestTaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace oat\taoTestTaker\actions;

use core_kernel_classes_Class;
use oat\generis\Helper\UserHashForEncryption;
use oat\generis\model\GenerisRdf;
use oat\oatbox\event\EventManagerAwareTrait;
use oat\tao\model\resources\ResourceWatcher;
Expand Down Expand Up @@ -112,11 +113,13 @@ public function editSubject()
$values = $myForm->getValues();

if ($addMode) {
$plainPassword = $values['password1'];
$values[GenerisRdf::PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($values['password1']);
unset($values['password1']);
unset($values['password2']);
} else {
if (! empty($values['password2'])) {
$plainPassword = $values['password2'];
$values[GenerisRdf::PROPERTY_USER_PASSWORD] = \core_kernel_users_Service::getPasswordHash()->encrypt($values['password2']);
}
unset($values['password2']);
Expand All @@ -126,7 +129,14 @@ public function editSubject()
$binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($subject);
$subject = $binder->bind($values);

$this->getEventManager()->trigger(new TestTakerUpdatedEvent($subject->getUri(), $values));
$data = [];
if (isset($plainPassword)){
$data = ['hashForKey' => UserHashForEncryption::hash($plainPassword)];
}

$this->getEventManager()->trigger(new TestTakerUpdatedEvent($subject->getUri(),
array_merge($values, $data)
));

if ($addMode) {
// force default subject roles to be the Delivery Role:
Expand Down
13 changes: 13 additions & 0 deletions config/default/csvImporterCallbacks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use oat\generis\model\GenerisRdf;

return new oat\oatbox\config\ConfigurationService(array(
'config' => array(
'callbacks' => array(
'*' => array('trim'),
GenerisRdf::PROPERTY_USER_PASSWORD => array('oat\taoTestTaker\models\CsvImporter::taoSubjectsPasswordEncode')
),
'use_properties_for_event' => false
)
));
324 changes: 324 additions & 0 deletions locales/fr-CA/messages.lang.php

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions locales/fr-CA/messages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
msgid ""
msgstr ""
"Project-Id-Version: TAO 3.3.0-sprint72-½\n"
"PO-Revision-Date: 2018-03-21T13:56:57\n"
"Last-Translator: TAO Translation Team <[email protected]>\n"
"MIME-Version: 1.0\n"
"Language: fr-CA\n"
"sourceLanguage: en-US\n"
"targetLanguage: fr-CA\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Basepath: ../../\n"
"X-Poedit-KeywordsList: __\n"
"X-Poedit-SearchPath-0: .\n"

#, tao-public
msgid "Delete"
msgstr "Supprimer"

msgid "Edit subject"
msgstr "Modifier le participant"

#, tao-public
msgid "Export"
msgstr "Exporter"

#, tao-public
msgid "Import"
msgstr "Importer"

msgid "Last updated on %2s"
msgstr ""

#, tao-public
msgid "Manage Schema"
msgstr ""

#, tao-public
msgid "Manage test takers"
msgstr "Gestion des participants"

#, tao-public
msgid "Move"
msgstr "Déplacer"

#, tao-public
msgid "New class"
msgstr "Nouvelle classe"

#, tao-public
msgid "New test-taker"
msgstr "Créer participant"

#, tao-public
msgid "Properties"
msgstr "Propriétés"

#, tao-public
msgid "Record and manage test takers."
msgstr "Enregistrer et gérer les participants."

msgid "Test taker saved"
msgstr "Participant enregistré"

msgid "Test takers"
msgstr "Participants"

#, tao-public
msgid "Test takers library"
msgstr "Participants"

msgid "Test takers may be assigned to sets according to the relevant assessment context (Human resources management, education, edumetric monitoring, etc.)."
msgstr "Les participants peuvent être assignés à des ensembles selon le contexte d’évaluation (gestion des ressources humaines, éducation, contrôle d'édumétrie, etc.)."

#, tao-public
msgid "Test-takers"
msgstr "Participants"

msgid "The Test takers module allows to record and manage test takers."
msgstr "Le module <i>Participants</i> vous permet d'ajouter et de gérer les sujets des tests."

1 change: 1 addition & 0 deletions locales/fr-CA/messages_po.js

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions locales/fr-CA/taosubject.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
@sourceLanguage en-US
@targetLanguage fr-CA
-->
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://www.tao.lu/Ontologies/TAOSubject.rdf#">
<rdf:Description rdf:about="http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject">
<!--
@sourceLanguage en-US
@targetLanguage fr-CA
@source Test-taker
@subject http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject
@predicate http://www.w3.org/2000/01/rdf-schema#label
-->
<rdfs:label xml:lang="fr-CA"><![CDATA[Participant]]></rdfs:label>
<!--
@sourceLanguage en-US
@targetLanguage fr-CA
@source The Test-taker class
@subject http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject
@predicate http://www.w3.org/2000/01/rdf-schema#comment
-->
<rdfs:comment xml:lang="fr-CA"><![CDATA[La classe des participants]]></rdfs:comment>
</rdf:Description>
<rdf:Description rdf:about="http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole">
<!--
@sourceLanguage en-US
@targetLanguage fr-CA
@source Test Takers Manager
@subject http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole
@predicate http://www.w3.org/2000/01/rdf-schema#label
-->
<rdfs:label xml:lang="fr-CA"><![CDATA[Gestionnaire Participants]]></rdfs:label>
<!--
@sourceLanguage en-US
@targetLanguage fr-CA
@source The Test Takers Manager Role
@subject http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole
@predicate http://www.w3.org/2000/01/rdf-schema#comment
-->
<rdfs:comment xml:lang="fr-CA"><![CDATA[Le rôle Gestionnaire Participants]]></rdfs:comment>
</rdf:Description>
</rdf:RDF>
32 changes: 32 additions & 0 deletions locales/fr-CA/taosubject.rdf.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
msgid ""
msgstr ""
"Project-Id-Version: TAO 3.3.0-sprint72-½\n"
"PO-Revision-Date: 2018-03-21T13:56:57\n"
"Last-Translator: TAO Translation Team <[email protected]>\n"
"MIME-Version: 1.0\n"
"Language: fr-CA\n"
"sourceLanguage: en-US\n"
"targetLanguage: fr-CA\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"

# http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject
msgctxt "http://www.w3.org/2000/01/rdf-schema#label"
msgid "Test-taker"
msgstr "Participants"

# http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject
msgctxt "http://www.w3.org/2000/01/rdf-schema#comment"
msgid "The Test-taker class"
msgstr "le groupe de participants"

# http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole
msgctxt "http://www.w3.org/2000/01/rdf-schema#label"
msgid "Test Takers Manager"
msgstr ""

# http://www.tao.lu/Ontologies/TAOSubject.rdf#SubjectsManagerRole
msgctxt "http://www.w3.org/2000/01/rdf-schema#comment"
msgid "The Test Takers Manager Role"
msgstr ""

8 changes: 6 additions & 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.4.0',
'version' => '3.6.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(
'taoBackOffice' => '>=1.3.0'
Expand All @@ -44,7 +44,11 @@
'install' => array(
'rdf' => array(
dirname(__FILE__). '/models/ontology/taosubject.rdf'
)
),
'php' => [
\oat\taoTestTaker\scripts\install\SetupConfig::class,
]

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

Expand Down Expand Up @@ -58,22 +59,34 @@ protected function getStaticData()
return array(
GenerisRdf::PROPERTY_USER_DEFLG => $lang,
GenerisRdf::PROPERTY_USER_TIMEZONE => TIME_ZONE,
GenerisRdf::PROPERTY_USER_ROLES => TaoOntology::PROPERTY_INSTANCE_ROLE_DELIVERY
GenerisRdf::PROPERTY_USER_ROLES => TaoOntology::PROPERTY_INSTANCE_ROLE_DELIVERY,
);
}

/**
* (non-PHPdoc)
* @see tao_models_classes_import_CsvImporter::getAdditionAdapterOptions()
* @throws \common_ext_ExtensionException
*/
protected function getAdditionAdapterOptions()
{
$returnValue = array(
'callbacks' => array(
'*' => array('trim'),
GenerisRdf::PROPERTY_USER_PASSWORD => array('oat\taoTestTaker\models\CsvImporter::taoSubjectsPasswordEncode')
)
);
/** @var \common_ext_ExtensionsManager $extManager */
$extManager = ServiceManager::getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID);
$taoTestTaker = $extManager->getExtensionById('taoTestTaker');
$config = $taoTestTaker->getConfig('csvImporterCallbacks');

if (empty($config['callbacks'])){
$returnValue = array(
'callbacks' => array(
'*' => array('trim'),
GenerisRdf::PROPERTY_USER_PASSWORD => array('oat\taoTestTaker\models\CsvImporter::taoSubjectsPasswordEncode')
)
);
} else {
$returnValue = array(
'callbacks' => $config['callbacks']
);
}

return $returnValue;
}
Expand Down
52 changes: 52 additions & 0 deletions models/TestTakerSavePasswordInMemory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2018 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/
namespace oat\taoTestTaker\models;

class TestTakerSavePasswordInMemory
{
/** @var array */
protected static $passwords = [];

/** @var int */
protected static $index = 0;

/**
* @return mixed
*/
public static function getPassword()
{
$value = static::$passwords[static::$index];
static::$index++;

return $value;
}

/**
* @param $value
* @return mixed
*/
public static function saveUserPassword($value)
{
static::$passwords[] = $value;

return $value;
}
}
Loading

0 comments on commit 3fe5ac6

Please sign in to comment.