Merge branch 'develop' of github.com:CHU-TDAP/E-learning-Server-v2 into develop
This commit is contained in:
commit
047a174f12
@ -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;
|
||||
}
|
||||
|
@ -1,57 +1,85 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../config.php';
|
||||
namespace UElearning\Recommand;
|
||||
|
||||
require_once UELEARNING_ROOT.'/config.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Target/Target.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Database/DBRecommand.php';
|
||||
require_once UELEARNING_LIB_ROOT.'/Study/Theme.php';
|
||||
use UElearning\Target;
|
||||
use UElearning\Exception;
|
||||
use UElearning\Study;
|
||||
use UElearning\Database;
|
||||
|
||||
/**
|
||||
* 推薦學習點
|
||||
* Usage:
|
||||
* $recommand = new RecommandPoint();
|
||||
* $recommand = new RecommandPoint();
|
||||
*/
|
||||
|
||||
class RecommandPoint
|
||||
{
|
||||
/**
|
||||
* 正規化參數
|
||||
*
|
||||
* @access private
|
||||
* @type double
|
||||
*/
|
||||
private $gamma;
|
||||
|
||||
/**
|
||||
* 調和參數(常數)
|
||||
*
|
||||
* @access private
|
||||
* @type double
|
||||
*/
|
||||
private const $ALPHA = 0.5;
|
||||
|
||||
private
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 計算正規化參數
|
||||
* @return double 正規化參數
|
||||
*/
|
||||
private function computeNormalizationParameter()
|
||||
{
|
||||
$
|
||||
}
|
||||
|
||||
/**
|
||||
* 推薦學習點
|
||||
* @return array 學習點清單
|
||||
*/
|
||||
public function recommand($ )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 正規化參數
|
||||
*
|
||||
* @access private
|
||||
* @type double
|
||||
*/
|
||||
private $gamma;
|
||||
|
||||
/**
|
||||
* 調和參數(常數)
|
||||
*
|
||||
* @access private
|
||||
* @type double
|
||||
*/
|
||||
const ALPHA=0.5;
|
||||
|
||||
private $recommand;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$gamma = 0;
|
||||
$this->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;$i<count($edge);$i++)
|
||||
{
|
||||
$next_point = $edge[$i]["next_point"];
|
||||
$move_time = $edge[$i]["move_time"];
|
||||
$next_target = new Target\Target($next_point);
|
||||
$belong = $this->recommand->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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class Theme {
|
||||
/**
|
||||
* 建構子
|
||||
*
|
||||
* @param int $inputTID 主題ID
|
||||
* @param int $inputID 主題ID
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function __construct($inputID){
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加學習標的目前人數
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user