Skip to content

Commit

Permalink
Merge pull request #551 from oat-sa/release-2.14.0
Browse files Browse the repository at this point in the history
Release 2.14.0
  • Loading branch information
llecaque committed Jan 29, 2016
2 parents 068e170 + a8da847 commit 7845e4e
Show file tree
Hide file tree
Showing 78 changed files with 5,374 additions and 400 deletions.
25 changes: 25 additions & 0 deletions config/default/compilerClass.conf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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;
*
*
*/

/**
* Default Item Qti compiler class
*/
return 'oat\\taoQtiItem\\model\\QtiItemCompiler';
25 changes: 25 additions & 0 deletions install/scripts/setQtiRunnerConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*/
\oat\tao\model\ClientLibConfigRegistry::getRegistry()->register(
'taoQtiItem/qtiRunner/core/QtiRunner',
array(
'inlineModalFeedback' => false
)
);
5 changes: 3 additions & 2 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'label' => 'QTI item model',
'description' => 'TAO QTI item model',
'license' => 'GPL-2.0',
'version' => '2.12.1',
'version' => '2.14.0',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoItems' => '>=2.6'
Expand All @@ -46,7 +46,8 @@
'php' => array(
dirname(__FILE__).'/install/local/setDefaultTheme.php',
dirname(__FILE__).'/install/local/addPortableContexts.php',
dirname(__FILE__).'/install/scripts/addPortableSharedLibraries.php'
dirname(__FILE__).'/install/scripts/addPortableSharedLibraries.php',
dirname(__FILE__).'/install/scripts/setQtiRunnerConfig.php'
)
),
'local' => array(
Expand Down
2 changes: 1 addition & 1 deletion model/ItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function getImportHandlers() {
}

public function getCompilerClass() {
return 'oat\\taoQtiItem\\model\\QtiItemCompiler';
return \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('compilerClass');
}

public function getPackerClass() {
Expand Down
105 changes: 105 additions & 0 deletions model/QtiJsonItemCompiler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?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 (under the project TAO-PRODUCT);
*
*/

namespace oat\taoQtiItem\model;

use common_Logger;
use common_report_Report;
use core_kernel_classes_Resource;
use oat\taoQtiItem\model\pack\QtiItemPacker;
use oat\taoQtiItem\model\qti\exception\XIncludeException;
use oat\taoQtiItem\model\qti\Service;
use tao_helpers_File;
use taoItems_models_classes_ItemsService;
use oat\taoQtiItem\model\qti\Parser;

/**
* The QTI Json Item Compiler
*
* @access public
* @author Antoine Robin
* @package taoItems
*/
class QtiJsonItemCompiler extends QtiItemCompiler
{

const ITEM_FILE_NAME = 'item.json';

/**
* Desploy all the required files into the provided directories
*
* @param core_kernel_classes_Resource $item
* @param string $language
* @param string $publicDirectory
* @param string $privateFolder
* @return common_report_Report
*/
protected function deployQtiItem(core_kernel_classes_Resource $item, $language, $publicDirectory, $privateFolder)
{
//start debugging here
common_Logger::d('destination original ' . $publicDirectory . ' ' . $privateFolder);

$qtiService = Service::singleton();

//create the item.json file in private directory
$itemPacker = new QtiItemPacker();
$itemPack = $itemPacker->packItem($item, $language);
file_put_contents($privateFolder.self::ITEM_FILE_NAME, json_encode($itemPack->JsonSerialize()));

//copy client side resources (javascript loader)
$qtiItemDir = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getDir();
$taoDir = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao')->getDir();
$assetPath = $qtiItemDir . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR;
$assetLibPath = $taoDir . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
if (\tao_helpers_Mode::is('production')) {
tao_helpers_File::copy($assetPath . 'qtiLoader.min.js', $publicDirectory . 'qtiLoader.min.js', false);
} else {
tao_helpers_File::copy($assetPath . 'qtiLoader.js', $publicDirectory . 'qtiLoader.js', false);
tao_helpers_File::copy($assetLibPath . 'require.js', $publicDirectory . 'require.js', false);
}

// retrieve the media assets
try {
$qtiItem = $this->retrieveAssets($item, $language, $publicDirectory);

//store variable qti elements data into the private directory
$variableElements = $qtiService->getVariableElements($qtiItem);
$serializedVariableElements = json_encode($variableElements);
file_put_contents($privateFolder . 'variableElements.json', $serializedVariableElements);

return new common_report_Report(
common_report_Report::TYPE_SUCCESS, __('Successfully compiled "%s"', $language)
);
} catch (\tao_models_classes_FileNotFoundException $e) {
return new common_report_Report(
common_report_Report::TYPE_ERROR, __('Unable to retrieve asset "%s"', $e->getFilePath())
);
} catch (XIncludeException $e){
return new common_report_Report(
common_report_Report::TYPE_ERROR, $e->getUserMessage()
);
} catch (\Exception $e){
return new common_report_Report(
common_report_Report::TYPE_ERROR, $e->getMessage()
);
}
}

}
76 changes: 76 additions & 0 deletions model/event/ItemImported.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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) 2015 (original work) Open Assessment Technologies SA
*
*/
namespace oat\taoQtiItem\model\event;

use oat\oatbox\event\Event;

class ItemImported implements Event
{

/**
* The Qti Item model object
* @var \oat\taoQtiItem\model\qti\Item
*/
private $item;

/**
* The Rdf Qti Item
* @var type
*/
private $rdfItem;


/**
* Create an instance of ItemImported event
*
* @param \core_kernel_classes_Resource $rdfItem
* @param \oat\taoQtiItem\model\qti\Item $item
*/
public function __construct(\core_kernel_classes_Resource $rdfItem, \oat\taoQtiItem\model\qti\Item $item)
{
$this->item = $item;
$this->rdfItem = $rdfItem;
}

/**
* @see \oat\oatbox\event\Event::getName()
*/
public function getName()
{
return __CLASS__;
}

/**
* @return \oat\taoQtiItem\model\qti\Item
*/
public function getItem()
{
return $this->item;
}

/**
* @return \core_kernel_classes_Resource
*/
public function getRdfItem()
{
return $this->rdfItem;
}

}
5 changes: 5 additions & 0 deletions model/qti/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@
use oat\taoQtiItem\model\qti\exception\ExtractException;
use oat\taoQtiItem\model\qti\exception\ParsingException;
use oat\taoQtiItem\model\qti\parser\ValidationException;
use oat\taoQtiItem\model\event\ItemImported;
use qtism\data\storage\xml\XmlStorageException;
use tao_helpers_File;
use tao_models_classes_GenerisService;
use taoItems_models_classes_ItemsService;
use oat\oatbox\event\EventManager;
use oat\oatbox\service\ServiceManager;

/**
* Short description of class oat\taoQtiItem\model\qti\ImportService
Expand Down Expand Up @@ -545,6 +548,8 @@ public function importQtiItem(
$this->storeApip($qtiFile, $rdfItem);
}

$eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID);
$eventManager->trigger(new ItemImported($rdfItem, $qtiModel));

$msg = __('The IMS QTI Item referenced as "%s" in the IMS Manifest file was successfully imported.',
$qtiItemResource->getIdentifier());
Expand Down
3 changes: 2 additions & 1 deletion model/qti/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use oat\taoQtiItem\controller\QTIform\AssessmentItem;
use \common_Serializable;
use \common_Logger;
use \common_ext_ExtensionsManager;
use \taoItems_models_classes_TemplateRenderer;
use \DOMDocument;
use oat\tao\helpers\Template;
Expand Down Expand Up @@ -105,7 +106,7 @@ class Item extends IdentifiedElement implements FlowContainer, IdentifiedElement
public function __construct($attributes = array()){
// override the tool options !
$attributes['toolName'] = PRODUCT_NAME;
$attributes['toolVersion'] = TAO_VERSION;
$attributes['toolVersion'] = \tao_models_classes_TaoService::singleton()->getPlatformVersion();

// create container
$this->body = new ContainerItemBody('', $this);
Expand Down
20 changes: 12 additions & 8 deletions model/qti/ParserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ protected function buildResponseProcessing(DOMElement $data, Item $item){
common_Logger::d('Processing is Template', array('TAOITEMS', 'QTI'));
}
}catch(UnexpectedResponseProcessing $e){

}
//try templatedriven
if(is_null($returnValue)){
Expand Down Expand Up @@ -1104,9 +1104,12 @@ protected function getResponse($identifier){
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param DOMElement data
* @param array interactions
* @return oat\taoQtiItem\model\qti\response\ResponseProcessing
* @param DOMElement $data
* @param $interactions
* @return TemplatesDriven
* @throws UnexpectedResponseProcessing
* @throws exception\QtiModelException
* @throws response\InvalidArgumentException
*/
protected function buildTemplatedrivenResponse(DOMElement $data, $interactions){

Expand Down Expand Up @@ -1263,10 +1266,11 @@ protected function buildTemplatedrivenResponse(DOMElement $data, $interactions){
}
}

if(count(array_diff($responseIdentifiers, array_keys($rules))) > 0 || count(array_diff(array_keys($rules), $responseIdentifiers)) > 0){
// drop rules that don't have a corresponding response identifier
if(count(array_diff($responseIdentifiers, array_keys($rules))) > 0){
throw new UnexpectedResponseProcessing('Not template driven, responseIdentifiers are '.implode(',', $responseIdentifiers).' while rules are '.implode(',', array_keys($rules)));
}

$templatesDrivenRP = new TemplatesDriven();
foreach($interactions as $interaction){
$pattern = $rules[$interaction->getResponse()->getIdentifier()];
Expand All @@ -1283,8 +1287,8 @@ protected function buildTemplatedrivenResponse(DOMElement $data, $interactions){
*
* @access private
* @author Joel Bout, <joel.bout@tudor.lu>
* @param DOMElement data
* @return oat\taoQtiItem\model\qti\Object
* @param DOMElement $data
* @return \oat\taoQtiItem\model\qti\Object
*/
private function buildObject(DOMElement $data){

Expand Down
6 changes: 3 additions & 3 deletions model/qti/response/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\InteractionResponseProcessing;
use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\None;
use oat\taoQtiItem\model\qti\response\Template;
use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\Template;
use oat\taoQtiItem\model\qti\response\interactionResponseProcessing\Template as IrpTemplate;
use oat\taoQtiItem\model\qti\response\TakeoverFailedException;
use oat\taoQtiItem\model\qti\response\TemplatesDriven;
use oat\taoQtiItem\model\qti\ResponseDeclaration;
Expand Down Expand Up @@ -158,7 +158,7 @@ public static function takeOverFrom(ResponseProcessing $responseProcessing, Item
foreach($item->getInteractions() as $interaction){
$response = $interaction->getResponse();
try{
$irp = Template::createByTemplate(
$irp = IrpTemplate::createByTemplate(
$responseProcessing->getUri(), $response, $item);
}catch(Exception $e){
throw new TakeoverFailedException();
Expand All @@ -172,7 +172,7 @@ public static function takeOverFrom(ResponseProcessing $responseProcessing, Item
foreach($item->getInteractions() as $interaction){
$response = $interaction->getResponse();
try{
$irp = Template::createByTemplate(
$irp = IrpTemplate::createByTemplate(
$responseProcessing->getTemplate($response)
, $response
, $item
Expand Down
Loading

0 comments on commit 7845e4e

Please sign in to comment.