本文整理汇总了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;
}