本文整理匯總了PHP中lti_get_url_thumbprint函數的典型用法代碼示例。如果您正苦於以下問題:PHP lti_get_url_thumbprint函數的具體用法?PHP lti_get_url_thumbprint怎麽用?PHP lti_get_url_thumbprint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了lti_get_url_thumbprint函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_lti_get_url_thumbprint
/**
* Test lti_get_url_thumbprint against various URLs
*/
public function test_lti_get_url_thumbprint()
{
// Note: trailing and double slash are expected right now. Must evaluate if it must be removed at some point.
$this->assertEquals('moodle.org/', lti_get_url_thumbprint('http://MOODLE.ORG'));
$this->assertEquals('moodle.org/', lti_get_url_thumbprint('http://www.moodle.org'));
$this->assertEquals('moodle.org/', lti_get_url_thumbprint('https://www.moodle.org'));
$this->assertEquals('moodle.org/', lti_get_url_thumbprint('moodle.org'));
$this->assertEquals('moodle.org//this/is/moodle', lti_get_url_thumbprint('http://moodle.org/this/is/moodle'));
$this->assertEquals('moodle.org//this/is/moodle', lti_get_url_thumbprint('https://moodle.org/this/is/moodle'));
$this->assertEquals('moodle.org//this/is/moodle', lti_get_url_thumbprint('moodle.org/this/is/moodle'));
$this->assertEquals('moodle.org//this/is/moodle', lti_get_url_thumbprint('moodle.org/this/is/moodle?foo=bar'));
}
示例2: lti_get_best_tool_by_url
function lti_get_best_tool_by_url($url, $tools, $courseid = null) {
if (count($tools) === 0) {
return null;
}
$urllower = lti_get_url_thumbprint($url);
foreach ($tools as $tool) {
$tool->_matchscore = 0;
$toolbaseurllower = lti_get_url_thumbprint($tool->baseurl);
if ($urllower === $toolbaseurllower) {
//100 points for exact thumbprint match
$tool->_matchscore += 100;
} else if (substr($urllower, 0, strlen($toolbaseurllower)) === $toolbaseurllower) {
//50 points if tool thumbprint starts with the base URL thumbprint
$tool->_matchscore += 50;
}
//Prefer course tools over site tools
if (!empty($courseid)) {
//Minus 10 points for not matching the course id (global tools)
if ($tool->course != $courseid) {
$tool->_matchscore -= 10;
}
}
}
$bestmatch = array_reduce($tools, function($value, $tool) {
if ($tool->_matchscore > $value->_matchscore) {
return $tool;
} else {
return $value;
}
}, (object)array('_matchscore' => -1));
//None of the tools are suitable for this URL
if ($bestmatch->_matchscore <= 0) {
return null;
}
return $bestmatch;
}