Skip to content

Commit

Permalink
Merge pull request #327 from oat-sa/release-2.18.0
Browse files Browse the repository at this point in the history
Release 2.18.0
  • Loading branch information
llecaque committed Feb 9, 2016
2 parents ebf8fde + b1ca4fb commit f768204
Show file tree
Hide file tree
Showing 57 changed files with 5,795 additions and 696 deletions.
148 changes: 134 additions & 14 deletions actions/class.Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,29 @@ public function getItemData()
try {
$serviceContext = $this->getServiceContext();

$response = [
'itemData' => $this->runnerService->getItemData($serviceContext, $itemRef),
'baseUrl' => $this->runnerService->getItemPublicUrl($serviceContext, $itemRef),
'success' => true,
];
$itemData = $this->runnerService->getItemData($serviceContext, $itemRef);
$baseUrl = $this->runnerService->getItemPublicUrl($serviceContext, $itemRef);
if (is_string($itemData)) {
$response = '{"success":true,"itemData":' . $itemData . ',"baseUrl":"'.$baseUrl.'"}';
} else {
$response = [
'itemData' => $itemData,
'success' => true,
'baseUrl' => $baseUrl
];
}

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
}

$this->returnJson($response, $code);
if (is_string($response)) {
header(HTTPToolkit::statusCodeHeader($code));
Context::getInstance()->getResponse()->setContentHeader('application/json');
echo $response;
} else {
$this->returnJson($response, $code);
}
}

/**
Expand Down Expand Up @@ -352,20 +363,28 @@ public function submitItemState()
public function storeItemResponse()
{
$code = 200;

$itemRef = $this->getRequestParameter('itemDefinition');

$itemResponse = \taoQtiCommon_helpers_Utils::readJsonPayload();

try {
$serviceContext = $this->getServiceContext();
$response = [

$response = array(
'success' => $this->runnerService->storeItemResponse($serviceContext, $itemRef, $itemResponse),
];

'displayFeedbacks' => $this->runnerService->displayFeedbacks($serviceContext)
);

if($response['displayFeedbacks'] == true){

//FIXME there is here a performance issue, at the end we need the defitions only once, not at each storage
$response['feedbacks'] = $this->runnerService->getFeedbacks($serviceContext, $itemRef);
$response['itemSession'] = $this->runnerService->getItemSession($serviceContext);
}

$this->runnerService->persist($serviceContext);

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
Expand Down Expand Up @@ -565,4 +584,105 @@ public function resume()

$this->returnJson($response, $code);
}

/**
* Flag an item
*/
public function flagItem()
{
$code = 200;

try {
$serviceContext = $this->getServiceContext();
$testSession = $serviceContext->getTestSession();

if ($this->hasRequestParameter('position')) {
$itemPosition = intval($this->getRequestParameter('position'));
} else {
$itemPosition = $testSession->getRoute()->getPosition();
}

if ($this->hasRequestParameter('flag')) {
$flag = $this->getRequestParameter('flag');
if (is_numeric($flag)) {
$flag = !!(intval($flag));
} else {
$flag = 'false' != strtolower($flag);
}
} else {
$flag = true;
}

taoQtiTest_helpers_TestRunnerUtils::setItemFlag($testSession, $itemPosition, $flag);

$response = [
'success' => true,
];

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
}

$this->returnJson($response, $code);
}

/**
* Comment the test
*/
public function comment()
{
$code = 200;

$comment = $this->getRequestParameter('comment');

try {
$serviceContext = $this->getServiceContext();
$result = $this->runnerService->comment($serviceContext, $comment);

$response = [
'success' => $result,
];

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
}

$this->returnJson($response, $code);
}

/**
* allow client to store information about the test, the section or the item
*/
public function storeTraceData(){
$code = 200;

$itemRef = ($this->hasRequestParameter('itemDefinition'))?$this->getRequestParameter('itemDefinition'): null;

$traceData = json_decode(html_entity_decode($this->getRequestParameter('traceData')), true);

try {
$serviceContext = $this->getServiceContext(false);
$stored = 0;
$size = count($traceData);

foreach($traceData as $variableIdentifier => $variableValue){
if($this->runnerService->storeTraceVariable($serviceContext, $itemRef, $variableIdentifier, json_encode($variableValue))){
$stored++;
}
}

$response = [
'success' => $stored == $size
];
common_Logger::d("Stored {$stored}/{$size} trace variables");

} catch (common_Exception $e) {
$response = $this->getErrorResponse($e);
$code = $this->getErrorCode($e);
}

$this->returnJson($response, $code);
}
}
10 changes: 8 additions & 2 deletions locales/es-ES/messages.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
$GLOBALS['__l10n']["Add the source file"]="Añadir el archivo origen";
$GLOBALS['__l10n']["Advanced Mode"]="Modo avanzado";
$GLOBALS['__l10n']["After you complete the section it would be impossible to return to this section to make changes. Are you sure you want to end the section?"]="Después de que complete la sección, no podrá regresar a ella para realizar cambios. ¿Está seguro de que desea terminar la sección?";
$GLOBALS['__l10n']["all"]="todos";
$GLOBALS['__l10n']["All"]="Todos";
$GLOBALS['__l10n']["all"]="todos";
$GLOBALS['__l10n']["All data will be removed in %s"]="Todos los datos seran removidos en %s";
$GLOBALS['__l10n']["All fields are required"]="Todos los campos son obligatorios";
$GLOBALS['__l10n']["Allow Comment"]="Permitir Comentario";
Expand Down Expand Up @@ -90,8 +90,8 @@
$GLOBALS['__l10n']["Categories"]="Categorías";
$GLOBALS['__l10n']["Change password"]="Cambiar contraseña";
$GLOBALS['__l10n']["Change the password"]="Cambiar la contraseña";
$GLOBALS['__l10n']["Check All"]="Seleccionar Todo";
$GLOBALS['__l10n']["Check all"]="Seleccionar todo";
$GLOBALS['__l10n']["Check All"]="Seleccionar Todo";
$GLOBALS['__l10n']["Check-in"]="Registrarse";
$GLOBALS['__l10n']["Choose export format"]="Elegir formato para exportar";
$GLOBALS['__l10n']["Choose import format"]="Elegir formato para importar";
Expand Down Expand Up @@ -124,6 +124,8 @@
$GLOBALS['__l10n']["Default user cannot be deleted"]="El usuario por defecto no puede ser borrado";
$GLOBALS['__l10n']["Define the default values"]="Define los valores por defecto";
$GLOBALS['__l10n']["Delete"]="Eliminar";
$GLOBALS['__l10n']["Deliveries"]="Entregas";
$GLOBALS['__l10n']["Deliveries library"]="Biblioteca de entregas";
$GLOBALS['__l10n']["Demo Sandbox"]="Demo Sanbox";
$GLOBALS['__l10n']["Disable validation"]="Desactivar validación";
$GLOBALS['__l10n']["Disabled %s"]="Deshabilitada %s";
Expand Down Expand Up @@ -293,6 +295,7 @@
$GLOBALS['__l10n']["Name"]="Nombre";
$GLOBALS['__l10n']["Navigation"]="Navegación";
$GLOBALS['__l10n']["New class"]="Nueva clase";
$GLOBALS['__l10n']["New delivery"]="Nueva entrega";
$GLOBALS['__l10n']["New Group"]="Nuevo grupo";
$GLOBALS['__l10n']["New item"]="Elemento nuevo";
$GLOBALS['__l10n']["New password"]="Nueva contraseña";
Expand Down Expand Up @@ -341,6 +344,7 @@
$GLOBALS['__l10n']["Please give a message to your commit"]="Por favor dejar un mensaje a su compromiso";
$GLOBALS['__l10n']["Please report bugs, ideas, comments or feedback on the TAO Forge"]="Por favor reporte errores, ideas, comentarios o sugerencias en el TAO Forge";
$GLOBALS['__l10n']["Post install processing"]="Fijar proceso de instalación";
$GLOBALS['__l10n']["Prepare, publish deliveries sessions."]="Preparar, publicar sesiones de entregas.";
$GLOBALS['__l10n']["Preparing installation..."]="Preparando instalación...";
$GLOBALS['__l10n']["Preview"]="Vista previa";
$GLOBALS['__l10n']["Previous"]="Anterior";
Expand Down Expand Up @@ -483,6 +487,8 @@
$GLOBALS['__l10n']["This password reset link is no longer valid. It may have already been used. If you still wish to reset your password please request a new link"]="Este enlace de restablecimiento de contraseña ya no es válido. Puede que ya se ha utilizado. Si aún desea restablecer su contraseña, por favor solicitar un nuevo enlace";
$GLOBALS['__l10n']["This resource is locked"]="El recurso está bloqueado";
$GLOBALS['__l10n']["This role is still given to one or more users. Please remove the role to these users first."]="Este rol todavía se da a uno o más usuarios. Por favor, remueva el rol a estos usuarios primero.";
$GLOBALS['__l10n']["This test has been suspended"]="Esta prueba ha sido suspendida";
$GLOBALS['__l10n']["This test has been terminated"]="Esta prueba es terminado";
$GLOBALS['__l10n']["Time limit reached for item \"%s\"."]="Alcanzó el límite de tiempo para el ítem \"%s\".";
$GLOBALS['__l10n']["Time limit reached, this part of the test has ended."]="Alcanzó el límite de tiempo, esta parte de la prueba ha finalizado.";
$GLOBALS['__l10n']["Time Limits"]="Tiempo Límite";
Expand Down
4 changes: 2 additions & 2 deletions locales/es-ES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ msgid "This constraint controls whether or not the candidate is allowed to provi
msgstr "Esta restricción controla si se permite o no al candidato proporcionar un comentario sobre el tema durante la sesión. Los comentarios no son parte de las respuestas evaluadas."

msgid "This test has been suspended"
msgstr ""
msgstr "Esta prueba ha sido suspendida"

msgid "This test has been terminated"
msgstr ""
msgstr "Esta prueba es terminado"

msgid "Time limit reached for item \"%s\"."
msgstr "Alcanzó el límite de tiempo para el ítem \"%s\"."
Expand Down
2 changes: 1 addition & 1 deletion locales/es-ES/messages_po.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'label' => 'QTI test model',
'description' => 'TAO QTI test implementation',
'license' => 'GPL-2.0',
'version' => '2.17.0',
'version' => '2.18.0',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoTests' => '>=2.6',
Expand Down
61 changes: 60 additions & 1 deletion models/classes/TestRunnerClientConfigRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ class TestRunnerClientConfigRegistry extends ClientLibConfigRegistry

const AMD = 'taoQtiTest/controller/runtime/testRunner';

/**
* Path to the runner controller module
*/
const RUNNER = 'taoQtiTest/controller/runner/runner';

/**
* Path to the runner controller module in production mode
*/
const RUNNER_PROD = 'taoQtiTest/qtiTestRunner.min';

/**
* Register a qti tools in the client lib config registry
*
Expand All @@ -43,4 +53,53 @@ public function registerQtiTools($name, $toolConfig){
$newConfig['qtiTools'][$name] = $toolConfig;
$this->register(self::AMD, $newConfig);
}
}

/**
* Register a runner plugin
* @param string $module
* @param string $category
* @param string|int $position
* @throws \common_exception_InvalidArgumentType
*/
public function registerPlugin($module, $category, $position = null){
if (!is_string($module)) {
throw new \common_exception_InvalidArgumentType('The module path must be a string!');
}

if (!is_string($category)) {
throw new \common_exception_InvalidArgumentType('The category name must be a string!');
}

if (!is_null($position) && !is_string($position) && !is_numeric($position)) {
throw new \common_exception_InvalidArgumentType('The position must be a string or a number!');
}

$config = [];
$registry = self::getRegistry();
if ($registry->isRegistered(self::RUNNER)) {
$config = $registry->get(self::RUNNER);
}

$plugins = [];
if (isset($config['plugins'])) {
foreach($config['plugins'] as $plugin) {
if ($plugin['module'] != $module) {
$plugins[] = $plugin;
}
}
}

$plugins[] = [
'module' => $module,
'category' => $category,
'position' => $position,
];

$config['plugins'] = $plugins;
$registry->set(self::RUNNER, $config);
$registry->set(self::RUNNER_PROD, $config);

// TODO: store the list of plugins into json file to compile the controller with dependencies
// example: file_put_contents($jsonPath, json_encode($plugins, JSON_PRETTY_PRINT));
}
}
Loading

0 comments on commit f768204

Please sign in to comment.