diff --git a/htdocs/lib/Database/DBRecommand.php b/htdocs/lib/Database/DBRecommand.php index b01061d..2f6241c 100644 --- a/htdocs/lib/Database/DBRecommand.php +++ b/htdocs/lib/Database/DBRecommand.php @@ -21,9 +21,10 @@ class DBRecommand extends Database * @param string $where SQL WHERE子句 * @return array 查詢結果 */ - protected function queryEdgeByWhere($where) - { - $sqlString = "SELECT DISTINCT ".$this->table('Edge').".Ti, ".$this->table('Edge').".Tj, ".$this->table('Edge').".MoveTime". + + protected function queryEdgeByWhere($where) + { + $sqlString = "SELECT DISTINCT ".$this->table('Edge').".Ti, ".$this->table('Edge').".Tj, ".$this->table('Edge').".MoveTime". " FROM ".$this->table('Edge')." WHERE ".$where; $query = $this->connDB->prepare($sqlString); $query->execute(); @@ -44,11 +45,16 @@ class DBRecommand extends Database return $result; } else return null; - } + } + /** + * 內部查詢用 + * @param string $where SQL WHERE子句 + * @return array 查詢結果 + */ protected function queryBelongByWhere($where) { - $sqlString = "SELECT ".$this->table('tbelong').".Weights FROM ".$this->table('tbelong')." WHERE ".$where; + $sqlString = "SELECT ".$this->table('TBelong').".Weights FROM ".$this->table('TBelong')." WHERE ".$where; $query = $this->connDB->prepare($sqlString); $query->execute(); @@ -66,19 +72,29 @@ class DBRecommand extends Database else return null; } + /** + * 以下一個學習點和主題編號查詢屬於的權重資料 + * @param string $next_point 下一個學習點編號 + * @return array 查詢結果 + */ public function queryBelongByID($next_point,$theme_number) { - $whereClause = $this->table('tbelong').".thID = ".$this->connDB->quote($theme_number)." AND ".$this->table('tbelong').".TID = ".$this->connDB->quote($next_point); + $whereClause = $this->table('TBelong').".ThID = ".$this->connDB->quote($theme_number)." AND ".$this->table('TBelong').".TID = ".$this->connDB->quote($next_point); $AllOfResult = $this->queryBelongByWhere($whereClause); if(count($AllOfResult) != 0) return $AllOfResult; else return null; } - + /** + * 以目前的學習點編號查詢下一個學習點的資訊 + * @param string $currentPoint 目前的學習點編號 + * @return array 查詢結果 + */ public function queryEdgeByID($currentPoint) { - $AllOfResult = $this->queryBelongByWhere("Ti = ".$this->connDB->quote($currentPoint)); + //echo "EEEEEEEEE"; + $AllOfResult = $this->queryEdgeByWhere($this->table('Edge').".Ti = ".$this->connDB->quote($currentPoint)); if(count($AllOfResult) != 0) return $AllOfResult; else return null; } diff --git a/htdocs/lib/Recommand/RecommandPoint.php b/htdocs/lib/Recommand/RecommandPoint.php index 0e297c7..3c23759 100644 --- a/htdocs/lib/Recommand/RecommandPoint.php +++ b/htdocs/lib/Recommand/RecommandPoint.php @@ -1,57 +1,85 @@ recommand = new Database\DBRecommand(); + } + + /** + * 計算正規化參數 + * @return double 正規化參數 + */ + private function computeNormalizationParameter($theme_number) + { + $normal = 0; //正規化之後的GAMMA值 + $EntitySum = 0; //實體學習點分別算銓重之後的值 + $VirtualSum = 0; //虛擬學習點分別算銓重之後的值 + + $edge = $this->recommand->queryEdgeByID('0'); + $theme = new Study\Theme($theme_number); + + for($i=0;$irecommand->queryBelongByID($next_point,$theme->getId()); + $weight = $belong[0]["weight"]; + + $VirtualSum += $weight / $next_target->getLearnTime(); + + if($next_target->isNumberOfPeopleZero()) $Rj = 0; + else $Rj = $next_target->getMj() / $next_target->getPLj(); + + $EntitySum += $weight * ($next_target->getS() - $Rj + 1) / ($move_time + $next_target->getLearnTime()); + } + return $EntitySum/$VirtualSum; + } + + /** + * 推薦學習點 + * @return array 學習點清單 + */ + public function recommand($current_point,$theme_number,$activity_number) + { + + } +} diff --git a/htdocs/lib/Study/Theme.php b/htdocs/lib/Study/Theme.php index 2fcb6d6..d255601 100644 --- a/htdocs/lib/Study/Theme.php +++ b/htdocs/lib/Study/Theme.php @@ -96,7 +96,7 @@ class Theme { /** * 建構子 * - * @param int $inputTID 主題ID + * @param int $inputID 主題ID * @since 2.0.0 */ public function __construct($inputID){ diff --git a/htdocs/lib/Target/Target.php b/htdocs/lib/Target/Target.php index c7b8f76..af82b26 100644 --- a/htdocs/lib/Target/Target.php +++ b/htdocs/lib/Target/Target.php @@ -293,6 +293,17 @@ class Target { return $this->getMj(); } + /** + * 判斷目前標的人數是否為零 + * + * @return bool true/此標的目前人數是空的,false/此標的目前人數不是空的 + * @since 2.0.0 + */ + public function isNumberOfPeopleZero(){ + if($this->getCurrentPeople() == 0) return true; + else return false; + } + /** * 增加學習標的目前人數 *