Skip to content

Commit

Permalink
Merge pull request #69 from oat-sa/release-2.8.1
Browse files Browse the repository at this point in the history
Release 2.8.1
  • Loading branch information
llecaque committed May 11, 2016
2 parents c7a8611 + 7c40861 commit 8a4080b
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 698 deletions.
18 changes: 9 additions & 9 deletions controller/ResultTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function index()
$deliveryService = DeliveryAssemblyService::singleton();
if($this->getRequestParameter('classUri') !== $deliveryService->getRootClass()->getUri()) {
$filter = $this->getRequestParameter('filter');
$classUri = $this->getRequestParameter('classUri');
$uri = $this->getRequestParameter('uri');
$this->setData('filter', $filter);
$this->setData('classUri', $classUri);
$this->setData('uri', $uri);
$this->setView('resultTable.tpl');
} else {
$this->setData('type', 'info');
Expand All @@ -91,13 +91,13 @@ public function getCsvFile(){
$filter = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : array();
$columns = $this->hasRequestParameter('columns') ? $this->getColumns('columns') : array();

$delivery = new \core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('classUri')));
$delivery = new \core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$implementation = $this->service->getReadableImplementation($delivery);
$this->service->setImplementation($implementation);

$delivery = array();
if($this->hasRequestParameter('classUri')){
$delivery[] = \tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
if($this->hasRequestParameter('uri')){
$delivery[] = \tao_helpers_Uri::decode($this->getRequestParameter('uri'));
}

//The list of delivery Results matching the current selection filters
Expand Down Expand Up @@ -192,14 +192,14 @@ protected function getVariableColumns($variableClassUri) {
$columns = array();
$filter = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : array();

$delivery = new \core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('classUri')));
$delivery = new \core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
$implementation = $this->service->getReadableImplementation($delivery);
$this->service->setImplementation($implementation);


$delivery = array();
if($this->hasRequestParameter('classUri')){
$delivery[] = \tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
if($this->hasRequestParameter('uri')){
$delivery[] = \tao_helpers_Uri::decode($this->getRequestParameter('uri'));
}

//The list of delivery Results matching the current selection filters
Expand Down Expand Up @@ -314,7 +314,7 @@ protected function getColumns($identifier) {
*/
public function data() {
$filterData = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : array();
$deliveryUri = \tao_helpers_Uri::decode($this->getRequestParameter('classUri'));
$deliveryUri = \tao_helpers_Uri::decode($this->getRequestParameter('uri'));

$columns = $this->hasRequestParameter('columns') ? $this->getColumns('columns') : array();
$page = $this->getRequestParameter('page');
Expand Down
130 changes: 87 additions & 43 deletions controller/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use \tao_helpers_Request;
use \tao_helpers_Uri;
use oat\taoOutcomeUi\model\ResultsService;
use oat\taoOutcomeUi\helper\ResultLabel;
use oat\taoDeliveryRdf\model\DeliveryAssemblyService;

/**
Expand All @@ -44,6 +43,8 @@
class Results extends tao_actions_SaSModule
{

private $deliveryService;

/**
* constructor: initialize the service and the default data
* @return Results
Expand All @@ -52,6 +53,8 @@ public function __construct()
{
parent::__construct();

$this->service = ResultsService::singleton();
$this->deliveryService = DeliveryAssemblyService::singleton();
$this->defaultData();
}

Expand All @@ -60,62 +63,105 @@ public function __construct()
*/
protected function getClassService()
{
return ResultsService::singleton();
return $this->service;
}

/**
* Get all delivery execution to feed the tree
* @throws \common_exception_IsAjaxAction
* Ontology data for deliveries (not results, so use deliveryService->getRootClass)
* @throws common_exception_IsAjaxAction
*/
public function getOntologyData()
{
if (!tao_helpers_Request::isAjax()) {
throw new common_exception_IsAjaxAction(__FUNCTION__);
}

$instances = array();
$deliveryService = DeliveryAssemblyService::singleton();
if (!$this->hasRequestParameter('classUri') || $deliveryService->getRootClass()->getUri() === $this->getRequestParameter('classUri')) {
// root
foreach ($deliveryService->getAllAssemblies() as $assembly) {
$child["attributes"] = array(
"id" => tao_helpers_Uri::encode($assembly->getUri()),
"class" => "node-class",
'data-uri' => $assembly->getUri()
$options = array(
'subclasses' => true,
'instances' => true,
'highlightUri' => '',
'chunk' => false,
'offset' => 0,
'limit' => 0
);
$child["data"] = htmlentities($assembly->getLabel());
$child["type"] = "class";

$instances[] = $child;
if ($this->hasRequestParameter('loadNode')) {
$options['uniqueNode'] = $this->getRequestParameter('loadNode');
}

if ($this->hasRequestParameter("selected")) {
$options['browse'] = array($this->getRequestParameter("selected"));
}

if(empty($instances) && !$this->hasRequestParameter('classUri')){
$instances["attributes"] = array(
"id" => $deliveryService->getRootClass()->getUri(),
"class" => "node-class",
);
$instances["data"] = __('No Results');
if ($this->hasRequestParameter('hideInstances')) {
if((bool) $this->getRequestParameter('hideInstances')) {
$options['instances'] = false;
}
}
if ($this->hasRequestParameter('classUri')) {
$clazz = $this->getCurrentClass();
$options['chunk'] = !$clazz->equals($this->deliveryService->getRootClass());
} else {
$clazz = $this->deliveryService->getRootClass();
}

$this->returnJson($instances);
if ($this->hasRequestParameter('offset')) {
$options['offset'] = $this->getRequestParameter('offset');
}

if ($this->hasRequestParameter('limit')) {
$options['limit'] = $this->getRequestParameter('limit');
}

//generate the tree from the given parameters
$tree = $this->getClassService()->toTree($clazz, $options);

$tree = $this->addPermissions($tree);

function sortTree(&$tree) {
usort($tree, function($a, $b) {
if (isset($a['data']) && isset($b['data'])) {
if ($a['type'] != $b['type']) {
return ($a['type'] == 'class') ? -1 : 1;
} else {
return strcasecmp($a['data'], $b['data']);
}
}
return 0;
});
}

if (isset($tree['children'])) {
sortTree($tree['children']);
} elseif(array_values($tree) === $tree) {//is indexed array
sortTree($tree);
}

//expose the tree
$this->returnJson($tree);
}

/**
* Action called on click on a delivery (class) construct and call the view to see the table of
* all delivery execution for a specific delivery
*/
public function index()
{
//Properties to filter on
$properties = array(
new \core_kernel_classes_Property(RDFS_LABEL),
$model = array(
array(
'id' => 'ttaker',
'label' => __('Test Taker'),
'sortable' => false
),
array(
'id' => 'time',
'label' => __('Start Time'),
'sortable' => false
)
);

$deliveryService = DeliveryAssemblyService::singleton();
$delivery = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('classUri')));
$delivery = new core_kernel_classes_Resource($this->getRequestParameter('id'));
if($delivery->getUri() !== $deliveryService->getRootClass()->getUri()){

try{
Expand All @@ -124,16 +170,9 @@ public function index()

$this->getClassService()->setImplementation($implementation);

$model = array();
foreach($properties as $property){
$model[] = array(
'id' => $property->getUri(),
'label' => $property->getLabel(),
'sortable' => true
);
}

$this->setData('classUri',tao_helpers_Uri::encode($delivery->getUri()));
$this->setData('uri',tao_helpers_Uri::encode($delivery->getUri()));
$this->setData('title',$delivery->getLabel());
$this->setData('model',$model);

$this->setView('resultList.tpl');
Expand Down Expand Up @@ -190,16 +229,16 @@ public function getResults()
$counti = $this->getClassService()->getImplementation()->countResultByDelivery(array($delivery->getUri()));
foreach($results as $res){

$deliveryResult = new core_kernel_classes_Resource($res['deliveryResultIdentifier']);
$deliveryExecution = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getDeliveryExecution($res['deliveryResultIdentifier']);
$testTaker = new core_kernel_classes_Resource($res['testTakerIdentifier']);
$label = new ResultLabel($deliveryResult, $testTaker, $delivery);

$data[] = array(
'id' => $deliveryResult->getUri(),
RDFS_LABEL => (string)$label,
'id' => $deliveryExecution->getIdentifier(),
'ttaker' => $testTaker->getLabel(),
'time' => \tao_helpers_Date::displayeDate($deliveryExecution->getStartTime()),
);

$readOnly[$deliveryResult->getUri()] = $rights;
$readOnly[$deliveryExecution->getIdentifier()] = $rights;
}

$this->returnJSON(array(
Expand Down Expand Up @@ -248,10 +287,12 @@ public function delete()
*/
public function viewResult()
{

$result = $this->getCurrentInstance();
$de = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getDeliveryExecution($result->getUri());

try{

$implementation = $this->getClassService()->getReadableImplementation($de->getDelivery());
$this->getClassService()->setImplementation($implementation);

Expand Down Expand Up @@ -291,13 +332,16 @@ public function viewResult()
$this->setData('userEmail', $userEmail);
}
$filter = ($this->hasRequestParameter("filter")) ? $this->getRequestParameter("filter") : "lastSubmitted";
$stats = $this->getClassService()->getItemVariableDataStatsFromDeliveryResult($de, $filter);
$variables = $this->getClassService()->getStructuredVariables($de, $filter);
$this->setData('variables', $variables);

$stats = $this->getClassService()->calculateResponseStatistics($variables);
$this->setData('nbResponses', $stats["nbResponses"]);
$this->setData('nbCorrectResponses', $stats["nbCorrectResponses"]);
$this->setData('nbIncorrectResponses', $stats["nbIncorrectResponses"]);
$this->setData('nbUnscoredResponses', $stats["nbUnscoredResponses"]);
$this->setData('deliveryResultLabel', $result->getLabel());
$this->setData('variables', $stats["data"]);

//retireve variables not related to item executions
$deliveryVariables = $this->getClassService()->getVariableDataFromDeliveryResult($de);
$this->setData('deliveryVariables', $deliveryVariables);
Expand Down
89 changes: 0 additions & 89 deletions controller/SimpleReport.php

This file was deleted.

Loading

0 comments on commit 8a4080b

Please sign in to comment.