diff --git a/htdocs/api/v2/index.php b/htdocs/api/v2/index.php index 7e54d09..5edcabf 100644 --- a/htdocs/api/v2/index.php +++ b/htdocs/api/v2/index.php @@ -1353,22 +1353,26 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) { // 取得本次採用的教材風格 $materialMode = $sact->getMaterialStyle(); - // 取得推薦的學習點 - $recommand = new Recommand\RecommandPoint(); - $recommandResult = $recommand->recommand($currentTId, $saId); - $recommandTotal = count($recommandResult); - if($recommandTotal > $maxItemTotal) { - $result_recommand_total = $maxItemTotal; - } - else { - $result_recommand_total = $recommandTotal; - } // 是否已經學完了 if($sact->getRemainingPointTotal() <= 0) { $isEnd = true; + + $recommandResult = array(); + $recommandTotal = 0; } else { $isEnd = false; + + // 取得推薦的學習點 + $recommand = new Recommand\RecommandPoint(); + $recommandResult = $recommand->recommand($currentTId, $saId); + $recommandTotal = count($recommandResult); + if($recommandTotal > $maxItemTotal) { + $result_recommand_total = $maxItemTotal; + } + else { + $result_recommand_total = $recommandTotal; + } } // 製作 diff --git a/htdocs/lib/Recommand/RecommandPoint.php b/htdocs/lib/Recommand/RecommandPoint.php index b796f4f..2f8c8bf 100644 --- a/htdocs/lib/Recommand/RecommandPoint.php +++ b/htdocs/lib/Recommand/RecommandPoint.php @@ -128,6 +128,7 @@ class RecommandPoint { $this->activity = new Study\StudyActivity($activity_number); $themeID = $this->activity->getThemeId(); + $enableVirtual = $this->activity->isEnableVirtual(); $this->theme = new Study\Theme($themeID); $this->gamma = $this->computeNormalizationParameter($themeID); $pointList = $this->recommand->queryEdgeByID($current_point); @@ -137,34 +138,44 @@ class RecommandPoint $pathCost = 0; $VirtualPathCost = 0; $recommand = array(); - $isEntity = true; for($i=0;$itheme->getWeightByNextTarget($next_point); + if($nextPoint->isFullPeople()) { - $pastCost = 0; + $pathCost = 0; $virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime()); $isEntity=false; + + if($enableVirtual) { + array_push($recommand,array("nextPoint" => $next_point, + "isEntity" => $isEntity, + "PathCost" => $pathCost, + "VirtualCost" => $virtualCost)); + } } else { + $isEntity=true; if($nextPoint->isNumberOfPeopleZero()) $Rj = 0; else $Rj = $nextPoint->getMj()/$nextPoint->getPLj(); $pathCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/($moveTime + $nextPoint->getLearnTime())); $virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime()); - } - array_push($recommand,array("nextPoint"=>$next_point, + + array_push($recommand,array("nextPoint" => $next_point, "isEntity" => $isEntity, - "PathCost"=>$pathCost, - "VirtualCost"=>$virtualCost)); + "PathCost" => $pathCost, + "VirtualCost" => $virtualCost)); + } + } if(count($recommand) >= 1) { - + foreach($recommand as $key=>$value) { $tmp[$key] = $value["PathCost"];