repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
oat-sa/extension-tao-itemqti | helpers/CssHelper.php | CssHelper.downloadCssFile | public static function downloadCssFile(\core_kernel_classes_resource $item, $lang, $styleSheetPath){
$directory = \taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $lang);
$file = $directory->getFile($styleSheetPath);
if ($file->exists()) {
return $file->read();
}
return null;
} | php | public static function downloadCssFile(\core_kernel_classes_resource $item, $lang, $styleSheetPath){
$directory = \taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $lang);
$file = $directory->getFile($styleSheetPath);
if ($file->exists()) {
return $file->read();
}
return null;
} | [
"public",
"static",
"function",
"downloadCssFile",
"(",
"\\",
"core_kernel_classes_resource",
"$",
"item",
",",
"$",
"lang",
",",
"$",
"styleSheetPath",
")",
"{",
"$",
"directory",
"=",
"\\",
"taoItems_models_classes_ItemsService",
"::",
"singleton",
"(",
")",
"->... | Download existing CSS file
@param \core_kernel_classes_resource $item
@param string $lang
@param string $styleSheetPath
@return string css on success | [
"Download",
"existing",
"CSS",
"file"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/CssHelper.php#L63-L71 |
oat-sa/extension-tao-itemqti | helpers/CssHelper.php | CssHelper.arrayToCss | public static function arrayToCss($array){
$css = '';
// rebuild CSS
foreach($array as $key1 => $value1){
$css .= $key1 . '{';
foreach($value1 as $key2 => $value2){
// in the case that the code is embedded in a media query
if(is_array($value2)){
foreach($value2 as $value3){
$css .= $key2 . '{';
foreach($value3 as $mProp){
$css .= $mProp . ':' . $value3 . ';';
}
$css .= '}';
}
}
// regular selectors
else{
$css .= $key2 . ':' . $value2 . ';';
}
}
$css .= "}\n";
}
return $css;
} | php | public static function arrayToCss($array){
$css = '';
// rebuild CSS
foreach($array as $key1 => $value1){
$css .= $key1 . '{';
foreach($value1 as $key2 => $value2){
// in the case that the code is embedded in a media query
if(is_array($value2)){
foreach($value2 as $value3){
$css .= $key2 . '{';
foreach($value3 as $mProp){
$css .= $mProp . ':' . $value3 . ';';
}
$css .= '}';
}
}
// regular selectors
else{
$css .= $key2 . ':' . $value2 . ';';
}
}
$css .= "}\n";
}
return $css;
} | [
"public",
"static",
"function",
"arrayToCss",
"(",
"$",
"array",
")",
"{",
"$",
"css",
"=",
"''",
";",
"// rebuild CSS",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key1",
"=>",
"$",
"value1",
")",
"{",
"$",
"css",
".=",
"$",
"key1",
".",
"'{'",
";",... | Convert incoming CSS array to proper CSS
@param $array
@return string | [
"Convert",
"incoming",
"CSS",
"array",
"to",
"proper",
"CSS"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/CssHelper.php#L120-L146 |
oat-sa/extension-tao-itemqti | helpers/CssHelper.php | CssHelper.loadCssFile | public static function loadCssFile(\core_kernel_classes_resource $item, $lang, $styleSheet) {
$directory = \taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $lang);
// no user style sheet has been created yet
$file = $directory->getFile($styleSheet);
if (! $file->exists()) {
\common_Logger::d('Stylesheet ' . $styleSheet . ' does not exist yet, returning empty array');
return array();
}
return self::cssToArray($file->read());
} | php | public static function loadCssFile(\core_kernel_classes_resource $item, $lang, $styleSheet) {
$directory = \taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $lang);
// no user style sheet has been created yet
$file = $directory->getFile($styleSheet);
if (! $file->exists()) {
\common_Logger::d('Stylesheet ' . $styleSheet . ' does not exist yet, returning empty array');
return array();
}
return self::cssToArray($file->read());
} | [
"public",
"static",
"function",
"loadCssFile",
"(",
"\\",
"core_kernel_classes_resource",
"$",
"item",
",",
"$",
"lang",
",",
"$",
"styleSheet",
")",
"{",
"$",
"directory",
"=",
"\\",
"taoItems_models_classes_ItemsService",
"::",
"singleton",
"(",
")",
"->",
"ge... | Loads the content of a css file into a css array
Returns an empty stylesheet if it does not yet exist
@param \core_kernel_classes_resource $item
@param string $lang
@param string $styleSheet
@return array array with structure of 'selector' => rules | [
"Loads",
"the",
"content",
"of",
"a",
"css",
"file",
"into",
"a",
"css",
"array",
"Returns",
"an",
"empty",
"stylesheet",
"if",
"it",
"does",
"not",
"yet",
"exist"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/CssHelper.php#L157-L169 |
oat-sa/extension-tao-itemqti | helpers/QtiRunner.php | QtiRunner.getVariableValues | public static function getVariableValues(Variable $variable) {
$returnValue = array();
$baseType = $variable->getBaseType();
$cardinalityType = $variable->getCardinality();
$value = $variable->getValue();
// This only works if the variable has a value ;)
if ($value !== null) {
if ($baseType === BaseType::IDENTIFIER) {
if ($cardinalityType === Cardinality::SINGLE) {
$returnValue[] = $value->getValue();
}
else if($cardinalityType === Cardinality::MULTIPLE) {
foreach($variable->getValue() as $value) {
$returnValue[] = $value->getValue();
}
}
}
}
return $returnValue;
} | php | public static function getVariableValues(Variable $variable) {
$returnValue = array();
$baseType = $variable->getBaseType();
$cardinalityType = $variable->getCardinality();
$value = $variable->getValue();
// This only works if the variable has a value ;)
if ($value !== null) {
if ($baseType === BaseType::IDENTIFIER) {
if ($cardinalityType === Cardinality::SINGLE) {
$returnValue[] = $value->getValue();
}
else if($cardinalityType === Cardinality::MULTIPLE) {
foreach($variable->getValue() as $value) {
$returnValue[] = $value->getValue();
}
}
}
}
return $returnValue;
} | [
"public",
"static",
"function",
"getVariableValues",
"(",
"Variable",
"$",
"variable",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"baseType",
"=",
"$",
"variable",
"->",
"getBaseType",
"(",
")",
";",
"$",
"cardinalityType",
"=",
"$",
... | Get the intrinsic values of a given QTI $variable.
@param Variable $variable
@return array | [
"Get",
"the",
"intrinsic",
"values",
"of",
"a",
"given",
"QTI",
"$variable",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiRunner.php#L48-L76 |
oat-sa/extension-tao-itemqti | helpers/QtiRunner.php | QtiRunner.getPrivatePathByLanguage | public static function getPrivatePathByLanguage(tao_models_classes_service_StorageDirectory $directory) {
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
if (!$directory->has($lang) && $directory->has(DEFAULT_LANG)) {
$lang = DEFAULT_LANG;
}
return $lang . DIRECTORY_SEPARATOR;
} | php | public static function getPrivatePathByLanguage(tao_models_classes_service_StorageDirectory $directory) {
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
if (!$directory->has($lang) && $directory->has(DEFAULT_LANG)) {
$lang = DEFAULT_LANG;
}
return $lang . DIRECTORY_SEPARATOR;
} | [
"public",
"static",
"function",
"getPrivatePathByLanguage",
"(",
"tao_models_classes_service_StorageDirectory",
"$",
"directory",
")",
"{",
"$",
"lang",
"=",
"\\",
"common_session_SessionManager",
"::",
"getSession",
"(",
")",
"->",
"getDataLanguage",
"(",
")",
";",
"... | Get the flysystem path to the compilation folder described by $directory.
@param tao_models_classes_service_StorageDirectory $directory The root directory resource where the item is stored.
@return string The flysystem path to the private folder with a trailing directory separator. | [
"Get",
"the",
"flysystem",
"path",
"to",
"the",
"compilation",
"folder",
"described",
"by",
"$directory",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiRunner.php#L84-L92 |
oat-sa/extension-tao-itemqti | helpers/QtiRunner.php | QtiRunner.getContentVariableElements | public static function getContentVariableElements(tao_models_classes_service_StorageDirectory $directory)
{
$jsonFile = self::getPrivatePathByLanguage($directory) . 'variableElements.json';
$data = $directory->read($jsonFile);
return json_decode($data, true);
} | php | public static function getContentVariableElements(tao_models_classes_service_StorageDirectory $directory)
{
$jsonFile = self::getPrivatePathByLanguage($directory) . 'variableElements.json';
$data = $directory->read($jsonFile);
return json_decode($data, true);
} | [
"public",
"static",
"function",
"getContentVariableElements",
"(",
"tao_models_classes_service_StorageDirectory",
"$",
"directory",
")",
"{",
"$",
"jsonFile",
"=",
"self",
"::",
"getPrivatePathByLanguage",
"(",
"$",
"directory",
")",
".",
"'variableElements.json'",
";",
... | Get the JSON QTI Model representing the elements (A.K.A. components) that vary over time for
the item stored in $directory.
@param tao_models_classes_service_StorageDirectory $directory
@return array A JSON decoded array. | [
"Get",
"the",
"JSON",
"QTI",
"Model",
"representing",
"the",
"elements",
"(",
"A",
".",
"K",
".",
"A",
".",
"components",
")",
"that",
"vary",
"over",
"time",
"for",
"the",
"item",
"stored",
"in",
"$directory",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiRunner.php#L101-L106 |
oat-sa/extension-tao-itemqti | helpers/QtiRunner.php | QtiRunner.getRubricBlocks | public static function getRubricBlocks(tao_models_classes_service_StorageDirectory $directory, $view) {
$returnValue = array();
$elements = self::getContentVariableElements($directory);
foreach ($elements as $serial => $data) {
if (isset($data['qtiClass']) && $data['qtiClass'] == 'rubricBlock') {
if (!empty($data['attributes']) && is_array($data['attributes']['view']) && in_array($view, $data['attributes']['view'])) {
$returnValue[$serial] = $data;
}
}
}
return $returnValue;
} | php | public static function getRubricBlocks(tao_models_classes_service_StorageDirectory $directory, $view) {
$returnValue = array();
$elements = self::getContentVariableElements($directory);
foreach ($elements as $serial => $data) {
if (isset($data['qtiClass']) && $data['qtiClass'] == 'rubricBlock') {
if (!empty($data['attributes']) && is_array($data['attributes']['view']) && in_array($view, $data['attributes']['view'])) {
$returnValue[$serial] = $data;
}
}
}
return $returnValue;
} | [
"public",
"static",
"function",
"getRubricBlocks",
"(",
"tao_models_classes_service_StorageDirectory",
"$",
"directory",
",",
"$",
"view",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"elements",
"=",
"self",
"::",
"getContentVariableElements",
... | Get rubric block visible by the given "view"
@param tao_models_classes_service_StorageDirectory $directory
@param type $view
@return array | [
"Get",
"rubric",
"block",
"visible",
"by",
"the",
"given",
"view"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiRunner.php#L115-L132 |
oat-sa/extension-tao-itemqti | helpers/QtiRunner.php | QtiRunner.getFeedbacks | public static function getFeedbacks(tao_models_classes_service_StorageDirectory $directory, AssessmentItemSession $itemSession) {
$returnValue = array();
$feedbackClasses = array('modalFeedback', 'feedbackInline', 'feedbackBlock');
$elements = self::getContentVariableElements($directory);
$outcomes = array();
foreach ($elements as $data) {
if (empty($data['qtiClass']) === false && in_array($data['qtiClass'], $feedbackClasses)) {
$feedbackIdentifier = $data['attributes']['identifier'];
$outcomeIdentifier = $data['attributes']['outcomeIdentifier'];
if (!isset($outcomes[$outcomeIdentifier])) {
$outcomes[$outcomeIdentifier] = array();
}
$outcomes[$outcomeIdentifier][$feedbackIdentifier] = $data;
}
}
foreach ($itemSession->getAllVariables() as $var) {
$identifier = $var->getIdentifier();
if (isset($outcomes[$identifier])) {
$feedbacks = $outcomes[$identifier];
$feedbackIds = QtiRunner::getVariableValues($var);
foreach($feedbackIds as $feedbackId) {
if (isset($feedbacks[$feedbackId])) {
$data = $feedbacks[$feedbackId];
$returnValue[$data['serial']] = $data;
}
}
}
}
return $returnValue;
} | php | public static function getFeedbacks(tao_models_classes_service_StorageDirectory $directory, AssessmentItemSession $itemSession) {
$returnValue = array();
$feedbackClasses = array('modalFeedback', 'feedbackInline', 'feedbackBlock');
$elements = self::getContentVariableElements($directory);
$outcomes = array();
foreach ($elements as $data) {
if (empty($data['qtiClass']) === false && in_array($data['qtiClass'], $feedbackClasses)) {
$feedbackIdentifier = $data['attributes']['identifier'];
$outcomeIdentifier = $data['attributes']['outcomeIdentifier'];
if (!isset($outcomes[$outcomeIdentifier])) {
$outcomes[$outcomeIdentifier] = array();
}
$outcomes[$outcomeIdentifier][$feedbackIdentifier] = $data;
}
}
foreach ($itemSession->getAllVariables() as $var) {
$identifier = $var->getIdentifier();
if (isset($outcomes[$identifier])) {
$feedbacks = $outcomes[$identifier];
$feedbackIds = QtiRunner::getVariableValues($var);
foreach($feedbackIds as $feedbackId) {
if (isset($feedbacks[$feedbackId])) {
$data = $feedbacks[$feedbackId];
$returnValue[$data['serial']] = $data;
}
}
}
}
return $returnValue;
} | [
"public",
"static",
"function",
"getFeedbacks",
"(",
"tao_models_classes_service_StorageDirectory",
"$",
"directory",
",",
"AssessmentItemSession",
"$",
"itemSession",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"$",
"feedbackClasses",
"=",
"array",
"... | Get the feedback to be displayed on an AssessmentItemSession
@param tao_models_classes_service_StorageDirectory $directory
@param \qtism\runtime\tests\AssessmentItemSession $itemSession
@return array | [
"Get",
"the",
"feedback",
"to",
"be",
"displayed",
"on",
"an",
"AssessmentItemSession"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiRunner.php#L141-L184 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.remove | public function remove($themeIds) {
$themeIds = (array)$themeIds;
foreach($themeIds as $themeId) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if(!$this->themeExists($prefixedId)) {
continue;
}
$this->registry->unregisterTheme($prefixedId);
}
$this->logInfo('Item themes removed: ' . implode(',', $themeIds));
return true;
} | php | public function remove($themeIds) {
$themeIds = (array)$themeIds;
foreach($themeIds as $themeId) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if(!$this->themeExists($prefixedId)) {
continue;
}
$this->registry->unregisterTheme($prefixedId);
}
$this->logInfo('Item themes removed: ' . implode(',', $themeIds));
return true;
} | [
"public",
"function",
"remove",
"(",
"$",
"themeIds",
")",
"{",
"$",
"themeIds",
"=",
"(",
"array",
")",
"$",
"themeIds",
";",
"foreach",
"(",
"$",
"themeIds",
"as",
"$",
"themeId",
")",
"{",
"$",
"prefixedId",
"=",
"$",
"this",
"->",
"getPrefixedTheme... | Remove themes from the configuration
@param array|string $themeIds
@return bool | [
"Remove",
"themes",
"from",
"the",
"configuration"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L129-L140 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.add | public function add(array $themes) {
foreach($themes as $themeId => $label) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if($this->themeExists($prefixedId)) {
continue;
}
$this->register($themeId, $label);
}
$this->logInfo('Item themes registered: ' . implode(',', array_keys($themes)));
return true;
} | php | public function add(array $themes) {
foreach($themes as $themeId => $label) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if($this->themeExists($prefixedId)) {
continue;
}
$this->register($themeId, $label);
}
$this->logInfo('Item themes registered: ' . implode(',', array_keys($themes)));
return true;
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"themes",
")",
"{",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"themeId",
"=>",
"$",
"label",
")",
"{",
"$",
"prefixedId",
"=",
"$",
"this",
"->",
"getPrefixedThemeId",
"(",
"$",
"themeId",
")",
";",
"if... | @param array $themes
@return bool | [
"@param",
"array",
"$themes"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L148-L160 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.update | public function update(array $themes) {
foreach($themes as $themeId => $label) {
$this->remove($themeId);
$this->register($themeId, $label);
}
$this->logInfo('Item themes updated: ' . implode(',', array_keys($themes)));
return true;
} | php | public function update(array $themes) {
foreach($themes as $themeId => $label) {
$this->remove($themeId);
$this->register($themeId, $label);
}
$this->logInfo('Item themes updated: ' . implode(',', array_keys($themes)));
return true;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"themes",
")",
"{",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"themeId",
"=>",
"$",
"label",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"themeId",
")",
";",
"$",
"this",
"->",
"register",
"("... | @param array $themes
@return bool | [
"@param",
"array",
"$themes"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L168-L175 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.setDefault | public function setDefault($themeId) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if(!$this->themeExists($prefixedId)) {
$this->logInfo($themeId . ' not installed, could not set to default');
return false;
}
$this->registry->setDefaultTheme('items', $prefixedId);
$this->logInfo('Default item theme set to ' . $themeId);
return true;
} | php | public function setDefault($themeId) {
$prefixedId = $this->getPrefixedThemeId($themeId);
if(!$this->themeExists($prefixedId)) {
$this->logInfo($themeId . ' not installed, could not set to default');
return false;
}
$this->registry->setDefaultTheme('items', $prefixedId);
$this->logInfo('Default item theme set to ' . $themeId);
return true;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"themeId",
")",
"{",
"$",
"prefixedId",
"=",
"$",
"this",
"->",
"getPrefixedThemeId",
"(",
"$",
"themeId",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"themeExists",
"(",
"$",
"prefixedId",
")",
")",
"{",
... | Set the current theme
@param $themeId
@return boolean|\common_report_Report | [
"Set",
"the",
"current",
"theme"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L185-L195 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.reset | public function reset() {
$map = $this->registry->getMap();
if(empty($map['items']['available'])) {
return false;
}
foreach($map['items']['available'] as $theme) {
// exclude themes that don't belong to this customer
if($theme['id'] === 'tao' || 0 !== strpos($theme['id'], $this->extensionId)) {
continue;
}
$this->registry->unregisterTheme($theme['id']);
}
// get the now updated map
$map = $this->registry->getMap();
$taoTheme = array(
'id' => 'tao',
'name' => 'TAO',
'path' => $this->getStylesheetPath('tao')
);
if(!$this->themeExists('tao')) {
array_unshift($map['items']['available'], $taoTheme);
}
$this->registry->set('items', array(
'base' => $map['items']['base'],
// potential other themes have not been removed
'available' => $map['items']['available'],
'default' => 'tao'
));
$this->logInfo('Removed ' . $this->extensionId . ' themes, restored TAO default');
return true;
} | php | public function reset() {
$map = $this->registry->getMap();
if(empty($map['items']['available'])) {
return false;
}
foreach($map['items']['available'] as $theme) {
// exclude themes that don't belong to this customer
if($theme['id'] === 'tao' || 0 !== strpos($theme['id'], $this->extensionId)) {
continue;
}
$this->registry->unregisterTheme($theme['id']);
}
// get the now updated map
$map = $this->registry->getMap();
$taoTheme = array(
'id' => 'tao',
'name' => 'TAO',
'path' => $this->getStylesheetPath('tao')
);
if(!$this->themeExists('tao')) {
array_unshift($map['items']['available'], $taoTheme);
}
$this->registry->set('items', array(
'base' => $map['items']['base'],
// potential other themes have not been removed
'available' => $map['items']['available'],
'default' => 'tao'
));
$this->logInfo('Removed ' . $this->extensionId . ' themes, restored TAO default');
return true;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"registry",
"->",
"getMap",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"map",
"[",
"'items'",
"]",
"[",
"'available'",
"]",
")",
")",
"{",
"return",
"false",
";",... | Reset the item theme registry to its initial values
@return bool|\common_report_Report | [
"Reset",
"the",
"item",
"theme",
"registry",
"to",
"its",
"initial",
"values"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L203-L237 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.themeExists | public function themeExists($themeId) {
// while this seem to be obsolete in most cases
// it can be useful when the function is called from the outside
$prefixedId = $this->getPrefixedThemeId($themeId);
$map = $this->registry->getMap();
if(empty($map['items']['available'])) {
return false;
}
foreach($map['items']['available'] as $theme) {
if($theme['id'] === $prefixedId) {
return true;
}
}
return false;
} | php | public function themeExists($themeId) {
// while this seem to be obsolete in most cases
// it can be useful when the function is called from the outside
$prefixedId = $this->getPrefixedThemeId($themeId);
$map = $this->registry->getMap();
if(empty($map['items']['available'])) {
return false;
}
foreach($map['items']['available'] as $theme) {
if($theme['id'] === $prefixedId) {
return true;
}
}
return false;
} | [
"public",
"function",
"themeExists",
"(",
"$",
"themeId",
")",
"{",
"// while this seem to be obsolete in most cases",
"// it can be useful when the function is called from the outside",
"$",
"prefixedId",
"=",
"$",
"this",
"->",
"getPrefixedThemeId",
"(",
"$",
"themeId",
")"... | Is a theme already registered?
@param $themeId
@return bool | [
"Is",
"a",
"theme",
"already",
"registered?"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L246-L260 |
oat-sa/extension-tao-itemqti | model/themes/ItemThemeInstaller.php | ItemThemeInstaller.getPrefixedThemeId | protected function getPrefixedThemeId($themeId) {
if($themeId === 'tao') {
return $themeId;
}
if(preg_match('~^' . $this->extensionId . '[A-Z]~', $themeId)) {
return $themeId;
}
return $this->extensionId . ucfirst($themeId);
} | php | protected function getPrefixedThemeId($themeId) {
if($themeId === 'tao') {
return $themeId;
}
if(preg_match('~^' . $this->extensionId . '[A-Z]~', $themeId)) {
return $themeId;
}
return $this->extensionId . ucfirst($themeId);
} | [
"protected",
"function",
"getPrefixedThemeId",
"(",
"$",
"themeId",
")",
"{",
"if",
"(",
"$",
"themeId",
"===",
"'tao'",
")",
"{",
"return",
"$",
"themeId",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'~^'",
".",
"$",
"this",
"->",
"extensionId",
".",
"'[... | Prefix theme id base on extension id from calling class. Pass through if already prefixed
@param $themeId
@return string | [
"Prefix",
"theme",
"id",
"base",
"on",
"extension",
"id",
"from",
"calling",
"class",
".",
"Pass",
"through",
"if",
"already",
"prefixed"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/themes/ItemThemeInstaller.php#L270-L278 |
oat-sa/extension-tao-itemqti | helpers/QtiFile.php | QtiFile.getQtiFileContent | public static function getQtiFileContent(core_kernel_classes_Resource $item, $language = '')
{
$itemDirectory = taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $language);
return $itemDirectory->getFile(self::FILE)->read();
} | php | public static function getQtiFileContent(core_kernel_classes_Resource $item, $language = '')
{
$itemDirectory = taoItems_models_classes_ItemsService::singleton()->getItemDirectory($item, $language);
return $itemDirectory->getFile(self::FILE)->read();
} | [
"public",
"static",
"function",
"getQtiFileContent",
"(",
"core_kernel_classes_Resource",
"$",
"item",
",",
"$",
"language",
"=",
"''",
")",
"{",
"$",
"itemDirectory",
"=",
"taoItems_models_classes_ItemsService",
"::",
"singleton",
"(",
")",
"->",
"getItemDirectory",
... | Get content of qti.xml following an item + language
@param core_kernel_classes_Resource $item
@param string $language
@return false|string
@throws \common_Exception | [
"Get",
"content",
"of",
"qti",
".",
"xml",
"following",
"an",
"item",
"+",
"language"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/helpers/QtiFile.php#L42-L46 |
oat-sa/extension-tao-itemqti | model/Export/ItemMetadataByClassExportHandler.php | ItemMetadataByClassExportHandler.getExportForm | public function getExportForm(core_kernel_classes_Resource $resource)
{
if ($resource instanceof \core_kernel_classes_Class) {
$formData = ['class' => $resource];
} else {
$formData = ['class' => $this->getClass($resource)];
}
$form = new MetadataExporterForm($formData);
return $form->getForm();
} | php | public function getExportForm(core_kernel_classes_Resource $resource)
{
if ($resource instanceof \core_kernel_classes_Class) {
$formData = ['class' => $resource];
} else {
$formData = ['class' => $this->getClass($resource)];
}
$form = new MetadataExporterForm($formData);
return $form->getForm();
} | [
"public",
"function",
"getExportForm",
"(",
"core_kernel_classes_Resource",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"resource",
"instanceof",
"\\",
"core_kernel_classes_Class",
")",
"{",
"$",
"formData",
"=",
"[",
"'class'",
"=>",
"$",
"resource",
"]",
";",
... | Create MetadataExporterForm with class uri
@param core_kernel_classes_Resource $resource
@return \tao_helpers_form_Form | [
"Create",
"MetadataExporterForm",
"with",
"class",
"uri"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/Export/ItemMetadataByClassExportHandler.php#L56-L66 |
oat-sa/extension-tao-itemqti | model/Export/ItemMetadataByClassExportHandler.php | ItemMetadataByClassExportHandler.getClassToExport | protected function getClassToExport($uri)
{
$resource = $this->getResource($uri);
if ($resource->isClass()) {
$classToExport = $this->getClass($uri);
} else {
$classToExport = reset($resource->getTypes());
}
return $classToExport;
} | php | protected function getClassToExport($uri)
{
$resource = $this->getResource($uri);
if ($resource->isClass()) {
$classToExport = $this->getClass($uri);
} else {
$classToExport = reset($resource->getTypes());
}
return $classToExport;
} | [
"protected",
"function",
"getClassToExport",
"(",
"$",
"uri",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getResource",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"resource",
"->",
"isClass",
"(",
")",
")",
"{",
"$",
"classToExport",
"=",
"$"... | Get class to export, from resource uri or class uri
If parameter is null, check id http parameter
@param null $uri
@return \core_kernel_classes_Class|mixed
@throws \common_exception_BadRequest | [
"Get",
"class",
"to",
"export",
"from",
"resource",
"uri",
"or",
"class",
"uri",
"If",
"parameter",
"is",
"null",
"check",
"id",
"http",
"parameter"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/Export/ItemMetadataByClassExportHandler.php#L129-L140 |
oat-sa/extension-tao-itemqti | controller/QtiCreator.php | QtiCreator.createItem | public function createItem()
{
if(!\tao_helpers_Request::isAjax()){
throw new common_exception_BadRequest('wrong request mode');
}
$clazz = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
if ($clazz->isClass()) {
$clazz = new \core_kernel_classes_Class($clazz);
} else {
foreach ($clazz->getTypes() as $type) {
// determine class from selected instance
$clazz = $type;
break;
}
}
$service = \taoItems_models_classes_ItemsService::singleton();
$label = $service->createUniqueLabel($clazz);
$item = $service->createInstance($clazz, $label);
if(!is_null($item)){
$service->setItemModel($item, new \core_kernel_classes_Resource(ItemModel::MODEL_URI));
$this->getEventManager()->trigger(new ItemCreatedEvent($item->getUri()));
$response = array(
'label' => $item->getLabel(),
'uri' => $item->getUri()
);
} else {
$response = false;
}
$this->returnJson($response);
} | php | public function createItem()
{
if(!\tao_helpers_Request::isAjax()){
throw new common_exception_BadRequest('wrong request mode');
}
$clazz = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
if ($clazz->isClass()) {
$clazz = new \core_kernel_classes_Class($clazz);
} else {
foreach ($clazz->getTypes() as $type) {
// determine class from selected instance
$clazz = $type;
break;
}
}
$service = \taoItems_models_classes_ItemsService::singleton();
$label = $service->createUniqueLabel($clazz);
$item = $service->createInstance($clazz, $label);
if(!is_null($item)){
$service->setItemModel($item, new \core_kernel_classes_Resource(ItemModel::MODEL_URI));
$this->getEventManager()->trigger(new ItemCreatedEvent($item->getUri()));
$response = array(
'label' => $item->getLabel(),
'uri' => $item->getUri()
);
} else {
$response = false;
}
$this->returnJson($response);
} | [
"public",
"function",
"createItem",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"tao_helpers_Request",
"::",
"isAjax",
"(",
")",
")",
"{",
"throw",
"new",
"common_exception_BadRequest",
"(",
"'wrong request mode'",
")",
";",
"}",
"$",
"clazz",
"=",
"new",
"\\",
"... | create a new QTI item
@throws common_exception_BadRequest
@throws common_exception_Error
@requiresRight id WRITE | [
"create",
"a",
"new",
"QTI",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/QtiCreator.php#L70-L101 |
oat-sa/extension-tao-itemqti | controller/QtiCreator.php | QtiCreator.getCreatorConfig | protected function getCreatorConfig(core_kernel_classes_Resource $item){
$config = new CreatorConfig();
$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$creatorConfig = $ext->getConfig('qtiCreator');
if (is_array($creatorConfig)) {
foreach ($creatorConfig as $prop => $value) {
$config->setProperty($prop, $value);
}
}
$config->setProperty('uri', $item->getUri());
$config->setProperty('label', $item->getLabel());
//set the current data lang in the item content to keep the integrity
//@todo : allow preview in a language other than the one in the session
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
$config->setProperty('lang', $lang);
//base url:
$url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array(
'uri' => $item->getUri(),
'lang' => $lang,
'relPath' => ''
));
$config->setProperty('baseUrl', $url);
//map the multi column config to the plugin
//TODO migrate the config
if($config->getProperty('multi-column') == true){
$config->addPlugin('blockAdder', 'taoQtiItem/qtiCreator/plugins/content/blockAdder', 'content');
}
$mediaSourcesUrl = tao_helpers_Uri::url(
'getMediaSources',
'QtiCreator',
'taoQtiItem'
);
$config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
//initialize all registered hooks:
$hookClasses = HookRegistry::getRegistry()->getMap();
foreach ($hookClasses as $hookClass) {
$hook = new $hookClass();
$hook->init($config);
}
$config->init();
return $config;
} | php | protected function getCreatorConfig(core_kernel_classes_Resource $item){
$config = new CreatorConfig();
$ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$creatorConfig = $ext->getConfig('qtiCreator');
if (is_array($creatorConfig)) {
foreach ($creatorConfig as $prop => $value) {
$config->setProperty($prop, $value);
}
}
$config->setProperty('uri', $item->getUri());
$config->setProperty('label', $item->getLabel());
//set the current data lang in the item content to keep the integrity
//@todo : allow preview in a language other than the one in the session
$lang = \common_session_SessionManager::getSession()->getDataLanguage();
$config->setProperty('lang', $lang);
//base url:
$url = tao_helpers_Uri::url('getFile', 'QtiCreator', 'taoQtiItem', array(
'uri' => $item->getUri(),
'lang' => $lang,
'relPath' => ''
));
$config->setProperty('baseUrl', $url);
//map the multi column config to the plugin
//TODO migrate the config
if($config->getProperty('multi-column') == true){
$config->addPlugin('blockAdder', 'taoQtiItem/qtiCreator/plugins/content/blockAdder', 'content');
}
$mediaSourcesUrl = tao_helpers_Uri::url(
'getMediaSources',
'QtiCreator',
'taoQtiItem'
);
$config->setProperty('mediaSourcesUrl', $mediaSourcesUrl);
//initialize all registered hooks:
$hookClasses = HookRegistry::getRegistry()->getMap();
foreach ($hookClasses as $hookClass) {
$hook = new $hookClass();
$hook->init($config);
}
$config->init();
return $config;
} | [
"protected",
"function",
"getCreatorConfig",
"(",
"core_kernel_classes_Resource",
"$",
"item",
")",
"{",
"$",
"config",
"=",
"new",
"CreatorConfig",
"(",
")",
";",
"$",
"ext",
"=",
"\\",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExte... | Get the configuration of the Item Creator
@param core_kernel_classes_Resource $item the selected item
@return CreatorConfig the configration | [
"Get",
"the",
"configuration",
"of",
"the",
"Item",
"Creator"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/QtiCreator.php#L234-L287 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.addInteraction | public function addInteraction(Interaction $interaction, $body){
$returnValue = false;
if(!is_null($interaction)){
$returnValue = $this->getBody()->setElement($interaction, $body);
}
return (bool) $returnValue;
} | php | public function addInteraction(Interaction $interaction, $body){
$returnValue = false;
if(!is_null($interaction)){
$returnValue = $this->getBody()->setElement($interaction, $body);
}
return (bool) $returnValue;
} | [
"public",
"function",
"addInteraction",
"(",
"Interaction",
"$",
"interaction",
",",
"$",
"body",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"interaction",
")",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
... | Short description of method addInteraction
@access public
@author Sam, <sam@taotesting.com>
@param Interaction $interaction
@param $body
@return bool | [
"Short",
"description",
"of",
"method",
"addInteraction"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L189-L197 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.removeInteraction | public function removeInteraction(Interaction $interaction){
$returnValue = false;
if(!is_null($interaction)){
$returnValue = $this->getBody()->removeElement($interaction);
}
return (bool) $returnValue;
} | php | public function removeInteraction(Interaction $interaction){
$returnValue = false;
if(!is_null($interaction)){
$returnValue = $this->getBody()->removeElement($interaction);
}
return (bool) $returnValue;
} | [
"public",
"function",
"removeInteraction",
"(",
"Interaction",
"$",
"interaction",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"interaction",
")",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getBody",
... | Short description of method removeInteraction
@access public
@author Sam, <sam@taotesting.com>
@param Interaction $interaction
@return bool | [
"Short",
"description",
"of",
"method",
"removeInteraction"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L207-L215 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.setOutcomes | public function setOutcomes($outcomes){
$this->outcomes = array();
foreach($outcomes as $outcome){
if(!$outcome instanceof OutcomeDeclaration){
throw new \InvalidArgumentException("wrong entry in outcomes list");
}
$this->addOutcome($outcome);
}
} | php | public function setOutcomes($outcomes){
$this->outcomes = array();
foreach($outcomes as $outcome){
if(!$outcome instanceof OutcomeDeclaration){
throw new \InvalidArgumentException("wrong entry in outcomes list");
}
$this->addOutcome($outcome);
}
} | [
"public",
"function",
"setOutcomes",
"(",
"$",
"outcomes",
")",
"{",
"$",
"this",
"->",
"outcomes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"outcomes",
"as",
"$",
"outcome",
")",
"{",
"if",
"(",
"!",
"$",
"outcome",
"instanceof",
"OutcomeDecl... | Short description of method setOutcomes
@access public
@author Sam, <sam@taotesting.com>
@param
array outcomes
@return mixed
@throws InvalidArgumentException | [
"Short",
"description",
"of",
"method",
"setOutcomes"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L266-L274 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.addOutcome | public function addOutcome(OutcomeDeclaration $outcome){
$this->outcomes[$outcome->getSerial()] = $outcome;
$outcome->setRelatedItem($this);
} | php | public function addOutcome(OutcomeDeclaration $outcome){
$this->outcomes[$outcome->getSerial()] = $outcome;
$outcome->setRelatedItem($this);
} | [
"public",
"function",
"addOutcome",
"(",
"OutcomeDeclaration",
"$",
"outcome",
")",
"{",
"$",
"this",
"->",
"outcomes",
"[",
"$",
"outcome",
"->",
"getSerial",
"(",
")",
"]",
"=",
"$",
"outcome",
";",
"$",
"outcome",
"->",
"setRelatedItem",
"(",
"$",
"th... | add an outcome declaration to the item
@param \oat\taoQtiItem\model\qti\OutcomeDeclaration $outcome | [
"add",
"an",
"outcome",
"declaration",
"to",
"the",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L281-L284 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.getOutcome | public function getOutcome($serial){
$returnValue = null;
if(!empty($serial)){
if(isset($this->outcomes[$serial])){
$returnValue = $this->outcomes[$serial];
}
}
return $returnValue;
} | php | public function getOutcome($serial){
$returnValue = null;
if(!empty($serial)){
if(isset($this->outcomes[$serial])){
$returnValue = $this->outcomes[$serial];
}
}
return $returnValue;
} | [
"public",
"function",
"getOutcome",
"(",
"$",
"serial",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"serial",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"outcomes",
"[",
"$",
"serial",
"]",
"... | Short description of method getOutcome
@access public
@author Sam, <sam@taotesting.com>
@param
string serial
@return \oat\taoQtiItem\model\qti\OutcomeDeclaration | [
"Short",
"description",
"of",
"method",
"getOutcome"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L306-L316 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.removeOutcome | public function removeOutcome(OutcomeDeclaration $outcome){
$returnValue = (bool) false;
if(!is_null($outcome)){
if(isset($this->outcomes[$outcome->getSerial()])){
unset($this->outcomes[$outcome->getSerial()]);
$returnValue = true;
}
}else{
common_Logger::w('Tried to remove null outcome');
}
if(!$returnValue){
common_Logger::w('outcome not found '.$outcome->getSerial());
}
return (bool) $returnValue;
} | php | public function removeOutcome(OutcomeDeclaration $outcome){
$returnValue = (bool) false;
if(!is_null($outcome)){
if(isset($this->outcomes[$outcome->getSerial()])){
unset($this->outcomes[$outcome->getSerial()]);
$returnValue = true;
}
}else{
common_Logger::w('Tried to remove null outcome');
}
if(!$returnValue){
common_Logger::w('outcome not found '.$outcome->getSerial());
}
return (bool) $returnValue;
} | [
"public",
"function",
"removeOutcome",
"(",
"OutcomeDeclaration",
"$",
"outcome",
")",
"{",
"$",
"returnValue",
"=",
"(",
"bool",
")",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"outcome",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
... | Short description of method removeOutcome
@access public
@author Sam, <sam@taotesting.com>
@param OutcomeDeclaration $outcome
@return bool | [
"Short",
"description",
"of",
"method",
"removeOutcome"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L326-L343 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.getIdentifiedElements | public function getIdentifiedElements(){
$returnValue = $this->getBody()->getIdentifiedElements();
$returnValue->addMultiple($this->getOutcomes());
$returnValue->addMultiple($this->getResponses());
$returnValue->addMultiple($this->getModalFeedbacks());
return $returnValue;
} | php | public function getIdentifiedElements(){
$returnValue = $this->getBody()->getIdentifiedElements();
$returnValue->addMultiple($this->getOutcomes());
$returnValue->addMultiple($this->getResponses());
$returnValue->addMultiple($this->getModalFeedbacks());
return $returnValue;
} | [
"public",
"function",
"getIdentifiedElements",
"(",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getBody",
"(",
")",
"->",
"getIdentifiedElements",
"(",
")",
";",
"$",
"returnValue",
"->",
"addMultiple",
"(",
"$",
"this",
"->",
"getOutcomes",
"(",
... | Get recursively all included identified QTI elements in the object (identifier => Object)
@return array | [
"Get",
"recursively",
"all",
"included",
"identified",
"QTI",
"elements",
"in",
"the",
"object",
"(",
"identifier",
"=",
">",
"Object",
")"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L425-L432 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.toXHTML | public function toXHTML($options = array(), &$filtered = array()){
$template = static::getTemplatePath().'/xhtml.item.tpl.php';
// get the variables to use in the template
$variables = $this->getAttributeValues();
$variables['stylesheets'] = array();
foreach($this->getStylesheets() as $stylesheet){
$variables['stylesheets'][] = $stylesheet->getAttributeValues();
}
//additional css:
if(isset($options['css'])){
foreach($options['css'] as $css){
$variables['stylesheets'][] = array('href' => $css, 'media' => 'all');
}
}
//additional js:
$variables['javascripts'] = array();
$variables['js_variables'] = array();
if(isset($options['js'])){
foreach($options['js'] as $js){
$variables['javascripts'][] = array('src' => $js);
}
}
if(isset($options['js_var'])){
foreach($options['js_var'] as $name => $value){
$variables['js_variables'][$name] = $value;
}
}
//user scripts
$variables['user_scripts'] = $this->getUserScripts();
$dataForDelivery = $this->getDataForDelivery();
$variables['itemData'] = $dataForDelivery['core'];
//copy all variable data into filtered array
foreach($dataForDelivery['variable'] as $serial => $data){
$filtered[$serial] = $data;
}
$variables['contentVariableElements'] = isset($options['contentVariableElements']) && is_array($options['contentVariableElements']) ? $options['contentVariableElements'] : array();
$variables['tao_lib_path'] = isset($options['path']) && isset($options['path']['tao']) ? $options['path']['tao'] : '';
$variables['taoQtiItem_lib_path'] = isset($options['path']) && isset($options['path']['taoQtiItem']) ? $options['path']['taoQtiItem'] : '';
$variables['client_config_url'] = isset($options['client_config_url']) ? $options['client_config_url'] : '';
$tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);
$returnValue = $tplRenderer->render();
return (string) $returnValue;
} | php | public function toXHTML($options = array(), &$filtered = array()){
$template = static::getTemplatePath().'/xhtml.item.tpl.php';
// get the variables to use in the template
$variables = $this->getAttributeValues();
$variables['stylesheets'] = array();
foreach($this->getStylesheets() as $stylesheet){
$variables['stylesheets'][] = $stylesheet->getAttributeValues();
}
//additional css:
if(isset($options['css'])){
foreach($options['css'] as $css){
$variables['stylesheets'][] = array('href' => $css, 'media' => 'all');
}
}
//additional js:
$variables['javascripts'] = array();
$variables['js_variables'] = array();
if(isset($options['js'])){
foreach($options['js'] as $js){
$variables['javascripts'][] = array('src' => $js);
}
}
if(isset($options['js_var'])){
foreach($options['js_var'] as $name => $value){
$variables['js_variables'][$name] = $value;
}
}
//user scripts
$variables['user_scripts'] = $this->getUserScripts();
$dataForDelivery = $this->getDataForDelivery();
$variables['itemData'] = $dataForDelivery['core'];
//copy all variable data into filtered array
foreach($dataForDelivery['variable'] as $serial => $data){
$filtered[$serial] = $data;
}
$variables['contentVariableElements'] = isset($options['contentVariableElements']) && is_array($options['contentVariableElements']) ? $options['contentVariableElements'] : array();
$variables['tao_lib_path'] = isset($options['path']) && isset($options['path']['tao']) ? $options['path']['tao'] : '';
$variables['taoQtiItem_lib_path'] = isset($options['path']) && isset($options['path']['taoQtiItem']) ? $options['path']['taoQtiItem'] : '';
$variables['client_config_url'] = isset($options['client_config_url']) ? $options['client_config_url'] : '';
$tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);
$returnValue = $tplRenderer->render();
return (string) $returnValue;
} | [
"public",
"function",
"toXHTML",
"(",
"$",
"options",
"=",
"array",
"(",
")",
",",
"&",
"$",
"filtered",
"=",
"array",
"(",
")",
")",
"{",
"$",
"template",
"=",
"static",
"::",
"getTemplatePath",
"(",
")",
".",
"'/xhtml.item.tpl.php'",
";",
"// get the v... | Short description of method toXHTML
@access public
@author Sam, <sam@taotesting.com>
@param array $options
@param array $filtered
@return string | [
"Short",
"description",
"of",
"method",
"toXHTML"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L443-L495 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.toXML | public function toXML($validate = false){
$returnValue = '';
$qti = $this->toQTI();
// render and clean the xml
$dom = new DOMDocument('1.0', 'UTF-8');
$domDocumentConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('XMLParser');
if (is_array($domDocumentConfig) && !empty($domDocumentConfig)) {
foreach ($domDocumentConfig as $param => $value) {
if (property_exists($dom, $param)) {
$dom->$param = $value;
}
}
} else {
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
$dom->validateOnParse = false;
}
if($dom->loadXML($qti)){
$returnValue = $dom->saveXML();
//in debug mode, systematically check if the save QTI is standard compliant
if($validate){
$parserValidator = new Parser($returnValue);
$parserValidator->validate();
if(!$parserValidator->isValid()){
common_Logger::w('Invalid QTI output: '.PHP_EOL.' '.$parserValidator->displayErrors());
}
}
}else{
$parserValidator = new Parser($qti);
$parserValidator->validate();
if(!$parserValidator->isValid()){
throw new QtiModelException('Wrong QTI item output format');
}
}
return (string) $returnValue;
} | php | public function toXML($validate = false){
$returnValue = '';
$qti = $this->toQTI();
// render and clean the xml
$dom = new DOMDocument('1.0', 'UTF-8');
$domDocumentConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('XMLParser');
if (is_array($domDocumentConfig) && !empty($domDocumentConfig)) {
foreach ($domDocumentConfig as $param => $value) {
if (property_exists($dom, $param)) {
$dom->$param = $value;
}
}
} else {
$dom->formatOutput = true;
$dom->preserveWhiteSpace = false;
$dom->validateOnParse = false;
}
if($dom->loadXML($qti)){
$returnValue = $dom->saveXML();
//in debug mode, systematically check if the save QTI is standard compliant
if($validate){
$parserValidator = new Parser($returnValue);
$parserValidator->validate();
if(!$parserValidator->isValid()){
common_Logger::w('Invalid QTI output: '.PHP_EOL.' '.$parserValidator->displayErrors());
}
}
}else{
$parserValidator = new Parser($qti);
$parserValidator->validate();
if(!$parserValidator->isValid()){
throw new QtiModelException('Wrong QTI item output format');
}
}
return (string) $returnValue;
} | [
"public",
"function",
"toXML",
"(",
"$",
"validate",
"=",
"false",
")",
"{",
"$",
"returnValue",
"=",
"''",
";",
"$",
"qti",
"=",
"$",
"this",
"->",
"toQTI",
"(",
")",
";",
"// render and clean the xml",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
"'1.... | Short description of method toQTI
@access public
@author Sam, <sam@taotesting.com>
@param boolean $validate (optional) Validate the XML output against QTI Specification (XML Schema). Default is false.
@return string
@throws exception\QtiModelException | [
"Short",
"description",
"of",
"method",
"toQTI"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L577-L620 |
oat-sa/extension-tao-itemqti | model/qti/Item.php | Item.toArray | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = parent::toArray($filterVariableContent, $filtered);
$data['namespaces'] = $this->getNamespaces();
$data['schemaLocations'] = $this->getSchemaLocations();
$data['stylesheets'] = $this->getArraySerializedElementCollection($this->getStylesheets(), $filterVariableContent, $filtered);
$data['outcomes'] = $this->getArraySerializedElementCollection($this->getOutcomes(), $filterVariableContent, $filtered);
$data['responses'] = $this->getArraySerializedElementCollection($this->getResponses(), $filterVariableContent, $filtered);
$data['feedbacks'] = $this->getArraySerializedElementCollection($this->getModalFeedbacks(), $filterVariableContent, $filtered);
$data['responseProcessing'] = $this->responseProcessing->toArray($filterVariableContent, $filtered);
$data['apipAccessibility'] = $this->getApipAccessibility();
return $data;
} | php | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = parent::toArray($filterVariableContent, $filtered);
$data['namespaces'] = $this->getNamespaces();
$data['schemaLocations'] = $this->getSchemaLocations();
$data['stylesheets'] = $this->getArraySerializedElementCollection($this->getStylesheets(), $filterVariableContent, $filtered);
$data['outcomes'] = $this->getArraySerializedElementCollection($this->getOutcomes(), $filterVariableContent, $filtered);
$data['responses'] = $this->getArraySerializedElementCollection($this->getResponses(), $filterVariableContent, $filtered);
$data['feedbacks'] = $this->getArraySerializedElementCollection($this->getModalFeedbacks(), $filterVariableContent, $filtered);
$data['responseProcessing'] = $this->responseProcessing->toArray($filterVariableContent, $filtered);
$data['apipAccessibility'] = $this->getApipAccessibility();
return $data;
} | [
"public",
"function",
"toArray",
"(",
"$",
"filterVariableContent",
"=",
"false",
",",
"&",
"$",
"filtered",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"parent",
"::",
"toArray",
"(",
"$",
"filterVariableContent",
",",
"$",
"filtered",
")",
";",... | Serialize item object into json format, handy to be used in js | [
"Serialize",
"item",
"object",
"into",
"json",
"format",
"handy",
"to",
"be",
"used",
"in",
"js"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Item.php#L625-L636 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.isQtiItem | private function isQtiItem(core_kernel_classes_Resource $itemResource){
$itemService = taoItems_models_classes_ItemsService::singleton();
return $itemService->hasItemModel($itemResource, [ItemModel::MODEL_URI]);
} | php | private function isQtiItem(core_kernel_classes_Resource $itemResource){
$itemService = taoItems_models_classes_ItemsService::singleton();
return $itemService->hasItemModel($itemResource, [ItemModel::MODEL_URI]);
} | [
"private",
"function",
"isQtiItem",
"(",
"core_kernel_classes_Resource",
"$",
"itemResource",
")",
"{",
"$",
"itemService",
"=",
"taoItems_models_classes_ItemsService",
"::",
"singleton",
"(",
")",
";",
"return",
"$",
"itemService",
"->",
"hasItemModel",
"(",
"$",
"... | Check if the resource in argument is a valid qti item
@param core_kernel_classes_Resource $itemResource
@return boolean | [
"Check",
"if",
"the",
"resource",
"in",
"argument",
"is",
"a",
"valid",
"qti",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L44-L47 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.getItemContent | private function getItemContent(core_kernel_classes_Resource $itemResource, $langCode = '')
{
if ($this->isQtiItem($itemResource)) {
$itemContent = Service::singleton()
->getDataItemByRdfItem($itemResource, $langCode)
->toXML();
if (!empty($itemContent)) {
return simplexml_load_string($itemContent);
}
}
return null;
} | php | private function getItemContent(core_kernel_classes_Resource $itemResource, $langCode = '')
{
if ($this->isQtiItem($itemResource)) {
$itemContent = Service::singleton()
->getDataItemByRdfItem($itemResource, $langCode)
->toXML();
if (!empty($itemContent)) {
return simplexml_load_string($itemContent);
}
}
return null;
} | [
"private",
"function",
"getItemContent",
"(",
"core_kernel_classes_Resource",
"$",
"itemResource",
",",
"$",
"langCode",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isQtiItem",
"(",
"$",
"itemResource",
")",
")",
"{",
"$",
"itemContent",
"=",
"Servic... | Get the item content for a qti item resource
@param core_kernel_classes_Resource $itemResource
@param string $langCode
@return SimpleXMLElement | [
"Get",
"the",
"item",
"content",
"for",
"a",
"qti",
"item",
"resource"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L56-L68 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.setItemContent | private function setItemContent(SimpleXMLElement $content, core_kernel_classes_Resource $itemResource)
{
if ($this->isQtiItem($itemResource)) {
return Service::singleton()->saveXmlItemToRdfItem($content->asXML(), $itemResource);
}
return false;
} | php | private function setItemContent(SimpleXMLElement $content, core_kernel_classes_Resource $itemResource)
{
if ($this->isQtiItem($itemResource)) {
return Service::singleton()->saveXmlItemToRdfItem($content->asXML(), $itemResource);
}
return false;
} | [
"private",
"function",
"setItemContent",
"(",
"SimpleXMLElement",
"$",
"content",
",",
"core_kernel_classes_Resource",
"$",
"itemResource",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isQtiItem",
"(",
"$",
"itemResource",
")",
")",
"{",
"return",
"Service",
"::",
... | Set the item content for a qti item resource
@param SimpleXMLElement $content
@param core_kernel_classes_Resource $itemResource
@return bool | [
"Set",
"the",
"item",
"content",
"for",
"a",
"qti",
"item",
"resource"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L77-L84 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.getBodyStyles | public function getBodyStyles(core_kernel_classes_Resource $itemResource, $langCode = ''){
$itemContent = $this->getItemContent($itemResource, $langCode);
if(is_null($itemContent)){
throw new \common_Exception('cannot find valid qti item content');
}else{
$classAttr = (string) $itemContent->itemBody['class'];
preg_match_all('/x-tao-style-'.self::STYLE_NAME_PATTERN.'/', $classAttr, $matches);
if(isset($matches[1])){
return $matches[1];
}
}
} | php | public function getBodyStyles(core_kernel_classes_Resource $itemResource, $langCode = ''){
$itemContent = $this->getItemContent($itemResource, $langCode);
if(is_null($itemContent)){
throw new \common_Exception('cannot find valid qti item content');
}else{
$classAttr = (string) $itemContent->itemBody['class'];
preg_match_all('/x-tao-style-'.self::STYLE_NAME_PATTERN.'/', $classAttr, $matches);
if(isset($matches[1])){
return $matches[1];
}
}
} | [
"public",
"function",
"getBodyStyles",
"(",
"core_kernel_classes_Resource",
"$",
"itemResource",
",",
"$",
"langCode",
"=",
"''",
")",
"{",
"$",
"itemContent",
"=",
"$",
"this",
"->",
"getItemContent",
"(",
"$",
"itemResource",
",",
"$",
"langCode",
")",
";",
... | Get the array of body style classes set to the itemBody of a qti item
@param core_kernel_classes_Resource $itemResource
@param string $langCode
@return array
@throws \common_Exception | [
"Get",
"the",
"array",
"of",
"body",
"style",
"classes",
"set",
"to",
"the",
"itemBody",
"of",
"a",
"qti",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L94-L105 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.addBodyStyles | public function addBodyStyles($styleNames, core_kernel_classes_Resource $itemResource, $langCode = ''){
$itemContent = $this->getItemContent($itemResource, $langCode);
if(!is_null($itemContent) && !empty($styleNames)){
$classAttr = (string) $itemContent->itemBody['class'];
foreach($styleNames as $styleName){
if(!empty($styleName) && preg_match(self::STYLE_NAME_PATTERN, $styleName)){
$newClass = 'x-tao-style-'.$styleName;
if(strpos($classAttr, $styleName) === false){
$classAttr .= ' '.$newClass;
}
}else{
throw new \common_Exception('invalid style name');
}
}
$itemContent->itemBody['class'] = trim($classAttr);
return $this->setItemContent($itemContent, $itemResource);
}
return false;
} | php | public function addBodyStyles($styleNames, core_kernel_classes_Resource $itemResource, $langCode = ''){
$itemContent = $this->getItemContent($itemResource, $langCode);
if(!is_null($itemContent) && !empty($styleNames)){
$classAttr = (string) $itemContent->itemBody['class'];
foreach($styleNames as $styleName){
if(!empty($styleName) && preg_match(self::STYLE_NAME_PATTERN, $styleName)){
$newClass = 'x-tao-style-'.$styleName;
if(strpos($classAttr, $styleName) === false){
$classAttr .= ' '.$newClass;
}
}else{
throw new \common_Exception('invalid style name');
}
}
$itemContent->itemBody['class'] = trim($classAttr);
return $this->setItemContent($itemContent, $itemResource);
}
return false;
} | [
"public",
"function",
"addBodyStyles",
"(",
"$",
"styleNames",
",",
"core_kernel_classes_Resource",
"$",
"itemResource",
",",
"$",
"langCode",
"=",
"''",
")",
"{",
"$",
"itemContent",
"=",
"$",
"this",
"->",
"getItemContent",
"(",
"$",
"itemResource",
",",
"$"... | Add an array of body style classes to the itemBody of a qti item
@param core_kernel_classes_Resource $itemResource
@param string $langCode
@return boolean
@throws \common_Exception | [
"Add",
"an",
"array",
"of",
"body",
"style",
"classes",
"to",
"the",
"itemBody",
"of",
"a",
"qti",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L115-L133 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.getClassBodyStyles | public function getClassBodyStyles(core_kernel_classes_Class $itemClass){
$usages = [];
$union = [];
$intersect = [];
$items = $itemClass->getInstances(true);
$i = 0;
foreach($items as $item){
if($this->isQtiItem($item)){
try{
$styles = $this->getBodyStyles($item);
$usages[$item->getUri()] = $styles;
if($i){
$intersect = array_intersect($styles, $intersect);
}else{
$intersect = $styles;
}
$union = array_unique(array_merge($styles, $union));
$i++;
}catch(\common_Exception $e){}
}
}
return [
'all' => $union,
'checked' => $intersect,
'indeterminate' => array_values(array_diff($union, $intersect))
];
} | php | public function getClassBodyStyles(core_kernel_classes_Class $itemClass){
$usages = [];
$union = [];
$intersect = [];
$items = $itemClass->getInstances(true);
$i = 0;
foreach($items as $item){
if($this->isQtiItem($item)){
try{
$styles = $this->getBodyStyles($item);
$usages[$item->getUri()] = $styles;
if($i){
$intersect = array_intersect($styles, $intersect);
}else{
$intersect = $styles;
}
$union = array_unique(array_merge($styles, $union));
$i++;
}catch(\common_Exception $e){}
}
}
return [
'all' => $union,
'checked' => $intersect,
'indeterminate' => array_values(array_diff($union, $intersect))
];
} | [
"public",
"function",
"getClassBodyStyles",
"(",
"core_kernel_classes_Class",
"$",
"itemClass",
")",
"{",
"$",
"usages",
"=",
"[",
"]",
";",
"$",
"union",
"=",
"[",
"]",
";",
"$",
"intersect",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"itemClass",
"-... | Get an array that give the style usage within an tao item subclasses.
It only takes into account qti item with a no-empty content
@param core_kernel_classes_Class $itemClass
@return array | [
"Get",
"an",
"array",
"that",
"give",
"the",
"style",
"usage",
"within",
"an",
"tao",
"item",
"subclasses",
".",
"It",
"only",
"takes",
"into",
"account",
"qti",
"item",
"with",
"a",
"no",
"-",
"empty",
"content"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L168-L194 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.addClassBodyStyles | public function addClassBodyStyles($styleNames, core_kernel_classes_Class $itemClass, $recursive = true){
$updatedItems = [];
$items = $itemClass->getInstances($recursive);
foreach($items as $item){
if($this->isQtiItem($item)){
if($this->addBodyStyles($styleNames, $item)){
$updatedItems[] = $item;
}
}
}
return $updatedItems;
} | php | public function addClassBodyStyles($styleNames, core_kernel_classes_Class $itemClass, $recursive = true){
$updatedItems = [];
$items = $itemClass->getInstances($recursive);
foreach($items as $item){
if($this->isQtiItem($item)){
if($this->addBodyStyles($styleNames, $item)){
$updatedItems[] = $item;
}
}
}
return $updatedItems;
} | [
"public",
"function",
"addClassBodyStyles",
"(",
"$",
"styleNames",
",",
"core_kernel_classes_Class",
"$",
"itemClass",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"updatedItems",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"itemClass",
"->",
"getInst... | Add an array of body style classes to the itemBody of all qti items in given class
@param array $styleNames
@param core_kernel_classes_Class $itemClass
@param boolean $recursive | [
"Add",
"an",
"array",
"of",
"body",
"style",
"classes",
"to",
"the",
"itemBody",
"of",
"all",
"qti",
"items",
"in",
"given",
"class"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L203-L214 |
oat-sa/extension-tao-itemqti | model/style/StyleService.php | StyleService.removeClassBodyStyles | public function removeClassBodyStyles($styleNames, core_kernel_classes_Class $itemClass, $recursive = true){
$updatedItems = [];
$items = $itemClass->getInstances($recursive);
foreach($items as $item){
if($this->isQtiItem($item)){
if($this->removeBodyStyles($styleNames, $item)){
$updatedItems[] = $item;
}
}
}
return $updatedItems;
} | php | public function removeClassBodyStyles($styleNames, core_kernel_classes_Class $itemClass, $recursive = true){
$updatedItems = [];
$items = $itemClass->getInstances($recursive);
foreach($items as $item){
if($this->isQtiItem($item)){
if($this->removeBodyStyles($styleNames, $item)){
$updatedItems[] = $item;
}
}
}
return $updatedItems;
} | [
"public",
"function",
"removeClassBodyStyles",
"(",
"$",
"styleNames",
",",
"core_kernel_classes_Class",
"$",
"itemClass",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"updatedItems",
"=",
"[",
"]",
";",
"$",
"items",
"=",
"$",
"itemClass",
"->",
"getI... | Remove an array of body style classes from the itemBody of all qti items in given class
@param array $styleNames
@param core_kernel_classes_Class $itemClass
@param boolean $recursive | [
"Remove",
"an",
"array",
"of",
"body",
"style",
"classes",
"from",
"the",
"itemBody",
"of",
"all",
"qti",
"items",
"in",
"given",
"class"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleService.php#L223-L234 |
oat-sa/extension-tao-itemqti | model/qti/metadata/exporter/MetadataExporter.php | MetadataExporter.inject | public function inject($identifier, $imsManifest)
{
if (! $imsManifest instanceof \DOMDocument) {
throw new MetadataExportException(__('Metadata export requires an instance of DomManifest to inject metadata'));
}
parent::inject($identifier, $imsManifest);
} | php | public function inject($identifier, $imsManifest)
{
if (! $imsManifest instanceof \DOMDocument) {
throw new MetadataExportException(__('Metadata export requires an instance of DomManifest to inject metadata'));
}
parent::inject($identifier, $imsManifest);
} | [
"public",
"function",
"inject",
"(",
"$",
"identifier",
",",
"$",
"imsManifest",
")",
"{",
"if",
"(",
"!",
"$",
"imsManifest",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"throw",
"new",
"MetadataExportException",
"(",
"__",
"(",
"'Metadata export requires an i... | Inject an identified metadata value to a dom IMS manifest
{@inheritdoc} | [
"Inject",
"an",
"identified",
"metadata",
"value",
"to",
"a",
"dom",
"IMS",
"manifest"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/metadata/exporter/MetadataExporter.php#L62-L69 |
oat-sa/extension-tao-itemqti | model/qti/metadata/exporter/MetadataExporter.php | MetadataExporter.registerMetadataService | protected function registerMetadataService()
{
$metadataService = $this->getServiceLocator()->get(MetadataService::SERVICE_ID);
$metadataService->setOption(MetadataService::EXPORTER_KEY, $this);
$this->getServiceManager()->register(MetadataService::SERVICE_ID, $metadataService);
} | php | protected function registerMetadataService()
{
$metadataService = $this->getServiceLocator()->get(MetadataService::SERVICE_ID);
$metadataService->setOption(MetadataService::EXPORTER_KEY, $this);
$this->getServiceManager()->register(MetadataService::SERVICE_ID, $metadataService);
} | [
"protected",
"function",
"registerMetadataService",
"(",
")",
"{",
"$",
"metadataService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"MetadataService",
"::",
"SERVICE_ID",
")",
";",
"$",
"metadataService",
"->",
"setOption",
"(",
... | Allow to register, into the config, the current exporter service | [
"Allow",
"to",
"register",
"into",
"the",
"config",
"the",
"current",
"exporter",
"service"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/metadata/exporter/MetadataExporter.php#L74-L79 |
oat-sa/extension-tao-itemqti | scripts/PortableReloadEventListener.php | PortableReloadEventListener.reloadPortableDevDirectory | public static function reloadPortableDevDirectory(ItemCreatorLoad $event)
{
$customInteractionDirs = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('debug_portable_element');
if(is_array($customInteractionDirs)){
$service = new PortableElementService();
$service->setServiceLocator(ServiceManager::getServiceManager());
foreach($customInteractionDirs as $path){
$sourceDir = '';
if(is_dir(ROOT_PATH.$path)){
$sourceDir = ROOT_PATH.$path;
}else if(is_dir($path)){
$sourceDir = $path;
}
if(!empty($sourceDir)){
$service->registerFromDirectorySource($sourceDir);
\common_Logger::i('Re-registered portable element from the source '.$sourceDir);
}else{
\common_Logger::w('Attempt to register a pci from a non-existing path : '.$path);
}
}
}
} | php | public static function reloadPortableDevDirectory(ItemCreatorLoad $event)
{
$customInteractionDirs = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('debug_portable_element');
if(is_array($customInteractionDirs)){
$service = new PortableElementService();
$service->setServiceLocator(ServiceManager::getServiceManager());
foreach($customInteractionDirs as $path){
$sourceDir = '';
if(is_dir(ROOT_PATH.$path)){
$sourceDir = ROOT_PATH.$path;
}else if(is_dir($path)){
$sourceDir = $path;
}
if(!empty($sourceDir)){
$service->registerFromDirectorySource($sourceDir);
\common_Logger::i('Re-registered portable element from the source '.$sourceDir);
}else{
\common_Logger::w('Attempt to register a pci from a non-existing path : '.$path);
}
}
}
} | [
"public",
"static",
"function",
"reloadPortableDevDirectory",
"(",
"ItemCreatorLoad",
"$",
"event",
")",
"{",
"$",
"customInteractionDirs",
"=",
"\\",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"'taoQtiItem'",
")",
"->"... | Re-register a portable element from its source directory
The list of portable elements to re-register is configure in the config file {TAO_ROOT}/config/taoQtiItem/debug_portable_element.conf.php
e.g.
return [
'myPci1' => 'qtiItemPci/views/js/pciCreator/dev/myPci1/',
'myPci2' => '/home/sam/dev/pcis/myPci2/'
];
@param ItemCreatorLoad $event
@throws \common_Exception
@throws \common_ext_ExtensionException | [
"Re",
"-",
"register",
"a",
"portable",
"element",
"from",
"its",
"source",
"directory",
"The",
"list",
"of",
"portable",
"elements",
"to",
"re",
"-",
"register",
"is",
"configure",
"in",
"the",
"config",
"file",
"{",
"TAO_ROOT",
"}",
"/",
"config",
"/",
... | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/scripts/PortableReloadEventListener.php#L25-L46 |
oat-sa/extension-tao-itemqti | model/qti/asset/AssetManager.php | AssetManager.loadAssetHandler | public function loadAssetHandler($assetHandler)
{
if (!$assetHandler instanceof AssetHandler) {
throw new AssetManagerException('Asset handler "' . get_class($assetHandler) . '" is not supported by AssetManager');
}
$this->assetHandlers[] = $assetHandler;
return $this;
} | php | public function loadAssetHandler($assetHandler)
{
if (!$assetHandler instanceof AssetHandler) {
throw new AssetManagerException('Asset handler "' . get_class($assetHandler) . '" is not supported by AssetManager');
}
$this->assetHandlers[] = $assetHandler;
return $this;
} | [
"public",
"function",
"loadAssetHandler",
"(",
"$",
"assetHandler",
")",
"{",
"if",
"(",
"!",
"$",
"assetHandler",
"instanceof",
"AssetHandler",
")",
"{",
"throw",
"new",
"AssetManagerException",
"(",
"'Asset handler \"'",
".",
"get_class",
"(",
"$",
"assetHandler... | Load an asset handler associated
@param $assetHandler
@return $this
@throws AssetManagerException | [
"Load",
"an",
"asset",
"handler",
"associated"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/asset/AssetManager.php#L54-L61 |
oat-sa/extension-tao-itemqti | model/qti/asset/AssetManager.php | AssetManager.importAuxiliaryFiles | public function importAuxiliaryFiles(QtiResource $qtiItemResource)
{
$qtiFile = $this->getSource() . \helpers_File::urlToPath($qtiItemResource->getFile());
foreach ($qtiItemResource->getAuxiliaryFiles() as $auxiliaryFile) {
$absolutePath = $this->getAbsolutePath($auxiliaryFile);
$relativePath = $this->getRelativePath($qtiFile, $absolutePath);
if (!\helpers_File::isFileInsideDirectory($relativePath, dirname($qtiFile))) {
throw new InvalidSourcePathException(dirname($qtiFile), $auxiliaryFile);
}
try {
$this->importAsset($absolutePath, $relativePath);
} catch(\common_Exception $e) {
throw new AssetManagerException(
'Error occurs during auxiliary assets handling for item: ' . $qtiItemResource->getIdentifier()
. ', assetFile: ' . $relativePath,
0, $e
);
}
}
return $this;
} | php | public function importAuxiliaryFiles(QtiResource $qtiItemResource)
{
$qtiFile = $this->getSource() . \helpers_File::urlToPath($qtiItemResource->getFile());
foreach ($qtiItemResource->getAuxiliaryFiles() as $auxiliaryFile) {
$absolutePath = $this->getAbsolutePath($auxiliaryFile);
$relativePath = $this->getRelativePath($qtiFile, $absolutePath);
if (!\helpers_File::isFileInsideDirectory($relativePath, dirname($qtiFile))) {
throw new InvalidSourcePathException(dirname($qtiFile), $auxiliaryFile);
}
try {
$this->importAsset($absolutePath, $relativePath);
} catch(\common_Exception $e) {
throw new AssetManagerException(
'Error occurs during auxiliary assets handling for item: ' . $qtiItemResource->getIdentifier()
. ', assetFile: ' . $relativePath,
0, $e
);
}
}
return $this;
} | [
"public",
"function",
"importAuxiliaryFiles",
"(",
"QtiResource",
"$",
"qtiItemResource",
")",
"{",
"$",
"qtiFile",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
".",
"\\",
"helpers_File",
"::",
"urlToPath",
"(",
"$",
"qtiItemResource",
"->",
"getFile",
"(",
... | Import auxiliaryFile e.q. css, js...
@param QtiResource $qtiItemResource
@return $this
@throws AssetManagerException
@throws InvalidSourcePathException | [
"Import",
"auxiliaryFile",
"e",
".",
"q",
".",
"css",
"js",
"..."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/asset/AssetManager.php#L119-L141 |
oat-sa/extension-tao-itemqti | model/qti/asset/AssetManager.php | AssetManager.importDependencyFiles | public function importDependencyFiles(QtiResource $qtiItemResource, $dependencies)
{
$qtiFile = $this->getSource() . \helpers_File::urlToPath($qtiItemResource->getFile());
foreach ($qtiItemResource->getDependencies() as $dependenciesFile) {
if (!isset($dependencies[$dependenciesFile])) {
continue;
}
$absolutePath = $this->getAbsolutePath($dependencies[$dependenciesFile]->getFile());
$relativePath = $this->getRelativePath($qtiFile, $absolutePath);
try {
$this->importAsset($absolutePath, $relativePath);
} catch(\common_Exception $e) {
throw new AssetManagerException(
'Error occurs during dependency assets handling for item: ' . $qtiItemResource->getIdentifier()
. ', assetFile: ' . $relativePath,
0, $e
);
}
}
return $this;
} | php | public function importDependencyFiles(QtiResource $qtiItemResource, $dependencies)
{
$qtiFile = $this->getSource() . \helpers_File::urlToPath($qtiItemResource->getFile());
foreach ($qtiItemResource->getDependencies() as $dependenciesFile) {
if (!isset($dependencies[$dependenciesFile])) {
continue;
}
$absolutePath = $this->getAbsolutePath($dependencies[$dependenciesFile]->getFile());
$relativePath = $this->getRelativePath($qtiFile, $absolutePath);
try {
$this->importAsset($absolutePath, $relativePath);
} catch(\common_Exception $e) {
throw new AssetManagerException(
'Error occurs during dependency assets handling for item: ' . $qtiItemResource->getIdentifier()
. ', assetFile: ' . $relativePath,
0, $e
);
}
}
return $this;
} | [
"public",
"function",
"importDependencyFiles",
"(",
"QtiResource",
"$",
"qtiItemResource",
",",
"$",
"dependencies",
")",
"{",
"$",
"qtiFile",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
".",
"\\",
"helpers_File",
"::",
"urlToPath",
"(",
"$",
"qtiItemResour... | Import dependencies files
@param QtiResource $qtiItemResource
@param $dependencies
@return $this
@throws AssetManagerException | [
"Import",
"dependencies",
"files"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/asset/AssetManager.php#L151-L171 |
oat-sa/extension-tao-itemqti | model/qti/asset/AssetManager.php | AssetManager.importAsset | protected function importAsset($absolutePath, $relativePath)
{
/** @var AssetHandler $assetHandler */
foreach ($this->assetHandlers as $assetHandler) {
if ($assetHandler->isApplicable($relativePath)) {
$info = $assetHandler->handle($absolutePath, $relativePath);
if ($relativePath != ltrim($info['uri'], '/')) {
$this->setItemContent(str_replace($relativePath, $info['uri'], $this->getItemContent()));
}
//Break chain of asset handler, first applicable is taken
return;
}
}
throw new AssetManagerException('Unable to import auxiliary & dependency files. No asset handler applicable to file : ' . $relativePath);
} | php | protected function importAsset($absolutePath, $relativePath)
{
/** @var AssetHandler $assetHandler */
foreach ($this->assetHandlers as $assetHandler) {
if ($assetHandler->isApplicable($relativePath)) {
$info = $assetHandler->handle($absolutePath, $relativePath);
if ($relativePath != ltrim($info['uri'], '/')) {
$this->setItemContent(str_replace($relativePath, $info['uri'], $this->getItemContent()));
}
//Break chain of asset handler, first applicable is taken
return;
}
}
throw new AssetManagerException('Unable to import auxiliary & dependency files. No asset handler applicable to file : ' . $relativePath);
} | [
"protected",
"function",
"importAsset",
"(",
"$",
"absolutePath",
",",
"$",
"relativePath",
")",
"{",
"/** @var AssetHandler $assetHandler */",
"foreach",
"(",
"$",
"this",
"->",
"assetHandlers",
"as",
"$",
"assetHandler",
")",
"{",
"if",
"(",
"$",
"assetHandler",... | Loop each assetHandlers populated by loadAssetHandler()
The first applicable return info about file handling processing
and break chain.
@param $absolutePath
@param $relativePath
@throws AssetManagerException | [
"Loop",
"each",
"assetHandlers",
"populated",
"by",
"loadAssetHandler",
"()",
"The",
"first",
"applicable",
"return",
"info",
"about",
"file",
"handling",
"processing",
"and",
"break",
"chain",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/asset/AssetManager.php#L216-L232 |
oat-sa/extension-tao-itemqti | model/qti/choice/Choice.php | Choice.isIdentifierAvailable | public function isIdentifierAvailable($newIdentifier){
$returnValue = false;
if(empty($newIdentifier) || is_null($newIdentifier)){
throw new InvalidArgumentException("newIdentifier must be set");
}
if(!empty($this->identifier) && $newIdentifier == $this->identifier){
$returnValue = true;
}else{
$relatedItem = $this->getRelatedItem();
if(is_null($relatedItem)){
$returnValue = true; //no restriction on identifier since not attached to any qti item
}else{
$collection = $relatedItem->getIdentifiedElements();
try{
$uniqueChoice = $collection->getUnique($newIdentifier, 'oat\\taoQtiItem\\model\\qti\\choice\\Choice');
$uniqueOutcome = $collection->getUnique($newIdentifier, 'oat\\taoQtiItem\\model\\qti\\OutcomeDeclaration');
if(is_null($uniqueChoice) && is_null($uniqueOutcome)){
$returnValue = true;
}
}catch(QtiModelException $e){
//return false
}
}
}
return $returnValue;
} | php | public function isIdentifierAvailable($newIdentifier){
$returnValue = false;
if(empty($newIdentifier) || is_null($newIdentifier)){
throw new InvalidArgumentException("newIdentifier must be set");
}
if(!empty($this->identifier) && $newIdentifier == $this->identifier){
$returnValue = true;
}else{
$relatedItem = $this->getRelatedItem();
if(is_null($relatedItem)){
$returnValue = true; //no restriction on identifier since not attached to any qti item
}else{
$collection = $relatedItem->getIdentifiedElements();
try{
$uniqueChoice = $collection->getUnique($newIdentifier, 'oat\\taoQtiItem\\model\\qti\\choice\\Choice');
$uniqueOutcome = $collection->getUnique($newIdentifier, 'oat\\taoQtiItem\\model\\qti\\OutcomeDeclaration');
if(is_null($uniqueChoice) && is_null($uniqueOutcome)){
$returnValue = true;
}
}catch(QtiModelException $e){
//return false
}
}
}
return $returnValue;
} | [
"public",
"function",
"isIdentifierAvailable",
"(",
"$",
"newIdentifier",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"newIdentifier",
")",
"||",
"is_null",
"(",
"$",
"newIdentifier",
")",
")",
"{",
"throw",
"new",
"Inval... | Check if the given new identifier is valid in the current state of the qti element
@param string $newIdentifier
@return booean
@throws InvalidArgumentException | [
"Check",
"if",
"the",
"given",
"new",
"identifier",
"is",
"valid",
"in",
"the",
"current",
"state",
"of",
"the",
"qti",
"element"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/choice/Choice.php#L70-L101 |
oat-sa/extension-tao-itemqti | model/qti/choice/Choice.php | Choice.toForm | public function toForm(){
$returnValue = null;
$choiceFormClass = '\\oat\\taoQtiItem\\controller\\QTIform\\choice\\'.ucfirst(static::$qtiTagName);
if(!class_exists($choiceFormClass)){
throw new QtiModelException("the class {$choiceFormClass} does not exist");
}else{
$formContainer = new $choiceFormClass($this);
$myForm = $formContainer->getForm();
$returnValue = $myForm;
}
return $returnValue;
} | php | public function toForm(){
$returnValue = null;
$choiceFormClass = '\\oat\\taoQtiItem\\controller\\QTIform\\choice\\'.ucfirst(static::$qtiTagName);
if(!class_exists($choiceFormClass)){
throw new QtiModelException("the class {$choiceFormClass} does not exist");
}else{
$formContainer = new $choiceFormClass($this);
$myForm = $formContainer->getForm();
$returnValue = $myForm;
}
return $returnValue;
} | [
"public",
"function",
"toForm",
"(",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"choiceFormClass",
"=",
"'\\\\oat\\\\taoQtiItem\\\\controller\\\\QTIform\\\\choice\\\\'",
".",
"ucfirst",
"(",
"static",
"::",
"$",
"qtiTagName",
")",
";",
"if",
"(",
"!",
... | Return the form to edit the current instance
@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return tao_helpers_form_Form | [
"Return",
"the",
"form",
"to",
"edit",
"the",
"current",
"instance"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/choice/Choice.php#L110-L123 |
oat-sa/extension-tao-itemqti | model/qti/Resource.php | Resource.isAllowed | public static function isAllowed($type){
return (!empty($type) && (in_array($type, self::$allowedTypes))) || self::isAssessmentItem($type) || self::isAssessmentTest($type);
} | php | public static function isAllowed($type){
return (!empty($type) && (in_array($type, self::$allowedTypes))) || self::isAssessmentItem($type) || self::isAssessmentTest($type);
} | [
"public",
"static",
"function",
"isAllowed",
"(",
"$",
"type",
")",
"{",
"return",
"(",
"!",
"empty",
"(",
"$",
"type",
")",
"&&",
"(",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"allowedTypes",
")",
")",
")",
"||",
"self",
"::",
"isAsse... | Check if the given type is allowed as a QTI Resource
@param string $type
@return boolean | [
"Check",
"if",
"the",
"given",
"type",
"is",
"allowed",
"as",
"a",
"QTI",
"Resource"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Resource.php#L124-L126 |
oat-sa/extension-tao-itemqti | model/qti/OutcomeDeclaration.php | OutcomeDeclaration.toJSON | public function toJSON(){
$outcomeValue = null;
if($this->defaultValue != ''){
$outcomeValue = Array($this->defaultValue);
}else if($this->getAttributeValue('baseType') == 'integer' || $this->getAttributeValue('baseType') == 'float'){
$outcomeValue = Array(0);
}else{
$outcomeValue = null;
}
$returnValue = taoQTI_models_classes_Matching_VariableFactory::createJSONVariableFromQTIData(
$this->getIdentifier()
, $this->getAttributeValue('cardinality')
, $this->getAttributeValue('baseType')
, $outcomeValue
);
return $returnValue;
} | php | public function toJSON(){
$outcomeValue = null;
if($this->defaultValue != ''){
$outcomeValue = Array($this->defaultValue);
}else if($this->getAttributeValue('baseType') == 'integer' || $this->getAttributeValue('baseType') == 'float'){
$outcomeValue = Array(0);
}else{
$outcomeValue = null;
}
$returnValue = taoQTI_models_classes_Matching_VariableFactory::createJSONVariableFromQTIData(
$this->getIdentifier()
, $this->getAttributeValue('cardinality')
, $this->getAttributeValue('baseType')
, $outcomeValue
);
return $returnValue;
} | [
"public",
"function",
"toJSON",
"(",
")",
"{",
"$",
"outcomeValue",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"defaultValue",
"!=",
"''",
")",
"{",
"$",
"outcomeValue",
"=",
"Array",
"(",
"$",
"this",
"->",
"defaultValue",
")",
";",
"}",
"else"... | get the outcome in JSON format
@deprecated now use the new qtism lib for response evaluation
@access public
@author Joel Bout, <joel.bout@tudor.lu> | [
"get",
"the",
"outcome",
"in",
"JSON",
"format"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/OutcomeDeclaration.php#L86-L104 |
oat-sa/extension-tao-itemqti | model/qti/exception/UnexpectedResponseProcessing.php | UnexpectedResponseProcessing.getUserMessage | public function getUserMessage() {
$requestedUri = $this->getRequestedUri();
if (empty($requestedUri) === true) {
return __('An unexpected error occured while dealing with Response Processing.');
}
else {
return __('The Response Processing Template "%s" is not supported.', $this->getRequestedUri());
}
} | php | public function getUserMessage() {
$requestedUri = $this->getRequestedUri();
if (empty($requestedUri) === true) {
return __('An unexpected error occured while dealing with Response Processing.');
}
else {
return __('The Response Processing Template "%s" is not supported.', $this->getRequestedUri());
}
} | [
"public",
"function",
"getUserMessage",
"(",
")",
"{",
"$",
"requestedUri",
"=",
"$",
"this",
"->",
"getRequestedUri",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"requestedUri",
")",
"===",
"true",
")",
"{",
"return",
"__",
"(",
"'An unexpected error occ... | Returns a human-readable message describing the error that occured.
@return string | [
"Returns",
"a",
"human",
"-",
"readable",
"message",
"describing",
"the",
"error",
"that",
"occured",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/exception/UnexpectedResponseProcessing.php#L94-L103 |
oat-sa/extension-tao-itemqti | model/portableElement/storage/PortableElementFileStorage.php | PortableElementFileStorage.registerFiles | public function registerFiles(PortableElementObject $object, $files, $source)
{
$registered = false;
$fileSystem = $this->getFileStorage();
$source = $this->sanitizeSourceAsDirectory($source);
foreach ($files as $file) {
if(!$object->isRegistrableFile($file)){
continue;
}
$filePath = $source . ltrim($file, DIRECTORY_SEPARATOR);
if (!file_exists($filePath) || ($resource = fopen($filePath, 'r'))===false) {
throw new PortableElementFileStorageException('File cannot be opened : ' . $filePath);
}
$fileId = $this->getPrefix($object) . $object->getRegistrationFileId($file);
if ($fileSystem->has($fileId)) {
$registered = $fileSystem->updateStream($fileId, $resource);
} else {
$registered = $fileSystem->writeStream($fileId, $resource);
}
fclose($resource);
\common_Logger::i('Portable element asset file "' . $fileId . '" copied.');
}
return $registered;
} | php | public function registerFiles(PortableElementObject $object, $files, $source)
{
$registered = false;
$fileSystem = $this->getFileStorage();
$source = $this->sanitizeSourceAsDirectory($source);
foreach ($files as $file) {
if(!$object->isRegistrableFile($file)){
continue;
}
$filePath = $source . ltrim($file, DIRECTORY_SEPARATOR);
if (!file_exists($filePath) || ($resource = fopen($filePath, 'r'))===false) {
throw new PortableElementFileStorageException('File cannot be opened : ' . $filePath);
}
$fileId = $this->getPrefix($object) . $object->getRegistrationFileId($file);
if ($fileSystem->has($fileId)) {
$registered = $fileSystem->updateStream($fileId, $resource);
} else {
$registered = $fileSystem->writeStream($fileId, $resource);
}
fclose($resource);
\common_Logger::i('Portable element asset file "' . $fileId . '" copied.');
}
return $registered;
} | [
"public",
"function",
"registerFiles",
"(",
"PortableElementObject",
"$",
"object",
",",
"$",
"files",
",",
"$",
"source",
")",
"{",
"$",
"registered",
"=",
"false",
";",
"$",
"fileSystem",
"=",
"$",
"this",
"->",
"getFileStorage",
"(",
")",
";",
"$",
"s... | Register files associated to a PCI track by $typeIdentifier
@refactor improve response
@param PortableElementObject $object
@param string[] $files Relative path of portable element files
@param string $source Location of temporary directory
@return bool
@throws PortableElementFileStorageException | [
"Register",
"files",
"associated",
"to",
"a",
"PCI",
"track",
"by",
"$typeIdentifier"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/portableElement/storage/PortableElementFileStorage.php#L87-L114 |
oat-sa/extension-tao-itemqti | model/portableElement/storage/PortableElementFileStorage.php | PortableElementFileStorage.unregisterFiles | public function unregisterFiles(PortableElementObject $object, $files)
{
$deleted = true;
$filesystem = $this->getFileStorage();
foreach ($files as $relPath) {
$fileId = $this->getPrefix($object) . $relPath;
if (!$filesystem->has($fileId)) {
throw new \common_Exception('File does not exists in the filesystem: ' . $relPath);
}
$deleted = $filesystem->delete($fileId);
}
return $deleted;
} | php | public function unregisterFiles(PortableElementObject $object, $files)
{
$deleted = true;
$filesystem = $this->getFileStorage();
foreach ($files as $relPath) {
$fileId = $this->getPrefix($object) . $relPath;
if (!$filesystem->has($fileId)) {
throw new \common_Exception('File does not exists in the filesystem: ' . $relPath);
}
$deleted = $filesystem->delete($fileId);
}
return $deleted;
} | [
"public",
"function",
"unregisterFiles",
"(",
"PortableElementObject",
"$",
"object",
",",
"$",
"files",
")",
"{",
"$",
"deleted",
"=",
"true",
";",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"getFileStorage",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
... | Unregister files by removing them from FileSystem
@param PortableElementObject $object
@param $files
@return bool
@throws \common_Exception | [
"Unregister",
"files",
"by",
"removing",
"them",
"from",
"FileSystem"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/portableElement/storage/PortableElementFileStorage.php#L124-L136 |
oat-sa/extension-tao-itemqti | model/style/StyleRegistry.php | StyleRegistry.getAllStyles | public function getAllStyles()
{
$styles = [];
foreach (self::getRegistry()->getMap() as $id => $styleData ){
$styles[$id] = $styleData;
}
return $styles;
} | php | public function getAllStyles()
{
$styles = [];
foreach (self::getRegistry()->getMap() as $id => $styleData ){
$styles[$id] = $styleData;
}
return $styles;
} | [
"public",
"function",
"getAllStyles",
"(",
")",
"{",
"$",
"styles",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"getRegistry",
"(",
")",
"->",
"getMap",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"styleData",
")",
"{",
"$",
"styles",
"[",
"$",
"... | Get all styles available from the registry
@return array | [
"Get",
"all",
"styles",
"available",
"from",
"the",
"registry"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleRegistry.php#L56-L63 |
oat-sa/extension-tao-itemqti | model/style/StyleRegistry.php | StyleRegistry.register | public function register($id, $styleData)
{
if (self::getRegistry()->isRegistered($id)) {
common_Logger::w('Style already registered');
}
if($this->isValidStyleData($styleData)){
self::getRegistry()->set($id, $styleData);
}else{
common_Logger::w('Invalid style data format');
}
} | php | public function register($id, $styleData)
{
if (self::getRegistry()->isRegistered($id)) {
common_Logger::w('Style already registered');
}
if($this->isValidStyleData($styleData)){
self::getRegistry()->set($id, $styleData);
}else{
common_Logger::w('Invalid style data format');
}
} | [
"public",
"function",
"register",
"(",
"$",
"id",
",",
"$",
"styleData",
")",
"{",
"if",
"(",
"self",
"::",
"getRegistry",
"(",
")",
"->",
"isRegistered",
"(",
"$",
"id",
")",
")",
"{",
"common_Logger",
"::",
"w",
"(",
"'Style already registered'",
")",
... | Register a style
@param string $id
@param array $styleData | [
"Register",
"a",
"style"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/style/StyleRegistry.php#L81-L92 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.setElement | public function setElement(Element $qtiElement, $body = '', $integrityCheck = true, $requiredPlaceholder = true){
return $this->setElements(array($qtiElement), $body, $integrityCheck, $requiredPlaceholder);
} | php | public function setElement(Element $qtiElement, $body = '', $integrityCheck = true, $requiredPlaceholder = true){
return $this->setElements(array($qtiElement), $body, $integrityCheck, $requiredPlaceholder);
} | [
"public",
"function",
"setElement",
"(",
"Element",
"$",
"qtiElement",
",",
"$",
"body",
"=",
"''",
",",
"$",
"integrityCheck",
"=",
"true",
",",
"$",
"requiredPlaceholder",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"setElements",
"(",
"array",
... | add one qtiElement into the body
if the body content is not specified, it appends to the end
@access public
@author Sam, <sam@taotesting.com>
@return boolean | [
"add",
"one",
"qtiElement",
"into",
"the",
"body",
"if",
"the",
"body",
"content",
"is",
"not",
"specified",
"it",
"appends",
"to",
"the",
"end"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L89-L91 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.edit | public function edit($body, $integrityCheck = false){
if(!is_string($body)){
throw new InvalidArgumentException('a QTI container must have a body of string type');
}
if($integrityCheck && !$this->checkIntegrity($body)){
return false;
}
$this->body = $body;
return true;
} | php | public function edit($body, $integrityCheck = false){
if(!is_string($body)){
throw new InvalidArgumentException('a QTI container must have a body of string type');
}
if($integrityCheck && !$this->checkIntegrity($body)){
return false;
}
$this->body = $body;
return true;
} | [
"public",
"function",
"edit",
"(",
"$",
"body",
",",
"$",
"integrityCheck",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"body",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'a QTI container must have a body of string type'"... | modify the content of the body
@param string $body
@param bool $integrityCheck
@return bool | [
"modify",
"the",
"content",
"of",
"the",
"body"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L157-L166 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.checkIntegrity | public function checkIntegrity($body, &$missingElements = null){
$returnValue = true;
foreach($this->elements as $element){
if(strpos($body, $element->getPlaceholder()) === false){
$returnValue = false;
if(is_array($missingElements)){
$missingElements[$element->getSerial()] = $element;
}else{
break;
}
}
}
return (bool) $returnValue;
} | php | public function checkIntegrity($body, &$missingElements = null){
$returnValue = true;
foreach($this->elements as $element){
if(strpos($body, $element->getPlaceholder()) === false){
$returnValue = false;
if(is_array($missingElements)){
$missingElements[$element->getSerial()] = $element;
}else{
break;
}
}
}
return (bool) $returnValue;
} | [
"public",
"function",
"checkIntegrity",
"(",
"$",
"body",
",",
"&",
"$",
"missingElements",
"=",
"null",
")",
"{",
"$",
"returnValue",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"strpos",... | Check if modifying the body won't have an element placeholder deleted
@param string $body
@return boolean | [
"Check",
"if",
"modifying",
"the",
"body",
"won",
"t",
"have",
"an",
"element",
"placeholder",
"deleted"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L174-L191 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.fixNonvoidTags | public function fixNonvoidTags($html) {
return preg_replace_callback('~(<([\w]+)[^>]*?)(\s*/>)~u', function ($matches) {
// something went wrong
if(empty($matches[2])) {
// do nothing
return $matches[0];
}
// regular void elements
if(in_array($matches[2], array('area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'))) {
// do nothing
return $matches[0];
}
// correctly closed element
return trim(mb_substr($matches[0], 0, -2), 'UTF-8') . '></' . $matches[2] . '>';
}, $html);
} | php | public function fixNonvoidTags($html) {
return preg_replace_callback('~(<([\w]+)[^>]*?)(\s*/>)~u', function ($matches) {
// something went wrong
if(empty($matches[2])) {
// do nothing
return $matches[0];
}
// regular void elements
if(in_array($matches[2], array('area','base','br','col','embed','hr','img','input','keygen','link','meta','param','source','track','wbr'))) {
// do nothing
return $matches[0];
}
// correctly closed element
return trim(mb_substr($matches[0], 0, -2), 'UTF-8') . '></' . $matches[2] . '>';
}, $html);
} | [
"public",
"function",
"fixNonvoidTags",
"(",
"$",
"html",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'~(<([\\w]+)[^>]*?)(\\s*/>)~u'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"// something went wrong",
"if",
"(",
"empty",
"(",
"$",
"matches",
"[",
... | Converts <foo/> to <foo></foo> unless foo is a proper void element such as img etc.
@param $html
@return mixed | [
"Converts",
"<foo",
"/",
">",
"to",
"<foo",
">",
"<",
"/",
"foo",
">",
"unless",
"foo",
"is",
"a",
"proper",
"void",
"element",
"such",
"as",
"img",
"etc",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L199-L214 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.getElement | public function getElement($serial){
$returnValue = null;
if(isset($this->elements[$serial])){
$returnValue = $this->elements[$serial];
}
return $returnValue;
} | php | public function getElement($serial){
$returnValue = null;
if(isset($this->elements[$serial])){
$returnValue = $this->elements[$serial];
}
return $returnValue;
} | [
"public",
"function",
"getElement",
"(",
"$",
"serial",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"serial",
"]",
")",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"ele... | Get the element by its serial
@param string $serial
@return oat\taoQtiItem\model\qti\Element | [
"Get",
"the",
"element",
"by",
"its",
"serial"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L244-L253 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.getElements | public function getElements($className = ''){
$returnValue = array();
if($className){
foreach($this->elements as $serial => $element){
if($element instanceof $className){
$returnValue[$serial] = $element;
}
}
}else{
$returnValue = $this->elements;
}
return $returnValue;
} | php | public function getElements($className = ''){
$returnValue = array();
if($className){
foreach($this->elements as $serial => $element){
if($element instanceof $className){
$returnValue[$serial] = $element;
}
}
}else{
$returnValue = $this->elements;
}
return $returnValue;
} | [
"public",
"function",
"getElements",
"(",
"$",
"className",
"=",
"''",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"className",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"serial",
"=>",
"$",
... | Get all elements of the given type
Returns all elements if class name is not specified
@param string $className
@return array | [
"Get",
"all",
"elements",
"of",
"the",
"given",
"type",
"Returns",
"all",
"elements",
"if",
"class",
"name",
"is",
"not",
"specified"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L262-L278 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.toQTI | public function toQTI(){
$returnValue = $this->getBody();
foreach($this->elements as $element){
$returnValue = str_replace($element->getPlaceholder(), $element->toQTI(), $returnValue);
}
return (string) $returnValue;
} | php | public function toQTI(){
$returnValue = $this->getBody();
foreach($this->elements as $element){
$returnValue = str_replace($element->getPlaceholder(), $element->toQTI(), $returnValue);
}
return (string) $returnValue;
} | [
"public",
"function",
"toQTI",
"(",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"getBody",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"returnValue",
"=",
"str_replace",
"(",
"$",
"elem... | Export the data to QTI XML format
@access public
@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@return string | [
"Export",
"the",
"data",
"to",
"QTI",
"XML",
"format"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L335-L343 |
oat-sa/extension-tao-itemqti | model/qti/container/Container.php | Container.toArray | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = array(
'serial' => $this->getSerial(),
'body' => $this->getBody(),
'elements' => $this->getArraySerializedElementCollection($this->getElements(), $filterVariableContent, $filtered),
);
if(DEBUG_MODE){
//in debug mode, add debug data, such as the related item
$data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
}
return $data;
} | php | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = array(
'serial' => $this->getSerial(),
'body' => $this->getBody(),
'elements' => $this->getArraySerializedElementCollection($this->getElements(), $filterVariableContent, $filtered),
);
if(DEBUG_MODE){
//in debug mode, add debug data, such as the related item
$data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
}
return $data;
} | [
"public",
"function",
"toArray",
"(",
"$",
"filterVariableContent",
"=",
"false",
",",
"&",
"$",
"filtered",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'serial'",
"=>",
"$",
"this",
"->",
"getSerial",
"(",
")",
",",
"'body'",
... | Get the array representation of the Qti Element.
Particularly helpful for data transformation, e.g. json
@access public
@author Sam, <sam@taotesting.com>
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"the",
"Qti",
"Element",
".",
"Particularly",
"helpful",
"for",
"data",
"transformation",
"e",
".",
"g",
".",
"json"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/container/Container.php#L353-L367 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.import | public function import()
{
try {
if ($this->getRequestMethod() != Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to import Qti package.');
}
// Get valid package parameter
$package = $this->getUploadedPackage();
// Call service to import package
\helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::LONG);
$report = ImportService::singleton()->importQTIPACKFile(
$package,
$this->getDestinationClass(),
true,
true,
true,
$this->isMetadataGuardiansEnabled(),
$this->isMetadataValidatorsEnabled(),
$this->isItemMustExistEnabled(),
$this->isItemMustBeOverwrittenEnabled()
);
\helpers_TimeOutHelper::reset();
\tao_helpers_File::remove($package);
if ($report->getType() !== \common_report_Report::TYPE_SUCCESS) {
$message = __("An unexpected error occurred during the import of the IMS QTI Item Package. ");
//get message of first error report
if (!empty($report->getErrors())) {
$message .= $report->getErrors()[0]->getMessage();
}
$this->returnFailure(new \common_Exception($message));
} else {
$itemIds = [];
/** @var \common_report_Report $subReport */
foreach ($report as $subReport) {
$itemIds[] = $subReport->getData()->getUri();
}
$this->returnSuccess(array('items' => $itemIds));
}
} catch (ExtractException $e) {
$this->returnFailure(new \common_Exception(__('The ZIP archive containing the IMS QTI Item cannot be extracted.')));
} catch (ParsingException $e) {
$this->returnFailure(new \common_Exception(__('The ZIP archive does not contain an imsmanifest.xml file or is an invalid ZIP archive.')));
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | php | public function import()
{
try {
if ($this->getRequestMethod() != Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to import Qti package.');
}
// Get valid package parameter
$package = $this->getUploadedPackage();
// Call service to import package
\helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::LONG);
$report = ImportService::singleton()->importQTIPACKFile(
$package,
$this->getDestinationClass(),
true,
true,
true,
$this->isMetadataGuardiansEnabled(),
$this->isMetadataValidatorsEnabled(),
$this->isItemMustExistEnabled(),
$this->isItemMustBeOverwrittenEnabled()
);
\helpers_TimeOutHelper::reset();
\tao_helpers_File::remove($package);
if ($report->getType() !== \common_report_Report::TYPE_SUCCESS) {
$message = __("An unexpected error occurred during the import of the IMS QTI Item Package. ");
//get message of first error report
if (!empty($report->getErrors())) {
$message .= $report->getErrors()[0]->getMessage();
}
$this->returnFailure(new \common_Exception($message));
} else {
$itemIds = [];
/** @var \common_report_Report $subReport */
foreach ($report as $subReport) {
$itemIds[] = $subReport->getData()->getUri();
}
$this->returnSuccess(array('items' => $itemIds));
}
} catch (ExtractException $e) {
$this->returnFailure(new \common_Exception(__('The ZIP archive containing the IMS QTI Item cannot be extracted.')));
} catch (ParsingException $e) {
$this->returnFailure(new \common_Exception(__('The ZIP archive does not contain an imsmanifest.xml file or is an invalid ZIP archive.')));
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | [
"public",
"function",
"import",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequestMethod",
"(",
")",
"!=",
"Request",
"::",
"HTTP_POST",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotImplemented",
"(",
"'Only post method is accepted to i... | Import file entry point by using $this->service
Check POST method & get valid uploaded file | [
"Import",
"file",
"entry",
"point",
"by",
"using",
"$this",
"-",
">",
"service",
"Check",
"POST",
"method",
"&",
"get",
"valid",
"uploaded",
"file"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L82-L130 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.importDeferred | public function importDeferred()
{
try {
if ($this->getRequestMethod() != Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to import Qti package.');
}
$task = ImportQtiItem::createTask(
$this->getUploadedPackage(),
$this->getDestinationClass(),
$this->getServiceLocator(),
$this->isMetadataGuardiansEnabled(),
$this->isMetadataValidatorsEnabled(),
$this->isItemMustExistEnabled(),
$this->isItemMustBeOverwrittenEnabled()
);
$result = [
'reference_id' => $task->getId()
];
/** @var TaskLogInterface $taskLog */
$taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID);
if ($report = $taskLog->getReport($task->getId())) {
$result['report'] = $report->toArray();
}
return $this->returnSuccess($result);
} catch (\Exception $e) {
return $this->returnFailure($e);
}
} | php | public function importDeferred()
{
try {
if ($this->getRequestMethod() != Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to import Qti package.');
}
$task = ImportQtiItem::createTask(
$this->getUploadedPackage(),
$this->getDestinationClass(),
$this->getServiceLocator(),
$this->isMetadataGuardiansEnabled(),
$this->isMetadataValidatorsEnabled(),
$this->isItemMustExistEnabled(),
$this->isItemMustBeOverwrittenEnabled()
);
$result = [
'reference_id' => $task->getId()
];
/** @var TaskLogInterface $taskLog */
$taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID);
if ($report = $taskLog->getReport($task->getId())) {
$result['report'] = $report->toArray();
}
return $this->returnSuccess($result);
} catch (\Exception $e) {
return $this->returnFailure($e);
}
} | [
"public",
"function",
"importDeferred",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequestMethod",
"(",
")",
"!=",
"Request",
"::",
"HTTP_POST",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotImplemented",
"(",
"'Only post method is accep... | Import item package through the task queue. | [
"Import",
"item",
"package",
"through",
"the",
"task",
"queue",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L143-L175 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.addExtraReturnData | protected function addExtraReturnData(EntityInterface $taskLogEntity)
{
$data = [];
if ($taskLogEntity->getReport()) {
$plainReport = $this->getPlainReport($taskLogEntity->getReport());
//the third report is report of import test
$itemsReport = array_slice($plainReport, 2);
foreach ($itemsReport as $itemReport) {
if (isset($itemReport->getData()['uriResource'])) {
$data['itemIds'][] = $itemReport->getData()['uriResource'];
}
}
}
return $data;
} | php | protected function addExtraReturnData(EntityInterface $taskLogEntity)
{
$data = [];
if ($taskLogEntity->getReport()) {
$plainReport = $this->getPlainReport($taskLogEntity->getReport());
//the third report is report of import test
$itemsReport = array_slice($plainReport, 2);
foreach ($itemsReport as $itemReport) {
if (isset($itemReport->getData()['uriResource'])) {
$data['itemIds'][] = $itemReport->getData()['uriResource'];
}
}
}
return $data;
} | [
"protected",
"function",
"addExtraReturnData",
"(",
"EntityInterface",
"$",
"taskLogEntity",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"taskLogEntity",
"->",
"getReport",
"(",
")",
")",
"{",
"$",
"plainReport",
"=",
"$",
"this",
"->",
"g... | Add extra values to the JSON returned.
@param EntityInterface $taskLogEntity
@return array | [
"Add",
"extra",
"values",
"to",
"the",
"JSON",
"returned",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L183-L200 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.getUploadedPackage | protected function getUploadedPackage()
{
if (!$this->hasRequestParameter(self::RESTITEM_PACKAGE_NAME)) {
throw new \common_exception_MissingParameter(self::RESTITEM_PACKAGE_NAME, __CLASS__);
}
$file = \tao_helpers_Http::getUploadedFile(self::RESTITEM_PACKAGE_NAME);
if (!in_array($file['type'], self::$accepted_types)) {
throw new \common_exception_BadRequest('Uploaded file has to be a valid archive.');
}
$pathinfo = pathinfo($file['tmp_name']);
$destination = $pathinfo['dirname'] . DIRECTORY_SEPARATOR . $file['name'];
\tao_helpers_File::move($file['tmp_name'], $destination);
return $destination;
} | php | protected function getUploadedPackage()
{
if (!$this->hasRequestParameter(self::RESTITEM_PACKAGE_NAME)) {
throw new \common_exception_MissingParameter(self::RESTITEM_PACKAGE_NAME, __CLASS__);
}
$file = \tao_helpers_Http::getUploadedFile(self::RESTITEM_PACKAGE_NAME);
if (!in_array($file['type'], self::$accepted_types)) {
throw new \common_exception_BadRequest('Uploaded file has to be a valid archive.');
}
$pathinfo = pathinfo($file['tmp_name']);
$destination = $pathinfo['dirname'] . DIRECTORY_SEPARATOR . $file['name'];
\tao_helpers_File::move($file['tmp_name'], $destination);
return $destination;
} | [
"protected",
"function",
"getUploadedPackage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasRequestParameter",
"(",
"self",
"::",
"RESTITEM_PACKAGE_NAME",
")",
")",
"{",
"throw",
"new",
"\\",
"common_exception_MissingParameter",
"(",
"self",
"::",
"REST... | Return a valid uploaded file
@return string
@throws \common_Exception
@throws \common_exception_Error
@throws \common_exception_MissingParameter
@throws \common_exception_BadRequest
@throws \oat\tao\helpers\FileUploadException | [
"Return",
"a",
"valid",
"uploaded",
"file"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L212-L229 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.createQtiItem | public function createQtiItem()
{
try {
// Check if it's post method
if ($this->getRequestMethod()!=Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to create empty item.');
}
$label = $this->hasRequestParameter('label') ? $this->getRequestParameter('label') : '';
// Call service to import package
$item = $this->getDestinationClass()->createInstance($label);
//set the QTI type
$itemService = \taoItems_models_classes_ItemsService::singleton();
$itemService->setItemModel($item, $this->getResource(ItemModel::MODEL_URI));
$this->returnSuccess($item->getUri());
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | php | public function createQtiItem()
{
try {
// Check if it's post method
if ($this->getRequestMethod()!=Request::HTTP_POST) {
throw new \common_exception_NotImplemented('Only post method is accepted to create empty item.');
}
$label = $this->hasRequestParameter('label') ? $this->getRequestParameter('label') : '';
// Call service to import package
$item = $this->getDestinationClass()->createInstance($label);
//set the QTI type
$itemService = \taoItems_models_classes_ItemsService::singleton();
$itemService->setItemModel($item, $this->getResource(ItemModel::MODEL_URI));
$this->returnSuccess($item->getUri());
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | [
"public",
"function",
"createQtiItem",
"(",
")",
"{",
"try",
"{",
"// Check if it's post method",
"if",
"(",
"$",
"this",
"->",
"getRequestMethod",
"(",
")",
"!=",
"Request",
"::",
"HTTP_POST",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotImplemented",
"... | Create an empty item | [
"Create",
"an",
"empty",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L234-L255 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.export | public function export() {
try {
if ($this->getRequestMethod()!=Request::HTTP_GET) {
throw new \common_exception_NotImplemented('Only GET method is accepted to export QIT Item.');
}
if(!$this->hasRequestParameter('id')) {
$this->returnFailure(new \common_exception_MissingParameter('required parameter `id` is missing'));
}
$id = $this->getRequestParameter('id');
$item = new \core_kernel_classes_Resource($id);
$itemService = \taoItems_models_classes_ItemsService::singleton();
if($itemService->hasItemModel($item, array(ItemModel::MODEL_URI))){
$path = \tao_helpers_Export::getExportFile();
$tmpZip = new \ZipArchive();
$tmpZip->open($path , \ZipArchive::CREATE);
$exporter = new QTIPackedItemExporter( $item , $tmpZip);
$exporter->export(array('apip' => false));
$exporter->getZip()->close();
header('Content-Type: application/zip');
\tao_helpers_Http::returnFile($path, false);
return;
} else {
$this->returnFailure(new \common_exception_NotFound('item can\'t be found'));
}
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | php | public function export() {
try {
if ($this->getRequestMethod()!=Request::HTTP_GET) {
throw new \common_exception_NotImplemented('Only GET method is accepted to export QIT Item.');
}
if(!$this->hasRequestParameter('id')) {
$this->returnFailure(new \common_exception_MissingParameter('required parameter `id` is missing'));
}
$id = $this->getRequestParameter('id');
$item = new \core_kernel_classes_Resource($id);
$itemService = \taoItems_models_classes_ItemsService::singleton();
if($itemService->hasItemModel($item, array(ItemModel::MODEL_URI))){
$path = \tao_helpers_Export::getExportFile();
$tmpZip = new \ZipArchive();
$tmpZip->open($path , \ZipArchive::CREATE);
$exporter = new QTIPackedItemExporter( $item , $tmpZip);
$exporter->export(array('apip' => false));
$exporter->getZip()->close();
header('Content-Type: application/zip');
\tao_helpers_Http::returnFile($path, false);
return;
} else {
$this->returnFailure(new \common_exception_NotFound('item can\'t be found'));
}
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | [
"public",
"function",
"export",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequestMethod",
"(",
")",
"!=",
"Request",
"::",
"HTTP_GET",
")",
"{",
"throw",
"new",
"\\",
"common_exception_NotImplemented",
"(",
"'Only GET method is accepted to exp... | render an item as a Qti zip package
@author christophe GARCIA <christopheg@taotesting.com> | [
"render",
"an",
"item",
"as",
"a",
"Qti",
"zip",
"package"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L261-L302 |
oat-sa/extension-tao-itemqti | controller/RestQtiItem.php | RestQtiItem.createClass | public function createClass()
{
try {
$class = $this->createSubClass(new \core_kernel_classes_Class(TaoOntology::ITEM_CLASS_URI));
$result = [
'message' => __('Class successfully created.'),
'class-uri' => $class->getUri(),
];
$this->returnSuccess($result);
} catch (\common_exception_ClassAlreadyExists $e) {
$result = [
'message' => $e->getMessage(),
'class-uri' => $e->getClass()->getUri(),
];
$this->returnSuccess($result);
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | php | public function createClass()
{
try {
$class = $this->createSubClass(new \core_kernel_classes_Class(TaoOntology::ITEM_CLASS_URI));
$result = [
'message' => __('Class successfully created.'),
'class-uri' => $class->getUri(),
];
$this->returnSuccess($result);
} catch (\common_exception_ClassAlreadyExists $e) {
$result = [
'message' => $e->getMessage(),
'class-uri' => $e->getClass()->getUri(),
];
$this->returnSuccess($result);
} catch (\Exception $e) {
$this->returnFailure($e);
}
} | [
"public",
"function",
"createClass",
"(",
")",
"{",
"try",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"createSubClass",
"(",
"new",
"\\",
"core_kernel_classes_Class",
"(",
"TaoOntology",
"::",
"ITEM_CLASS_URI",
")",
")",
";",
"$",
"result",
"=",
"[",
"'mes... | Create an Item Class
Label parameter is mandatory
If parent class parameter is an uri of valid test class, new class will be created under it
If not parent class parameter is provided, class will be created under root class
Comment parameter is not mandatory, used to describe new created class
@return \core_kernel_classes_Class | [
"Create",
"an",
"Item",
"Class"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/controller/RestQtiItem.php#L314-L334 |
oat-sa/extension-tao-itemqti | model/qti/response/ResponseCondition.php | ResponseCondition.getRule | public function getRule()
{
$returnValue = (string) '';
// Get the if / elseif conditions and the associated actions
foreach ($this->responseIfs as $responseElseIf){
$returnValue .= (empty($returnValue) ? '' : ' else ').$responseElseIf->getRule();
}
// Get the else actions
if (!empty($this->responseElse)){
$returnValue .= 'else {';
foreach ($this->responseElse as $actions){
$returnValue .= $actions->getRule();
}
$returnValue .= '}';
}
return (string) $returnValue;
} | php | public function getRule()
{
$returnValue = (string) '';
// Get the if / elseif conditions and the associated actions
foreach ($this->responseIfs as $responseElseIf){
$returnValue .= (empty($returnValue) ? '' : ' else ').$responseElseIf->getRule();
}
// Get the else actions
if (!empty($this->responseElse)){
$returnValue .= 'else {';
foreach ($this->responseElse as $actions){
$returnValue .= $actions->getRule();
}
$returnValue .= '}';
}
return (string) $returnValue;
} | [
"public",
"function",
"getRule",
"(",
")",
"{",
"$",
"returnValue",
"=",
"(",
"string",
")",
"''",
";",
"// Get the if / elseif conditions and the associated actions",
"foreach",
"(",
"$",
"this",
"->",
"responseIfs",
"as",
"$",
"responseElseIf",
")",
"{",
"$",
... | Short description of method getRule
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return string | [
"Short",
"description",
"of",
"method",
"getRule"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/response/ResponseCondition.php#L71-L94 |
oat-sa/extension-tao-itemqti | model/qti/ManifestParserFactory.php | ManifestParserFactory.getResourcesFromManifest | public static function getResourcesFromManifest( SimpleXMLElement $source)
{
$returnValue = array();
//check of the root tag
if($source->getName() != 'manifest'){
throw new ParsingException("incorrect manifest root tag");
}
$resourceNodes = $source->xpath("//*[name(.)='resource']");
foreach($resourceNodes as $resourceNode){
$type = (string) $resourceNode['type'];
if(Resource::isAssessmentItem($type)){
$id = (string) $resourceNode['identifier'];
$href = (isset($resourceNode['href'])) ? (string) $resourceNode['href'] : '';
$auxFiles = array();
//parse for auxiliary files
foreach($resourceNode->file as $fileNode){
$fileHref = (string) $fileNode['href'];
if($href != $fileHref){
$auxFiles[] = $fileHref;
}
}
//include dependency files in item
foreach($resourceNode->dependency as $dependencyNode){
$ref = (string) $dependencyNode['identifierref'];
//find referenced files within the current manifest:
$refResourceNodes = $source->xpath("//*[name(.)='resource' and @identifier='".$ref."']");
foreach($refResourceNodes as $refResourceNode){
if(isset($refResourceNode['href'])){
$auxFiles[] = (string) $refResourceNode['href'];
}
}
}
$resource = new Resource($id, $type, $href);
$resource->setAuxiliaryFiles($auxFiles);
$returnValue[] = $resource;
}
}
return (array) $returnValue;
} | php | public static function getResourcesFromManifest( SimpleXMLElement $source)
{
$returnValue = array();
//check of the root tag
if($source->getName() != 'manifest'){
throw new ParsingException("incorrect manifest root tag");
}
$resourceNodes = $source->xpath("//*[name(.)='resource']");
foreach($resourceNodes as $resourceNode){
$type = (string) $resourceNode['type'];
if(Resource::isAssessmentItem($type)){
$id = (string) $resourceNode['identifier'];
$href = (isset($resourceNode['href'])) ? (string) $resourceNode['href'] : '';
$auxFiles = array();
//parse for auxiliary files
foreach($resourceNode->file as $fileNode){
$fileHref = (string) $fileNode['href'];
if($href != $fileHref){
$auxFiles[] = $fileHref;
}
}
//include dependency files in item
foreach($resourceNode->dependency as $dependencyNode){
$ref = (string) $dependencyNode['identifierref'];
//find referenced files within the current manifest:
$refResourceNodes = $source->xpath("//*[name(.)='resource' and @identifier='".$ref."']");
foreach($refResourceNodes as $refResourceNode){
if(isset($refResourceNode['href'])){
$auxFiles[] = (string) $refResourceNode['href'];
}
}
}
$resource = new Resource($id, $type, $href);
$resource->setAuxiliaryFiles($auxFiles);
$returnValue[] = $resource;
}
}
return (array) $returnValue;
} | [
"public",
"static",
"function",
"getResourcesFromManifest",
"(",
"SimpleXMLElement",
"$",
"source",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"//check of the root tag",
"if",
"(",
"$",
"source",
"->",
"getName",
"(",
")",
"!=",
"'manifest'",
"... | Enables you to build the QTI_Resources from a manifest xml data node
Content Packaging 1.1)
@access public
@author Joel Bout, <joel.bout@tudor.lu>
@param SimpleXMLElement source
@return array
@see http://www.imsglobal.org/question/qti_v2p0/imsqti_intgv2p0.html#section10003 | [
"Enables",
"you",
"to",
"build",
"the",
"QTI_Resources",
"from",
"a",
"manifest",
"xml",
"data",
"node",
"Content",
"Packaging",
"1",
".",
"1",
")"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/ManifestParserFactory.php#L50-L98 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.resetAttributes | public function resetAttributes(){
$this->attributes = array();
foreach($this->getUsedAttributes() as $attributeClass){
if(class_exists($attributeClass) && is_subclass_of($attributeClass, 'oat\\taoQtiItem\\model\\qti\\attribute\\Attribute')){
$attribute = new $attributeClass();
$this->attributes[$attribute->getName()] = $attribute;
}else{
common_Logger::w('attr does not exists '.$attributeClass);
}
}
} | php | public function resetAttributes(){
$this->attributes = array();
foreach($this->getUsedAttributes() as $attributeClass){
if(class_exists($attributeClass) && is_subclass_of($attributeClass, 'oat\\taoQtiItem\\model\\qti\\attribute\\Attribute')){
$attribute = new $attributeClass();
$this->attributes[$attribute->getName()] = $attribute;
}else{
common_Logger::w('attr does not exists '.$attributeClass);
}
}
} | [
"public",
"function",
"resetAttributes",
"(",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getUsedAttributes",
"(",
")",
"as",
"$",
"attributeClass",
")",
"{",
"if",
"(",
"class_exists",
"(",... | Reset the attributes values to the default values defined by the standard | [
"Reset",
"the",
"attributes",
"values",
"to",
"the",
"default",
"values",
"defined",
"by",
"the",
"standard"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L93-L103 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.removeAttributeValue | public function removeAttributeValue($name){
if(isset($this->attributes[$name])){
$this->attributes[$name]->setNull();
}
} | php | public function removeAttributeValue($name){
if(isset($this->attributes[$name])){
$this->attributes[$name]->setNull();
}
} | [
"public",
"function",
"removeAttributeValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"->",
"setNull",
"(",
... | Remove the actual value of an attribute, distinguish from empty value
@param string $name | [
"Remove",
"the",
"actual",
"value",
"of",
"an",
"attribute",
"distinguish",
"from",
"empty",
"value"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L114-L118 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.setAttributes | public function setAttributes($values){
if(is_array($values)){
foreach($values as $name => $value){
$this->setAttribute($name, $value);
}
}else{
throw new InvalidArgumentException('"values" must be an array');
}
} | php | public function setAttributes($values){
if(is_array($values)){
foreach($values as $name => $value){
$this->setAttribute($name, $value);
}
}else{
throw new InvalidArgumentException('"values" must be an array');
}
} | [
"public",
"function",
"setAttributes",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"... | Set the attributes for the the Qti Element
Argument format: array(attributeName => value)
@param array $values
@throws InvalidArgumentException | [
"Set",
"the",
"attributes",
"for",
"the",
"the",
"Qti",
"Element",
"Argument",
"format",
":",
"array",
"(",
"attributeName",
"=",
">",
"value",
")"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L127-L137 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.setAttribute | public function setAttribute($name, $value){
$returnValue = false;
if(is_null($value)){
return $returnValue;
}
if(isset($this->attributes[$name])){
$datatypeClass = $this->attributes[$name]->getType();
// check if the attribute needs an element level validation
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
if($value instanceof IdentifiedElement){
if($this->validateAttribute($name, $value)){
$this->attributes[$name]->setValue($value);
$returnValue = true;
}else{
$vr = print_r($value, true);
common_Logger::w($vr);
throw new InvalidArgumentException('Invalid identifier attribute value');
}
}elseif(is_string($value)){
// try converting to string identifier and search the identified object:
$identifier = (string) $value;
$elt = $this->getIdentifiedElement($identifier, $datatypeClass::getAllowedClasses());
if(!is_null($elt)){
// ok, found among allowed classes
$this->attributes[$name]->setValue($elt);
$returnValue = true;
}else{
throw new QtiModelException('No QTI element with the identifier has been found: '.$identifier);
}
}
}else{
$this->attributes[$name]->setValue($value);
$returnValue = true;
}
}else{
$this->attributes[$name] = new Generic($value);
$returnValue = true;
}
return $returnValue;
} | php | public function setAttribute($name, $value){
$returnValue = false;
if(is_null($value)){
return $returnValue;
}
if(isset($this->attributes[$name])){
$datatypeClass = $this->attributes[$name]->getType();
// check if the attribute needs an element level validation
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
if($value instanceof IdentifiedElement){
if($this->validateAttribute($name, $value)){
$this->attributes[$name]->setValue($value);
$returnValue = true;
}else{
$vr = print_r($value, true);
common_Logger::w($vr);
throw new InvalidArgumentException('Invalid identifier attribute value');
}
}elseif(is_string($value)){
// try converting to string identifier and search the identified object:
$identifier = (string) $value;
$elt = $this->getIdentifiedElement($identifier, $datatypeClass::getAllowedClasses());
if(!is_null($elt)){
// ok, found among allowed classes
$this->attributes[$name]->setValue($elt);
$returnValue = true;
}else{
throw new QtiModelException('No QTI element with the identifier has been found: '.$identifier);
}
}
}else{
$this->attributes[$name]->setValue($value);
$returnValue = true;
}
}else{
$this->attributes[$name] = new Generic($value);
$returnValue = true;
}
return $returnValue;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"returnValue",
";",
"}",
"if",
"(",
"isset",
"(",
"$"... | Set the value of an attribute
@param string $name
@param mixed $value
@return boolean
@throws InvalidArgumentException
@throws \oat\taoQtiItem\model\qti\exception\QtiModelException | [
"Set",
"the",
"value",
"of",
"an",
"attribute"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L148-L193 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.validateAttribute | public function validateAttribute($name, $value = null){
$returnValue = false;
if(isset($this->attributes[$name])){
if(is_null($value)){
$value = $this->attributes[$name]->getValue();
}
$datatypeClass = $this->attributes[$name]->getType();
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
}else{
$returnValue = $datatypeClass::validate($value);
}
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
if($datatypeClass::validate($value)){
// validate itentifier
$relatedItem = $this->getRelatedItem();
if(!is_null($relatedItem)){
$idCollection = $relatedItem->getIdentifiedElements();
if($value instanceof IdentifiedElement && $idCollection->exists($value->getIdentifier())){
$returnValue = true;
}
}else{
common_Logger::w('iden');
throw new QtiModelException('Cannot verify identifier reference because the element is not in a QTI Item '.get_class($this).'::'.$name, 0);
}
}
}else{
$returnValue = $datatypeClass::validate($value);
}
}else{
throw new InvalidArgumentException('no attribute found with the name "'.$name.'"');
}
return $returnValue;
} | php | public function validateAttribute($name, $value = null){
$returnValue = false;
if(isset($this->attributes[$name])){
if(is_null($value)){
$value = $this->attributes[$name]->getValue();
}
$datatypeClass = $this->attributes[$name]->getType();
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
}else{
$returnValue = $datatypeClass::validate($value);
}
if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){
if($datatypeClass::validate($value)){
// validate itentifier
$relatedItem = $this->getRelatedItem();
if(!is_null($relatedItem)){
$idCollection = $relatedItem->getIdentifiedElements();
if($value instanceof IdentifiedElement && $idCollection->exists($value->getIdentifier())){
$returnValue = true;
}
}else{
common_Logger::w('iden');
throw new QtiModelException('Cannot verify identifier reference because the element is not in a QTI Item '.get_class($this).'::'.$name, 0);
}
}
}else{
$returnValue = $datatypeClass::validate($value);
}
}else{
throw new InvalidArgumentException('no attribute found with the name "'.$name.'"');
}
return $returnValue;
} | [
"public",
"function",
"validateAttribute",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",... | Validate an attribute of the element, at the element level
(the validator of the attributes are on the attribute level)
@param string $name
@param mixed $value
@return boolean
@throws \oat\taoQtiItem\model\qti\exception\QtiModelException | [
"Validate",
"an",
"attribute",
"of",
"the",
"element",
"at",
"the",
"element",
"level",
"(",
"the",
"validator",
"of",
"the",
"attributes",
"are",
"on",
"the",
"attribute",
"level",
")"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L204-L242 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getIdentifiedElement | public function getIdentifiedElement($identifier, $elementClasses = array()){
$returnValue = null;
if(!is_array($elementClasses)){
throw new InvalidArgumentException('elementClasses must be an array');
}
$relatedItem = $this->getRelatedItem();
if(!is_null($relatedItem)){
$identifiedElementsCollection = $relatedItem->getIdentifiedElements();
if(empty($elementClasses)){
$returnValue = $identifiedElementsCollection->getUnique($identifier);
}else{
foreach($elementClasses as $elementClass){
$returnValue = $identifiedElementsCollection->getUnique($identifier, $elementClass);
if(!is_null($returnValue)){
break;
}
}
}
}
return $returnValue;
} | php | public function getIdentifiedElement($identifier, $elementClasses = array()){
$returnValue = null;
if(!is_array($elementClasses)){
throw new InvalidArgumentException('elementClasses must be an array');
}
$relatedItem = $this->getRelatedItem();
if(!is_null($relatedItem)){
$identifiedElementsCollection = $relatedItem->getIdentifiedElements();
if(empty($elementClasses)){
$returnValue = $identifiedElementsCollection->getUnique($identifier);
}else{
foreach($elementClasses as $elementClass){
$returnValue = $identifiedElementsCollection->getUnique($identifier, $elementClass);
if(!is_null($returnValue)){
break;
}
}
}
}
return $returnValue;
} | [
"public",
"function",
"getIdentifiedElement",
"(",
"$",
"identifier",
",",
"$",
"elementClasses",
"=",
"array",
"(",
")",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"elementClasses",
")",
")",
"{",
"throw",
"new... | Find the identified object corresponding to the identifier string
The optional argument $elementClasses search a specific QTI element class
@param string $identifier
@param array $elementClasses
@return \oat\taoQtiItem\model\qti\IdentifiedElement | [
"Find",
"the",
"identified",
"object",
"corresponding",
"to",
"the",
"identifier",
"string",
"The",
"optional",
"argument",
"$elementClasses",
"search",
"a",
"specific",
"QTI",
"element",
"class"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L252-L277 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.attr | public function attr($name, $value = null){
if(is_null($value)){
return $this->getAttributeValue($name);
}else{
return $this->setAttribute($name, $value);
}
} | php | public function attr($name, $value = null){
if(is_null($value)){
return $this->getAttributeValue($name);
}else{
return $this->setAttribute($name, $value);
}
} | [
"public",
"function",
"attr",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getAttributeValue",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"ret... | Short handy method to get/set an attribute value
@param string $name
@param mixed $value
@return mixed | [
"Short",
"handy",
"method",
"to",
"get",
"/",
"set",
"an",
"attribute",
"value"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L296-L302 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.addClass | public function addClass($className) {
$oldClassName = $this->getAttributeValue('class');
$oldClassNameArr = $oldClassName ? explode(' ', $oldClassName) : array();
$classNameArr = array_merge($oldClassNameArr, explode(' ', $className));
// housekeeping
$classNameArr = array_unique(array_filter(array_map('trim', $classNameArr)));
$this->setAttribute('class', implode(' ', $classNameArr));
} | php | public function addClass($className) {
$oldClassName = $this->getAttributeValue('class');
$oldClassNameArr = $oldClassName ? explode(' ', $oldClassName) : array();
$classNameArr = array_merge($oldClassNameArr, explode(' ', $className));
// housekeeping
$classNameArr = array_unique(array_filter(array_map('trim', $classNameArr)));
$this->setAttribute('class', implode(' ', $classNameArr));
} | [
"public",
"function",
"addClass",
"(",
"$",
"className",
")",
"{",
"$",
"oldClassName",
"=",
"$",
"this",
"->",
"getAttributeValue",
"(",
"'class'",
")",
";",
"$",
"oldClassNameArr",
"=",
"$",
"oldClassName",
"?",
"explode",
"(",
"' '",
",",
"$",
"oldClass... | Add a CSS class to the item body
@author Dieter Raber <dieter@taotesting.com>
@param $className one or more class names, separated by space | [
"Add",
"a",
"CSS",
"class",
"to",
"the",
"item",
"body"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L310-L317 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.removeClass | public function removeClass($className) {
$oldClassName = $this->getAttributeValue('class');
$oldClassNameArr = $oldClassName ? explode(' ', $oldClassName) : array();
unset($oldClassNameArr[array_search($className, $oldClassNameArr)]);
$this->setAttribute('class', implode(' ', $oldClassNameArr));
} | php | public function removeClass($className) {
$oldClassName = $this->getAttributeValue('class');
$oldClassNameArr = $oldClassName ? explode(' ', $oldClassName) : array();
unset($oldClassNameArr[array_search($className, $oldClassNameArr)]);
$this->setAttribute('class', implode(' ', $oldClassNameArr));
} | [
"public",
"function",
"removeClass",
"(",
"$",
"className",
")",
"{",
"$",
"oldClassName",
"=",
"$",
"this",
"->",
"getAttributeValue",
"(",
"'class'",
")",
";",
"$",
"oldClassNameArr",
"=",
"$",
"oldClassName",
"?",
"explode",
"(",
"' '",
",",
"$",
"oldCl... | Add a CSS class from the item body
@author Dieter Raber <dieter@taotesting.com>
@param $className | [
"Add",
"a",
"CSS",
"class",
"from",
"the",
"item",
"body"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L325-L330 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getAttributeValue | public function getAttributeValue($name){
$returnValue = null;
if($this->hasAttribute($name)){
$returnValue = $this->attributes[$name]->getValue();
}
return $returnValue;
} | php | public function getAttributeValue($name){
$returnValue = null;
if($this->hasAttribute($name)){
$returnValue = $this->attributes[$name]->getValue();
}
return $returnValue;
} | [
"public",
"function",
"getAttributeValue",
"(",
"$",
"name",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"name",
")",
")",
"{",
"$",
"returnValue",
"=",
"$",
"this",
"->",
"attributes",
"[",
... | Get the attribute's actual value (not as an Attribute object)
@param string $name
@return mixed | [
"Get",
"the",
"attribute",
"s",
"actual",
"value",
"(",
"not",
"as",
"an",
"Attribute",
"object",
")"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L348-L354 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getAttributeValues | public function getAttributeValues($filterNull = true){
$returnValue = array();
foreach($this->attributes as $name => $attribute){
if(!$filterNull || !$attribute->isNull()){
$returnValue[$name] = $attribute->getValue();
}
}
return $returnValue;
} | php | public function getAttributeValues($filterNull = true){
$returnValue = array();
foreach($this->attributes as $name => $attribute){
if(!$filterNull || !$attribute->isNull()){
$returnValue[$name] = $attribute->getValue();
}
}
return $returnValue;
} | [
"public",
"function",
"getAttributeValues",
"(",
"$",
"filterNull",
"=",
"true",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"attribute",
")",
"{",
"if",
"(",... | Get all attributes' values
@return array | [
"Get",
"all",
"attributes",
"values"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L361-L369 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getTemplateQti | public static function getTemplateQti(){
if(empty(static::$qtiTagName)){
throw new QtiModelException('The element has no tag name defined : '.get_called_class());
}
$template = static::getTemplatePath().'/qti.'.static::$qtiTagName.'.tpl.php';
if(!file_exists($template)){
$template = static::getTemplatePath().'/qti.element.tpl.php';
}
return $template;
} | php | public static function getTemplateQti(){
if(empty(static::$qtiTagName)){
throw new QtiModelException('The element has no tag name defined : '.get_called_class());
}
$template = static::getTemplatePath().'/qti.'.static::$qtiTagName.'.tpl.php';
if(!file_exists($template)){
$template = static::getTemplatePath().'/qti.element.tpl.php';
}
return $template;
} | [
"public",
"static",
"function",
"getTemplateQti",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"qtiTagName",
")",
")",
"{",
"throw",
"new",
"QtiModelException",
"(",
"'The element has no tag name defined : '",
".",
"get_called_class",
"(",
")",
"... | Get the absolute path of the template of the qti.xml
@return string
@throws \oat\taoQtiItem\model\qti\exception\QtiModelException | [
"Get",
"the",
"absolute",
"path",
"of",
"the",
"template",
"of",
"the",
"qti",
".",
"xml"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L387-L397 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getTemplateQtiVariables | protected function getTemplateQtiVariables(){
$variables = array();
$variables['tag'] = static::$qtiTagName;
$variables['attributes'] = $this->getAttributeValues();
if($this instanceof FlowContainer){
$variables['body'] = $this->getBody()->toQTI();
}
return $variables;
} | php | protected function getTemplateQtiVariables(){
$variables = array();
$variables['tag'] = static::$qtiTagName;
$variables['attributes'] = $this->getAttributeValues();
if($this instanceof FlowContainer){
$variables['body'] = $this->getBody()->toQTI();
}
return $variables;
} | [
"protected",
"function",
"getTemplateQtiVariables",
"(",
")",
"{",
"$",
"variables",
"=",
"array",
"(",
")",
";",
"$",
"variables",
"[",
"'tag'",
"]",
"=",
"static",
"::",
"$",
"qtiTagName",
";",
"$",
"variables",
"[",
"'attributes'",
"]",
"=",
"$",
"thi... | Get the variables to be used in the qti.xml template
@return array | [
"Get",
"the",
"variables",
"to",
"be",
"used",
"in",
"the",
"qti",
".",
"xml",
"template"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L404-L413 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.toQTI | public function toQTI(){
$template = static::getTemplateQti();
$variables = $this->getTemplateQtiVariables();
if(isset($variables['attributes'])){
$variables['attributes'] = $this->xmlizeOptions($variables['attributes'], true);
}
$tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);
$returnValue = $tplRenderer->render();
return (string) $returnValue;
} | php | public function toQTI(){
$template = static::getTemplateQti();
$variables = $this->getTemplateQtiVariables();
if(isset($variables['attributes'])){
$variables['attributes'] = $this->xmlizeOptions($variables['attributes'], true);
}
$tplRenderer = new taoItems_models_classes_TemplateRenderer($template, $variables);
$returnValue = $tplRenderer->render();
return (string) $returnValue;
} | [
"public",
"function",
"toQTI",
"(",
")",
"{",
"$",
"template",
"=",
"static",
"::",
"getTemplateQti",
"(",
")",
";",
"$",
"variables",
"=",
"$",
"this",
"->",
"getTemplateQtiVariables",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"variables",
"[",
"'a... | Export the data to the QTI XML format
@return string | [
"Export",
"the",
"data",
"to",
"the",
"QTI",
"XML",
"format"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L420-L431 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.toArray | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = array();
$data['serial'] = $this->getSerial();
$tag = $this->getQtiTag();
if(!empty($tag)){
$data['qtiClass'] = $tag;
}
$attributes = $this->getAttributeValues();
$data['attributes'] = empty($attributes) ? new StdClass() : $attributes;
if($this instanceof FlowContainer){
$data['body'] = $this->getBody()->toArray($filterVariableContent, $filtered);
}
if(DEBUG_MODE){
//in debug mode, add debug data, such as the related item
$data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
}
return $data;
} | php | public function toArray($filterVariableContent = false, &$filtered = array()){
$data = array();
$data['serial'] = $this->getSerial();
$tag = $this->getQtiTag();
if(!empty($tag)){
$data['qtiClass'] = $tag;
}
$attributes = $this->getAttributeValues();
$data['attributes'] = empty($attributes) ? new StdClass() : $attributes;
if($this instanceof FlowContainer){
$data['body'] = $this->getBody()->toArray($filterVariableContent, $filtered);
}
if(DEBUG_MODE){
//in debug mode, add debug data, such as the related item
$data['debug'] = array('relatedItem' => is_null($this->getRelatedItem())?'':$this->getRelatedItem()->getSerial());
}
return $data;
} | [
"public",
"function",
"toArray",
"(",
"$",
"filterVariableContent",
"=",
"false",
",",
"&",
"$",
"filtered",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'serial'",
"]",
"=",
"$",
"this",
"->",
"get... | Get the array representation of the Qti Element.
Particularly helpful for data transformation, e.g. json
@param $filterVariableContent
@param array $filtered
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"the",
"Qti",
"Element",
".",
"Particularly",
"helpful",
"for",
"data",
"transformation",
"e",
".",
"g",
".",
"json"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L441-L462 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getTemplatePath | public static function getTemplatePath(){
if(empty(self::$templatesPath)){
$dir = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getDir();
self::$templatesPath = $dir.'model/qti/templates/';
}
$returnValue = self::$templatesPath;
return (string) $returnValue;
} | php | public static function getTemplatePath(){
if(empty(self::$templatesPath)){
$dir = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getDir();
self::$templatesPath = $dir.'model/qti/templates/';
}
$returnValue = self::$templatesPath;
return (string) $returnValue;
} | [
"public",
"static",
"function",
"getTemplatePath",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"templatesPath",
")",
")",
"{",
"$",
"dir",
"=",
"\\",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
... | Get the main template directory
@access public
@author Sam, <sam@taotesting.com>
@return string | [
"Get",
"the",
"main",
"template",
"directory"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L471-L479 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.setRelatedItem | public function setRelatedItem(Item $item, $force = false){
$returnValue = false;
if(!is_null($this->relatedItem) && $this->relatedItem->getSerial() == $item->getSerial()){
$returnValue = true; // identical
}elseif(!$force && !is_null($this->relatedItem)){
throw new QtiModelException('attempt to change item reference for a QTI element');
}else{
// propagate the assignation of item to all included objects
$reflection = new ReflectionClass($this);
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() && !$property->isPrivate()){
$propertyName = $property->getName();
$value = $this->$propertyName;
if(is_array($value)){
foreach($value as $subvalue){
if(is_object($subvalue) && $subvalue instanceof Element){
$subvalue->setRelatedItem($item);
}elseif(is_object($subvalue) && $subvalue instanceof ResponseIdentifier){
// manage the reference of identifier
$idenfierBaseType = $subvalue->getValue(true);
if(!is_null($idenfierBaseType)){
$idenfierBaseType->getReferencedObject()->setRelatedItem($item);
}
}
}
}elseif(is_object($value) && $value instanceof Element){
$value->setRelatedItem($item);
}
}
}
// set item reference to current object
$this->relatedItem = $item;
$returnValue = true;
}
return $returnValue;
} | php | public function setRelatedItem(Item $item, $force = false){
$returnValue = false;
if(!is_null($this->relatedItem) && $this->relatedItem->getSerial() == $item->getSerial()){
$returnValue = true; // identical
}elseif(!$force && !is_null($this->relatedItem)){
throw new QtiModelException('attempt to change item reference for a QTI element');
}else{
// propagate the assignation of item to all included objects
$reflection = new ReflectionClass($this);
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() && !$property->isPrivate()){
$propertyName = $property->getName();
$value = $this->$propertyName;
if(is_array($value)){
foreach($value as $subvalue){
if(is_object($subvalue) && $subvalue instanceof Element){
$subvalue->setRelatedItem($item);
}elseif(is_object($subvalue) && $subvalue instanceof ResponseIdentifier){
// manage the reference of identifier
$idenfierBaseType = $subvalue->getValue(true);
if(!is_null($idenfierBaseType)){
$idenfierBaseType->getReferencedObject()->setRelatedItem($item);
}
}
}
}elseif(is_object($value) && $value instanceof Element){
$value->setRelatedItem($item);
}
}
}
// set item reference to current object
$this->relatedItem = $item;
$returnValue = true;
}
return $returnValue;
} | [
"public",
"function",
"setRelatedItem",
"(",
"Item",
"$",
"item",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"returnValue",
"=",
"false",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"relatedItem",
")",
"&&",
"$",
"this",
"->",
"relat... | Set the item the current Qti Element belongs to.
The related item assignment is propagated to all containing Qti Element of the current one.
The "force" option allows changing the associated item (even if it has already been defined)
@param \oat\taoQtiItem\model\qti\Item $item
@param boolean $force
@return boolean
@throws \oat\taoQtiItem\model\qti\exception\QtiModelException | [
"Set",
"the",
"item",
"the",
"current",
"Qti",
"Element",
"belongs",
"to",
".",
"The",
"related",
"item",
"assignment",
"is",
"propagated",
"to",
"all",
"containing",
"Qti",
"Element",
"of",
"the",
"current",
"one",
".",
"The",
"force",
"option",
"allows",
... | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L491-L530 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getComposingElements | public function getComposingElements($className = ''){
$returnValue = array();
if($className === ''){
$className = 'oat\taoQtiItem\model\qti\Element';
}
$reflection = new ReflectionClass($this);
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() && !$property->isPrivate()){
$propertyName = $property->getName();
if($propertyName != 'relatedItem'){
$value = $this->$propertyName;
if(is_array($value)){
foreach ($value as $subvalue) {
if($subvalue instanceof Element){
if($subvalue instanceof $className){
$returnValue[$subvalue->getSerial()] = $subvalue;
}
$returnValue = array_merge($returnValue, $subvalue->getComposingElements($className));
}
}
}else{
if($value instanceof Element){
if($value instanceof $className){
if($value->getSerial() != $this->getSerial()){
$returnValue[$value->getSerial()] = $value;
}
}
$returnValue = array_merge($returnValue, $value->getComposingElements($className));
}
}
}
}
}
return $returnValue;
} | php | public function getComposingElements($className = ''){
$returnValue = array();
if($className === ''){
$className = 'oat\taoQtiItem\model\qti\Element';
}
$reflection = new ReflectionClass($this);
foreach($reflection->getProperties() as $property){
if(!$property->isStatic() && !$property->isPrivate()){
$propertyName = $property->getName();
if($propertyName != 'relatedItem'){
$value = $this->$propertyName;
if(is_array($value)){
foreach ($value as $subvalue) {
if($subvalue instanceof Element){
if($subvalue instanceof $className){
$returnValue[$subvalue->getSerial()] = $subvalue;
}
$returnValue = array_merge($returnValue, $subvalue->getComposingElements($className));
}
}
}else{
if($value instanceof Element){
if($value instanceof $className){
if($value->getSerial() != $this->getSerial()){
$returnValue[$value->getSerial()] = $value;
}
}
$returnValue = array_merge($returnValue, $value->getComposingElements($className));
}
}
}
}
}
return $returnValue;
} | [
"public",
"function",
"getComposingElements",
"(",
"$",
"className",
"=",
"''",
")",
"{",
"$",
"returnValue",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"className",
"===",
"''",
")",
"{",
"$",
"className",
"=",
"'oat\\taoQtiItem\\model\\qti\\Element'",
";... | Recursively get all Qti Elements contained within the current Qti Element
@param string $className
@return array | [
"Recursively",
"get",
"all",
"Qti",
"Elements",
"contained",
"within",
"the",
"current",
"Qti",
"Element"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L538-L575 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.xmlizeOptions | protected function xmlizeOptions($formalOpts = array(), $recursive = false){
$returnValue = (string) '';
if(!is_array($formalOpts)){
throw new InvalidArgumentException('formalOpts must be an array, '.gettype($formalOpts).' given');
}
$options = (!$recursive) ? $this->getAttributeValues() : $formalOpts;
foreach($options as $key => $value){
if(is_string($value) || is_numeric($value)){
// str_replace is unicode safe...
$returnValue .= ' '.$key.'="'.str_replace(array(
'&',
'<',
'>',
'\'',
'"'
), array(
'&',
'<',
'>',
''',
'"'
), $value).'"';
}
if(is_bool($value)){
$returnValue .= ' '.$key.'="'.(($value) ? 'true' : 'false').'"';
}
if(is_array($value)){
if(count($value) > 0){
$keys = array_keys($value);
if(is_int($keys[0])){ // repeat the attribute key
$returnValue .= ' '.$key.'="'.implode(' ', array_values($value)).'"';
}else{
$returnValue .= $this->xmlizeOptions($value, true);
}
}
}
}
return (string) $returnValue;
} | php | protected function xmlizeOptions($formalOpts = array(), $recursive = false){
$returnValue = (string) '';
if(!is_array($formalOpts)){
throw new InvalidArgumentException('formalOpts must be an array, '.gettype($formalOpts).' given');
}
$options = (!$recursive) ? $this->getAttributeValues() : $formalOpts;
foreach($options as $key => $value){
if(is_string($value) || is_numeric($value)){
// str_replace is unicode safe...
$returnValue .= ' '.$key.'="'.str_replace(array(
'&',
'<',
'>',
'\'',
'"'
), array(
'&',
'<',
'>',
''',
'"'
), $value).'"';
}
if(is_bool($value)){
$returnValue .= ' '.$key.'="'.(($value) ? 'true' : 'false').'"';
}
if(is_array($value)){
if(count($value) > 0){
$keys = array_keys($value);
if(is_int($keys[0])){ // repeat the attribute key
$returnValue .= ' '.$key.'="'.implode(' ', array_values($value)).'"';
}else{
$returnValue .= $this->xmlizeOptions($value, true);
}
}
}
}
return (string) $returnValue;
} | [
"protected",
"function",
"xmlizeOptions",
"(",
"$",
"formalOpts",
"=",
"array",
"(",
")",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"$",
"returnValue",
"=",
"(",
"string",
")",
"''",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"formalOpts",
")",
... | This method enables you to build a string of attributes for an xml node
from the Qti Element attributes according to their types.
@access protected
@author Sam, <sam@taotesting.com>
@param array formalOpts
@param boolean recursive
@return string | [
"This",
"method",
"enables",
"you",
"to",
"build",
"a",
"string",
"of",
"attributes",
"for",
"an",
"xml",
"node",
"from",
"the",
"Qti",
"Element",
"attributes",
"according",
"to",
"their",
"types",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L596-L636 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.getSerial | public function getSerial(){
if(empty($this->serial)){
$this->serial = $this->buildSerial();
}
$returnValue = $this->serial;
return (string) $returnValue;
} | php | public function getSerial(){
if(empty($this->serial)){
$this->serial = $this->buildSerial();
}
$returnValue = $this->serial;
return (string) $returnValue;
} | [
"public",
"function",
"getSerial",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"serial",
")",
")",
"{",
"$",
"this",
"->",
"serial",
"=",
"$",
"this",
"->",
"buildSerial",
"(",
")",
";",
"}",
"$",
"returnValue",
"=",
"$",
"this",
"... | Obtain a serial for the instance of the class that implements the
@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return string | [
"Obtain",
"a",
"serial",
"for",
"the",
"instance",
"of",
"the",
"class",
"that",
"implements",
"the"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L645-L652 |
oat-sa/extension-tao-itemqti | model/qti/Element.php | Element.buildSerial | protected function buildSerial(){
if(DEBUG_MODE){
//in debug mode, use more meaningful serials
$clazz = strtolower(get_class($this));
$prefix = substr($clazz, strpos($clazz, 'taoqtiitem\\model\\qti\\') + 21).'_';
$serial = str_replace('.', '', uniqid($prefix, true));
$serial = str_replace('\\', '_', $serial);
}else{
//build a short unique id for memory saving
$serial = uniqid('i');
}
return (string) $serial;
} | php | protected function buildSerial(){
if(DEBUG_MODE){
//in debug mode, use more meaningful serials
$clazz = strtolower(get_class($this));
$prefix = substr($clazz, strpos($clazz, 'taoqtiitem\\model\\qti\\') + 21).'_';
$serial = str_replace('.', '', uniqid($prefix, true));
$serial = str_replace('\\', '_', $serial);
}else{
//build a short unique id for memory saving
$serial = uniqid('i');
}
return (string) $serial;
} | [
"protected",
"function",
"buildSerial",
"(",
")",
"{",
"if",
"(",
"DEBUG_MODE",
")",
"{",
"//in debug mode, use more meaningful serials",
"$",
"clazz",
"=",
"strtolower",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"prefix",
"=",
"substr",
"(",
"... | create a unique serial number
@access protected
@author Sam, <sam@taotesting.com>
@return string | [
"create",
"a",
"unique",
"serial",
"number"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/qti/Element.php#L661-L675 |
oat-sa/extension-tao-itemqti | model/Export/QTIPackedItemExporter.php | QTIPackedItemExporter.containsItem | protected function containsItem()
{
$found = false;
if ($this->hasManifest()) {
foreach ($this->getManifest()->getElementsByTagName('resource') as $resourceNode) {
/** @var \DOMElement $resourceNode */
if ($resourceNode->getAttribute('identifier') == $this->buildIdentifier()) {
$found = true;
break;
}
}
}
return $found;
} | php | protected function containsItem()
{
$found = false;
if ($this->hasManifest()) {
foreach ($this->getManifest()->getElementsByTagName('resource') as $resourceNode) {
/** @var \DOMElement $resourceNode */
if ($resourceNode->getAttribute('identifier') == $this->buildIdentifier()) {
$found = true;
break;
}
}
}
return $found;
} | [
"protected",
"function",
"containsItem",
"(",
")",
"{",
"$",
"found",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"hasManifest",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getManifest",
"(",
")",
"->",
"getElementsByTagName",
"(",
"'r... | Whenever the item is already in the manifest
@return boolean | [
"Whenever",
"the",
"item",
"is",
"already",
"in",
"the",
"manifest"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/Export/QTIPackedItemExporter.php#L94-L107 |
oat-sa/extension-tao-itemqti | model/Export/QTIPackedItemExporter.php | QTIPackedItemExporter.exportManifest | public function exportManifest($options = [], $exportResult = [])
{
$base = $this->buildBasePath();
$zipArchive = $this->getZip();
$qtiFile = '';
$qtiResources = array();
$sharedAssets = isset($exportResult['portableAssets']) ? $exportResult['portableAssets'] : [];
for ($i = 0; $i < $zipArchive->numFiles; $i++) {
$fileName = $zipArchive->getNameIndex($i);
//shared assets are authorized to be added at the root of the package
if (preg_match("@^" . preg_quote($base) . "@", $fileName) || in_array($fileName, $sharedAssets)) {
if (basename($fileName) == 'qti.xml') {
$qtiFile = $fileName;
} else {
if (!empty($fileName)) {
$qtiResources[] = $fileName;
}
}
}
}
$qtiItemService = Service::singleton();
//@todo add support of multi language packages
$rdfItem = $this->getItem();
$qtiItem = $qtiItemService->getDataItemByRdfItem($rdfItem);
if (!is_null($qtiItem)) {
// -- Prepare data transfer to the imsmanifest.tpl template.
$qtiItemData = array();
// alter identifier for export to avoid any "clash".
$qtiItemData['identifier'] = $this->buildIdentifier();
$qtiItemData['filePath'] = $qtiFile;
$qtiItemData['medias'] = $qtiResources;
$qtiItemData['adaptive'] = ($qtiItem->getAttributeValue('adaptive') === 'adaptive') ? true : false;
$qtiItemData['timeDependent'] = ($qtiItem->getAttributeValue('timeDependent') === 'timeDependent') ? true : false;
$qtiItemData['toolName'] = $qtiItem->getAttributeValue('toolVendor');
$qtiItemData['toolVersion'] = $qtiItem->getAttributeValue('toolVersion');
$qtiItemData['interactions'] = array();
foreach ($qtiItem->getInteractions() as $interaction) {
$interactionData = array();
$interactionData['type'] = $interaction->getQtiTag();
$qtiItemData['interactions'][] = $interactionData;
}
// -- Build a brand new IMS Manifest.
$newManifest = $this->renderManifest($options, $qtiItemData);
if ($this->hasManifest()) {
// Merge old manifest and new one.
$dom1 = $this->getManifest();
$dom2 = $newManifest;
$resourceNodes = $dom2->getElementsByTagName('resource');
$resourcesNodes = $dom1->getElementsByTagName('resources');
foreach ($resourcesNodes as $resourcesNode) {
foreach ($resourceNodes as $resourceNode) {
$newResourceNode = $dom1->importNode($resourceNode, true);
$resourcesNode->appendChild($newResourceNode);
}
}
// rendered manifest is now useless.
unset($dom2);
} else {
// Brand new manifest.
$this->setManifest($newManifest);
}
$manifest = $this->getManifest();
$this->getMetadataExporter()->export($this->getItem(), $manifest);
$this->setManifest($manifest);
// -- Overwrite manifest in the current ZIP archive.
$zipArchive->addFromString('imsmanifest.xml', $this->getManifest()->saveXML());
} else {
//the item has no item content, there are 2 possibilities:
$itemLabel = $this->getItem()->getLabel();
if (empty($itemLabel)) {
//it has no label at all: the item does not exist anymore
throw new ExportException($this->getItem()->getUri(), 'item not found');
} else {
//there is one, so the item does exist but might not have any content
throw new ExportException($itemLabel, 'no item content');
}
}
} | php | public function exportManifest($options = [], $exportResult = [])
{
$base = $this->buildBasePath();
$zipArchive = $this->getZip();
$qtiFile = '';
$qtiResources = array();
$sharedAssets = isset($exportResult['portableAssets']) ? $exportResult['portableAssets'] : [];
for ($i = 0; $i < $zipArchive->numFiles; $i++) {
$fileName = $zipArchive->getNameIndex($i);
//shared assets are authorized to be added at the root of the package
if (preg_match("@^" . preg_quote($base) . "@", $fileName) || in_array($fileName, $sharedAssets)) {
if (basename($fileName) == 'qti.xml') {
$qtiFile = $fileName;
} else {
if (!empty($fileName)) {
$qtiResources[] = $fileName;
}
}
}
}
$qtiItemService = Service::singleton();
//@todo add support of multi language packages
$rdfItem = $this->getItem();
$qtiItem = $qtiItemService->getDataItemByRdfItem($rdfItem);
if (!is_null($qtiItem)) {
// -- Prepare data transfer to the imsmanifest.tpl template.
$qtiItemData = array();
// alter identifier for export to avoid any "clash".
$qtiItemData['identifier'] = $this->buildIdentifier();
$qtiItemData['filePath'] = $qtiFile;
$qtiItemData['medias'] = $qtiResources;
$qtiItemData['adaptive'] = ($qtiItem->getAttributeValue('adaptive') === 'adaptive') ? true : false;
$qtiItemData['timeDependent'] = ($qtiItem->getAttributeValue('timeDependent') === 'timeDependent') ? true : false;
$qtiItemData['toolName'] = $qtiItem->getAttributeValue('toolVendor');
$qtiItemData['toolVersion'] = $qtiItem->getAttributeValue('toolVersion');
$qtiItemData['interactions'] = array();
foreach ($qtiItem->getInteractions() as $interaction) {
$interactionData = array();
$interactionData['type'] = $interaction->getQtiTag();
$qtiItemData['interactions'][] = $interactionData;
}
// -- Build a brand new IMS Manifest.
$newManifest = $this->renderManifest($options, $qtiItemData);
if ($this->hasManifest()) {
// Merge old manifest and new one.
$dom1 = $this->getManifest();
$dom2 = $newManifest;
$resourceNodes = $dom2->getElementsByTagName('resource');
$resourcesNodes = $dom1->getElementsByTagName('resources');
foreach ($resourcesNodes as $resourcesNode) {
foreach ($resourceNodes as $resourceNode) {
$newResourceNode = $dom1->importNode($resourceNode, true);
$resourcesNode->appendChild($newResourceNode);
}
}
// rendered manifest is now useless.
unset($dom2);
} else {
// Brand new manifest.
$this->setManifest($newManifest);
}
$manifest = $this->getManifest();
$this->getMetadataExporter()->export($this->getItem(), $manifest);
$this->setManifest($manifest);
// -- Overwrite manifest in the current ZIP archive.
$zipArchive->addFromString('imsmanifest.xml', $this->getManifest()->saveXML());
} else {
//the item has no item content, there are 2 possibilities:
$itemLabel = $this->getItem()->getLabel();
if (empty($itemLabel)) {
//it has no label at all: the item does not exist anymore
throw new ExportException($this->getItem()->getUri(), 'item not found');
} else {
//there is one, so the item does exist but might not have any content
throw new ExportException($itemLabel, 'no item content');
}
}
} | [
"public",
"function",
"exportManifest",
"(",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"exportResult",
"=",
"[",
"]",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"buildBasePath",
"(",
")",
";",
"$",
"zipArchive",
"=",
"$",
"this",
"->",
"getZip",
... | Build, merge and export the IMS Manifest into the target ZIP archive.
@throws | [
"Build",
"merge",
"and",
"export",
"the",
"IMS",
"Manifest",
"into",
"the",
"target",
"ZIP",
"archive",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/Export/QTIPackedItemExporter.php#L124-L219 |
oat-sa/extension-tao-itemqti | model/CustomInteractionRegistry.php | CustomInteractionRegistry.register | public static function register($qtiClass, $phpClass) {
if (!class_exists($phpClass)) {
throw new common_exception_Error('Custom interaction class '.$phpClass.' not found');
}
if (!is_subclass_of($phpClass, 'oat\taoQtiItem\model\qti\interaction\CustomInteraction')) {
throw new common_exception_Error('Class '.$phpClass.' not a subclass of CustomInteraction');
}
$taoQtiItem = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$map = self::getCustomInteractions();
$map[$qtiClass] = $phpClass;
$taoQtiItem->setConfig(self::CONFIG_ID, $map);
} | php | public static function register($qtiClass, $phpClass) {
if (!class_exists($phpClass)) {
throw new common_exception_Error('Custom interaction class '.$phpClass.' not found');
}
if (!is_subclass_of($phpClass, 'oat\taoQtiItem\model\qti\interaction\CustomInteraction')) {
throw new common_exception_Error('Class '.$phpClass.' not a subclass of CustomInteraction');
}
$taoQtiItem = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$map = self::getCustomInteractions();
$map[$qtiClass] = $phpClass;
$taoQtiItem->setConfig(self::CONFIG_ID, $map);
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"qtiClass",
",",
"$",
"phpClass",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"phpClass",
")",
")",
"{",
"throw",
"new",
"common_exception_Error",
"(",
"'Custom interaction class '",
".",
"$",
"ph... | Register a new custom interaction
@param string $qtiClass
@param string $phpClass
@deprecated
@throws common_exception_Error | [
"Register",
"a",
"new",
"custom",
"interaction"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/CustomInteractionRegistry.php#L65-L76 |
oat-sa/extension-tao-itemqti | model/CustomInteractionRegistry.php | CustomInteractionRegistry.getCustomInteractions | public static function getCustomInteractions() {
$taoQtiItem = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$map = $taoQtiItem->getConfig(self::CONFIG_ID);
return is_array($map) ? $map : array();
} | php | public static function getCustomInteractions() {
$taoQtiItem = common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem');
$map = $taoQtiItem->getConfig(self::CONFIG_ID);
return is_array($map) ? $map : array();
} | [
"public",
"static",
"function",
"getCustomInteractions",
"(",
")",
"{",
"$",
"taoQtiItem",
"=",
"common_ext_ExtensionsManager",
"::",
"singleton",
"(",
")",
"->",
"getExtensionById",
"(",
"'taoQtiItem'",
")",
";",
"$",
"map",
"=",
"$",
"taoQtiItem",
"->",
"getCo... | Returns a list of registered custom interactions.
With the qti classes as keys and the php classnames that
implementat these interactions as values
@deprecated
@return array | [
"Returns",
"a",
"list",
"of",
"registered",
"custom",
"interactions",
"."
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/CustomInteractionRegistry.php#L87-L91 |
oat-sa/extension-tao-itemqti | model/CustomInteractionRegistry.php | CustomInteractionRegistry.getCustomInteractionByName | public static function getCustomInteractionByName($name){
$all = self::getCustomInteractions();
if(isset($all[$name])){
return $all[$name];
}
return '';
} | php | public static function getCustomInteractionByName($name){
$all = self::getCustomInteractions();
if(isset($all[$name])){
return $all[$name];
}
return '';
} | [
"public",
"static",
"function",
"getCustomInteractionByName",
"(",
"$",
"name",
")",
"{",
"$",
"all",
"=",
"self",
"::",
"getCustomInteractions",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"all",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
... | Get the php class that represents a custom interaction from its class attribute
@param string $name
@deprecated
@return string | [
"Get",
"the",
"php",
"class",
"that",
"represents",
"a",
"custom",
"interaction",
"from",
"its",
"class",
"attribute"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/CustomInteractionRegistry.php#L101-L107 |
oat-sa/extension-tao-itemqti | model/portableElement/parser/itemParser/PortableElementItemParser.php | PortableElementItemParser.importPortableElementFile | public function importPortableElementFile($absolutePath, $relativePath)
{
if ($this->isPortableElementAsset($relativePath)) {
//marked the file as being ok to be imported in the end
$this->importingFiles[] = $relativePath;
//@todo remove qti file used by PCI
return $this->getFileInfo($absolutePath, $relativePath);
} else {
throw new \common_Exception('trying to import an asset that is not part of the portable element asset list');
}
} | php | public function importPortableElementFile($absolutePath, $relativePath)
{
if ($this->isPortableElementAsset($relativePath)) {
//marked the file as being ok to be imported in the end
$this->importingFiles[] = $relativePath;
//@todo remove qti file used by PCI
return $this->getFileInfo($absolutePath, $relativePath);
} else {
throw new \common_Exception('trying to import an asset that is not part of the portable element asset list');
}
} | [
"public",
"function",
"importPortableElementFile",
"(",
"$",
"absolutePath",
",",
"$",
"relativePath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPortableElementAsset",
"(",
"$",
"relativePath",
")",
")",
"{",
"//marked the file as being ok to be imported in the end",
... | Handle pci import process for a file
@param $absolutePath
@param $relativePath
@return array
@throws \common_Exception
@throws \tao_models_classes_FileNotFoundException | [
"Handle",
"pci",
"import",
"process",
"for",
"a",
"file"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/portableElement/parser/itemParser/PortableElementItemParser.php#L85-L98 |
oat-sa/extension-tao-itemqti | model/portableElement/parser/itemParser/PortableElementItemParser.php | PortableElementItemParser.getFileInfo | public function getFileInfo($path, $relPath) {
if (file_exists($path)) {
return array(
'name' => basename($path),
'uri' => $relPath,
'mime' => \tao_helpers_File::getMimeType($path),
'filePath' => $path,
'size' => filesize($path),
);
}
throw new \tao_models_classes_FileNotFoundException($path);
} | php | public function getFileInfo($path, $relPath) {
if (file_exists($path)) {
return array(
'name' => basename($path),
'uri' => $relPath,
'mime' => \tao_helpers_File::getMimeType($path),
'filePath' => $path,
'size' => filesize($path),
);
}
throw new \tao_models_classes_FileNotFoundException($path);
} | [
"public",
"function",
"getFileInfo",
"(",
"$",
"path",
",",
"$",
"relPath",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"array",
"(",
"'name'",
"=>",
"basename",
"(",
"$",
"path",
")",
",",
"'uri'",
"=>",
"$",
"re... | Get details about file
@param $path
@param $relPath
@return array
@throws \tao_models_classes_FileNotFoundException | [
"Get",
"details",
"about",
"file"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/portableElement/parser/itemParser/PortableElementItemParser.php#L129-L142 |
oat-sa/extension-tao-itemqti | model/portableElement/parser/itemParser/PortableElementItemParser.php | PortableElementItemParser.feedRequiredFiles | protected function feedRequiredFiles(Item $item)
{
$this->requiredFiles = [];
$this->portableObjects = [];
$this->picModels = [];
$models = $this->getPortableFactory()->getModels();
foreach ($models as $model) {
$className = $model->getQtiElementClassName();
$portableElementsXml = $item->getComposingElements($className);
foreach($portableElementsXml as $portableElementXml) {
$this->parsePortableElement($model, $portableElementXml);
}
}
} | php | protected function feedRequiredFiles(Item $item)
{
$this->requiredFiles = [];
$this->portableObjects = [];
$this->picModels = [];
$models = $this->getPortableFactory()->getModels();
foreach ($models as $model) {
$className = $model->getQtiElementClassName();
$portableElementsXml = $item->getComposingElements($className);
foreach($portableElementsXml as $portableElementXml) {
$this->parsePortableElement($model, $portableElementXml);
}
}
} | [
"protected",
"function",
"feedRequiredFiles",
"(",
"Item",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"requiredFiles",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"portableObjects",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"picModels",
"=",
"[",
"]",
";",
"$... | Feed the instance with portable related data extracted from the item
@param Item $item
@throws \common_Exception | [
"Feed",
"the",
"instance",
"with",
"portable",
"related",
"data",
"extracted",
"from",
"the",
"item"
] | train | https://github.com/oat-sa/extension-tao-itemqti/blob/a55b73c7894523bde169ba520d5001ce7b5bb88c/model/portableElement/parser/itemParser/PortableElementItemParser.php#L170-L185 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.