本文整理汇总了PHP中tao_helpers_Uri::getUniqueId方法的典型用法代码示例。如果您正苦于以下问题:PHP tao_helpers_Uri::getUniqueId方法的具体用法?PHP tao_helpers_Uri::getUniqueId怎么用?PHP tao_helpers_Uri::getUniqueId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tao_helpers_Uri
的用法示例。
在下文中一共展示了tao_helpers_Uri::getUniqueId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
*
* @param core_kernel_classes_Resource $test
* @param array $itemUris
* @return boolean
*/
public function save(core_kernel_classes_Resource $test, array $content)
{
$serializer = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID);
$serial = $test->getOnePropertyValue($this->getProperty(TEST_TESTCONTENT_PROP));
if (!is_null($serial)) {
$directory = $serializer->unserializeDirectory($serial);
} else {
// null so create one
$fss = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID);
$base = $fss->getDirectory($this->getOption(self::OPTION_FILESYSTEM));
$directory = $base->getDirectory(\tao_helpers_Uri::getUniqueId(\common_Utils::getNewUri()));
$test->editPropertyValues($this->getProperty(TEST_TESTCONTENT_PROP), $serializer->serialize($directory));
}
return $directory->getFile('content.json')->put(json_encode($content));
}
示例2: referenceAuxiliaryFile
/**
* Reference a Test Auxiliary File (e.g. media, stylesheet, ...) in the IMS Manifest.
*
* @param string $href The path (base path is the ZIP archive) to the auxiliary file in the ZIP archive.
*/
protected function referenceAuxiliaryFile($href)
{
$manifest = $this->getManifest();
$testIdentifier = tao_helpers_Uri::getUniqueId($this->getItem()->getUri());
$xpath = new DOMXPath($manifest);
// Find the first <dependency> element.
$dependencies = $xpath->query("//resource[@identifier='{$testIdentifier}']/dependency");
$firstDependencyElt = $dependencies->item(0);
// Create an IMS Manifest <file> element.
$fileElt = $manifest->createElement('file');
$fileElt->setAttribute('href', ltrim($href, '/'));
$firstDependencyElt->parentNode->insertBefore($fileElt, $firstDependencyElt);
}
示例3: getDefaultFilePath
/**
* Short description of method getDefaultFilePath
*
* @access public
* @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
* @return string
*/
public function getDefaultFilePath()
{
$returnValue = (string) '';
$returnValue = tao_helpers_Uri::getUniqueId($this->ownerInstance->getUri()) . '/' . tao_helpers_Uri::getUniqueId($this->property->getUri());
return (string) $returnValue;
}
示例4: setItemContent
/**
* Short description of method setItemContent
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Resource item
* @param string content
* @param string lang
* @param string commitMessage
* @return boolean
*/
public function setItemContent(core_kernel_classes_Resource $item, $content, $lang = '', $commitMessage = '')
{
$returnValue = (bool) false;
if (is_null($item) && !$this->isItemModelDefined($item)) {
throw new common_exception_Error('No item or itemmodel in ' . __FUNCTION__);
}
$lang = empty($lang) ? $lang = $this->getSessionLg() : $lang;
$itemModel = $item->getUniquePropertyValue($this->itemModelProperty);
$dataFile = (string) $itemModel->getOnePropertyValue(new core_kernel_classes_Property(TAO_ITEM_MODEL_DATAFILE_PROPERTY));
if ($this->hasItemContent($item, $lang)) {
$itemContents = $item->getPropertyValuesByLg($this->itemContentProperty, $lang);
$itemContent = $itemContents->get(0);
if (!core_kernel_file_File::isFile($itemContent)) {
throw new common_Exception('Item ' . $item->getUri() . ' has none file itemContent');
}
$file = new core_kernel_versioning_File($itemContent);
$returnValue = $file->setContent($content);
} else {
$repository = $this->getDefaultFileSource();
$file = $repository->createFile($dataFile, tao_helpers_Uri::getUniqueId($item->getUri()) . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $lang);
$item->setPropertyValueByLg($this->itemContentProperty, $file->getUri(), $lang);
$file->setContent($content);
$returnValue = $file->add(true, true);
}
if ($commitMessage != 'HOLD_COMMIT') {
//hack to control commit or not
$returnValue = $file->commit($commitMessage);
}
return (bool) $returnValue;
}
示例5: getItemDirectory
/**
* Returns the items flysystem directory
*
* @param core_kernel_classes_Resource $item
* @param string $language
* @return \oat\oatbox\filesystem\Directory
* @throws Exception
* @throws common_Exception
* @throws core_kernel_persistence_Exception
*/
public function getItemDirectory(core_kernel_classes_Resource $item, $language = '')
{
// Get file by language
if ($language === '') {
$files = $item->getPropertyValues($this->itemContentProperty);
} else {
$files = $item->getPropertyValuesByLg($this->itemContentProperty, $language)->toArray();
}
// If multiple files then throw exception
if (count($files) > 1) {
common_Logger::i(print_r($files, true));
throw new common_Exception(__METHOD__ . ': Item ' . $item->getUri() . ' has multiple.');
}
// If there is one file then return directory
if (count($files) == 1) {
$file = reset($files);
$file = is_object($file) && $file instanceof core_kernel_classes_Resource ? $file->getUri() : (string) $file;
return $this->getFileReferenceSerializer()->unserializeDirectory($file);
}
// Otherwise there is no file, create one and return directory
$model = $this->getItemModel($item);
if (is_null($model)) {
throw new common_Exception('Call to ' . __FUNCTION__ . ' for item without model');
}
// File does not exist, let's create it
$actualLang = empty($language) ? $this->getSessionLg() : $language;
$filePath = tao_helpers_Uri::getUniqueId($item->getUri()) . DIRECTORY_SEPARATOR . 'itemContent' . DIRECTORY_SEPARATOR . $actualLang;
// Create item directory
$itemDirectory = $this->getDefaultItemDirectory()->getDirectory($filePath);
// Set uri file value as serial to item persistence
$serial = $this->getFileReferenceSerializer()->serialize($itemDirectory);
$item->setPropertyValueByLg($this->itemContentProperty, $serial, $actualLang);
// Store file into persistence, purpose of serializer ?
$dataFile = (string) $model->getOnePropertyValue($this->getProperty(TAO_ITEM_MODEL_DATAFILE_PROPERTY));
$this->getFileReferenceSerializer()->serialize($itemDirectory->getFile($dataFile));
return $itemDirectory;
}
示例6: getQtiResultXml
public function getQtiResultXml($deliveryId, $resultId)
{
$delivery = new \core_kernel_classes_Resource($deliveryId);
$resultService = $this->getServiceLocator()->get(ResultServerService::SERVICE_ID);
$resultServer = $resultService->getResultStorage($deliveryId);
$crudService = new CrudResultsService();
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$itemResults = $crudService->format($resultServer, $resultId, CrudResultsService::GROUP_BY_ITEM);
$testResults = $crudService->format($resultServer, $resultId, CrudResultsService::GROUP_BY_TEST);
$assessmentResultElt = $dom->createElementNS(self::QTI_NS, 'assessmentResult');
$dom->appendChild($assessmentResultElt);
/** Context */
$contextElt = $dom->createElementNS(self::QTI_NS, 'context');
$contextElt->setAttribute('sourcedId', \tao_helpers_Uri::getUniqueId($resultServer->getTestTaker($resultId)));
$assessmentResultElt->appendChild($contextElt);
/** Test Result */
foreach ($testResults as $testResultIdentifier => $testResult) {
$identifierParts = explode('.', $testResultIdentifier);
$testIdentifier = array_pop($identifierParts);
$testResultElement = $dom->createElementNS(self::QTI_NS, 'testResult');
$testResultElement->setAttribute('identifier', $testIdentifier);
$testResultElement->setAttribute('datestamp', \tao_helpers_Date::displayeDate($testResult[0]['epoch'], \tao_helpers_Date::FORMAT_ISO8601));
/** Item Variable */
foreach ($testResult as $itemVariable) {
$isResponseVariable = $itemVariable['type']->getUri() === 'http://www.tao.lu/Ontologies/TAOResult.rdf#ResponseVariable';
$testVariableElement = $dom->createElementNS(self::QTI_NS, $isResponseVariable ? 'responseVariable' : 'outcomeVariable');
$testVariableElement->setAttribute('identifier', $itemVariable['identifier']);
$testVariableElement->setAttribute('cardinality', $itemVariable['cardinality']);
$testVariableElement->setAttribute('baseType', $itemVariable['basetype']);
$valueElement = $this->createCDATANode($dom, 'value', trim($itemVariable['value']));
if ($isResponseVariable) {
$candidateResponseElement = $dom->createElementNS(self::QTI_NS, 'candidateResponse');
$candidateResponseElement->appendChild($valueElement);
$testVariableElement->appendChild($candidateResponseElement);
} else {
$testVariableElement->appendChild($valueElement);
}
$testResultElement->appendChild($testVariableElement);
}
$assessmentResultElt->appendChild($testResultElement);
}
/** Item Result */
foreach ($itemResults as $itemResultIdentifier => $itemResult) {
// Retrieve identifier.
$identifierParts = explode('.', $itemResultIdentifier);
$occurenceNumber = array_pop($identifierParts);
$refIdentifier = array_pop($identifierParts);
$itemElement = $dom->createElementNS(self::QTI_NS, 'itemResult');
$itemElement->setAttribute('identifier', $refIdentifier);
$itemElement->setAttribute('datestamp', \tao_helpers_Date::displayeDate($itemResult[0]['epoch'], \tao_helpers_Date::FORMAT_ISO8601));
$itemElement->setAttribute('sessionStatus', 'final');
/** Item variables */
foreach ($itemResult as $key => $itemVariable) {
$isResponseVariable = $itemVariable['type']->getUri() === 'http://www.tao.lu/Ontologies/TAOResult.rdf#ResponseVariable';
if ($itemVariable['identifier'] == 'comment') {
/** Comment */
$itemVariableElement = $dom->createElementNS(self::QTI_NS, 'candidateComment', $itemVariable['value']);
} else {
/** Item variable */
$itemVariableElement = $dom->createElementNS(self::QTI_NS, $isResponseVariable ? 'responseVariable' : 'outcomeVariable');
$itemVariableElement->setAttribute('identifier', $itemVariable['identifier']);
$itemVariableElement->setAttribute('cardinality', $itemVariable['cardinality']);
$itemVariableElement->setAttribute('baseType', $itemVariable['basetype']);
/** Split multiple response */
$itemVariable['value'] = trim($itemVariable['value'], '[]');
if ($itemVariable['cardinality'] !== Cardinality::getNameByConstant(Cardinality::SINGLE)) {
$values = explode(';', $itemVariable['value']);
$returnValue = [];
foreach ($values as $value) {
$returnValue[] = $this->createCDATANode($dom, 'value', $value);
}
} else {
$returnValue = $this->createCDATANode($dom, 'value', $itemVariable['value']);
}
/** Get response parent element */
if ($isResponseVariable) {
/** Response variable */
$responseElement = $dom->createElementNS(self::QTI_NS, 'candidateResponse');
} else {
/** Outcome variable */
$responseElement = $itemVariableElement;
}
/** Write a response node foreach answer */
if (is_array($returnValue)) {
foreach ($returnValue as $valueElement) {
$responseElement->appendChild($valueElement);
}
} else {
$responseElement->appendChild($returnValue);
}
if ($isResponseVariable) {
$itemVariableElement->appendChild($responseElement);
}
}
$itemElement->appendChild($itemVariableElement);
}
$assessmentResultElt->appendChild($itemElement);
}
return $dom->saveXML();
//.........这里部分代码省略.........