From 9fafd6e4c9461669363b20db15f0a722d946eebd Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 26 Jan 2015 16:23:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?Fix=20Study=20Namespace=E8=A3=A1=E7=9A=84?= =?UTF-8?q?=E9=A1=9E=E5=88=A5=E5=AF=AB=E6=B3=95=E5=BC=8A=E7=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Study/StudyManager.php | 4 ++-- htdocs/lib/Target/Target.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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..37994a1 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 unction addMj($number){ $setedNum = $this->queryResultArray['Mj']+$number; if($setedNum < 0) $setedNum = 0; $this->setUpdate('Mj', $setedNum); From 7993614724127bb7d7fff8b08e8d2d42029a1bd2 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 26 Jan 2015 16:30:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Fix=20Target=20Class:=20=E6=89=8B=E8=AA=A4?= =?UTF-8?q?=E7=A0=8D=E5=88=B0=E4=B8=80=E5=80=8B=E5=AD=97=E6=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Target/Target.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/lib/Target/Target.php b/htdocs/lib/Target/Target.php index 37994a1..818689d 100644 --- a/htdocs/lib/Target/Target.php +++ b/htdocs/lib/Target/Target.php @@ -280,7 +280,7 @@ class Target { * @return int 學習標的目前人數 * @since 2.0.0 */ - public unction addMj($number){ + public function addMj($number){ $setedNum = $this->queryResultArray['Mj']+$number; if($setedNum < 0) $setedNum = 0; $this->setUpdate('Mj', $setedNum); From 2e7ea6d6abad27b933f4b54dd113bb31adbdd9c6 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 26 Jan 2015 16:31:42 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=B0=87learned=5Ftotal=E6=94=B9=E7=82=BA?= =?UTF-8?q?=E5=8D=B3=E4=BD=BF=E6=9C=AA=E6=A8=99=E8=A8=98=E7=82=BA=E9=9B=A2?= =?UTF-8?q?=E9=96=8B=EF=BC=8C=E4=B9=9F=E7=AE=97=E9=80=B2=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/lib/Database/DBStudyActivity.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/Database/DBStudyActivity.php b/htdocs/lib/Database/DBStudyActivity.php index c6bd534..ec607a1 100644 --- a/htdocs/lib/Database/DBStudyActivity.php +++ b/htdocs/lib/Database/DBStudyActivity.php @@ -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` From 009d8eea2c0763118e7e41d0269416062e2b64c6 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Wed, 28 Jan 2015 23:22:26 +0800 Subject: [PATCH 4/5] Fix Database Table Name --- htdocs/lib/Database/DBStudyActivity.php | 2 +- htdocs/lib/Database/DBTheme.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/lib/Database/DBStudyActivity.php b/htdocs/lib/Database/DBStudyActivity.php index ec607a1..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)". 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; From 86b3e562a65bdab7379b2b00ac56fdf5c9079b07 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Thu, 29 Jan 2015 00:23:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?Fix=20getRemainingPointTotal=20=E4=B8=8D?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E5=85=A5=E5=8F=A3=E6=9C=AC=E8=BA=AB=20&=20Fi?= =?UTF-8?q?x=20API=20Recommand=20is=5Fend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/api/v2/index.php | 9 ++++++--- htdocs/lib/Recommand/RecommandPoint.php | 11 +++++++---- htdocs/lib/Study/StudyActivity.php | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/htdocs/api/v2/index.php b/htdocs/api/v2/index.php index 2b82909..0cbfbc3 100644 --- a/htdocs/api/v2/index.php +++ b/htdocs/api/v2/index.php @@ -1208,9 +1208,12 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) { $result_recommand_total = $recommandTotal; } // 是否已經學完了 - // TODO: 改以取得已學習標的數來判定 - if($recommandTotal <= 0) { $isEnd = true; } - else { $isEnd = false; } + if($sact->getRemainingPointTotal() <= 0) { + $isEnd = true; + } + else { + $isEnd = false; + } // 製作 $output_targets = array(); 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; } // ========================================================================