大修正XAPI產生並介接
This commit is contained in:
parent
c4d5de11d3
commit
2ff752ed82
@ -97,20 +97,6 @@ function login($user_id = null) {
|
|||||||
$db_material = new Database\DBMaterial();
|
$db_material = new Database\DBMaterial();
|
||||||
$all_material_kind = $db_material->queryAllKind();
|
$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(
|
$app->render(201,array(
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@ -758,9 +744,27 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
|||||||
if($sact->getUserId() == $user_id) {
|
if($sact->getUserId() == $user_id) {
|
||||||
|
|
||||||
// 結束學習活動
|
// 結束學習活動
|
||||||
|
|
||||||
$sact->finishActivity();
|
$sact->finishActivity();
|
||||||
|
|
||||||
|
// 傳送紀錄給紀錄模組伺服器
|
||||||
|
if(UELEARNING_UEHBASE_ENABLE) {
|
||||||
|
$user = new User\User($user_id);
|
||||||
|
$xapi = new Log\XApi();
|
||||||
|
$u_name = $user->getName();
|
||||||
|
$u_email = $user->getEmail();
|
||||||
|
$c_name = $user->getClassName();
|
||||||
|
$lmode = $user->getLearnStyle();
|
||||||
|
|
||||||
|
//$date = strtotime("now");
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
$duration = 1; // TODO: 期間
|
||||||
|
$post_data = $xapi->endStudyActivity($date, $token, $duration, $u_name, $u_email, $c_name,
|
||||||
|
$saId, $lmode);
|
||||||
|
|
||||||
|
$hbase = new Util\UEHBase();
|
||||||
|
$hbase->sendLog($post_data);
|
||||||
|
}
|
||||||
|
|
||||||
// 噴出學習完畢後的活動資料
|
// 噴出學習完畢後的活動資料
|
||||||
$app->render(201,array(
|
$app->render(201,array(
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
@ -1151,21 +1155,69 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
|||||||
|
|
||||||
// 離開學習點
|
// 離開學習點
|
||||||
try {
|
try {
|
||||||
|
$smang = new Study\StudyManager();
|
||||||
|
$the_study_id = $smang->getCurrentInStudyId($saId);
|
||||||
|
$the_study = new Study\Study($the_study_id);
|
||||||
$sact->toOutTarget($tId);
|
$sact->toOutTarget($tId);
|
||||||
|
|
||||||
// 紀錄回答問題
|
// // 紀錄回答問題
|
||||||
$db_recommend = new Database\DBQuestion();
|
$db_recommend = new Database\DBQuestion();
|
||||||
foreach($ans_json as $the_ans) {
|
foreach($ans_json as $the_ans) {
|
||||||
$db_recommend->insert($saId, $the_ans->target_id, $the_ans->question_time, $the_ans->answer_time, $the_ans->quest_id, $the_ans->answer, $the_ans->correct);
|
$db_recommend->insert($saId, $the_ans->target_id, $the_ans->question_time, $the_ans->answer_time, $the_ans->quest_id, $the_ans->answer, $the_ans->correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 傳送紀錄給紀錄模組伺服器
|
||||||
|
if(UELEARNING_UEHBASE_ENABLE) {
|
||||||
|
$user = new User\User($user_id);
|
||||||
|
$xapi = new Log\XApi();
|
||||||
|
$u_name = $user->getName();
|
||||||
|
$u_email = $user->getEmail();
|
||||||
|
$c_name = $user->getClassName();
|
||||||
|
$lmode = $user->getLearnStyle();
|
||||||
|
$target_id = $the_study->getTargetId();
|
||||||
|
$target = new Target\Target($target_id);
|
||||||
|
$target_name = $target->getName();
|
||||||
|
$floor = $target->getFloor();
|
||||||
|
$hall_id = $target->getHallId();
|
||||||
|
$hall_name = $target->getHallName();
|
||||||
|
$area_id = $target->getAreaId();
|
||||||
|
$area_name = $target->getAreaName();
|
||||||
|
|
||||||
|
//$date = strtotime("now");
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
$duration = $the_study->getElapsedSec();
|
||||||
|
// TODO: Material ID
|
||||||
|
$post_data = $xapi->readMaterial($date, $token, $duration, $u_name, $u_email, $c_name,
|
||||||
|
$saId, $lmode,
|
||||||
|
$hall_id, $hall_name, $area_id, $area_name, $floor, $target_id, $target_name, '1');
|
||||||
|
|
||||||
|
$hbase = new Util\UEHBase();
|
||||||
|
$hbase->sendLog($post_data);
|
||||||
|
|
||||||
|
$debug_array = array();
|
||||||
|
foreach($ans_json as $the_ans) {
|
||||||
|
$qDate = strtotime($the_ans->question_time);
|
||||||
|
$aDate = strtotime($the_ans->answer_time);
|
||||||
|
$ans_duration = (int)$aDate - (int)$qDate;
|
||||||
|
|
||||||
|
$post_ans_data = $xapi->answerQuestion($the_ans->question_time, $token, $ans_duration, $u_name, $u_email, $c_name,
|
||||||
|
$saId, $lmode,
|
||||||
|
$hall_id, $hall_name, $area_id, $area_name, $floor, $target_id, $target_name,
|
||||||
|
$the_ans->quest_id, $the_ans->answer, $the_ans->correct);
|
||||||
|
|
||||||
|
array_push($debug_array, $post_ans_data);
|
||||||
|
$hbase->sendLog($post_ans_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 噴出結果
|
// 噴出結果
|
||||||
$app->render(201,array(
|
$app->render(201,array(
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'answers' => $ans_json,
|
'answers' => $ans_json,
|
||||||
'activity_id' => $sact->getId(),
|
'activity_id' => $sact->getId(),
|
||||||
'error' => false
|
'error' => false,
|
||||||
|
'debug' => $debug_array
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
// 如果此標的尚未登記為已進入
|
// 如果此標的尚未登記為已進入
|
||||||
|
@ -433,8 +433,7 @@ class DBStudy extends Database {
|
|||||||
public function getCurrentInStudyId($activity_id) {
|
public function getCurrentInStudyId($activity_id) {
|
||||||
|
|
||||||
$sqlString = "SELECT `SID` FROM `".$this->table('user_history')."` ".
|
$sqlString = "SELECT `SID` FROM `".$this->table('user_history')."` ".
|
||||||
"WHERE `Out_TargetTime` IS NULL AND `SaID` = :said ".
|
"WHERE `Out_TargetTime` IS NULL AND `SaID` = :said ";
|
||||||
" AND `IsEnter` = '1'";
|
|
||||||
|
|
||||||
$query = $this->connDB->prepare($sqlString);
|
$query = $this->connDB->prepare($sqlString);
|
||||||
$query->bindParam(":said", $activity_id);
|
$query->bindParam(":said", $activity_id);
|
||||||
|
@ -17,5 +17,413 @@ use UElearning\Exception;
|
|||||||
*/
|
*/
|
||||||
class XApi {
|
class XApi {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 閱讀教材
|
||||||
|
* @param [type] $date [description]
|
||||||
|
* @param [type] $token [description]
|
||||||
|
* @param [type] $duration [description]
|
||||||
|
* @param [type] $u_name [description]
|
||||||
|
* @param [type] $u_email [description]
|
||||||
|
* @param [type] $c_name [description]
|
||||||
|
* @param [type] $sa_id [description]
|
||||||
|
* @param [type] $l_mode [description]
|
||||||
|
* @param [type] $hall_id [description]
|
||||||
|
* @param [type] $hall_name [description]
|
||||||
|
* @param [type] $area_id [description]
|
||||||
|
* @param [type] $area_name [description]
|
||||||
|
* @param [type] $floor [description]
|
||||||
|
* @param [type] $target_id [description]
|
||||||
|
* @param [type] $target_name [description]
|
||||||
|
* @param [type] $material_id [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function readMaterial($date, $token, $duration, $u_name, $u_email, $c_name,
|
||||||
|
$sa_id, $l_mode,
|
||||||
|
$hall_id, $hall_name, $area_id, $area_name, $floor, $target_id, $target_name, $material_id)
|
||||||
|
{
|
||||||
|
$result = array(
|
||||||
|
"actor"=> array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> "篤行國小", //固定
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> $c_name, //資料表=>user_class的cname
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Agent", //固定
|
||||||
|
"name"=> $u_name, //資料表=>user的URealName
|
||||||
|
"mbox"=> $u_email, //資料表=>user的UEmail
|
||||||
|
"account"=> array(
|
||||||
|
"homePage"=> null, //沒有
|
||||||
|
"token"=> $token, //資料表=>user_session的UToken
|
||||||
|
"said" => $sa_id, //資料表user_activity的SaID
|
||||||
|
"born"=> null, //沒有
|
||||||
|
"gender"=> null, //沒有
|
||||||
|
"lmode"=> $l_mode //資料表=>user的LMode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"verb"=> array(
|
||||||
|
"id"=> "https=>//w3id.org/xapi/adb/verbs/read", //固定
|
||||||
|
"display"=> array(
|
||||||
|
"zh-TW"=> "閱讀" //固定
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"object"=> array(
|
||||||
|
"objectType"=> "Activity", //固定
|
||||||
|
"id"=> "http=>//material/id/".$material_id, //資料庫=>material的MID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "編號".$material_id."教材" //資料庫=>material的MID
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"place"=> array(
|
||||||
|
"longitude"=> null, //經度
|
||||||
|
"latitude"=> null, //緯度
|
||||||
|
"Museum"=> array( //展館
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//museum/id/1", //固定
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "台中科學博物館" //固定
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Hall"=> array( //展廳
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//hall/id/".$hall_id, //資料表=>learn_hall的HID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $hall_name //資料表=>learn_hall的HName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Area"=> array( //展區
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//area/id/".$area_id, //資料表=>learn_area的AID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $area_name //資料表learn_area的AName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Floor"=> array( //樓層
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//floor/id/".$floor, //資料表=>learn_area的AFloor
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "樓層".$floor //資料表=>learn_area的AFloor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Spot"=> array( //展點
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//spot/id/".$target_id, //資料表=>learn_target的TID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $target_name //資料表=>learn_target的TName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Exhibits"=> array( //展品
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"result" => array(
|
||||||
|
"success"=> true, //true or false
|
||||||
|
"completion"=> true, //true or false
|
||||||
|
"response" => null, //空
|
||||||
|
"duration"=> $duration //閱讀期間多久 (進入教材到開啟問題的時間)
|
||||||
|
),
|
||||||
|
"timestamp"=> $date //資料表=>user_history的In_TargetTime
|
||||||
|
);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回答問題
|
||||||
|
* @param [type] $date [description]
|
||||||
|
* @param [type] $token [description]
|
||||||
|
* @param [type] $duration [description]
|
||||||
|
* @param [type] $u_name [description]
|
||||||
|
* @param [type] $u_email [description]
|
||||||
|
* @param [type] $c_name [description]
|
||||||
|
* @param [type] $sa_id [description]
|
||||||
|
* @param [type] $l_mode [description]
|
||||||
|
* @param [type] $hall_id [description]
|
||||||
|
* @param [type] $hall_name [description]
|
||||||
|
* @param [type] $area_id [description]
|
||||||
|
* @param [type] $area_name [description]
|
||||||
|
* @param [type] $floor [description]
|
||||||
|
* @param [type] $target_id [description]
|
||||||
|
* @param [type] $target_name [description]
|
||||||
|
* @param [type] $question_id [description]
|
||||||
|
* @param [type] $answer [description]
|
||||||
|
* @param [type] $completion [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function answerQuestion($date, $token, $duration, $u_name, $u_email, $c_name,
|
||||||
|
$sa_id, $l_mode,
|
||||||
|
$hall_id, $hall_name, $area_id, $area_name, $floor, $target_id, $target_name,
|
||||||
|
$question_id, $answer, $completion)
|
||||||
|
{
|
||||||
|
$result = array(
|
||||||
|
"actor"=> array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> "篤行國小", //固定
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> $c_name, //資料表=>user_class的cname
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Agent", //固定
|
||||||
|
"name"=> $u_name, //資料表=>user的URealName
|
||||||
|
"mbox"=> $u_email, //資料表=>user的UEmail
|
||||||
|
"account"=> array(
|
||||||
|
"homePage"=> null, //沒有
|
||||||
|
"token"=> $token, //資料表=>user_session的UToken
|
||||||
|
"said" => $sa_id, //資料表user_activity的SaID
|
||||||
|
"born"=> null, //沒有
|
||||||
|
"gender"=> null, //沒有
|
||||||
|
"lmode"=> $l_mode //資料表=>user的LMode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"verb"=> array(
|
||||||
|
"id"=> "https=>//w3id.org/xapi/adb/verbs/answer", //固定
|
||||||
|
"display"=> array(
|
||||||
|
"zh-TW"=> "回答" //固定
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"object"=> array(
|
||||||
|
"objectType"=> "Activity", //固定
|
||||||
|
"id"=> "http=>//option/id/".$question_id, //資料表=>user_history_question的QID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "問題".$question_id //資料表=>user_history_question的QID
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"place"=> array(
|
||||||
|
"longitude"=> null, //經度
|
||||||
|
"latitude"=> null, //緯度
|
||||||
|
"Museum"=> array( //展館
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//museum/id/1", //固定
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "台中科學博物館" //固定
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Hall"=> array( //展廳
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//hall/id/".$hall_id, //資料表=>learn_hall的HID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $hall_name //資料表=>learn_hall的HName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Area"=> array( //展區
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//area/id/".$area_id, //資料表=>learn_area的AID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $area_name //資料表learn_area的AName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Floor"=> array( //樓層
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//floor/id/".$floor, //資料表=>learn_area的AFloor
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "樓層" //資料表=>learn_area的AFloor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Spot"=> array( //展點
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//spot/id/".$target_id, //資料表=>learn_target的TID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> $target_name //資料表=>learn_target的TName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Exhibits"=> array( //展品
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"result" => array(
|
||||||
|
"success"=> true, //true or false
|
||||||
|
"completion"=> $completion, //true or false
|
||||||
|
"response" => $answer, //資料表=>user_history_question的Ans
|
||||||
|
"duration"=> $duration //回答期間多久(進入問題到回答問題的時間)
|
||||||
|
),
|
||||||
|
"timestamp"=> $date //資料表=>user_history_question的ADate
|
||||||
|
);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function endStudyActivity($date, $token, $duration, $u_name, $u_email, $c_name,
|
||||||
|
$sa_id, $l_mode)
|
||||||
|
{
|
||||||
|
$result = array(
|
||||||
|
"actor"=> array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> "篤行國小", //固定
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Group", //固定
|
||||||
|
"name"=> $c_name, //資料表=>user_class的cname
|
||||||
|
"mbox"=> null, //沒有
|
||||||
|
"member"=> array(
|
||||||
|
array(
|
||||||
|
"objectType"=> "Agent", //固定
|
||||||
|
"name"=> $u_name, //資料表=>user的URealName
|
||||||
|
"mbox"=> $u_email, //資料表=>user的UEmail
|
||||||
|
"account"=> array(
|
||||||
|
"homePage"=> null, //沒有
|
||||||
|
"token"=> $token, //資料表=>user_session的UToken
|
||||||
|
"said" => $sa_id, //資料表user_activity的SaID
|
||||||
|
"born"=> null, //沒有
|
||||||
|
"gender"=> null, //沒有
|
||||||
|
"lmode"=> $l_mode //資料表=>user的LMode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"verb"=> array(
|
||||||
|
"id"=> "https=>//w3id.org/xapi/adb/verbs/finish", //固定
|
||||||
|
"display"=> array(
|
||||||
|
"zh-TW"=> "結束" //固定
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"object"=> array(
|
||||||
|
"objectType"=> "Activity", //固定
|
||||||
|
"id"=> "http=>//elearning/id/".$sa_id, //固定
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "學習導覽系統" //固定
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"place"=> array(
|
||||||
|
"longitude"=> null, //經度
|
||||||
|
"latitude"=> null, //緯度
|
||||||
|
"Museum"=> array( //展館
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//museum/id/1", //固定
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "台中科學博物館" //固定
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Hall"=> array( //展廳
|
||||||
|
array(
|
||||||
|
"id"=> "http=>//hall/id/1", //資料表=>learn_hall的HID
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> "生命科學廳" //資料表=>learn_hall的HName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Area"=> array( //展區
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Floor"=> array( //樓層
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Spot"=> array( //展點
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"Exhibits"=> array( //展品
|
||||||
|
array(
|
||||||
|
"id"=> null,
|
||||||
|
"definition"=> array(
|
||||||
|
"name"=> array(
|
||||||
|
"zh-TW"=> null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"result" => array(
|
||||||
|
"success"=> true, //true or false
|
||||||
|
"completion"=> true, //true or false
|
||||||
|
"response" => null, //空
|
||||||
|
"duration"=> $duration //在學習導覽系統期間多久(登入到登出的時間)
|
||||||
|
),
|
||||||
|
"timestamp"=> $date //資料表=>user_history_question的ADate
|
||||||
|
);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,35 @@ class Study {
|
|||||||
return $this->queryResultArray['out_target_time'];
|
return $this->queryResultArray['out_target_time'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得學習點時間
|
||||||
|
*
|
||||||
|
* @return string 學習點時間
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public function getElapsedSec(){
|
||||||
|
|
||||||
|
// 假如還在學習點內當中
|
||||||
|
if($this->isIn()) {
|
||||||
|
// 現在時間-開始時間 = 已經過了多久
|
||||||
|
$nowDate = strtotime("now");
|
||||||
|
$startDate = strtotime($this->getInTime());
|
||||||
|
$elapsedDate = $nowDate - $startDate;
|
||||||
|
$elapsedSec = (int)($elapsedDate);
|
||||||
|
|
||||||
|
return $elapsedSec;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 結束時間-開始時間 = 已經過了多久
|
||||||
|
$endDate = strtotime($this->getOutTime());
|
||||||
|
$startDate = strtotime($this->getInTime());
|
||||||
|
$elapsedDate = $endDate - $startDate;
|
||||||
|
$elapsedSec = (int)($elapsedDate);
|
||||||
|
|
||||||
|
return $elapsedSec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 離開學習點
|
* 離開學習點
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,8 @@ namespace UElearning\Target;
|
|||||||
require_once UELEARNING_LIB_ROOT.'/Database/DBTarget.php';
|
require_once UELEARNING_LIB_ROOT.'/Database/DBTarget.php';
|
||||||
require_once UELEARNING_LIB_ROOT.'/Database/DBMaterial.php';
|
require_once UELEARNING_LIB_ROOT.'/Database/DBMaterial.php';
|
||||||
require_once UELEARNING_LIB_ROOT.'/Target/Exception.php';
|
require_once UELEARNING_LIB_ROOT.'/Target/Exception.php';
|
||||||
|
require_once UELEARNING_LIB_ROOT.'/Target/Area.php';
|
||||||
|
require_once UELEARNING_LIB_ROOT.'/Target/Hall.php';
|
||||||
use UElearning\Database;
|
use UElearning\Database;
|
||||||
use UElearning\Exception;
|
use UElearning\Exception;
|
||||||
|
|
||||||
@ -132,6 +134,28 @@ class Target {
|
|||||||
return $this->queryResultArray['area_id'];
|
return $this->queryResultArray['area_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得標的所在的區域名稱
|
||||||
|
*
|
||||||
|
* @return string 標的所在的區域名稱
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public function getAreaName(){
|
||||||
|
$area = new Area($this->getAreaId());
|
||||||
|
return $area->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得標的所在的樓層
|
||||||
|
*
|
||||||
|
* @return int 標的所在的樓層
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public function getFloor(){
|
||||||
|
$area = new Area($this->getAreaId());
|
||||||
|
return $area->getFloor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得標的所在的廳ID
|
* 取得標的所在的廳ID
|
||||||
*
|
*
|
||||||
@ -142,6 +166,17 @@ class Target {
|
|||||||
return $this->queryResultArray['hall_id'];
|
return $this->queryResultArray['hall_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得標的所在的廳名稱
|
||||||
|
*
|
||||||
|
* @return string 標的所在的廳名稱
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public function getHallName(){
|
||||||
|
$hall = new Hall($this->getHallId());
|
||||||
|
return $hall->getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得標的地圖上的編號
|
* 取得標的地圖上的編號
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace UElearning\Util;
|
namespace UElearning\Util;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use \GuzzleHttp\Client;
|
||||||
|
|
||||||
class UEHBase {
|
class UEHBase {
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ class UEHBase {
|
|||||||
{
|
{
|
||||||
$client = new \GuzzleHttp\Client();
|
$client = new \GuzzleHttp\Client();
|
||||||
$response = $client->request('POST', UELEARNING_UEHBASE_URL, [
|
$response = $client->request('POST', UELEARNING_UEHBASE_URL, [
|
||||||
'json' => $result
|
'json' => $xapi_array
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user