Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.6.1 #8

Merged
merged 51 commits into from
Dec 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ee5c52f
blueprint's editor : distributor component
krampstudio Nov 25, 2016
c43eb7d
test and doc the distributor component
krampstudio Nov 28, 2016
ef002af
add a property selector component
krampstudio Dec 1, 2016
aaf01c1
update the distributor
krampstudio Dec 1, 2016
1f2272f
create an editor component
krampstudio Dec 1, 2016
9cafddf
editor provider structure
krampstudio Dec 1, 2016
3a1b214
Merge branch 'develop' into feature/TAO-3416_blueprint-component
krampstudio Dec 1, 2016
216d0a2
update version number and RDF
Dec 1, 2016
8b3966d
add a way to get blueprint from identifier and from section and test
Dec 1, 2016
c7c4c7e
Integrate the editor to the blueprint
krampstudio Dec 1, 2016
ca78bc7
distributor no and empty values
krampstudio Dec 2, 2016
7841fae
Add save content feature
siwane Dec 2, 2016
ce67541
Bump to version 0.3.0
siwane Dec 2, 2016
24817a0
Remove controller method
siwane Dec 2, 2016
a4edb75
improve component unit tests
krampstudio Dec 2, 2016
630693a
blueprint icon
krampstudio Dec 2, 2016
fba12fc
Translated message
siwane Dec 2, 2016
4060698
Change selection value to int & allow value as zero or more
siwane Dec 2, 2016
13cd7d6
modify rdf representation
Dec 2, 2016
e052555
transfert test section link related method a specific service
Dec 2, 2016
79d3719
exclude model and content properties
krampstudio Dec 2, 2016
7231654
visual improvments
krampstudio Dec 2, 2016
ff8f3d3
use the new service
Dec 2, 2016
86312cd
Merge pull request #3 from oat-sa/feature/allow_save_blueprint_content
Dec 2, 2016
619c0af
make test section link service configurable
Dec 2, 2016
8c80629
use the test section link service
Dec 2, 2016
99f461f
Merge branch 'develop' into feature/TAO-3402-blueprint-association
Dec 2, 2016
b6eb510
correct service id
Dec 2, 2016
6f9c940
modify author tag
Dec 2, 2016
1ad7781
editor component doc and unit test
krampstudio Dec 2, 2016
541ce53
provider test
krampstudio Dec 2, 2016
7af5de0
Merge branch 'develop' into feature/TAO-3416_blueprint-component
krampstudio Dec 2, 2016
cf71757
add install script
Dec 2, 2016
a69e569
fix feedback call and container selector
krampstudio Dec 2, 2016
8bca30a
implement save
krampstudio Dec 2, 2016
87f126b
bundles
krampstudio Dec 2, 2016
4cccb7c
Merge pull request #4 from oat-sa/feature/TAO-3402-blueprint-association
siwane Dec 2, 2016
d477ec2
Add save target property method
siwane Dec 2, 2016
6e0db53
Bump to version 0.5.0
siwane Dec 2, 2016
2947ccd
put to prevent duplicate issue
krampstudio Dec 2, 2016
6d598ab
prevent URI override
krampstudio Dec 2, 2016
c14508b
Merge branch 'feature/saveBlueprintTargetProperty' into develop
krampstudio Dec 2, 2016
8634623
Merge branch 'develop' into feature/TAO-3416_blueprint-component
krampstudio Dec 2, 2016
228c840
better support without properties
krampstudio Dec 2, 2016
b2528c9
bump version
krampstudio Dec 2, 2016
3d4c637
fix typos
krampstudio Dec 2, 2016
7ca2c87
fix tao dep
krampstudio Dec 2, 2016
490d296
Merge pull request #5 from oat-sa/feature/TAO-3416_blueprint-component
jsconan Dec 2, 2016
20e52d4
return an empty results array if no blueprint found
Dec 2, 2016
6b1680a
Merge branch 'fix/no-blueprint' into develop
krampstudio Dec 2, 2016
79897f2
recompile assets
krampstudio Dec 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion controller/Blueprints.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use oat\generis\model\OntologyAwareTrait;
use oat\taoBlueprints\model\Service;
use oat\taoBlueprints\model\TestSectionLinkService;

/**
* Blueprints controller
Expand All @@ -36,13 +37,17 @@ class Blueprints extends \tao_actions_RdfController
{
use OntologyAwareTrait;

/** @var TestSectionLinkService $testSectionLinkService */
private $testSectionLinkService = null;

/**
* Blueprints constructor.
* Set resource service
*/
public function __construct()
{
$this->service = Service::singleton();
$this->testSectionLinkService = $this->getServiceManager()->get(TestSectionLinkService::SERVICE_ID);
$this->getServiceManager()->propagate($this->service);
}

Expand Down Expand Up @@ -115,7 +120,8 @@ public function editInstance()

$this->setData('formTitle', __('Edit Blueprint'));
$this->setData('myForm', $myForm->render());
$this->setView('form.tpl', 'tao');
$this->setData('uri', $instance->getUri());
$this->setView('form_blueprints.tpl', 'taoBlueprints');
}

/**
Expand Down Expand Up @@ -151,4 +157,53 @@ public function editBlueprintClass()
$this->setView('form.tpl', 'tao');
}

/**
* Get all blueprint by identifier
*/
public function getBlueprintsByIdentifier()
{
if (!\tao_helpers_Request::isAjax()) {
throw new \common_exception_IsAjaxAction(__FUNCTION__);
}

if(!$this->hasRequestParameter('identifier')){
throw new \common_exception_MissingParameter('identifier');
}

$blueprints = $this->getClassService()->getBlueprintsByIdentifier($this->getRequestParameter('identifier'));

$returnValue['results'] = [];
foreach($blueprints as $blueprint){
$returnValue['results'][] = ['text' => $blueprint->getLabel(), 'id' => $blueprint->getUri()];
}

$this->returnJson($returnValue);
}

/**
* Get Blueprint for one section in one test
*/
public function getBlueprintsByTestSection()
{
$returnValue = [];
if (!\tao_helpers_Request::isAjax()) {
throw new \common_exception_IsAjaxAction(__FUNCTION__);
}

if(!$this->hasRequestParameter('test')){
throw new \common_exception_MissingParameter('test');
}

if(!$this->hasRequestParameter('section')){
throw new \common_exception_MissingParameter('section');
}

$blueprint = $this->testSectionLinkService->getBlueprintByTestSection($this->getRequestParameter('test'), $this->getRequestParameter('section'));

if(!empty($blueprint)){
$returnValue = ['text' => $blueprint->getLabel(), 'uri' => $blueprint->getUri()];
}
$this->returnJson($returnValue);
}

}
170 changes: 170 additions & 0 deletions controller/Editor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?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) 2016 (original work) Open Assessment Technologies SA;
*
*
*/

namespace oat\taoBlueprints\controller;

use oat\taoBlueprints\model\Service;

/**
* Blueprints manages blueprint's editor
*
* @author Bertrand Chevrier <bertrand@taotesting.com>
* @package taoBlueprints
* @license GPL-2.0
*
*/
class Editor extends \tao_actions_CommonModule
{
protected $blueprintsService;

/**
* Set resource service
*/
public function __construct()
{
$this->blueprintsService = Service::singleton();
$this->getServiceManager()->propagate($this->blueprintsService);
}

/**
* Get blueprint's data
*/
public function get()
{
if($this->hasRequestParameter('uri')) {
$uri = $this->getRequestParameter('uri');

if (! empty($uri)){
$blueprintData = [
'property' => false
];

$property = $this->blueprintsService->getBlueprintTargetProperty($uri);
if(!is_null($property) ){
$blueprintData['property'] = [
'label' => $property->getLabel(),
'uri' => $property->getUri()
];
}
$matrix = $this->blueprintsService->getBlueprintMatrix($uri);
foreach( $matrix as $resourceUri => $value){
$resource = new \core_kernel_classes_Resource($resourceUri);
$blueprintData['selection'][$resourceUri] = [
'label' => $resource->getLabel(),
'value' => $value
];
}
$blueprintData['availableProperties'] = $this->blueprintsService->getNonLiteralItemProperties();

return $this->returnSuccess($blueprintData);
}
}
return $this->returnFailure(__('A blueprint need to be selected first'), 412);
}

/**
* Get a selection from a property URI
*/
public function getSelection()
{
if($this->hasRequestParameter('uri')) {
$uri = $this->getRequestParameter('uri');

if (! empty($uri)){

try {
$matrix = $this->blueprintsService->getTargetPropertyMatrix($uri);
return $this->returnSuccess($matrix);
} catch(\common_exception_NotFound $nfe) {
$this->returnEmpty();
}
}
}
return $this->returnFailure(__('The property is not found or inacurrate'), 412);
}

/**
* Save the blueprint's data
*/
public function save()
{
if($this->hasRequestParameter('uri') && $this->hasRequestParameter('values')) {
$uri = $this->getRequestParameter('uri');
$values = $this->getRequestParameter('values');
if(isset($values['selection']) && isset($values['property'])){

$matrix = [];
foreach($values['selection'] as $propUri => $value){
$matrix[$propUri] = $value['value'];
}

$report = $this->blueprintsService->saveBlueprintTargetPorperty($uri, $values['property']['uri']);
if($report->getType() != \common_report_Report::TYPE_SUCCESS){
return $this->returnFailure($report->getMessage(), 412);
}

$report = $this->blueprintsService->saveBlueprintsMatrix($uri, $matrix);
if($report->getType() != \common_report_Report::TYPE_SUCCESS){
return $this->returnFailure($report->getMessage(), 412);
}
return $this->returnSuccess(true);
}
return $this->returnFailure(__('A blueprint need values'), 412);
}
return $this->returnFailure(__('A blueprint need to be selected first'), 412);
}

/**
* Convenience method to create a formated success response
* @param mixed $data - any serializable data
*/
private function returnSuccess($data){
return $this->returnJson([
'success' => true,
'data' => $data
], 200);
}

/**
* Convenience method to create a formated empty response
*/
private function returnEmpty()
{
return $this->returnJson([
'success' => true,
'data' => null
], 204);
}

/**
* Convenience method to create a formated error response
* @param string $message the error message (for the user)
* @param int $code the error code (for the devs)
*/
protected function returnFailure($message, $code)
{
return $this->returnJson([
'success' => false,
'errorCode' => $code,
'errorMsg' => $message
], $code);
}
}
5 changes: 3 additions & 2 deletions controller/structures.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE structures SYSTEM "../doc/structures.dtd">
<!DOCTYPE structures SYSTEM "../../tao/doc/structures.dtd">
<structures>
<structure id="taoBlueprints_main" name="Blueprints" level="15" group="main">
<description />
<icon id="icon-map-o"/>
<sections>
<section id="taoBlueprints_main" name="Blueprint" url="/taoBlueprints/Blueprints/index">
<trees>
Expand Down Expand Up @@ -40,4 +41,4 @@
</section>
</sections>
</structure>
</structures>
</structures>
43 changes: 43 additions & 0 deletions install/ontology/taotests.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<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.taotesting.com/ontologies/blueprints.rdf#"
xmlns:generis="http://www.tao.lu/Ontologies/generis.rdf#"
>

<rdf:Description rdf:about="http://www.taotesting.com/ontologies/blueprint.rdf#TestSectionLink">
<rdfs:label xml:lang="en-US">Link</rdfs:label>
<rdfs:comment xml:lang="en-US">Link between test, section and blueprint</rdfs:comment>
<rdfs:subClassOf rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#TAOObject"/>
</rdf:Description>

<rdf:Description rdf:about="http://www.taotesting.com/ontologies/blueprint.rdf#AssociatedBlueprint">
<rdf:type>http://www.w3.org/1999/02/22-rdf-syntax-ns#Property</rdf:type>
<rdfs:label xml:lang="en-US">Associated Blueprint</rdfs:label>
<rdfs:comment xml:lang="en-US">Associated Blueprint</rdfs:comment>
<generis:is_language_dependent>http://www.tao.lu/Ontologies/generis.rdf#False</generis:is_language_dependent>
<rdfs:domain>http://www.taotesting.com/ontologies/blueprint.rdf#TestSectionLink</rdfs:domain>
<rdfs:range>http://www.taotesting.com/ontologies/blueprint.rdf#Blueprint</rdfs:range>
</rdf:Description>


<rdf:Description rdf:about="http://www.taotesting.com/ontologies/blueprint.rdf#AssociatedSection">
<rdf:type>http://www.w3.org/1999/02/22-rdf-syntax-ns#Property</rdf:type>
<rdfs:label xml:lang="en-US">Section</rdfs:label>
<rdfs:comment xml:lang="en-US">Section</rdfs:comment>
<generis:Multiple rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#False"/>
<generis:is_language_dependent>http://www.tao.lu/Ontologies/generis.rdf#False</generis:is_language_dependent>
<rdfs:domain>http://www.tao.lu/Ontologies/TAOTest.rdf#TestSectionLink</rdfs:domain>
<rdfs:range>http://www.w3.org/2000/01/rdf-schema#Literal</rdfs:range>
</rdf:Description>

<rdf:Description rdf:about="http://www.taotesting.com/ontologies/blueprint.rdf#AssociatedTest">
<rdf:type>http://www.w3.org/1999/02/22-rdf-syntax-ns#Property</rdf:type>
<rdfs:label xml:lang="en-US">Test</rdfs:label>
<rdfs:comment xml:lang="en-US">Test</rdfs:comment>
<generis:is_language_dependent>http://www.tao.lu/Ontologies/generis.rdf#False</generis:is_language_dependent>
<rdfs:domain>http://www.tao.lu/Ontologies/TAOTest.rdf#TestSectionLink</rdfs:domain>
<rdfs:range>http://www.tao.lu/Ontologies/TAOTest.rdf#Test</rdfs:range>
</rdf:Description>

</rdf:RDF>
6 changes: 4 additions & 2 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
'label' => 'Blueprints Extension',
'description' => 'Extension to manage Test Blueprints',
'license' => 'GPL-2.0',
'version' => '0.2.0',
'version' => '0.6.1',
'author' => 'Open Assessment Technologies SA',
'requires' => [
'tao' => '>=7.29.0'
'tao' => '>=7.35.0'
],
'managementRole' => 'http://www.tao.lu/Ontologies/generis.rdf#taoBlueprintsManager',
'acl' => array(
Expand All @@ -40,9 +40,11 @@
'rdf' => array(
dirname(__FILE__) . '/install/ontology/blueprints.rdf',
dirname(__FILE__) . '/install/ontology/indexation.rdf',
dirname(__FILE__) . '/install/ontology/taotests.rdf',
),
'php' => array(
\oat\taoBlueprints\scripts\install\InitBlueprintFilesystem::class,
\oat\taoBlueprints\scripts\install\InitTestSectionLink::class,
)
),
'uninstall' => array(
Expand Down
Loading