Fix API: 重複進入標的時,會將上個已進入紀錄標示為離開
This commit is contained in:
parent
8ba983a999
commit
7c4bf21d93
@ -1033,12 +1033,6 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
||||
// 進入學習點
|
||||
try{
|
||||
$sid = $sact->toInTarget($tId, $is_entity);
|
||||
}
|
||||
// 若狀態為正在標的內學習時,強制當成離開標的,重新進入
|
||||
catch (Exception\InLearningException $e) {
|
||||
$sact->toOutTarget($tId);
|
||||
$sid = $sact->toInTarget($tId, $is_entity);
|
||||
}
|
||||
|
||||
// 噴出結果
|
||||
$app->render(200,array(
|
||||
@ -1048,6 +1042,28 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
||||
'study_id' => $sid,
|
||||
'error' => false
|
||||
));
|
||||
}
|
||||
// 若狀態為正在標的內學習時,強制當成離開標的,重新進入
|
||||
catch (Exception\InLearningException $e) {
|
||||
|
||||
// 查詢目前所在的標的
|
||||
$inTId = $sact->getCurrentInTarget();
|
||||
|
||||
// 登記離開此標的
|
||||
$sact->toOutTarget($inTId);
|
||||
|
||||
// 重新登記進入此標的
|
||||
$sid = $sact->toInTarget($tId, $is_entity);
|
||||
|
||||
// 噴出結果
|
||||
$app->render(200,array(
|
||||
'token' => $token,
|
||||
'user_id' => $user_id,
|
||||
'activity_id' => $sact->getId(),
|
||||
'study_id' => $sid,
|
||||
'error' => false
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
// 若非本人所有,則視同無此活動
|
||||
@ -1192,6 +1208,7 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
||||
$result_recommand_total = $recommandTotal;
|
||||
}
|
||||
// 是否已經學完了
|
||||
// TODO: 改以取得已學習標的數來判定
|
||||
if($recommandTotal <= 0) { $isEnd = true; }
|
||||
else { $isEnd = false; }
|
||||
|
||||
|
@ -438,6 +438,20 @@ class StudyActivity {
|
||||
|
||||
// ========================================================================
|
||||
|
||||
/**
|
||||
* 取得目前已進入的學習點
|
||||
*
|
||||
* @return int 標的編號,若無則null
|
||||
*/
|
||||
public function getCurrentInTarget() {
|
||||
|
||||
// 活動編號
|
||||
$saId = $this->id;
|
||||
|
||||
$sct = new StudyManager();
|
||||
return $sct->getCurrentInTargetId($saId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此標的是否已學習過
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user