Fix 結束學習活動時,若還尚有進行中的學習點,將自動標記為離開此學習點

This commit is contained in:
Yuan Chiu 2015-03-15 00:29:23 +08:00
parent d2d24d9ba0
commit 61642d9846

View File

@ -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;
}
}
}