public static function buildServiceApi(AssessmentTestSession $session, $qtiTestDefinitionUri, $qtiTestCompilationUri) { $serviceCall = self::buildItemServiceCall($session, $qtiTestDefinitionUri, $qtiTestCompilationUri); $itemServiceCallId = self::buildServiceCallId($session); return tao_helpers_ServiceJavascripts::getServiceApi($serviceCall, $itemServiceCallId); }
protected function buildItemScript($execution) { $serviceCall = $execution->getCurrentServiceCall(); $itemCallId = $execution->getItemServiceCallId(); return \tao_helpers_ServiceJavascripts::getServiceApi($serviceCall, $itemCallId); }
public function index() { if (is_null($this->processExecution)) { common_Logger::w('ProcessBrowser invoked without processExecution'); $this->redirectToMain(); return; } if ($this->autoRedirecting) { $this->autoredirectToIndex(); return; } /* * @todo: clean usage * known use of Session::setAttribute("processUri") in: * - taoDelivery_actions_ItemDelivery::runner() * - tao_actions_Api::createAuthEnvironment() */ $this->setSessionAttribute("processUri", $this->processExecution->getUri()); //user data for browser view $userViewData = wfEngine_helpers_UsersHelper::buildCurrentUserForView(); $this->setData('userViewData', $userViewData); $browserViewData = array(); // general data for browser view. //init services: $userService = wfEngine_models_classes_UserService::singleton(); $activityService = wfEngine_models_classes_ActivityService::singleton(); $interactiveServiceService = wfEngine_models_classes_InteractiveServiceService::singleton(); //get current user: $currentUser = $userService->getCurrentUser(); if (is_null($currentUser)) { throw new wfEngine_models_classes_ProcessExecutionException("No current user found!"); } //get activity execution from currently available process definitions: $currentlyAvailableActivityExecutions = $this->processExecutionService->getAvailableCurrentActivityExecutions($this->processExecution, $currentUser, true); $activityExecution = null; if (count($currentlyAvailableActivityExecutions) == 0) { common_Logger::w('No available current activity exec found: no permission or issue in process execution'); $this->pause(); return; } else { if (!is_null($this->activityExecution) && $this->activityExecution instanceof core_kernel_classes_Resource) { foreach ($currentlyAvailableActivityExecutions as $availableActivityExec) { if ($availableActivityExec->getUri() == $this->activityExecution->getUri()) { $activityExecution = $this->processExecutionService->initCurrentActivityExecution($this->processExecution, $this->activityExecution, $currentUser); break; } } if (is_null($activityExecution)) { //invalid choice of activity execution: $this->activityExecution = null; // $invalidActivity = new core_kernel_classes_Resource($activityUri); // throw new wfEngine_models_classes_ProcessExecutionException("invalid choice of activity definition in process browser {$invalidActivity->getLabel()} ({$invalidActivity->getUri()}). \n<br/> The link may be outdated."); $this->autoredirectToIndex(); return; } } else { if (count($currentlyAvailableActivityExecutions) == 1) { $activityExecution = $this->processExecutionService->initCurrentActivityExecution($this->processExecution, reset($currentlyAvailableActivityExecutions), $currentUser); if (is_null($activityExecution)) { throw new wfEngine_models_classes_ProcessExecutionException('cannot initiate the activity execution of the unique next activity definition'); } } else { //count > 1: //parallel branch, ask the user to select activity to execute: common_Logger::i('Ask the user to select activity'); $this->pause(); return; } } } if (!is_null($activityExecution)) { $this->activityExecution = $activityExecution; $browserViewData[''] = $this->processExecution->getUri(); $browserViewData['activityExecutionUri'] = $activityExecution->getUri(); $this->activityExecutionService->createNonce($this->activityExecution); $browserViewData['activityExecutionNonce'] = $this->activityExecutionService->getNonce($activityExecution); //get interactive services (call of services): $activityDefinition = $this->activityExecutionService->getExecutionOf($activityExecution); $interactiveServices = $activityService->getInteractiveServices($activityDefinition); $services = array(); foreach ($interactiveServices as $interactiveService) { $serviceCallModel = tao_models_classes_service_ServiceCall::fromResource($interactiveService); $vars = $serviceCallModel->getRequiredVariables(); $parameters = array(); foreach ($vars as $variable) { $key = (string) $variable->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_PROCESSVARIABLES_CODE)); $value = $activityExecution->getOnePropertyValue(new core_kernel_classes_Property($variable)); if ($value instanceof core_kernel_classes_Resource) { $parameters[$key] = $value->getUri(); } elseif ($value instanceof core_kernel_classes_Literal) { $parameters[$key] = (string) $value; } } $serviceCallId = $activityExecution->getUri() . (count($interactiveServices) == 1 ? '' : $interactiveService->getUri()); $jsServiceApi = tao_helpers_ServiceJavascripts::getServiceApi($serviceCallModel, $serviceCallId, $parameters); $services[] = array('style' => $interactiveServiceService->getStyle($interactiveService), 'api' => $jsServiceApi); } $this->setData('services', $services); //set activity control: $controls = $activityService->getControls($activityDefinition); $browserViewData['controls'] = array('backward' => isset($controls[INSTANCE_CONTROL_BACKWARD]) ? (bool) $controls[INSTANCE_CONTROL_BACKWARD] : false, 'forward' => isset($controls[INSTANCE_CONTROL_FORWARD]) ? (bool) $controls[INSTANCE_CONTROL_FORWARD] : false); // If paused, resume it: if ($this->processExecutionService->isFinished($this->processExecution)) { $this->processExecutionService->resume($this->processExecution); } //get process definition: $processDefinition = $this->processExecutionService->getExecutionOf($this->processExecution); // Browser view main data. $browserViewData['processLabel'] = $processDefinition->getLabel(); $browserViewData['processExecutionLabel'] = $this->processExecution->getLabel(); $browserViewData['activityLabel'] = $activityDefinition->getLabel(); $browserViewData['processUri'] = $this->processExecution->getUri(); $browserViewData['active_Resource'] = "'" . $activityDefinition->getUri() . "'"; $browserViewData['isInteractiveService'] = true; $this->setData('browserViewData', $browserViewData); $this->setData('activity', $activityDefinition); /* <DEBUG> :populate the debug widget */ if (DEBUG_MODE) { $this->setData('debugWidget', DEBUG_MODE); $servicesResources = array(); foreach ($services as $service) { $servicesResource = $service; $servicesResource['input'] = $interactiveServiceService->getInputValues($interactiveService, $activityExecution); $servicesResource['output'] = $interactiveServiceService->getOutputValues($interactiveService, $activityExecution); $servicesResources[] = $servicesResource; } $variableService = wfEngine_models_classes_VariableService::singleton(); $this->setData('debugData', array('Activity' => $activityDefinition, 'ActivityExecution' => $activityExecution, 'CurrentActivities' => $currentlyAvailableActivityExecutions, 'Services' => $servicesResources, 'VariableStack' => $variableService->getAll())); } /* </DEBUG> */ $this->setData('activityExecutionUri', $browserViewData['activityExecutionUri']); $this->setData('processUri', $browserViewData['processUri']); $this->setData('activityExecutionNonce', $browserViewData['activityExecutionNonce']); $this->setData('client_config_url', $this->getClientConfigUrl()); $this->setView('process_browser.tpl'); } }
public function runDeliveryExecution() { $deliveryExecution = $this->getCurrentDeliveryExecution(); if ($deliveryExecution->getState()->getUri() != INSTANCE_DELIVERYEXEC_ACTIVE) { $this->redirect($this->getReturnUrl()); } $userUri = common_session_SessionManager::getSession()->getUserUri(); if ($deliveryExecution->getUserIdentifier() != $userUri) { throw new common_exception_Error('User ' . $userUri . ' is not the owner of the execution ' . $deliveryExecution->getIdentifier()); } $compiledDelivery = $deliveryExecution->getDelivery(); $this->initResultServer($compiledDelivery, $deliveryExecution->getIdentifier()); $runtime = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRuntime($compiledDelivery); $this->setData('serviceApi', tao_helpers_ServiceJavascripts::getServiceApi($runtime, $deliveryExecution->getIdentifier())); $this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel()); $this->setData('deliveryExecution', $deliveryExecution->getIdentifier()); $this->setData('showControls', $this->showControls()); $this->setData('client_config_url', $this->getClientConfigUrl()); $this->setData('client_timeout', $this->getClientTimeout()); $this->setView('runtime/deliveryExecution.tpl', 'taoDelivery'); }
/** * @inheritDoc */ protected function init() { $delivery = $this->deliveryExecution->getDelivery(); $runtime = ServiceManager::getServiceManager()->get(AssignmentService::CONFIG_ID)->getRuntime($delivery); $this->setData('serviceApi', \tao_helpers_ServiceJavascripts::getServiceApi($runtime, $this->deliveryExecution->getIdentifier())); }