整合RecommandPoint進API & Fix RecommandPoint Class
This commit is contained in:
parent
6f159c3a63
commit
b239c28046
@ -10,9 +10,11 @@ require_once UELEARNING_LIB_ROOT.'/Study/StudyActivityManager.php';
|
|||||||
require_once UELEARNING_LIB_ROOT.'/Study/StudyManager.php';
|
require_once UELEARNING_LIB_ROOT.'/Study/StudyManager.php';
|
||||||
require_once UELEARNING_LIB_ROOT.'/Target/Target.php';
|
require_once UELEARNING_LIB_ROOT.'/Target/Target.php';
|
||||||
require_once UELEARNING_LIB_ROOT.'/Target/TargetManager.php';
|
require_once UELEARNING_LIB_ROOT.'/Target/TargetManager.php';
|
||||||
|
require_once UELEARNING_LIB_ROOT.'/Recommand/RecommandPoint.php';
|
||||||
use UElearning\User;
|
use UElearning\User;
|
||||||
use UElearning\Study;
|
use UElearning\Study;
|
||||||
use UElearning\Target;
|
use UElearning\Target;
|
||||||
|
use UElearning\Recommand;
|
||||||
use UElearning\Exception;
|
use UElearning\Exception;
|
||||||
|
|
||||||
$app = new \Slim\Slim(array(
|
$app = new \Slim\Slim(array(
|
||||||
@ -1173,21 +1175,31 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
|||||||
|
|
||||||
$currentTId = (int)$currentTId;
|
$currentTId = (int)$currentTId;
|
||||||
|
|
||||||
// TODO: 動作撰寫區
|
$tid = $sact->getThemeId(); // 取得此活動的主題
|
||||||
|
$maxItemTotal = $sact->getLearnStyle(); // 取得最大推薦數
|
||||||
// 取得此活動的主題
|
|
||||||
$tid = $sact->getThemeId();
|
|
||||||
|
|
||||||
// 取得本次採用的教材風格
|
// 取得本次採用的教材風格
|
||||||
$materialMode = $sact->getMaterialStyle();
|
$materialMode = $sact->getMaterialStyle();
|
||||||
|
|
||||||
// 取得主題內所有的標的資訊
|
// 取得推薦的學習點
|
||||||
$target_manager = new Target\TargetManager();
|
$recommand = new Recommand\RecommandPoint();
|
||||||
$output_targets = array( output_the_target_array(3, true, $materialMode),
|
$recommandResult = $recommand->recommand($currentTId, $saId);
|
||||||
output_the_target_array(7, true, $materialMode),
|
$recommandTotal = count($recommandResult);
|
||||||
output_the_target_array(12, true, $materialMode),
|
if($recommandTotal > $maxItemTotal) {
|
||||||
);
|
$result_recommand_total = $maxItemTotal;
|
||||||
$recommand_total = count($output_targets);
|
}
|
||||||
|
else {
|
||||||
|
$result_recommand_total = $recommandTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 製作
|
||||||
|
$output_targets = array();
|
||||||
|
for($i=0; $i<$result_recommand_total; $i++) {
|
||||||
|
$target_id = $recommandResult[$i]['nextPoint'];
|
||||||
|
$isEntity = $recommandResult[$i]['isEntity'];
|
||||||
|
array_push($output_targets, output_the_target_array($target_id, $isEntity, $materialMode));
|
||||||
|
}
|
||||||
|
|
||||||
// 噴出結果
|
// 噴出結果
|
||||||
$app->render(200,array(
|
$app->render(200,array(
|
||||||
@ -1195,7 +1207,7 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) {
|
|||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'activity_id' => $sact->getId(),
|
'activity_id' => $sact->getId(),
|
||||||
'current_target_id' => $currentTId,
|
'current_target_id' => $currentTId,
|
||||||
'recommand_total' => $recommand_total,
|
'recommand_total' => $result_recommand_total,
|
||||||
'recommand_target' => $output_targets,
|
'recommand_target' => $output_targets,
|
||||||
'error' => false
|
'error' => false
|
||||||
));
|
));
|
||||||
|
@ -51,17 +51,17 @@ class DBTarget extends Database {
|
|||||||
foreach($queryResultAll as $key => $thisResult) {
|
foreach($queryResultAll as $key => $thisResult) {
|
||||||
|
|
||||||
array_push($result,
|
array_push($result,
|
||||||
array( 'target_id' => $thisResult['TID'],
|
array( 'target_id' => (int)$thisResult['TID'],
|
||||||
'area_id' => $thisResult['AID'],
|
'area_id' => (int)$thisResult['AID'],
|
||||||
'hall_id' => $thisResult['HID'],
|
'hall_id' => (int)$thisResult['HID'],
|
||||||
'target_number' => $thisResult['TNum'],
|
'target_number' => (int)$thisResult['TNum'],
|
||||||
'name' => $thisResult['TName'],
|
'name' => $thisResult['TName'],
|
||||||
'map_url' => $thisResult['TMapID'],
|
'map_url' => $thisResult['TMapID'],
|
||||||
'learn_time' => $thisResult['TLearnTime'],
|
'learn_time' => (int)$thisResult['TLearnTime'],
|
||||||
'PLj' => $thisResult['PLj'],
|
'PLj' => (int)$thisResult['PLj'],
|
||||||
'Mj' => $thisResult['Mj'],
|
'Mj' => (int)$thisResult['Mj'],
|
||||||
'S' => $thisResult['S'],
|
'S' => (int)$thisResult['S'],
|
||||||
'Fj' => $thisResult['Fj']
|
'Fj' => (int)$thisResult['Fj']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -154,7 +154,7 @@ class RecommandPoint
|
|||||||
{
|
{
|
||||||
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
if($nextPoint->isNumberOfPeopleZero()) $Rj = 0;
|
||||||
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
else $Rj = $nextPoint->getMj()/$nextPoint->getPLj();
|
||||||
$pathCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/$moveTime + $nextPoint->getLearnTime());
|
$pathCost = RecommandPoint::ALPHA * $this->gamma * ($weight * ($nextPoint->getS()-$Rj+1)/($moveTime + $nextPoint->getLearnTime()));
|
||||||
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
|
$virtualCost = RecommandPoint::ALPHA * $this->gamma * ($weight/$nextPoint->getLearnTime());
|
||||||
}
|
}
|
||||||
array_push($recommand,array("nextPoint"=>$next_point,
|
array_push($recommand,array("nextPoint"=>$next_point,
|
||||||
|
@ -105,7 +105,7 @@ class Target {
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct($inputTID){
|
public function __construct($inputTID){
|
||||||
$this->tId = $inputTID;
|
$this->tId = (int)$inputTID;
|
||||||
$this->getQuery();
|
$this->getQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user