_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q244300 | QtiRunnerServiceContext.selectAdaptiveNextItem | validation | public function selectAdaptiveNextItem()
{
$lastItemId = $this->getCurrentCatItemId();
$lastOutput = $this->getLastCatItemOutput();
$catSession = $this->getCatSession();
$preSelection = $catSession->getTestMap();
try {
if (!$this->syncingMode) {
$selection = $catSession->getTestMap(array_values($lastOutput));
if (!$this->saveAdaptiveResults($catSession)) {
\common_Logger::w('Unable to save CatService results.');
}
$isShadowItem = false;
} else {
$selection = $catSession->getTestMap();
$isShadowItem = true;
}
} catch (CatEngineException $e) {
\common_Logger::e('Error during CatEngine processing. ' . $e->getMessage());
$selection = $catSession->getTestMap();
$isShadowItem = true;
}
$event = new SelectAdaptiveNextItemEvent($this->getTestSession(), $lastItemId, $preSelection, $selection, $isShadowItem);
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
$this->persistCatSession($catSession);
if (is_array($selection) && count($selection) > 0) {
\common_Logger::d("New CAT item selection is '" . implode(', ', $selection) . "'.");
return $selection[0];
} else {
\common_Logger::d('No new CAT item selection.');
return null;
}
} | php | {
"resource": ""
} |
q244301 | QtiRunnerServiceContext.getCurrentAssessmentItemRef | validation | public function getCurrentAssessmentItemRef()
{
if ($this->isAdaptive()) {
return $this->getServiceManager()->get(CatService::SERVICE_ID)->getAssessmentItemRefByIdentifier(
$this->getCompilationDirectory()['private'],
$this->getCurrentCatItemId()
);
} else {
return $this->getTestSession()->getCurrentAssessmentItemRef();
}
} | php | {
"resource": ""
} |
q244302 | QtiRunnerServiceContext.getCurrentPosition | validation | public function getCurrentPosition()
{
$route = $this->getTestSession()->getRoute();
$routeCount = $route->count();
$routeItemPosition = $route->getPosition();
$currentRouteItem = $route->getRouteItemAt($routeItemPosition);
$finalPosition = 0;
for ($i = 0; $i < $routeCount; $i++) {
$routeItem = $route->getRouteItemAt($i);
if ($routeItem !== $currentRouteItem) {
if (!$this->isAdaptive($routeItem->getAssessmentItemRef())) {
$finalPosition++;
} else {
$finalPosition += count($this->getShadowTest($routeItem));
}
} else {
if ($this->isAdaptive($routeItem->getAssessmentItemRef())) {
$finalPosition += array_search(
$this->getCurrentCatItemId($routeItem),
$this->getShadowTest($routeItem)
);
}
break;
}
}
return $finalPosition;
} | php | {
"resource": ""
} |
q244303 | QtiRunnerServiceContext.canMoveBackward | validation | public function canMoveBackward()
{
$moveBack = false;
$session = $this->getTestSession();
if ($this->isAdaptive()) {
$positionInCatSession = array_search(
$this->getCurrentCatItemId(),
$this->getShadowTest()
);
if ($positionInCatSession === 0) {
// First item in cat section.
if ($session->getRoute()->getPosition() !== 0) {
$moveBack = $session->getPreviousRouteItem()->getTestPart()->getNavigationMode() === NavigationMode::NONLINEAR;
}
} else {
$moveBack = $session->getRoute()->current()->getTestPart()->getNavigationMode() === NavigationMode::NONLINEAR;
}
} else {
$moveBack = $session->canMoveBackward();
//check also if the sectionPause prevents you from moving backward
if($moveBack){
$moveBack = $this->getServiceManager()->get(SectionPauseService::SERVICE_ID)->canMoveBackward($session);
}
}
return $moveBack;
} | php | {
"resource": ""
} |
q244304 | QtiRunnerServiceContext.saveAdaptiveResults | validation | protected function saveAdaptiveResults(CatSession $catSession)
{
$testResult = $catSession->getTestResult();
$testResult = empty($testResult) ? [] : [$testResult];
return $this->storeResult(array_merge($testResult, $catSession->getItemResults()));
} | php | {
"resource": ""
} |
q244305 | QtiRunnerServiceContext.storeResult | validation | protected function storeResult(array $results)
{
/** @var QtiRunnerService $runnerService */
$runnerService = $this->getServiceLocator()->get(QtiRunnerService::SERVICE_ID);
$success = true;
try {
foreach ($results as $result) {
if (!$result instanceof AbstractResult) {
throw new \common_Exception(__FUNCTION__ . ' requires a CAT result to store it.');
}
$variables = $this->convertCatVariables($result->getVariables());
if (empty($variables)) {
\common_Logger::t('No Cat result variables to store.');
continue;
}
if ($result instanceof ItemResult) {
$itemId = $result->getItemRefId();
$itemUri = $this->getItemUriFromRefId($itemId);
} else {
$itemUri = $itemId = null;
$sectionId = $this
->getTestSession()
->getRoute()
->current()
->getAssessmentSection()
->getIdentifier();
/** @var \taoResultServer_models_classes_Variable $variable */
foreach ($variables as $variable) {
$variable->setIdentifier($sectionId . '-' . $variable->getIdentifier());
}
}
if (!$runnerService->storeVariables($this, $itemUri, $variables, $itemId)) {
$success = false;
}
}
} catch (\Exception $e) {
\common_Logger::w('An error has occurred during CAT result storing: ' . $e->getMessage());
$success = false;
}
return $success;
} | php | {
"resource": ""
} |
q244306 | QtiRunnerServiceContext.convertCatVariables | validation | protected function convertCatVariables(array $variables)
{
/** @var QtiRunnerService $runnerService */
$runnerService = $this->getServiceLocator()->get(QtiRunnerService::SERVICE_ID);
$convertedVariables = [];
foreach ($variables as $variable) {
switch ($variable->getVariableType()) {
case ResultVariable::TRACE_VARIABLE:
$getVariableMethod = 'getTraceVariable';
break;
case ResultVariable::RESPONSE_VARIABLE:
$getVariableMethod = 'getResponseVariable';
break;
case ResultVariable::OUTCOME_VARIABLE:
$getVariableMethod = 'getOutcomeVariable';
break;
case ResultVariable::TEMPLATE_VARIABLE:
default:
$getVariableMethod = null;
break;
}
if (is_null($getVariableMethod)) {
\common_Logger::w('Variable of type ' . $variable->getVariableType(). ' is not implemented in ' . __METHOD__);
throw new \common_exception_NotImplemented();
}
$convertedVariables[] = call_user_func_array(
array($runnerService, $getVariableMethod), array($variable->getId(), $variable->getValue())
);
}
return $convertedVariables;
} | php | {
"resource": ""
} |
q244307 | SyncChannel.process | validation | public function process(QtiRunnerServiceContext $context, array $data = [])
{
return $this->getServiceManager()->get(SynchronisationService::SERVICE_ID)->process($data, $context);
} | php | {
"resource": ""
} |
q244308 | Move.process | validation | public function process()
{
$this->validate();
$ref = ($this->getRequestParameter('ref') === false) ? null : $this->getRequestParameter('ref');
$direction = $this->getRequestParameter('direction');
$scope = $this->getRequestParameter('scope');
$start = ($this->getRequestParameter('start') !== false);
try {
/** @var QtiRunnerServiceContext $serviceContext */
$serviceContext = $this->getServiceContext();
$this->saveToolStates();
if (!$this->getRunnerService()->isTerminated($serviceContext)) {
$this->endItemTimer($this->getTime());
$this->saveItemState();
}
$this->initServiceContext();
$this->saveItemResponses(false);
if ($this->getRequestParameter('offline') === true) {
$this->setOffline();
}
$serviceContext->getTestSession()->initItemTimer($this->getTime());
$result = $this->getRunnerService()->move($serviceContext, $direction, $scope, $ref);
$response = [
'success' => $result,
];
if ($result) {
$response['testContext'] = $this->getRunnerService()->getTestContext($serviceContext);
if ($serviceContext->containsAdaptive()) {
// Force map update.
$response['testMap'] = $this->getRunnerService()->getTestMap($serviceContext, true);
}
}
common_Logger::d('Test session state : ' . $serviceContext->getTestSession()->getState());
if ($start === true) {
// start the timer only when move starts the item session
// and after context build to avoid timing error
$this->getRunnerService()->startTimer($serviceContext, $this->getTime());
}
} catch (Exception $e) {
common_Logger::e($e->getMessage());
$response = $this->getErrorResponse($e);
}
return $response;
} | php | {
"resource": ""
} |
q244309 | RunnerParamParserTrait.initServiceContext | validation | protected function initServiceContext()
{
$serviceContext = $this->getServiceContext();
$this->getRunnerService()->check($serviceContext);
return $serviceContext->init();
} | php | {
"resource": ""
} |
q244310 | RunnerParamParserTrait.endItemTimer | validation | protected function endItemTimer($timestamp = null)
{
if($this->getRequestParameter('itemDuration')){
$serviceContext = $this->getServiceContext();
$itemDuration = $this->getRequestParameter('itemDuration');
return $this->getRunnerService()->endTimer($serviceContext, $itemDuration, $timestamp);
}
return false;
} | php | {
"resource": ""
} |
q244311 | RunnerParamParserTrait.saveItemState | validation | protected function saveItemState()
{
if ($this->getRequestParameter('itemDefinition') && $this->getRequestParameter('itemState')) {
$serviceContext = $this->getServiceContext();
$itemIdentifier = $this->getRequestParameter('itemDefinition');
$state = $this->getRequestParameter('itemState') ? json_decode($this->getRequestParameter('itemState'), true) : new \stdClass();
return $this->getRunnerService()->setItemState($serviceContext, $itemIdentifier, $state);
}
return false;
} | php | {
"resource": ""
} |
q244312 | RunnerParamParserTrait.saveItemResponses | validation | protected function saveItemResponses($emptyAllowed = true)
{
if ($this->getRequestParameter('itemDefinition') && $this->getRequestParameter('itemResponse')) {
$itemDefinition = $this->getRequestParameter('itemDefinition');
$serviceContext = $this->getServiceContext();
$itemResponse = $this->getRequestParameter('itemResponse')
? json_decode($this->getRequestParameter('itemResponse'), true)
: null;
if (!is_null($itemResponse) && !empty($itemDefinition)) {
$responses = $this
->getRunnerService()
->parsesItemResponse($serviceContext, $itemDefinition, $itemResponse);
//still verify allowSkipping & empty responses
if (
!$emptyAllowed
&& $this->getRunnerService()->getTestConfig()->getConfigValue('enableAllowSkipping')
&& !TestRunnerUtils::doesAllowSkipping($serviceContext->getTestSession())) {
if ($this->getRunnerService()->emptyResponse($serviceContext, $responses)) {
throw new QtiRunnerEmptyResponsesException();
}
}
return $this->getRunnerService()->storeItemResponse($serviceContext, $itemDefinition, $responses);
}
}
return false;
} | php | {
"resource": ""
} |
q244313 | RunnerParamParserTrait.getItemRef | validation | protected function getItemRef($itemIdentifier)
{
$serviceContext = $this->getServiceContext();
/** @var QtiRunnerMap $mapService */
$mapService = $this->getServiceLocator()->get(QtiRunnerMap::SERVICE_ID);
return $mapService->getItemHref($serviceContext, $itemIdentifier);
} | php | {
"resource": ""
} |
q244314 | Timeout.process | validation | public function process()
{
$this->validate();
$ref = $this->getRequestParameter('ref') ?: null;
$scope = $this->getRequestParameter('scope');
$start = ($this->getRequestParameter('start') !== false);
try {
$serviceContext = $this->getServiceContext();
$this->saveToolStates();
if (!$this->getRunnerService()->isTerminated($serviceContext)) {
$this->endItemTimer($this->getTime());
$this->saveItemState();
}
$this->initServiceContext();
$this->saveItemResponses();
if ($this->getRequestParameter('offline') === true) {
$this->setOffline();
}
$result = $this->getRunnerService()->timeout($serviceContext, $scope, $ref);
$response = [
'success' => $result,
];
if ($result) {
$response['testContext'] = $this->getRunnerService()->getTestContext($serviceContext);
if ($serviceContext->containsAdaptive()) {
// Force map update.
$response['testMap'] = $this->getRunnerService()->getTestMap($serviceContext, true);
}
}
if ($start == true) {
// start the timer only when move starts the item session
// and after context build to avoid timing error
$this->getRunnerService()->startTimer($serviceContext, $this->getTime());
}
} catch (Exception $e) {
$response = $this->getErrorResponse($e);
}
return $response;
} | php | {
"resource": ""
} |
q244315 | QtiRunnerRubric.getRubrics | validation | public function getRubrics(RunnerServiceContext $context, AssessmentItemRef $itemRef = null)
{
/* @var AssessmentTestSession $session */
$session = $context->getTestSession();
$routeItem = null;
if (!is_null($itemRef)) {
try {
$routeItem = $session->getRoute()->getRouteItemsByAssessmentItemRef($itemRef);
if ($routeItem) {
$routeItem = $routeItem[0];
}
} catch (OutOfBoundsException $obe) {
\common_Logger::d("Could not retrieve the route for item '${itemRef}'.");
}
} else {
$routeItem = $session->getRoute()->current();
}
return implode('', $this->getRubricBlock($routeItem, $session, $context->getCompilationDirectory()));
} | php | {
"resource": ""
} |
q244316 | Pause.process | validation | public function process()
{
$this->validate();
try {
$serviceContext = $this->getServiceContext();
$this->saveToolStates();
if ($this->getRequestParameter('offline') === true) {
$this->setOffline();
}
$result = $this->getRunnerService()->pause($serviceContext);
$response = [
'success' => $result
];
} catch (Exception $e) {
$response = $this->getErrorResponse($e);
}
return $response;
} | php | {
"resource": ""
} |
q244317 | QtiCommunicationService.processInput | validation | public function processInput(QtiRunnerServiceContext $context, array $input)
{
$responses = [];
foreach ($input as $data) {
if (!is_array($data) || !isset($data['channel']) || !isset($data['message'])) {
throw new \common_exception_InconsistentData('Wrong message chunk received by the bidirectional communication service: either channel or message content is missing!');
}
if ($this->hasChannel($data['channel'], self::CHANNEL_TYPE_INPUT)) {
$channel = $this->getChannel($data['channel'], self::CHANNEL_TYPE_INPUT);
// known channel, forward...
$responses[] = $this->processChannel($channel, $context, $data['message']);
} else {
// unknown channel, fallback!
$responses[] = $this->fallback($data['channel'], $context, $data['message']);
}
}
return $responses;
} | php | {
"resource": ""
} |
q244318 | QtiCommunicationService.processOutput | validation | public function processOutput(QtiRunnerServiceContext $context)
{
$messages = [];
$channels = $this->getOption(self::OPTION_CHANNELS);
if (is_array($channels[self::CHANNEL_TYPE_OUTPUT])) {
foreach ($channels[self::CHANNEL_TYPE_OUTPUT] as $outputChannelName => $outputChannelClass) {
$channel = $this->getChannel($outputChannelName, self::CHANNEL_TYPE_OUTPUT);
$message = $this->processChannel($channel, $context);
if ($message !== null) {
$messages[] = [
'channel' => $channel->getName(),
'message' => $message,
];
}
}
}
return $messages;
} | php | {
"resource": ""
} |
q244319 | QtiCommunicationService.hasChannel | validation | protected function hasChannel($channelName, $channelType)
{
$channels = $this->getOption(self::OPTION_CHANNELS);
return isset($channels[$channelType][$channelName]);
} | php | {
"resource": ""
} |
q244320 | CatUtils.getCatInfo | validation | public static function getCatInfo(AssessmentTest $test, $namespace = '')
{
if ($namespace === '') {
$namespace = CatService::QTI_2X_ADAPTIVE_XML_NAMESPACE;
}
$info = [];
foreach ($test->getComponentsByClassName('assessmentSection') as $assessmentSection) {
if (($selection = $assessmentSection->getSelection()) !== null && (($xmlExtension = $selection->getXml())) !== null) {
$xpath = new \DOMXPath($xmlExtension);
$xpath->registerNamespace('ais', $namespace);
// Reference QTI assessmentSection identifier.
$sectionIdentifier = $assessmentSection->getIdentifier();
$sectionInfo = [];
// Get the adaptiveEngineRef.
foreach ($xpath->query('.//ais:adaptiveItemSelection/ais:adaptiveEngineRef', $xmlExtension) as $adaptiveEngineRef) {
$sectionInfo['adaptiveEngineRef'] = $adaptiveEngineRef->getAttribute('href');
}
// Get the adaptiveSettingsRef.
foreach ($xpath->query('.//ais:adaptiveItemSelection/ais:adaptiveSettingsRef', $xmlExtension) as $adaptiveSettingsRef) {
$sectionInfo['adaptiveSettingsRef'] = $adaptiveSettingsRef->getAttribute('href');
}
// Get the qtiUsagedataRef.
foreach ($xpath->query('.//ais:adaptiveItemSelection/ais:qtiUsagedataRef', $xmlExtension) as $qtiUsagedataRef) {
$sectionInfo['qtiUsagedataRef'] = $qtiUsagedataRef->getAttribute('href');
}
// Get the qtiUsagedataRef.
foreach ($xpath->query('.//ais:adaptiveItemSelection/ais:qtiMetadataRef', $xmlExtension) as $qtiMetadataRef) {
$sectionInfo['qtiMetadataRef'] = $qtiMetadataRef->getAttribute('href');
}
if (!empty($sectionInfo)) {
$info[$sectionIdentifier] = $sectionInfo;
}
}
}
return $info;
} | php | {
"resource": ""
} |
q244321 | CatUtils.isAssessmentSectionAdaptive | validation | public static function isAssessmentSectionAdaptive(AssessmentSection $section, $namespace = '')
{
if ($namespace === '') {
$namespace = CatService::QTI_2X_ADAPTIVE_XML_NAMESPACE;
}
$isAdaptive = false;
if (($selection = $section->getSelection()) !== null && (($xmlExtension = $selection->getXml())) !== null)
{
$xpath = new \DOMXPath($xmlExtension);
$xpath->registerNamespace('ais', $namespace);
if ($xpath->query('.//ais:adaptiveItemSelection', $xmlExtension)->length > 0) {
$isAdaptive = true;
}
}
return $isAdaptive;
} | php | {
"resource": ""
} |
q244322 | QtiRunnerConfig.buildOptions | validation | protected function buildOptions(RunnerServiceContext $context)
{
$session = $context->getTestSession();
// Comment allowed? Skipping allowed? Logout or Exit allowed ?
$options = [
'allowComment' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowComment($session),
'allowSkipping' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowSkipping($session),
'exitButton' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowExit($session, $context),
'logoutButton' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowLogout($session),
'validateResponses' => \taoQtiTest_helpers_TestRunnerUtils::doesValidateResponses($session),
'sectionPause' => $this->getServiceManager()->get(SectionPauseService::SERVICE_ID)->couldBePaused($session)
];
// get the options from the categories owned by the current item
$categories = $this->getCategories($context);
$prefixCategory = 'x-tao-option-';
$prefixCategoryLen = strlen($prefixCategory);
foreach ($categories as $category) {
if (!strncmp($category, $prefixCategory, $prefixCategoryLen)) {
// extract the option name from the category, transform to camelCase if needed
$optionName = lcfirst(str_replace(' ', '', ucwords(strtr(substr($category, $prefixCategoryLen), ['-' => ' ', '_' => ' ']))));
// the options added by the categories are just flags
$options[$optionName] = true;
}
}
return $options;
} | php | {
"resource": ""
} |
q244323 | CatService.getEngine | validation | public function getEngine($endpoint)
{
if ($this->isInitialCall == true) {
$endpointCached = $endpoint . '-init';
} else {
$endpointCached = $endpoint;
}
if (!isset($this->engines[$endpointCached])) {
$endPoints = $this->getOption(self::OPTION_ENGINE_ENDPOINTS);
if (!empty($endPoints[$endpoint])) {
$engineOptions = $endPoints[$endpoint];
$class = $engineOptions[self::OPTION_ENGINE_CLASS];
$args = $engineOptions[self::OPTION_ENGINE_ARGS];
$args = $this->alterTimeoutCallValue($args);
$url = isset($engineOptions[self::OPTION_ENGINE_URL])
? $engineOptions[self::OPTION_ENGINE_URL]
: $endpoint;
array_unshift($args, $endpoint);
try {
$this->engines[$endpointCached] = new $class($url, $this->getCatEngineVersion($args), $this->getCatEngineClient($args));
} catch (\Exception $e) {
\common_Logger::e('Fail to connect to CAT endpoint : ' . $e->getMessage());
throw new CatEngineNotFoundException('CAT Engine for endpoint "' . $endpoint . '" is misconfigured.', $endpoint, 0, $e);
}
}
}
if (empty($this->engines[$endpointCached])) {
// No configured endpoint found.
throw new CatEngineNotFoundException("CAT Engine for endpoint '${endpoint}' is not configured.", $endpoint);
}
return $this->engines[$endpointCached];
} | php | {
"resource": ""
} |
q244324 | CatService.getAssessmentItemRefByIdentifier | validation | public function getAssessmentItemRefByIdentifier(\tao_models_classes_service_StorageDirectory $privateCompilationDirectory, $identifier)
{
$compilationDataService = $this->getServiceLocator()->get(CompilationDataService::SERVICE_ID);
$filename = "adaptive-assessment-item-ref-${identifier}";
return $compilationDataService->readPhpCompilationData(
$privateCompilationDirectory,
"${filename}.php",
"${filename}"
);
} | php | {
"resource": ""
} |
q244325 | CatService.getAssessmentItemRefByIdentifiers | validation | public function getAssessmentItemRefByIdentifiers(\tao_models_classes_service_StorageDirectory $privateCompilationDirectory, array $identifiers)
{
$assessmentItemRefs = [];
foreach ($identifiers as $identifier) {
$assessmentItemRefs[] = $this->getAssessmentItemRefByIdentifier($privateCompilationDirectory, $identifier);
}
return $assessmentItemRefs;
} | php | {
"resource": ""
} |
q244326 | CatService.getAssessmentItemRefsByPlaceholder | validation | public function getAssessmentItemRefsByPlaceholder(\tao_models_classes_service_StorageDirectory $privateCompilationDirectory, AssessmentItemRef $placeholder)
{
$urlinfo = parse_url($placeholder->getHref());
$adaptiveSectionId = ltrim($urlinfo['path'], '/');
$compilationDataService = $this->getServiceLocator()->get(CompilationDataService::SERVICE_ID);
$filename = "adaptive-assessment-section-${adaptiveSectionId}";
$component = $compilationDataService->readPhpCompilationData(
$privateCompilationDirectory,
"${filename}.php",
$filename
);
return $component->getComponentsByClassName('assessmentItemRef')->getArrayCopy();
} | php | {
"resource": ""
} |
q244327 | CatService.getAdaptiveAssessmentSectionInfo | validation | public function getAdaptiveAssessmentSectionInfo(AssessmentTest $test, \tao_models_classes_service_StorageDirectory $compilationDirectory, $basePath, $qtiAssessmentSectionIdentifier)
{
$info = CatUtils::getCatInfo($test);
$adaptiveInfo = [
'qtiSectionIdentifier' => $qtiAssessmentSectionIdentifier,
'adaptiveSectionIdentifier' => false,
'adaptiveEngineRef' => false
];
if (isset($info[$qtiAssessmentSectionIdentifier])) {
if (isset($info[$qtiAssessmentSectionIdentifier]['adaptiveEngineRef'])) {
$adaptiveInfo['adaptiveEngineRef'] = $info[$qtiAssessmentSectionIdentifier]['adaptiveEngineRef'];
}
if (isset($info[$qtiAssessmentSectionIdentifier]['adaptiveSettingsRef'])) {
$adaptiveInfo['adaptiveSectionIdentifier'] = trim($compilationDirectory->read("./${basePath}/" . $info[$qtiAssessmentSectionIdentifier]['adaptiveSettingsRef']));
}
}
return (!isset($info[$qtiAssessmentSectionIdentifier]['adaptiveEngineRef']) || !isset($info[$qtiAssessmentSectionIdentifier]['adaptiveSettingsRef'])) ? false : $adaptiveInfo;
} | php | {
"resource": ""
} |
q244328 | CatService.validateAdaptiveAssessmentSection | validation | public function validateAdaptiveAssessmentSection(SectionPartCollection $sectionsParts, $ref, $testAdminId)
{
$engine = $this->getEngine($ref);
$adaptSection = $engine->setupSection($testAdminId);
//todo: remove this checking if tests/{getSectionId}/items will become a part of standard.
if (method_exists($adaptSection, 'getItemReferences')) {
$itemReferences = $adaptSection->getItemReferences();
$dependencies = $sectionsParts->getKeys();
if ($catDiff = array_diff($dependencies, $itemReferences)) {
throw new AdaptiveSectionInjectionException('Missed some CAT service items: '. implode(', ', $catDiff), $catDiff);
}
if ($packageDiff = array_diff($dependencies, $itemReferences)) {
throw new AdaptiveSectionInjectionException('Missed some package items: '. implode(', ', $packageDiff), $packageDiff);
}
}
} | php | {
"resource": ""
} |
q244329 | CatService.isAssessmentSectionAdaptive | validation | public function isAssessmentSectionAdaptive(AssessmentSection $section)
{
$assessmentItemRefs = $section->getComponentsByClassName('assessmentItemRef');
return count($assessmentItemRefs) === 1 && $this->isAdaptivePlaceholder($assessmentItemRefs[0]);
} | php | {
"resource": ""
} |
q244330 | CatService.alterTimeoutCallValue | validation | protected function alterTimeoutCallValue(array $options)
{
$timeoutValue = null;
if ($this->isInitialCall === true) {
if ($this->hasOption(self::OPTION_INITIAL_CALL_TIMEOUT)) {
$timeoutValue = $this->getOption(self::OPTION_INITIAL_CALL_TIMEOUT);
}
} else {
if ($this->hasOption(self::OPTION_NEXT_ITEM_CALL_TIMEOUT)) {
$timeoutValue = $this->getOption(self::OPTION_NEXT_ITEM_CALL_TIMEOUT);
}
}
if (!is_null($timeoutValue)) {
$options[self::OPTION_ENGINE_CLIENT]['options']['http_client_options']['timeout'] = $timeoutValue;
}
return $options;
} | php | {
"resource": ""
} |
q244331 | StoreTraceData.process | validation | public function process()
{
$this->validate();
$itemRef = $this->hasRequestParameter('itemDefinition')
? $this->getItemRef($this->getRequestParameter('itemDefinition'))
: null;
$traceData = json_decode(html_entity_decode($this->getRequestParameter('traceData')), true);
try {
$serviceContext = $this->getServiceContext();
$stored = 0;
$size = count($traceData);
foreach ($traceData as $variableIdentifier => $variableValue) {
if ($this
->getRunnerService()
->storeTraceVariable($serviceContext, $itemRef, $variableIdentifier, $variableValue)
) {
$stored++;
}
}
$response = [
'success' => $stored == $size
];
common_Logger::d('Stored "' . $stored . '/' . $size . '" trace variables');
/** @var EventManager $eventManager */
$eventManager = $this->getServiceLocator()->get(EventManager::SERVICE_ID);
$event = new TraceVariableStored($serviceContext->getTestSession()->getSessionId(), $traceData);
$eventManager->trigger($event);
} catch (Exception $e) {
$response = $this->getErrorResponse($e);
}
return $response;
} | php | {
"resource": ""
} |
q244332 | QtiTimeStorage.store | validation | public function store($data)
{
$this->cache[$this->testSessionId] = &$data;
$encodedData = $this->getStorageFormat()->encode($data);
$this->getStorageService()->set($this->getUserKey(), $this->getStorageKey(), $encodedData);
\common_Logger::d(sprintf('QtiTimer: Stored %d bytes into state storage', strlen($encodedData)));
return $this;
} | php | {
"resource": ""
} |
q244333 | QtiTimeStorage.load | validation | public function load()
{
if (!isset($this->cache[$this->testSessionId])) {
$encodedData = $this->getStorageService()->get($this->getUserKey(), $this->getStorageKey());
\common_Logger::d(sprintf('QtiTimer: Loaded %d bytes from state storage', strlen($encodedData)));
$this->cache[$this->testSessionId] = $this->getStorageFormat()->decode($encodedData);
}
return $this->cache[$this->testSessionId];
} | php | {
"resource": ""
} |
q244334 | SynchronisationService.process | validation | public function process($data, $serviceContext)
{
if (empty($data)) {
throw new \common_exception_InconsistentData('No action to check. Processing action requires data.');
}
// first, extract the actions and build usable instances
// also compute the total duration to synchronise
$actions = [];
$duration = 0;
foreach ($data as $entry) {
$action = $this->resolve($entry);
$actions[] = $action;
if ($action->hasRequestParameter('itemDuration')) {
$duration += $action->getRequestParameter('itemDuration') + self::TIMEPOINT_INTERVAL;
}
}
// determine the start timestamp of the actions:
// - check if the total duration of actions to sync is comprised within
// the elapsed time since the last TimePoint.
// - otherwise compute the start timestamp from now minus the duration
// (caution! this could introduce inconsistency in the TimeLine as the ranges could be interlaced)
$now = microtime(true);
$last = $serviceContext->getTestSession()->getTimer()->getLastRegisteredTimestamp();
$elapsed = $now - $last;
if ($duration > $elapsed) {
\common_Logger::t('Ignoring the last timestamp to take into account the actual duration to sync. Could introduce TimeLine inconsistency!');
$last = $now - $duration;
}
// ensure the actions are in chronological order
usort($actions, function($a, $b) {
return $a->getTimestamp() - $b->getTimestamp();
});
$response = [];
/** @var TestRunnerAction $action */
foreach( $actions as $action) {
try {
$serviceContext->setSyncingMode($action->getRequestParameter('offline'));
if ($action->hasRequestParameter('itemDuration') && $serviceContext->isSyncingMode()) {
$last += $action->getRequestParameter('itemDuration') + self::TIMEPOINT_INTERVAL;
$action->setTime($last);
} else {
$action->setTime($now);
}
$action->setServiceContext($serviceContext);
if ($serviceContext instanceof QtiRunnerServiceContext) {
}
$responseAction = $action->process();
} catch (\common_Exception $e) {
$responseAction = ['error' => $e->getMessage()];
$responseAction['success'] = false;
}
$responseAction['name'] = $action->getName();
$responseAction['timestamp'] = $action->getTimeStamp();
$responseAction['requestParameters'] = $action->getRequestParameters();
$response[] = $responseAction;
if ($responseAction['success'] === false) {
break;
}
}
$this->getRunnerService()->persist($serviceContext);
return $response;
} | php | {
"resource": ""
} |
q244335 | SynchronisationService.getAvailableActions | validation | public function getAvailableActions()
{
return is_array($this->getOption(self::ACTIONS_OPTION))
? $this->getOption(self::ACTIONS_OPTION)
: [];
} | php | {
"resource": ""
} |
q244336 | SynchronisationService.resolve | validation | protected function resolve($data)
{
if (!isset($data['action']) || !isset($data['timestamp']) || !isset($data['parameters']) || !is_array($data['parameters'])) {
throw new \common_exception_InconsistentData(
'Action parameters have to contain "action", "timestamp" and "parameters" fields.');
}
$availableActions = $this->getAvailableActions();
$actionName = $data['action'];
$actionClass = null;
// Search by key (e.q. key)
if (isset($availableActions[$actionName])) {
$actionClass = $availableActions[$actionName];
}
if (is_null($actionClass) || !is_a($actionClass, TestRunnerAction::class, true)) {
throw new \ResolverException('Action name "' . $actionName . '" could not be resolved.');
}
return $this->getServiceManager()->propagate(new $actionClass($actionName, $data['timestamp'], $data['parameters']));
} | php | {
"resource": ""
} |
q244337 | NextItemData.process | validation | public function process()
{
$this->validate();
$itemIdentifier = $this->hasRequestParameter('itemDefinition')
? $this->getRequestParameter('itemDefinition')
: null;
if (!is_array($itemIdentifier)) {
$itemIdentifier = [$itemIdentifier];
}
try {
if (!$this->getRunnerService()->getTestConfig()->getConfigValue('itemCaching.enabled')) {
common_Logger::w('Attempt to disclose the next items without the configuration');
throw new common_exception_Unauthorized();
}
$response = [];
foreach ($itemIdentifier as $itemId) {
//load item data
$response['items'][] = $this->getItemData($itemId);
}
if (isset($response['items'])) {
$response['success'] = true;
}
} catch (\Exception $e) {
$response = $this->getErrorResponse($e);
}
return $response;
} | php | {
"resource": ""
} |
q244338 | NextItemData.getItemData | validation | protected function getItemData($itemIdentifier)
{
$serviceContext = $this->getServiceContext();
$itemRef = $this->getRunnerService()->getItemHref($serviceContext, $itemIdentifier);
$itemData = $this->getRunnerService()->getItemData($serviceContext, $itemRef);
$baseUrl = $this->getRunnerService()->getItemPublicUrl($serviceContext, $itemRef);
$itemState = $this->getRunnerService()->getItemState($serviceContext, $itemIdentifier);
if ($itemState === null || !count($itemState)) {
$itemState = new stdClass();
}
return [
'baseUrl' => $baseUrl,
'itemData' => $itemData,
'itemState' => $itemState,
'itemIdentifier' => $itemIdentifier,
];
} | php | {
"resource": ""
} |
q244339 | QtiRunnerMessageService.getStateMessage | validation | public function getStateMessage($testSession)
{
if ($testSession instanceof AssessmentTestSession) {
switch ($testSession->getState()) {
case AssessmentTestSessionState::SUSPENDED:
return $this->getPausedStateMessage($testSession);
case AssessmentTestSessionState::CLOSED:
return $this->getTerminatedStateMessage($testSession);
case AssessmentTestSessionState::INITIAL:
return $this->getInitialStateMessage($testSession);
default:
return $this->getRunningStateMessages($testSession);
}
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerMessageService',
'getStateMessage',
0,
'qtism\runtime\tests\AssessmentTestSession',
$testSession
);
}
} | php | {
"resource": ""
} |
q244340 | OfflineQtiRunnerService.getItems | validation | public function getItems(RunnerServiceContext $serviceContext)
{
$this->getRunnerService()->assertQtiRunnerServiceContext($serviceContext);
$runnerService = $this->getRunnerService();
$testMap = $runnerService->getTestMap($serviceContext);
$items = [];
foreach ($this->getItemIdentifiersFromTestMap($testMap) as $itemIdentifier) {
$itemRef = $runnerService->getItemHref($serviceContext, $itemIdentifier);
/** @var QtiRunnerServiceContext $serviceContext */
$items[$itemIdentifier] = [
'baseUrl' => $runnerService->getItemPublicUrl($serviceContext, $itemRef),
'itemData' => $this->getItemData($serviceContext, $itemRef),
'itemState' => $runnerService->getItemState($serviceContext, $itemIdentifier),
'itemIdentifier' => $itemIdentifier,
'portableElements' => $runnerService->getItemPortableElements($serviceContext, $itemRef),
];
}
return $items;
} | php | {
"resource": ""
} |
q244341 | OfflineQtiRunnerService.getItemData | validation | private function getItemData(RunnerServiceContext $context, $itemRef)
{
$this->getRunnerService()->assertQtiRunnerServiceContext($context);
$itemData = $this->getRunnerService()->getItemData($context, $itemRef);
$itemDataVariable = $this->getRunnerService()->getItemVariableElementsData($context, $itemRef);
$responses = $itemData['data']['responses'];
foreach (array_keys($responses) as $responseId) {
if (array_key_exists($responseId, $itemDataVariable)) {
$itemData['data']['responses'][$responseId] = array_merge(...[
$responses[$responseId],
$itemDataVariable[$responseId],
]);
}
}
return $itemData;
} | php | {
"resource": ""
} |
q244342 | OfflineQtiRunnerService.getSubIdentifiersRecursively | validation | private function getSubIdentifiersRecursively($array, $identifiers)
{
$identifier = array_shift($identifiers);
if (count($identifiers) > 0) {
$result = [];
foreach ($array[$identifier] as $key => $value) {
$result[] = $this->getSubIdentifiersRecursively(
$array[$identifier][$key],
$identifiers
);
}
return array_merge(...$result);
}
return array_keys($array[$identifier]);
} | php | {
"resource": ""
} |
q244343 | ExtendedState.getStorage | validation | public function getStorage()
{
if (!$this->storage) {
$this->storage = $this->getServiceLocator()->get(StorageManager::SERVICE_ID);
}
return $this->storage;
} | php | {
"resource": ""
} |
q244344 | ExtendedState.load | validation | public function load()
{
$storage = $this->getStorage();
if ($storage) {
$data = $storage->get($this->userId, $this->getStorageKey());
if ($data) {
$this->state = json_decode($data, true);
} else {
$this->state = [];
}
$success = is_array($this->state);
} else {
$success = false;
}
return $success;
} | php | {
"resource": ""
} |
q244345 | ExtendedState.save | validation | public function save()
{
$storage = $this->getStorage();
if ($storage) {
$success = $storage->set($this->userId, $this->getStorageKey(), json_encode($this->state));
} else {
$success = false;
}
return $success;
} | php | {
"resource": ""
} |
q244346 | ExtendedState.getStoreId | validation | public function getStoreId()
{
return isset($this->state[self::VAR_STORE_ID]) ? $this->state[self::VAR_STORE_ID] : false;
} | php | {
"resource": ""
} |
q244347 | ExtendedState.getEvents | validation | public function getEvents()
{
if (isset($this->state[self::VAR_EVENTS_QUEUE])) {
$events = $this->state[self::VAR_EVENTS_QUEUE];
} else {
$events = [];
}
return $events;
} | php | {
"resource": ""
} |
q244348 | ExtendedState.getItemHrefIndex | validation | public function getItemHrefIndex()
{
if (isset($this->state[self::VAR_HREF_INDEX])) {
$table = $this->state[self::VAR_HREF_INDEX];
} else {
$table = [];
}
return $table;
} | php | {
"resource": ""
} |
q244349 | ExtendedState.setCatValue | validation | public function setCatValue($assessmentSectionId, $key, $value)
{
$this->state[self::VAR_CAT][$assessmentSectionId][$key] = $value;
return $this;
} | php | {
"resource": ""
} |
q244350 | ExtendedState.getCatValue | validation | public function getCatValue($assessmentSectionId, $key)
{
return (isset($this->state[self::VAR_CAT]) && isset($this->state[self::VAR_CAT][$assessmentSectionId]) && isset($this->state[self::VAR_CAT][$assessmentSectionId][$key])) ? $this->state[self::VAR_CAT][$assessmentSectionId][$key] : null;
} | php | {
"resource": ""
} |
q244351 | ExtendedState.removeCatValue | validation | public function removeCatValue($assessmentSectionId, $key)
{
if (isset($this->state[self::VAR_CAT]) && isset($this->state[self::VAR_CAT][$assessmentSectionId]) && isset($this->state[self::VAR_CAT][$assessmentSectionId][$key])) {
unset($this->state[self::VAR_CAT][$assessmentSectionId][$key]);
}
return $this;
} | php | {
"resource": ""
} |
q244352 | ExtendedStateService.getStorageService | validation | public function getStorageService()
{
if (!$this->storageService) {
$this->storageService = $this->getServiceLocator()->get(StorageManager::SERVICE_ID);
}
return $this->storageService;
} | php | {
"resource": ""
} |
q244353 | ExtendedStateService.persist | validation | public function persist($testSessionId)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->save();
$this->getStorageService()->persist($extendedState->getUserId(), $extendedState->getStorageKey());
} | php | {
"resource": ""
} |
q244354 | ExtendedStateService.setStoreId | validation | public function setStoreId($testSessionId, $storeId)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->setStoreId($storeId);
$extendedState->save();
} | php | {
"resource": ""
} |
q244355 | ExtendedStateService.clearEvents | validation | public function clearEvents($testSessionId)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->clearEvents();
$extendedState->save();
} | php | {
"resource": ""
} |
q244356 | ExtendedStateService.storeItemHrefIndex | validation | public function storeItemHrefIndex($testSessionId, $table)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->setItemHrefIndex($table);
$extendedState->save();
} | php | {
"resource": ""
} |
q244357 | ExtendedStateService.setCatValue | validation | public function setCatValue($testSessionId, $assessmentSectionId, $key, $value)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->setCatValue($assessmentSectionId, $key, $value);
$extendedState->save();
} | php | {
"resource": ""
} |
q244358 | ExtendedStateService.getCatValue | validation | public function getCatValue($testSessionId, $assessmentSectionId, $key)
{
$extendedState = $this->getExtendedState($testSessionId);
return $extendedState->getCatValue($assessmentSectionId, $key);
} | php | {
"resource": ""
} |
q244359 | ExtendedStateService.removeCatValue | validation | public function removeCatValue($testSessionId, $assessmentSectionId, $key)
{
$extendedState = $this->getExtendedState($testSessionId);
$extendedState->removeCatValue($assessmentSectionId, $key);
$extendedState->save();
} | php | {
"resource": ""
} |
q244360 | QtiTimeLine.fromArray | validation | public function fromArray($data)
{
$this->points = [];
if (is_array($data)) {
foreach ($data as $dataPoint) {
$point = new TimePoint();
$point->fromArray($dataPoint);
$this->points[] = $point;
}
}
} | php | {
"resource": ""
} |
q244361 | QtiTimeLine.remove | validation | public function remove($tag, $target = TimePoint::TARGET_ALL, $type = TimePoint::TYPE_ALL)
{
$tags = is_array($tag) ? $tag : [$tag];
$removed = 0;
foreach ($this->points as $idx => $point) {
if ($point->match($tags, $target, $type)) {
unset($this->points[$idx]);
$removed++;
}
}
return $removed;
} | php | {
"resource": ""
} |
q244362 | QtiTimeLine.filter | validation | public function filter($tag = null, $target = TimePoint::TARGET_ALL, $type = TimePoint::TYPE_ALL)
{
// the tag criteria can be omitted
$tags = null;
if (isset($tag)) {
$tags = is_array($tag) ? $tag : [$tag];
}
// create a another instance of the same class
$subset = new static();
// fill the new instance with filtered TimePoint
foreach ($this->points as $idx => $point) {
if ($point->match($tags, $target, $type)) {
$subset->add($point);
}
}
return $subset;
} | php | {
"resource": ""
} |
q244363 | QtiTimeLine.find | validation | public function find($tag = null, $target = TimePoint::TARGET_ALL, $type = TimePoint::TYPE_ALL)
{
// the tag criteria can be omitted
$tags = null;
if (isset($tag)) {
$tags = is_array($tag) ? $tag : [$tag];
}
// gather filterer TimePoint
$points = [];
foreach ($this->points as $point) {
if ($point->match($tags, $target, $type)) {
$points [] = $point;
}
}
return $points;
} | php | {
"resource": ""
} |
q244364 | QtiTimeLine.computeRange | validation | protected function computeRange($range)
{
// a range must be built from pairs of TimePoint
if (count($range) % 2) {
throw new IncompleteRangeException();
}
$duration = 0;
$start = null;
$end = null;
foreach ($range as $point) {
// grab the START TimePoint
if ($this->isStartPoint($point)) {
// we cannot have the START TimePoint twice
if ($start) {
throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice START found.');
}
$start = $point;
}
// grab the END TimePoint
if ($this->isEndPoint($point)) {
// we cannot have the END TimePoint twice
if ($end) {
throw new MalformedRangeException('A time range must be defined by a START and a END TimePoint! Twice END found.');
}
$end = $point;
}
// when we have got START and END TimePoint, compute the duration
if ($start && $end) {
$duration += $this->getRangeDuration($start, $end);
$start = null;
$end = null;
}
}
return $duration;
} | php | {
"resource": ""
} |
q244365 | QtiTimeLine.fixRange | validation | protected function fixRange($range, $lastTimestamp = null)
{
$fixedRange = [];
$last = null;
$open = false;
foreach ($range as $point) {
if ($this->isStartPoint($point)) { // start of range
// the last range could be still open...
if ($last && $open) {
$fixedRange[] = $this->cloneTimePoint($point, TimePoint::TYPE_END);
}
$open = true;
} else if ($this->isEndPoint($point)) { // end of range
// this range could not be started...
if (!$open) {
$fixedRange[] = $this->cloneTimePoint($last ? $last : $point, TimePoint::TYPE_START);
}
$open = false;
}
$fixedRange[] = $point;
$last = $point;
}
// the last range could be still open...
if ($last && $open) {
$fixedRange[] = $this->cloneTimePoint($last, TimePoint::TYPE_END, $lastTimestamp);
}
return $fixedRange;
} | php | {
"resource": ""
} |
q244366 | QtiTimeLine.cloneTimePoint | validation | protected function cloneTimePoint(TimePoint $point, $type, $timestamp = null)
{
if (is_null($timestamp)) {
$timestamp = $point->getTimestamp();
}
\common_Logger::d("Create missing TimePoint at " . $timestamp);
return new TimePoint($point->getTags(), $timestamp, $type, $point->getTarget());
} | php | {
"resource": ""
} |
q244367 | QtiTimeLine.isStartPoint | validation | protected function isStartPoint(TimePoint $point)
{
return $point->match(null, TimePoint::TARGET_ALL, TimePoint::TYPE_START);
} | php | {
"resource": ""
} |
q244368 | QtiTimeLine.isEndPoint | validation | protected function isEndPoint(TimePoint $point)
{
return $point->match(null, TimePoint::TARGET_ALL, TimePoint::TYPE_END);
} | php | {
"resource": ""
} |
q244369 | QtiTimeLine.getRangeDuration | validation | protected function getRangeDuration($start, $end)
{
// the two TimePoint must have the same target to be consistent
if ($start->getTarget() != $end->getTarget()) {
throw new InconsistentRangeException('A time range must be defined by two TimePoint with the same target');
}
// the two TimePoint must be correctly ordered
$rangeDuration = $end->getTimestamp() - $start->getTimestamp();
if ($rangeDuration < 0) {
throw new InconsistentRangeException('A START TimePoint cannot take place after the END!');
}
return $rangeDuration;
} | php | {
"resource": ""
} |
q244370 | QtiRunnerService.loadItemData | validation | private function loadItemData($itemRef, $path)
{
$cacheKey = $itemRef . $path;
if(! empty($cacheKey) && isset($this->dataCache[$itemRef . $path])) {
return $this->dataCache[$itemRef . $path];
}
$directoryIds = explode('|', $itemRef);
if (count($directoryIds) < 3) {
if (is_scalar($itemRef)) {
$itemRefInfo = gettype($itemRef) . ': ' . strval($itemRef);
} elseif (is_object($itemRef)) {
$itemRefInfo = gettype($itemRef) . ': ' . get_class($itemRef);
} else {
$itemRefInfo = gettype($itemRef);
}
throw new \common_exception_InconsistentData("The itemRef (value = '${itemRefInfo}') is not formatted correctly.");
}
$itemUri = $directoryIds[0];
$userDataLang = \common_session_SessionManager::getSession()->getDataLanguage();
$directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[2]);
if ($directory->has($userDataLang))
{
$lang = $userDataLang;
} elseif ($directory->has(DEFAULT_LANG)) {
\common_Logger::d(
$userDataLang . ' is not part of compilation directory for item : ' . $itemUri . ' use ' . DEFAULT_LANG
);
$lang = DEFAULT_LANG;
} else {
throw new \common_Exception(
'item : ' . $itemUri . 'is neither compiled in ' . $userDataLang . ' nor in ' . DEFAULT_LANG
);
}
try {
$content = $directory->read($lang.DIRECTORY_SEPARATOR.$path);
/** @var ItemAssetsReplacement $assetService */
$assetService = $this->getServiceManager()->get(ItemAssetsReplacement::SERVICE_ID);
$jsonContent = json_decode($content, true);
$jsonAssets = [];
if(isset($jsonContent['assets'])){
foreach ($jsonContent['assets'] as $type => $assets){
foreach ($assets as $key => $asset){
$jsonAssets[$type][$key] = $assetService->postProcessAssets($asset);
}
}
$jsonContent["assets"] = $jsonAssets;
}
$this->dataCache[$cacheKey] = $jsonContent;
return $this->dataCache[$cacheKey];
} catch (\FileNotFoundException $e) {
throw new \tao_models_classes_FileNotFoundException(
$path . ' for item reference ' . $itemRef
);
} catch (\League\Flysystem\FileNotFoundException $e) {
throw new \tao_models_classes_FileNotFoundException(
$path . ' for item reference ' . $itemRef
);
}
} | php | {
"resource": ""
} |
q244371 | QtiRunnerService.getServiceContext | validation | public function getServiceContext($testDefinitionUri, $testCompilationUri, $testExecutionUri, $userUri = null)
{
// create a service context based on the provided URI
// initialize the test session and related objects
$serviceContext = new QtiRunnerServiceContext($testDefinitionUri, $testCompilationUri, $testExecutionUri);
$serviceContext->setServiceManager($this->getServiceManager());
$serviceContext->setTestConfig($this->getTestConfig());
$serviceContext->setUserUri($userUri);
$sessionService = $this->getServiceManager()->get(TestSessionService::SERVICE_ID);
$sessionService->registerTestSession(
$serviceContext->getTestSession(),
$serviceContext->getStorage(),
$serviceContext->getCompilationDirectory()
);
return $serviceContext;
} | php | {
"resource": ""
} |
q244372 | QtiRunnerService.persist | validation | public function persist(QtiRunnerServiceContext $context)
{
$testSession = $context->getTestSession();
$sessionId = $testSession->getSessionId();
\common_Logger::d("Persisting QTI Assessment Test Session '${sessionId}'...");
$context->getStorage()->persist($testSession);
if($this->isTerminated($context)){
$userId = \common_session_SessionManager::getSession()->getUser()->getIdentifier();
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->trigger(new AfterAssessmentTestSessionClosedEvent($testSession, $userId));
}
} | php | {
"resource": ""
} |
q244373 | QtiRunnerService.init | validation | public function init(RunnerServiceContext $context)
{
if ($context instanceof QtiRunnerServiceContext) {
/* @var TestSession $session */
$session = $context->getTestSession();
// code borrowed from the previous implementation, but the reset timers option has been discarded
if ($session->getState() === AssessmentTestSessionState::INITIAL) {
// The test has just been instantiated.
$session->beginTestSession();
$event = new TestInitEvent($session);
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
\common_Logger::i("Assessment Test Session begun.");
if ($context->isAdaptive()) {
\common_Logger::t("Very first item is adaptive.");
$nextCatItemId = $context->selectAdaptiveNextItem();
$context->persistCurrentCatItemId($nextCatItemId);
$context->persistSeenCatItemIds($nextCatItemId);
}
} elseif ($session->getState() === AssessmentTestSessionState::SUSPENDED) {
$session->resume();
}
$session->initItemTimer();
if ($session->isTimeout() === false) {
TestRunnerUtils::beginCandidateInteraction($session);
}
$this->getServiceManager()->get(ExtendedStateService::SERVICE_ID)->clearEvents($session->getSessionId());
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'init',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return true;
} | php | {
"resource": ""
} |
q244374 | QtiRunnerService.getRubrics | validation | public function getRubrics(RunnerServiceContext $context, AssessmentItemRef $itemRef = null)
{
if ($context instanceof QtiRunnerServiceContext) {
$rubricHelper = $this->getServiceLocator()->get(QtiRunnerRubric::SERVICE_ID);
return $rubricHelper->getRubrics($context, $itemRef);
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'getRubrics',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244375 | QtiRunnerService.getItemData | validation | public function getItemData(RunnerServiceContext $context, $itemRef)
{
if ($context instanceof QtiRunnerServiceContext) {
return $this->loadItemData($itemRef, QtiJsonItemCompiler::ITEM_FILE_NAME);
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'getItemData',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244376 | QtiRunnerService.getItemState | validation | public function getItemState(RunnerServiceContext $context, $itemRef)
{
if ($context instanceof QtiRunnerServiceContext) {
$serviceService = $this->getServiceManager()->get(StorageManager::SERVICE_ID);
$userUri = \common_session_SessionManager::getSession()->getUserUri();
$stateId = $this->getStateId($context, $itemRef);
$state = is_null($userUri) ? null : $serviceService->get($userUri, $stateId);
if ($state) {
$state = json_decode($state, true);
if (is_null($state)) {
throw new \common_exception_InconsistentData('Unable to decode the state for the item '.$itemRef);
}
}
return $state;
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'getItemState',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244377 | QtiRunnerService.setItemState | validation | public function setItemState(RunnerServiceContext $context, $itemRef, $state)
{
if ($context instanceof QtiRunnerServiceContext) {
$serviceService = $this->getServiceManager()->get(StorageManager::SERVICE_ID);
$userUri = \common_session_SessionManager::getSession()->getUserUri();
$stateId = $this->getStateId($context, $itemRef);
if(!isset($state)){
$state = '';
}
return is_null($userUri) ? false : $serviceService->set($userUri, $stateId, json_encode($state));
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'setItemState',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244378 | QtiRunnerService.parsesItemResponse | validation | public function parsesItemResponse(RunnerServiceContext $context, $itemRef, $response)
{
if ($context instanceof QtiRunnerServiceContext) {
/** @var TestSession $session */
$session = $context->getTestSession();
$currentItem = $context->getCurrentAssessmentItemRef();
$responses = new State();
if ($currentItem === false) {
$msg = "Trying to store item variables but the state of the test session is INITIAL or CLOSED.\n";
$msg .= "Session state value: " . $session->getState() . "\n";
$msg .= "Session ID: " . $session->getSessionId() . "\n";
$msg .= "JSON Payload: " . mb_substr(json_encode($response), 0, 1000);
\common_Logger::e($msg);
}
$filler = new \taoQtiCommon_helpers_PciVariableFiller(
$currentItem,
$this->getServiceManager()->get(QtiFlysystemFileManager::SERVICE_ID)
);
if (is_array($response)) {
foreach ($response as $id => $responseData) {
try {
$var = $filler->fill($id, $responseData);
// Do not take into account QTI File placeholders.
if (\taoQtiCommon_helpers_Utils::isQtiFilePlaceHolder($var) === false) {
$responses->setVariable($var);
}
} catch (\OutOfRangeException $e) {
\common_Logger::d("Could not convert client-side value for variable '${id}'.");
} catch (\OutOfBoundsException $e) {
\common_Logger::d("Could not find variable with identifier '${id}' in current item.");
}
}
} else {
\common_Logger::e('Invalid json payload');
}
return $responses;
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'storeItemResponse',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244379 | QtiRunnerService.emptyResponse | validation | public function emptyResponse(RunnerServiceContext $context, $responses)
{
if ($context instanceof QtiRunnerServiceContext) {
$similar = 0;
/** @var ResponseVariable $responseVariable */
foreach ($responses as $responseVariable) {
$value = $responseVariable->getValue();
$default = $responseVariable->getDefaultValue();
// Similar to default ?
if (TestRunnerUtils::isQtiValueNull($value) === true) {
if (TestRunnerUtils::isQtiValueNull($default) === true) {
$similar++;
}
} elseif ($value->equals($default) === true) {
$similar++;
}
}
$respCount = count($responses);
return $respCount > 0 && $similar == $respCount;
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'storeItemResponse',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244380 | QtiRunnerService.storeItemResponse | validation | public function storeItemResponse(RunnerServiceContext $context, $itemRef, $responses)
{
if ($context instanceof QtiRunnerServiceContext) {
$session = $this->getCurrentAssessmentSession($context);
try {
\common_Logger::t('Responses sent from the client-side. The Response Processing will take place.');
if ($context->isAdaptive()) {
$session->beginItemSession();
$session->beginAttempt();
$session->endAttempt($responses);
$assessmentItem = $session->getAssessmentItem();
$assessmentItemIdentifier = $assessmentItem->getIdentifier();
$score = $session->getVariable('SCORE');
$output = $context->getLastCatItemOutput();
if ($score !== null) {
$output[$assessmentItemIdentifier] = new ItemResult(
$assessmentItemIdentifier,
new ResultVariable(
$score->getIdentifier(),
BaseType::getNameByConstant($score->getBaseType()),
$score->getValue()->getValue(),
null,
$score->getCardinality()
),
microtime(true)
);
} else {
\common_Logger::i("No 'SCORE' outcome variable for item '${assessmentItemIdentifier}' involved in an adaptive section.");
}
$context->persistLastCatItemOutput($output);
// Send results to TAO Results.
$resultTransmitter = new \taoQtiCommon_helpers_ResultTransmitter($context->getSessionManager()->getResultServer());
$outcomeVariables = [];
$hrefParts = explode('|', $assessmentItem->getHref());
$sessionId = $context->getTestSession()->getSessionId();
$itemIdentifier = $assessmentItem->getIdentifier();
// Deal with attempts.
$attempt = $context->getCatAttempts($itemIdentifier);
$transmissionId = "${sessionId}.${itemIdentifier}.${attempt}";
$attempt++;
foreach ($session->getAllVariables() as $var) {
if ($var->getIdentifier() === 'numAttempts') {
$var->setValue(new \qtism\common\datatypes\QtiInteger($attempt));
}
$variables[] = $var;
}
$resultTransmitter->transmitItemVariable($variables, $transmissionId, $hrefParts[0], $hrefParts[2]);
$context->persistCatAttempts($itemIdentifier, $attempt);
$context->getTestSession()->endAttempt(new State(), true);
} else {
// Non adaptive case.
$session->endAttempt($responses, true);
}
return true;
} catch (AssessmentTestSessionException $e) {
\common_Logger::w($e->getMessage());
return false;
}
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'storeItemResponse',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244381 | QtiRunnerService.hasFeedbacks | validation | public function hasFeedbacks(RunnerServiceContext $context, $itemRef)
{
$hasFeedbacks = false;
$displayFeedbacks = $this->displayFeedbacks($context);
if($displayFeedbacks) {
$feedbacks = $this->getFeedbacks($context, $itemRef);
foreach ($feedbacks as $entry) {
if(isset($entry['feedbackRules'])){
if(count($entry['feedbackRules']) > 0){
$hasFeedbacks = true;
}
break;
}
}
}
return $hasFeedbacks;
} | php | {
"resource": ""
} |
q244382 | QtiRunnerService.move | validation | public function move(RunnerServiceContext $context, $direction, $scope, $ref)
{
$result = true;
if ($context instanceof QtiRunnerServiceContext) {
try {
$result = QtiRunnerNavigation::move($direction, $scope, $context, $ref);
if ($result) {
$this->continueInteraction($context);
}
} catch (AssessmentTestSessionException $e) {
switch ($e->getCode()) {
case AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW:
case AssessmentTestSessionException::TEST_PART_DURATION_OVERFLOW:
case AssessmentTestSessionException::ASSESSMENT_SECTION_DURATION_OVERFLOW:
case AssessmentTestSessionException::ASSESSMENT_ITEM_DURATION_OVERFLOW:
$this->onTimeout($context, $e);
break;
}
}
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'move',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return $result;
} | php | {
"resource": ""
} |
q244383 | QtiRunnerService.skip | validation | public function skip(RunnerServiceContext $context, $scope, $ref)
{
return $this->move($context, 'skip', $scope, $ref);
} | php | {
"resource": ""
} |
q244384 | QtiRunnerService.timeout | validation | public function timeout(RunnerServiceContext $context, $scope, $ref, $late = false)
{
if ($context instanceof QtiRunnerServiceContext) {
/* @var TestSession $session */
$session = $context->getTestSession();
if ($context->isAdaptive()) {
\common_Logger::t("Select next item before timeout");
$context->selectAdaptiveNextItem();
}
try {
$session->closeTimer($ref, $scope);
if ($late) {
if ($scope == 'assessmentTest') {
$code = AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW;
} else if ($scope == 'testPart') {
$code = AssessmentTestSessionException::TEST_PART_DURATION_OVERFLOW;
} else if ($scope == 'assessmentSection') {
$code = AssessmentTestSessionException::ASSESSMENT_SECTION_DURATION_OVERFLOW;
} else {
$code = AssessmentTestSessionException::ASSESSMENT_ITEM_DURATION_OVERFLOW;
}
throw new AssessmentTestSessionException("Maximum duration of ${scope} '${ref}' not respected.", $code);
} else {
$session->checkTimeLimits(false, true, false);
}
} catch (AssessmentTestSessionException $e) {
$this->onTimeout($context, $e);
}
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'timeout',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return true;
} | php | {
"resource": ""
} |
q244385 | QtiRunnerService.finish | validation | public function finish(RunnerServiceContext $context, $finalState = DeliveryExecution::STATE_FINISHED)
{
if ($context instanceof QtiRunnerServiceContext) {
$executionUri = $context->getTestExecutionUri();
$userUri = \common_session_SessionManager::getSession()->getUserUri();
$executionService = ServiceProxy::singleton();
$deliveryExecution = $executionService->getDeliveryExecution($executionUri);
if ($deliveryExecution->getUserIdentifier() == $userUri) {
\common_Logger::i("Finishing the delivery execution {$executionUri}");
$result = $deliveryExecution->setState($finalState);
} else {
\common_Logger::w("Non owner {$userUri} tried to finish deliveryExecution {$executionUri}");
$result = false;
}
$this->getServiceManager()->get(ExtendedStateService::SERVICE_ID)->clearEvents($executionUri);
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'finish',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return $result;
} | php | {
"resource": ""
} |
q244386 | QtiRunnerService.pause | validation | public function pause(RunnerServiceContext $context)
{
if ($context instanceof QtiRunnerServiceContext) {
$context->getTestSession()->suspend();
$this->persist($context);
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'pause',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return true;
} | php | {
"resource": ""
} |
q244387 | QtiRunnerService.resume | validation | public function resume(RunnerServiceContext $context)
{
if ($context instanceof QtiRunnerServiceContext) {
$context->getTestSession()->resume();
$this->persist($context);
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'resume',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
return true;
} | php | {
"resource": ""
} |
q244388 | QtiRunnerService.check | validation | public function check(RunnerServiceContext $context)
{
$state = $context->getTestSession()->getState();
if ($state == AssessmentTestSessionState::CLOSED) {
throw new QtiRunnerClosedException();
}
return true;
} | php | {
"resource": ""
} |
q244389 | QtiRunnerService.isItemCompleted | validation | public function isItemCompleted(RunnerServiceContext $context, $routeItem, $itemSession, $partially = true) {
if ($context instanceof QtiRunnerServiceContext && $context->isAdaptive()) {
$itemIdentifier = $context->getCurrentAssessmentItemRef()->getIdentifier();
$itemState = $this->getItemState($context, $itemIdentifier);
if ($itemState !== null) {
// as the item comes from a CAT section, it is simpler to load the responses from the state
$itemResponse = [];
foreach ($itemState as $key => $value) {
if (isset($value['response'])) {
$itemResponse[$key] = $value['response'];
}
}
$responses = $this->parsesItemResponse($context, $itemIdentifier, $itemResponse);
// fork of AssessmentItemSession::isResponded()
$excludedResponseVariables = array('numAttempts', 'duration');
foreach ($responses as $var) {
if ($var instanceof ResponseVariable && in_array($var->getIdentifier(), $excludedResponseVariables) === false) {
$value = $var->getValue();
$defaultValue = $var->getDefaultValue();
if (Utils::isNull($value) === true) {
if (Utils::isNull($defaultValue) === (($partially) ? false : true)) {
return (($partially) ? true : false);
}
} else {
if ($value->equals($defaultValue) === (($partially) ? false : true)) {
return (($partially) ? true : false);
}
}
}
}
}
return (($partially) ? false : true);
} else {
return TestRunnerUtils::isItemCompleted($routeItem, $itemSession, $partially);
}
} | php | {
"resource": ""
} |
q244390 | QtiRunnerService.getItemPublicUrl | validation | public function getItemPublicUrl(RunnerServiceContext $context, $itemRef){
if ($context instanceof QtiRunnerServiceContext) {
$directoryIds = explode('|', $itemRef);
$userDataLang = \common_session_SessionManager::getSession()->getDataLanguage();
$directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[1]);
// do fallback in case userlanguage is not default language
if ($userDataLang != DEFAULT_LANG && !$directory->has($userDataLang) && $directory->has(DEFAULT_LANG)) {
$userDataLang = DEFAULT_LANG;
}
return $directory->getPublicAccessUrl().$userDataLang.'/';
} else {
throw new \common_exception_InvalidArgumentType(
'QtiRunnerService',
'getItemPublicUrl',
0,
'oat\taoQtiTest\models\runner\QtiRunnerServiceContext',
$context
);
}
} | php | {
"resource": ""
} |
q244391 | QtiRunnerService.comment | validation | public function comment(RunnerServiceContext $context, $comment)
{
// prepare transmission Id for result server.
$testSession = $context->getTestSession();
$item = $testSession->getCurrentAssessmentItemRef()->getIdentifier();
$occurrence = $testSession->getCurrentAssessmentItemRefOccurence();
$sessionId = $testSession->getSessionId();
$transmissionId = "${sessionId}.${item}.${occurrence}";
/** @var DeliveryServerService $deliveryServerService */
$deliveryServerService = $this->getServiceManager()->get(DeliveryServerService::SERVICE_ID);
$resultStore = $deliveryServerService->getResultStoreWrapper($sessionId);
$transmitter = new \taoQtiCommon_helpers_ResultTransmitter($resultStore);
// build variable and send it.
$itemUri = TestRunnerUtils::getCurrentItemUri($testSession);
$testUri = $testSession->getTest()->getUri();
$variable = new ResponseVariable('comment', Cardinality::SINGLE, BaseType::STRING, new QtismString($comment));
$transmitter->transmitItemVariable($variable, $transmissionId, $itemUri, $testUri);
return true;
} | php | {
"resource": ""
} |
q244392 | QtiRunnerService.continueInteraction | validation | protected function continueInteraction(RunnerServiceContext $context)
{
$continue = false;
/* @var TestSession $session */
$session = $context->getTestSession();
if ($session->isRunning() === true && $session->isTimeout() === false) {
$event = new QtiContinueInteractionEvent($context, $this);
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
TestRunnerUtils::beginCandidateInteraction($session);
$continue = true;
} else {
$this->finish($context);
}
return $continue;
} | php | {
"resource": ""
} |
q244393 | QtiRunnerService.onTimeout | validation | protected function onTimeout(RunnerServiceContext $context, AssessmentTestSessionException $timeOutException)
{
/* @var TestSession $session */
$session = $context->getTestSession();
$event = new TestTimeoutEvent($session, $timeOutException->getCode(), true);
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
$isLinear = $session->getCurrentNavigationMode() === NavigationMode::LINEAR;
switch ($timeOutException->getCode()) {
case AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW:
\common_Logger::i('TIMEOUT: closing the assessment test session');
$session->endTestSession();
break;
case AssessmentTestSessionException::TEST_PART_DURATION_OVERFLOW:
if ($isLinear) {
\common_Logger::i('TIMEOUT: moving to the next test part');
$session->moveNextTestPart();
} else {
\common_Logger::i('TIMEOUT: closing the assessment test part');
$session->closeTestPart();
}
break;
case AssessmentTestSessionException::ASSESSMENT_SECTION_DURATION_OVERFLOW:
if ($isLinear) {
\common_Logger::i('TIMEOUT: moving to the next assessment section');
$session->moveNextAssessmentSection();
} else {
\common_Logger::i('TIMEOUT: closing the assessment section session');
$session->closeAssessmentSection();
}
break;
case AssessmentTestSessionException::ASSESSMENT_ITEM_DURATION_OVERFLOW:
if ($isLinear) {
\common_Logger::i('TIMEOUT: moving to the next item');
$session->moveNextAssessmentItem();
} else {
\common_Logger::i('TIMEOUT: closing the assessment item session');
$session->closeAssessmentItem();
}
break;
}
$event = new TestTimeoutEvent($session, $timeOutException->getCode(), false);
$this->getServiceManager()->get(EventManager::SERVICE_ID)->trigger($event);
$this->continueInteraction($context);
} | php | {
"resource": ""
} |
q244394 | QtiRunnerService.storeTraceVariable | validation | public function storeTraceVariable(RunnerServiceContext $context, $itemUri, $variableIdentifier, $variableValue)
{
$this->assertQtiRunnerServiceContext($context);
$metaVariable = $this->getTraceVariable($variableIdentifier, $variableValue);
return $this->storeVariable($context, $itemUri, $metaVariable);
} | php | {
"resource": ""
} |
q244395 | QtiRunnerService.getTraceVariable | validation | public function getTraceVariable($variableIdentifier, $variableValue)
{
if (!is_string($variableValue) && !is_numeric($variableValue)) {
$variableValue = json_encode($variableValue);
}
$metaVariable = new \taoResultServer_models_classes_TraceVariable();
$metaVariable->setIdentifier($variableIdentifier);
$metaVariable->setBaseType('string');
$metaVariable->setCardinality(Cardinality::getNameByConstant(Cardinality::SINGLE));
$metaVariable->setTrace($variableValue);
return $metaVariable;
} | php | {
"resource": ""
} |
q244396 | QtiRunnerService.storeOutcomeVariable | validation | public function storeOutcomeVariable(RunnerServiceContext $context, $itemUri, $variableIdentifier, $variableValue)
{
$this->assertQtiRunnerServiceContext($context);
$metaVariable = $this->getOutcomeVariable($variableIdentifier, $variableValue);
return $this->storeVariable($context, $itemUri, $metaVariable);
} | php | {
"resource": ""
} |
q244397 | QtiRunnerService.getOutcomeVariable | validation | public function getOutcomeVariable($variableIdentifier, $variableValue)
{
if (!is_string($variableValue) && !is_numeric($variableValue)) {
$variableValue = json_encode($variableValue);
}
$metaVariable = new \taoResultServer_models_classes_OutcomeVariable();
$metaVariable->setIdentifier($variableIdentifier);
$metaVariable->setBaseType('string');
$metaVariable->setCardinality(Cardinality::getNameByConstant(Cardinality::SINGLE));
$metaVariable->setValue($variableValue);
return $metaVariable;
} | php | {
"resource": ""
} |
q244398 | QtiRunnerService.storeResponseVariable | validation | public function storeResponseVariable(RunnerServiceContext $context, $itemUri, $variableIdentifier, $variableValue)
{
$this->assertQtiRunnerServiceContext($context);
$metaVariable = $this->getResponseVariable($variableIdentifier, $variableValue);
return $this->storeVariable($context, $itemUri, $metaVariable);
} | php | {
"resource": ""
} |
q244399 | QtiRunnerService.getResponseVariable | validation | public function getResponseVariable($variableIdentifier, $variableValue)
{
if (!is_string($variableValue) && !is_numeric($variableValue)) {
$variableValue = json_encode($variableValue);
}
$metaVariable = new \taoResultServer_models_classes_ResponseVariable();
$metaVariable->setIdentifier($variableIdentifier);
$metaVariable->setBaseType('string');
$metaVariable->setCardinality(Cardinality::getNameByConstant(Cardinality::SINGLE));
$metaVariable->setValue($variableValue);
return $metaVariable;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.