diff --git a/htdocs/api/v2/index.php b/htdocs/api/v2/index.php index b9ba1ad..bd73020 100644 --- a/htdocs/api/v2/index.php +++ b/htdocs/api/v2/index.php @@ -14,6 +14,8 @@ require_once UELEARNING_LIB_ROOT.'/Database/DBInfo.php'; require_once UELEARNING_LIB_ROOT.'/Database/DBQuestion.php'; require_once UELEARNING_LIB_ROOT.'/Recommand/RecommandPoint.php'; require_once UELEARNING_LIB_ROOT.'/Log/Log.php'; +require_once UELEARNING_LIB_ROOT.'/Log/XApi.php'; +require_once UELEARNING_LIB_ROOT.'/Util/UEHBase.php'; use UElearning\User; use UElearning\Study; use UElearning\Target; @@ -21,6 +23,7 @@ use UElearning\Recommand; use UElearning\Exception; use UElearning\Database; use UElearning\Log; +use UElearning\Util; $app = new \Slim\Slim(array( 'templates.path' => './', // 設定Path @@ -94,6 +97,20 @@ function login($user_id = null) { $db_material = new Database\DBMaterial(); $all_material_kind = $db_material->queryAllKind(); + // 紀錄進HBase + if(UELEARNING_UEHBASE_ENABLE) { + $xapi = new Log\XApi(); + $uname = $user->getName(); + $umail = $user->getEmail(); + $cname = $user->getClassName(); + $lmode = $user->getLearnStyle(); + $post_data = $xapi->login($nowDate,$loginToken,$uname,$umail,$cname,$lmode); + + $hbase = new Util\UEHBase(); + $hbase->sendLog($post_data); + } + + // 輸出結果 $app->render(201,array( 'user_id' => $user_id, diff --git a/htdocs/config.sample.php b/htdocs/config.sample.php index 7ff625b..13c71d1 100644 --- a/htdocs/config.sample.php +++ b/htdocs/config.sample.php @@ -125,3 +125,15 @@ * 這份設定檔的路徑 */ define('UELEARNING_CONFIG_PATH', __FILE__); + +// 連接HBase伺服器 ============================================================= + + /** + * 是否啟用介接學習歷程紀錄伺服器 + */ + define('UELEARNING_UEHBASE_ENABLE', false); + + /** + * 介接學習歷程紀錄伺服器紀錄模組網址 + */ + define('UELEARNING_UEHBASE_URL', 'http://localhost/'); diff --git a/htdocs/lib/Util/UEHBase.php b/htdocs/lib/Util/UEHBase.php new file mode 100644 index 0000000..4bba6b3 --- /dev/null +++ b/htdocs/lib/Util/UEHBase.php @@ -0,0 +1,18 @@ +request('POST', UELEARNING_UEHBASE_URL, [ + 'json' => $result + ]); + } +}