當前位置: 首頁>>代碼示例>>PHP>>正文


PHP lti_get_url_thumbprint函數代碼示例

本文整理匯總了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'));
 }
開發者ID:aleph-n,項目名稱:lms.aaenl,代碼行數:15,代碼來源:locallib_test.php

示例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;
}
開發者ID:numbas,項目名稱:moodle,代碼行數:45,代碼來源:locallib.php


注:本文中的lti_get_url_thumbprint函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。