Add: get appData for writing (typing exam)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
class MenuCollection extends DBMethodContainer
|
||||
{
|
||||
private $writingCollection = null;
|
||||
|
||||
|
||||
public function getAppGroupName($appGroupCode)
|
||||
{
|
||||
@@ -71,41 +73,22 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
// return $this->getTypingExamWritingList($maestroID, $playerID, $appGroup, $language);
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$systemWritingList = $writingCollection->getSystemList($language);
|
||||
return $systemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
// return $this->getMouseAppList($maestroID, $playerID, $appGroup);
|
||||
return $this->getMouseAppList();
|
||||
}
|
||||
}
|
||||
|
||||
public function getTypingAppList($maestroID, $playerID, $appGroup, $language)
|
||||
{
|
||||
/*
|
||||
$query = "
|
||||
SELECT A.AppID, A.AppName, A.KoreanName, A.AppType
|
||||
FROM app AS A
|
||||
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = ? AND AA.MaestroID=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("ii", $this->getTypingAppType($appGroup, $language), $maestroID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($app_id, $app_name, $korean_name, $app_type);
|
||||
|
||||
$resultArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$rowArray = array();
|
||||
$rowArray["AppID"] = $app_id;
|
||||
$rowArray["AppName"] = $app_name;
|
||||
$rowArray["KoreanName"] = $korean_name;
|
||||
$rowArray["AppType"] = $app_type;
|
||||
array_push($resultArray, $rowArray);
|
||||
}
|
||||
$stmt->close();
|
||||
*/
|
||||
|
||||
$query = "
|
||||
SELECT A.AppID, A.KoreanName
|
||||
FROM app AS A
|
||||
WHERE A.AppType=? AND A.Status=1";
|
||||
SELECT AppID, KoreanName
|
||||
FROM app
|
||||
WHERE AppType=? AND Status=1";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("i", $this->getTypingAppType($appGroup, $language));
|
||||
$stmt->execute();
|
||||
@@ -123,12 +106,26 @@ class MenuCollection extends DBMethodContainer
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
public function getMouseAppList($maestroID, $playerID, $appGroup, $language)
|
||||
public function getMouseAppList()
|
||||
{
|
||||
}
|
||||
$query = "
|
||||
SELECT AppID, KoreanName
|
||||
FROM app
|
||||
WHERE AppType=100 AND Status=1";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($appID, $koreanName);
|
||||
|
||||
public function getTypingExamWritingList($maestroID, $playerID, $appGroup, $language)
|
||||
{
|
||||
$resultArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$rowArray = array();
|
||||
$rowArray["appID"] = $appID;
|
||||
$rowArray["koreanName"] = $koreanName;
|
||||
array_push($resultArray, $rowArray);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,11 +140,13 @@ class MenuCollection extends DBMethodContainer
|
||||
return $this->getTypingActiveAppList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 2:
|
||||
// return $this->getTypingExamWritingList($maestroID, $playerID, $appGroup, $language);
|
||||
break;
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
$activeSystemWritingList = $writingCollection->getActiveSystemList($maestroID, $language);
|
||||
return $activeSystemWritingList;
|
||||
|
||||
case 4: // mouse play
|
||||
// return $this->getMouseActiveAppList($maestroID, $playerID, $appGroup);
|
||||
return $this->getMouseActiveAppList($maestroID, $playerID, $appGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@ class MenuCollection extends DBMethodContainer
|
||||
$query = "
|
||||
SELECT A.AppID
|
||||
FROM app AS A
|
||||
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = ? AND AA.MaestroID=?";
|
||||
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType=? AND AA.MaestroID=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("ii", $this->getTypingAppType($appGroup, $language), $maestroID);
|
||||
$stmt->execute();
|
||||
@@ -173,9 +172,26 @@ class MenuCollection extends DBMethodContainer
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
public function getMouseActiveAppList($maestroID, $playerID, $appGroup, $language)
|
||||
public function getMouseActiveAppList($maestroID)
|
||||
{
|
||||
return null;
|
||||
$query = "
|
||||
SELECT A.AppID
|
||||
FROM app AS A
|
||||
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType=100 AND AA.MaestroID=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("i", $maestroID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($appID);
|
||||
|
||||
$resultArray = array();
|
||||
while($stmt->fetch()) {
|
||||
$rowArray = array();
|
||||
$rowArray["appID"] = $appID;
|
||||
array_push($resultArray, $rowArray);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,18 +202,32 @@ class MenuCollection extends DBMethodContainer
|
||||
switch($appGroup) {
|
||||
case 0: // typing practice
|
||||
case 1: // typing test
|
||||
return $this->getTypingHighestRecordList($maestroID, $playerID, $appList);
|
||||
|
||||
case 2:
|
||||
// return $this->getTypingExamHighestRecordWritingList($maestroID, $playerID, $appGroup, $language);
|
||||
|
||||
case 3: // typing play
|
||||
case 4: // mouse play
|
||||
return null;
|
||||
break;
|
||||
return $this->getTypingHighestRecordList($maestroID, $playerID, $appList);
|
||||
|
||||
// case 2:
|
||||
// return $this->getWritingHighestRecordList($maestroID, $playerID, $appList);
|
||||
}
|
||||
}
|
||||
|
||||
public function getWritingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
if($writingCollection === null)
|
||||
$writingCollection = new WritingCollection($this->mysqli);
|
||||
|
||||
$highestRecordArray = array();
|
||||
$count = count($appList);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
$writingID = $appList[$i]["writingID"];
|
||||
$highestRecord["writingID"] = $writingID;
|
||||
$highestRecord["HighestRecord"] = $writingCollection->getWritingHighestRecord($maestroID, $playerID, $writingID);
|
||||
array_push($highestRecordArray, $highestRecord);
|
||||
}
|
||||
|
||||
return $highestRecordArray;
|
||||
}
|
||||
|
||||
public function getTypingHighestRecordList($maestroID, $playerID, $appList)
|
||||
{
|
||||
$highestRecordArray = array();
|
||||
@@ -231,11 +261,6 @@ class MenuCollection extends DBMethodContainer
|
||||
return $highestRecord;
|
||||
}
|
||||
|
||||
public function getTypingExamHighestRecordWritingList($maestroID, $playerID, $appGroup, $language)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,87 @@
|
||||
<?php
|
||||
class WritingCollection extends DBMethodContainer
|
||||
{
|
||||
private function getLanguage($languageCode)
|
||||
{
|
||||
if(intval($languageCode) === 0)
|
||||
return "korean";
|
||||
|
||||
return "english";
|
||||
}
|
||||
|
||||
public function getSystemList($languageCode)
|
||||
{
|
||||
$language = $this->getLanguage($languageCode);
|
||||
|
||||
$query = "
|
||||
SELECT WritingID, Name, Filename, LetterCount
|
||||
FROM writing
|
||||
WHERE Language=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("s", $language);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($writingID, $name, $filename, $letterCount);
|
||||
|
||||
$writingList = array();
|
||||
while($stmt->fetch()) {
|
||||
$writingData = array();
|
||||
$writingData["writingID"] = $writingID;
|
||||
$writingData["name"] = $name;
|
||||
$writingData["filename"] = $filename;
|
||||
$writingData["letterCount"] = $letterCount;
|
||||
array_push($writingList, $writingData);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $writingList;
|
||||
}
|
||||
|
||||
public function getActiveSystemList($maestroID, $languageCode)
|
||||
{
|
||||
$language = $this->getLanguage($languageCode);
|
||||
|
||||
$query = "
|
||||
SELECT WritingID
|
||||
FROM writing
|
||||
WHERE Language=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("s", $language);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($writingID);
|
||||
|
||||
$writingList = array();
|
||||
while($stmt->fetch()) {
|
||||
$writingData = array();
|
||||
$writingData["writingID"] = $writingID;
|
||||
array_push($writingList, $writingData);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
return $writingList;
|
||||
}
|
||||
|
||||
public function getWritingHighestRecord($maestroID, $playerID, $writingID)
|
||||
{
|
||||
$query = "
|
||||
SELECT WritingID, HighestRecord
|
||||
FROM typing_exam_highest_record
|
||||
WHERE MaestroID=? AND PlayerID=? AND WritingID=?";
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID, $writingID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($writingID, $highestRecord);
|
||||
$returnValue = $stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
if($returnValue === NULL || $returnValue === FALSE)
|
||||
return 0;
|
||||
|
||||
return $highestRecord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getSystemWritingList()
|
||||
{
|
||||
|
||||
@@ -23,17 +23,24 @@ if (!$isConnected) {
|
||||
|
||||
|
||||
include "./../db/db_method_container.php";
|
||||
include "./../db/writing_collection.php";
|
||||
include "./../db/menu_collection.php";
|
||||
|
||||
$menuCollection = new MenuCollection($dbConnector->getMysqli());
|
||||
$appList = $menuCollection->getAppList($maestroID, $playerID, $appGroup, $language);
|
||||
$activeAppList = $menuCollection->getActiveAppList($maestroID, $playerID, $appGroup, $language);
|
||||
$highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appList);
|
||||
$jsonBuilder->setData("appGroup", $appGroup);
|
||||
|
||||
$menuCollection = new MenuCollection($dbConnector->getMysqli());
|
||||
$jsonBuilder->setData("appGroup", $appGroup);
|
||||
$jsonBuilder->setData("appGroupName", $menuCollection->getAppGroupName($appGroup));
|
||||
$jsonBuilder->setData("languageName", $menuCollection->getLanguageName($language));
|
||||
|
||||
$jsonBuilder->setData("appGroup", $appGroup);
|
||||
$appList = $menuCollection->getAppList($maestroID, $playerID, $appGroup, $language);
|
||||
$activeAppList = $menuCollection->getActiveAppList($maestroID, $playerID, $appGroup, $language);
|
||||
if($appGroup === "2") // typing exam
|
||||
$highestRecordList = $menuCollection->getWritingHighestRecordList($maestroID, $playerID, $appList);
|
||||
else
|
||||
$highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appList);
|
||||
// $highestRecordList = $menuCollection->getHighestRecordList($maestroID, $playerID, $appList);
|
||||
|
||||
|
||||
$appData["appList"] = $appList;
|
||||
$appData["activeAppList"] = $activeAppList;
|
||||
@@ -44,39 +51,4 @@ $appData["highestRecordList"] = $highestRecordList;
|
||||
$jsonBuilder->setData("appData", $appData);
|
||||
|
||||
$jsonBuilder->sendResultSuccess();
|
||||
|
||||
/*
|
||||
function activate_app($maestroID, $appID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
INSERT INTO active_app (MaestroID, AppID)
|
||||
VALUES (?, ?);
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('ii', $maestroID, $appID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result();
|
||||
}
|
||||
|
||||
function get_app_name($appID) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "
|
||||
SELECT AppName, KoreanName
|
||||
FROM app
|
||||
WHERE AppID = ?
|
||||
";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('i', $appID);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($appName, $koreanName);
|
||||
$stmt->fetch();
|
||||
|
||||
$result["AppName"] = $appName;
|
||||
$result["KoreanName"] = $koreanName;
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user