From 61642d9846cf2db328b84d0ffbba860d3c76f47b Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sun, 15 Mar 2015 00:29:23 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20=E7=B5=90=E6=9D=9F=E5=AD=B8=E7=BF=92?= =?UTF-8?q?=E6=B4=BB=E5=8B=95=E6=99=82=EF=BC=8C=E8=8B=A5=E9=82=84=E5=B0=9A?= =?UTF-8?q?=E6=9C=89=E9=80=B2=E8=A1=8C=E4=B8=AD=E7=9A=84=E5=AD=B8=E7=BF=92?= =?UTF-8?q?=E9=BB=9E=EF=BC=8C=E5=B0=87=E8=87=AA=E5=8B=95=E6=A8=99=E8=A8=98?= =?UTF-8?q?=E7=82=BA=E9=9B=A2=E9=96=8B=E6=AD=A4=E5=AD=B8=E7=BF=92=E9=BB=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Study/StudyActivity.php | 61 ++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/htdocs/lib/Study/StudyActivity.php b/htdocs/lib/Study/StudyActivity.php index 269c771..c0a230a 100644 --- a/htdocs/lib/Study/StudyActivity.php +++ b/htdocs/lib/Study/StudyActivity.php @@ -114,6 +114,15 @@ class StudyActivity { // 此活動還在進行中 if($this->isLearning()) { + + // 確定目前有無進行中的學習點 + $cur_inTId = $this->getCurrentInTarget(); + $cur_inEnTId = $this->getCurrentEnteringTargetId(); + if($cur_inTId) { $this->toOutTarget($cur_inTId); } + if($cur_inEnTId) { $this->outEnteringInTarget($cur_inEnTId); } + + + // 標記結束時間 $db = new Database\DBStudyActivity(); $db->setEndTimeNow($this->id); } @@ -452,6 +461,20 @@ class StudyActivity { return $sct->getCurrentInTargetId($saId); } + /** + * 取得目前行進中的學習點 + * + * @return int 標的編號,若無則null + */ + public function getCurrentEnteringTargetId() { + + // 活動編號 + $saId = $this->id; + + $sct = new StudyManager(); + return $sct->getCurrentEnteringTargetId($saId); + } + /** * 此標的是否已學習過 * @@ -492,6 +515,22 @@ class StudyActivity { } + /** + * 離開標的 + * + * @param int $target_id 標的編號 + * @throw UElearning\Exception\NoInLearningException + */ + public function toOutTarget($target_id) { + + // 活動編號 + $saId = $this->id; + + $sct = new StudyManager(); + // 離開學習點 + $sct->toOutTarget($saId, $target_id); + } + /** * 行進中,準備進入的學習點 * @@ -518,19 +557,27 @@ class StudyActivity { } /** - * 離開標的 + * 取消行進中,準備進入的學習點 * - * @param int $target_id 標的編號 - * @throw UElearning\Exception\NoInLearningException + * @param int $target_id 標的編號 + * @param bool $is_entity 是否為現場學習 + * @throw UElearning\Exception\InLearningException + * return int 進出紀錄編號 */ - public function toOutTarget($target_id) { + public function outEnteringInTarget($target_id) { // 活動編號 $saId = $this->id; $sct = new StudyManager(); - // 離開學習點 - $sct->toOutTarget($saId, $target_id); - } + // 進入學習點 + try{ + return $sct->outEnteringInTarget($saId, $target_id); + } + // 若狀態為正在標的內學習時,送出例外 + catch (Exception\InLearningException $e) { + throw $e; + } + } }