diff --git a/htdocs/api/v2/index.php b/htdocs/api/v2/index.php index ac0dd0f..6b785ba 100644 --- a/htdocs/api/v2/index.php +++ b/htdocs/api/v2/index.php @@ -1193,8 +1193,13 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) { $currentTId = (int)$currentTId; +<<<<<<< HEAD $tid = $sact->getThemeId(); // 取得此活動的主題 $maxItemTotal = $sact->getLearnStyle(); // 取得最大推薦數 +======= + // 取得此活動的主題 + $tid = $sact->getThemeId(); +>>>>>>> 345e83e160f83e726d8571e101f54f40a63b7a13 // 取得本次採用的教材風格 $materialMode = $sact->getMaterialStyle(); @@ -1210,9 +1215,18 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) { $result_recommand_total = $recommandTotal; } // 是否已經學完了 +<<<<<<< HEAD // TODO: 改以取得已學習標的數來判定 if($recommandTotal <= 0) { $isEnd = true; } else { $isEnd = false; } +======= + if($sact->getRemainingPointTotal() <= 0) { + $isEnd = true; + } + else { + $isEnd = false; + } +>>>>>>> 345e83e160f83e726d8571e101f54f40a63b7a13 // 製作 $output_targets = array(); diff --git a/htdocs/lib/Database/DBStudyActivity.php b/htdocs/lib/Database/DBStudyActivity.php index c6bd534..2940e8a 100644 --- a/htdocs/lib/Database/DBStudyActivity.php +++ b/htdocs/lib/Database/DBStudyActivity.php @@ -157,7 +157,7 @@ class DBStudyActivity extends Database { protected function queryActivityByWhere($where) { $sqlString = "SELECT `SaID`, `UID`, `ThID`, ". - "(SELECT `ThName` FROM `chu__Theme` AS `th` ". + "(SELECT `ThName` FROM `".$this->table('Theme')."` AS `th` ". "WHERE `th`.`ThID` = `sa`.`ThID`) AS `ThName`, ". "`StartTime`, ". "FROM_UNIXTIME(UNIX_TIMESTAMP(`StartTime`)+(`LearnTime`+`Delay`)*60)". @@ -172,8 +172,7 @@ class DBStudyActivity extends Database { "(SELECT count(DISTINCT `TID`) FROM `".$this->table('Study')."` AS `study` - WHERE `Out_TargetTime` IS NOT NULL - AND `study`.`SaID` = `sa`.`SaID`) AS `LearnedTotal`". + WHERE `study`.`SaID` = `sa`.`SaID`) AS `LearnedTotal`". "FROM `".$this->table('StudyActivity')."` AS sa ". "WHERE ".$where; @@ -754,7 +753,7 @@ SELECT 'study' AS `Type`, `LMode`, `LModeForce`, `MMode`, `EnableVirtual`, '1' AS `Lock`, (SELECT count(`TID`) FROM `".$this->table('TBelong')."` AS `belong` WHERE `belong`.`ThID` = `sa`.`ThID`) AS ` TargetTotal`, -(SELECT count(DISTINCT `TID`) FROM `".$this->table('Study')."` AS `study` WHERE `Out_TargetTime` IS NOT NULL AND `study`.`SaID` = `sa`.`SaID`) AS `LearnedTotal` +(SELECT count(DISTINCT `TID`) FROM `".$this->table('Study')."` AS `study` WHERE `study`.`SaID` = `sa`.`SaID`) AS `LearnedTotal` FROM `".$this->table('StudyActivity')."` AS `sa` LEFT JOIN `".$this->table('Theme')."` AS `th` diff --git a/htdocs/lib/Database/DBTheme.php b/htdocs/lib/Database/DBTheme.php index 256f460..7a4a977 100644 --- a/htdocs/lib/Database/DBTheme.php +++ b/htdocs/lib/Database/DBTheme.php @@ -30,7 +30,7 @@ class DBTheme extends Database { $sqlString = "SELECT `ThID`, `ThName`, ". "`ThLearnTime`, `StartTID`, `ThIntroduction`, ". "`ThBuildTime`, `ThModifyTime`, ". - "(SELECT count(`TID`) FROM `chu__TBelong` AS `belong` + "(SELECT count(`TID`) FROM `".$this->table('TBelong')."` AS `belong` WHERE `belong`.`ThID` = `theme`.`ThID`) AS `TargetTotal`". "FROM `".$this->table('Theme')."` AS `theme` ". "WHERE ".$where; diff --git a/htdocs/lib/Recommand/RecommandPoint.php b/htdocs/lib/Recommand/RecommandPoint.php index fd9eef1..24499fe 100644 --- a/htdocs/lib/Recommand/RecommandPoint.php +++ b/htdocs/lib/Recommand/RecommandPoint.php @@ -163,11 +163,14 @@ class RecommandPoint "VirtualCost"=>$virtualCost)); } - foreach($recommand as $key=>$value) - { - $tmp[$key] = $value["PathCost"]; + if(count($recommand) >= 1) { + + foreach($recommand as $key=>$value) + { + $tmp[$key] = $value["PathCost"]; + } + array_multisort($tmp,SORT_DESC,$recommand,SORT_DESC); } - array_multisort($tmp,SORT_DESC,$recommand,SORT_DESC); return $recommand; } diff --git a/htdocs/lib/Study/StudyActivity.php b/htdocs/lib/Study/StudyActivity.php index de99a18..8e72767 100644 --- a/htdocs/lib/Study/StudyActivity.php +++ b/htdocs/lib/Study/StudyActivity.php @@ -171,7 +171,7 @@ class StudyActivity { $total = $this->getPointTotal(); $learned = $this->getLearnedPointTotal(); - return $total - $learned; + return ($total-1) - $learned; } // ======================================================================== diff --git a/htdocs/lib/Study/StudyManager.php b/htdocs/lib/Study/StudyManager.php index dd12778..c845c53 100644 --- a/htdocs/lib/Study/StudyManager.php +++ b/htdocs/lib/Study/StudyManager.php @@ -26,8 +26,8 @@ class StudyManager { /** * 取得目前已進入的學習點 - * @param string $activity_id 活動編號 - * @return string 標的編號,若無則null + * @param int $activity_id 活動編號 + * @return int 標的編號,若無則null */ public function getCurrentInTargetId($activity_id) { diff --git a/htdocs/lib/Target/Target.php b/htdocs/lib/Target/Target.php index 7c72a88..818689d 100644 --- a/htdocs/lib/Target/Target.php +++ b/htdocs/lib/Target/Target.php @@ -267,7 +267,7 @@ class Target { * @param int $number 學習標的目前人數 * @since 2.0.0 */ - function setMj($number){ + public function setMj($number){ $this->setUpdate('Mj', $number); } @@ -280,7 +280,7 @@ class Target { * @return int 學習標的目前人數 * @since 2.0.0 */ - function addMj($number){ + public function addMj($number){ $setedNum = $this->queryResultArray['Mj']+$number; if($setedNum < 0) $setedNum = 0; $this->setUpdate('Mj', $setedNum);