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