/** * Splits the custom parameters field to the various parameters * * @param string $customstr String containing the parameters * * @return Array of custom parameters */ function lti_split_custom_parameters($customstr) { $lines = preg_split("/[\n;]/", $customstr); $retval = array(); foreach ($lines as $line) { $pos = strpos($line, "="); if ( $pos === false || $pos < 1 ) { continue; } $key = trim(textlib::substr($line, 0, $pos)); $val = trim(textlib::substr($line, $pos+1, strlen($line))); $key = lti_map_keyname($key); $retval['custom_'.$key] = $val; } return $retval; }
/** * Adds the custom parameters to an array * * @param object $toolproxy Tool proxy instance object * @param object $tool Tool instance object * @param array $params LTI launch parameters * @param array $parameters Array containing the parameters * * @return array Array of custom parameters */ function lti_get_custom_parameters($toolproxy, $tool, $params, $parameters) { $retval = array(); foreach ($parameters as $key => $val) { $key2 = lti_map_keyname($key); $val = lti_parse_custom_parameter($toolproxy, $tool, $params, $val, true); $retval['custom_' . $key2] = $val; if ($key != $key2) { $retval['custom_' . $key] = $val; } } return $retval; }