Add: show animal icon in typing app button

This commit is contained in:
2018-09-02 20:41:44 +09:00
parent 5de2b1daa8
commit ac46b61539
10 changed files with 182 additions and 42 deletions
@@ -2,6 +2,7 @@
header("Content-Type: application/json");
$maestro_id = $_POST["maestro_id"];
$player_id = $_POST["player_id"];
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
@@ -21,13 +22,19 @@ if($englishAppList === null) {
send_result_fail();
exit;
}
$koreanActiveAppList = get_active_typing_practice_app_list($maestro_id, 1);
$englishActiveAppList = get_active_typing_practice_app_list($maestro_id, 2);
$koreanHighScoreList = get_high_score_list($maestro_id, $player_id, $koreanAppList);
$englishHighScoreList = get_high_score_list($maestro_id, $player_id, $englishAppList);
set_data("KoreanAppList", $koreanAppList);
set_data("EnglishAppList", $englishAppList);
set_data("KoreanActiveAppList", $koreanActiveAppList);
set_data("EnglishActiveAppList", $englishActiveAppList);
set_data("KoreanHighScoreList", $koreanHighScoreList);
set_data("EnglishHighScoreList", $englishHighScoreList);
send_result_success();
exit;
@@ -84,4 +91,44 @@ function get_active_typing_practice_app_list($maestro_id, $appType) {
return $return_array;
}
function get_high_score_list($maestro_id, $player_id, $appList) {
global $db_conn;
$return_array = array();
$count = count($appList);
for($i = 0; $i < $count; $i++) {
$app_id_list = $appList[$i]['AppID'];
$query = "
SELECT MAX(BR.BestRecord)
FROM app AS A
INNER JOIN best_record AS BR
ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ?
ORDER BY A.AppID ASC";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id);
$stmt->execute();
$stmt->bind_result($best_record);
$returnValue = $stmt->fetch();
$stmt->close();
if($returnValue === NULL || $returnValue === FALSE)
continue;
// $row_array['maestro_id'] = $maestro_id;
// $row_array['player_id'] = $player_id;
$row_array['AppID'] = $app_id_list;
if($best_record === NULL)
$row_array['BestRecord'] = 0;
else
$row_array['BestRecord'] = $best_record;
array_push($return_array, $row_array);
}
return $return_array;
}
?>
@@ -2,6 +2,7 @@
header('Content-Type: application/json');
$maestro_id = $_POST["maestro_id"];
$player_id = $_POST["player_id"];
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
@@ -21,13 +22,19 @@ if($englishAppList === null) {
send_result_fail();
exit;
}
$koreanActiveAppList = get_active_typing_practice_app_list($maestro_id, 11);
$englishActiveAppList = get_active_typing_practice_app_list($maestro_id, 12);
$koreanHighScoreList = get_high_score_list($maestro_id, $player_id, $koreanAppList);
$englishHighScoreList = get_high_score_list($maestro_id, $player_id, $englishAppList);
set_data("KoreanAppList", $koreanAppList);
set_data("EnglishAppList", $englishAppList);
set_data("KoreanActiveAppList", $koreanActiveAppList);
set_data("EnglishActiveAppList", $englishActiveAppList);
set_data("KoreanHighScoreList", $koreanHighScoreList);
set_data("EnglishHighScoreList", $englishHighScoreList);
send_result_success();
exit;
@@ -84,4 +91,44 @@ function get_active_typing_practice_app_list($maestro_id, $appType) {
return $return_array;
}
function get_high_score_list($maestro_id, $player_id, $appList) {
global $db_conn;
$return_array = array();
$count = count($appList);
for($i = 0; $i < $count; $i++) {
$app_id_list = $appList[$i]['AppID'];
$query = "
SELECT MAX(BR.BestRecord)
FROM app AS A
INNER JOIN best_record AS BR
ON A.AppID = ? AND A.AppID = BR.AppID AND BR.MaestroID = ? AND BR.PlayerID = ?
ORDER BY A.AppID ASC";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iii', $app_id_list, $maestro_id, $player_id);
$stmt->execute();
$stmt->bind_result($best_record);
$returnValue = $stmt->fetch();
$stmt->close();
if($returnValue === NULL || $returnValue === FALSE)
continue;
// $row_array['maestro_id'] = $maestro_id;
// $row_array['player_id'] = $player_id;
$row_array['AppID'] = $app_id_list;
if($best_record === NULL)
$row_array['BestRecord'] = 0;
else
$row_array['BestRecord'] = $best_record;
array_push($return_array, $row_array);
}
return $return_array;
}
?>