Skip to content

Commit

Permalink
Merge pull request #678 from oat-sa/release-2.28.0
Browse files Browse the repository at this point in the history
Release 2.28.0
  • Loading branch information
llecaque committed May 11, 2016
2 parents 47f2dd2 + ada79b7 commit 6b78750
Show file tree
Hide file tree
Showing 61 changed files with 3,392 additions and 1,903 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"minimum-stability" : "dev",
"require": {
"oat-sa/lib-tao-qti" : "dev-master",
"oat-sa/lib-tao-qti" : "~0.1.0",
"oat-sa/oatbox-extension-installer": "dev-master"
},
"autoload" : {
Expand Down
7 changes: 4 additions & 3 deletions config/default/simpleExporter.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@
),
'BR' => array (
'extractor' => 'QtiExtractor',
'parameters' => array (
'parameters' => array(
'callback' => 'getRightAnswer',
'callbackParameters' => array(
'delimiter' => '|'
)
'delimiter' => '|',
),
'valuesAsColumns' => true
)
),
'choiceInteraction' => array (
Expand Down
121 changes: 67 additions & 54 deletions controller/QtiCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class QtiCreator extends tao_actions_CommonModule
{
/**
* create a new QTI item
*
*
* @requiresRight id WRITE
*/
public function createItem()
Expand All @@ -66,10 +66,10 @@ public function createItem()
}
}
$service = \taoItems_models_classes_ItemsService::singleton();

$label = $service->createUniqueLabel($clazz);
$item = $service->createInstance($clazz, $label);

if(!is_null($item)){
$service->setItemModel($item, new \core_kernel_classes_Resource(ItemModel::MODEL_URI));
$response = array(
Expand All @@ -85,59 +85,13 @@ public function createItem()
public function index()
{

$config = new CreatorConfig();

$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$creatorConfig = $ext->getConfig('qtiCreator');

if (is_array($creatorConfig)) {
foreach ($creatorConfig as $prop => $value) {
$config->setProperty($prop, $value);
}
if (!$this->hasRequestParameter('instance')) {
throw new common_exception_Error('The item creator needs to be opened with an item');
}
$item = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('instance')));

if ($this->hasRequestParameter('instance')) {
//uri:
$itemUri = tao_helpers_Uri::decode($this->getRequestParameter('instance'));
$config->setProperty('uri', $itemUri);

//get label:
$rdfItem = new core_kernel_classes_Resource($itemUri);
$config->setProperty('label', $rdfItem->getLabel());

//set the current data lang in the item content to keep the integrity
//@todo : allow preview in a language other than the one in the session
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
$config->setProperty('lang', $lang);

//base url:
$url = tao_helpers_Uri::url(
'getFile',
'QtiCreator',
'taoQtiItem',
array(
'uri' => $itemUri,
'lang' => $lang
)
);
$config->setProperty('baseUrl', $url . '&relPath=');
}
$config = $this->getCreatorConfig($item);

$mediaSourcesUrl = tao_helpers_Uri::url(
'getMediaSources',
'QtiCreator',
'taoQtiItem'
);

$config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
//initialize all registered hooks:
$hookClasses = HookRegistry::getRegistry()->getMap();
foreach ($hookClasses as $hookClass) {
$hook = new $hookClass();
$hook->init($config);
}

$config->init();
$this->setData('config', $config->toArray());
$this->setView('QtiCreator/index.tpl');
}
Expand Down Expand Up @@ -243,4 +197,63 @@ private function renderFile($item, $path, $lang)
}
}

}
/**
* Get the configuration of the Item Creator
* @param core_kernel_classes_Resource $item the selected item
* @return CreatorConfig the configration
*/
protected function getCreatorConfig(core_kernel_classes_Resource $item){

$config = new CreatorConfig();

$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$creatorConfig = $ext->getConfig('qtiCreator');

if (is_array($creatorConfig)) {
foreach ($creatorConfig as $prop => $value) {
$config->setProperty($prop, $value);
}
}

$config->setProperty('uri', $item->getUri());
$config->setProperty('label', $item->getLabel());

//set the current data lang in the item content to keep the integrity
//@todo : allow preview in a language other than the one in the session
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
$config->setProperty('lang', $lang);

//base url:
$url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array(
'uri' => $item->getUri(),
'lang' => $lang,
'relPath' => ''
));
$config->setProperty('baseUrl', $url);

//map the multi column config to the plugin
//TODO migrate the config
if($config->getProperty('multi-column') == true){
$config->addPlugin('blockAdder', 'taoQtiItem/qtiCreator/plugins/content/blockAdder', 'content');
}

$mediaSourcesUrl = tao_helpers_Uri::url(
'getMediaSources',
'QtiCreator',
'taoQtiItem'
);

$config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);

//initialize all registered hooks:
$hookClasses = HookRegistry::getRegistry()->getMap();
foreach ($hookClasses as $hookClass) {
$hook = new $hookClass();
$hook->init($config);
}

$config->init();

return $config;
}
}
2 changes: 1 addition & 1 deletion helpers/Authoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function sanitizeQtiXml($qti)

$ids = array();
/** @var \DOMElement $elementWithId */
foreach ($xpath->query("//*[@id]") as $elementWithId) {
foreach ($xpath->query("//*[not(local-name()='lib') and @id]") as $elementWithId) {
$id = $elementWithId->getAttribute('id');
if(in_array($id, $ids)){
$elementWithId->removeAttribute('id');
Expand Down
14 changes: 10 additions & 4 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/
use oat\taoQtiItem\controller\QtiPreview;
use oat\taoQtiItem\controller\QtiCreator;
use oat\taoQtiItem\controller\QtiCssAuthoring;

$extpath = dirname(__FILE__).DIRECTORY_SEPARATOR;
$taopath = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'tao'.DIRECTORY_SEPARATOR;
Expand All @@ -26,10 +29,10 @@
'label' => 'QTI item model',
'description' => 'TAO QTI item model',
'license' => 'GPL-2.0',
'version' => '2.23.0',
'version' => '2.28.0',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoItems' => '>=2.13',
'taoItems' => '>=2.15',
'tao' => '>=2.17'
),
'models' => array(
Expand All @@ -51,6 +54,7 @@
dirname(__FILE__).'/install/scripts/setQtiRunnerConfig.php',
'oat\\taoQtiItem\\install\\scripts\\addValidationSettings',
'oat\\taoQtiItem\\install\\scripts\\createExportDirectory',
'oat\\taoQtiItem\\scripts\\install\\SetQtiCreatorConfig'
)
),
'local' => array(
Expand All @@ -66,8 +70,10 @@
'acl' => array(
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#QTIManagerRole', array('ext'=>'taoQtiItem')),
array('grant', 'http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole', array('ext'=>'taoQtiItem', 'mod' => 'QtiItemRunner')),
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#ItemsManagerRole', array('ext'=>'taoQtiItem', 'mod' => 'QtiCreator')),
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#ItemsManagerRole', array('ext'=>'taoQtiItem', 'mod' => 'QtiPreview'))
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#AbstractItemAuthor', QtiPreview::class),
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#AbstractItemAuthor', QtiCreator::class),
array('grant', 'http://www.tao.lu/Ontologies/TAOItem.rdf#AbstractItemAuthor', QtiCssAuthoring::class)

),
'constants' => array(
# views directory
Expand Down
43 changes: 37 additions & 6 deletions model/CreatorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace oat\taoQtiItem\model;

use oat\taoQtiItem\model\Config;
use oat\taoQtiItem\model\QtiCreatorClientConfigRegistry;

/**
* Interface defining required method for a plugin
Expand All @@ -32,6 +33,7 @@

protected $interactions = array();
protected $infoControls = array();
protected $plugins = array();

public function addInteraction($interactionFile){
$this->interactions[] = $interactionFile;
Expand All @@ -41,6 +43,32 @@ public function addInfoControl($infoControl){
$this->infoControls[] = $infoControl;
}

/**
* Add a plugin to the configuration
* @param string $name - the plugin name
* @param string $module - the plugin AMD module
* @param string $category - the plugin category
*/
public function addPlugin($name, $module, $category){
$this->plugins[] = array(
'name' => $name,
'module' => $module,
'category' => $category
);
}

/**
* Remove a plugin from the configuration
* @param string $name - the plugin name
*/
public function removePlugin($name){
foreach($this->plugins as $key => $plugin){
if($plugin['name'] == $name){
$this->plugins[$key]['exclude'] = true;
}
}
}

public function toArray(){

$interactions = array();
Expand All @@ -56,10 +84,10 @@ public function toArray(){
}

return array(
'properties' => $this->properties,
'uiHooks' => $this->uiHooks,
'interactions' => $interactions,
'infoControls' => $infoControls
'properties' => $this->properties,
'contextPlugins' => $this->plugins,
'interactions' => $interactions,
'infoControls' => $infoControls
);
}

Expand All @@ -71,6 +99,10 @@ public function init(){
foreach($this->infoControls as $infoControl){
$this->prepare($infoControl);
}

//as the config overrides the plugins, we get the list from the registry
$registry = QtiCreatorClientConfigRegistry::getRegistry();
$this->plugins = $registry->getPlugins();
}

protected function prepare($hook){
Expand All @@ -91,5 +123,4 @@ protected function prepare($hook){
throw new \common_Exception('cannot prepare hook because of missing property in config : "uri" ');
}
}

}
}
Loading

0 comments on commit 6b78750

Please sign in to comment.