Add: maestro record page - writing record
This commit is contained in:
@@ -84,16 +84,16 @@ function activateMouseApp(activatedList) {
|
|||||||
function getGroupName(groupName) {
|
function getGroupName(groupName) {
|
||||||
switch(groupName) {
|
switch(groupName) {
|
||||||
case "typing_practice_kor":
|
case "typing_practice_kor":
|
||||||
return "자리 연습 - 한글";
|
return "손가락 연습 - 한글";
|
||||||
|
|
||||||
case "typing_practice_eng":
|
case "typing_practice_eng":
|
||||||
return "자리 연습 - 영문";
|
return "손가락 연습 - 영문";
|
||||||
|
|
||||||
case "typing_test_kor":
|
case "typing_test_kor":
|
||||||
return "타자 시험 - 한글";
|
return "단어/문장 연습 - 한글";
|
||||||
|
|
||||||
case "typing_test_eng":
|
case "typing_test_eng":
|
||||||
return "타자 시험 - 영문";
|
return "단어/문장 연습 - 영문";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ function loadAppList() {
|
|||||||
// console.log(jsonData);
|
// console.log(jsonData);
|
||||||
makeTypingPracticeSubjectList(jsonData["appList"]);
|
makeTypingPracticeSubjectList(jsonData["appList"]);
|
||||||
makeTypingTestSubjectList(jsonData["appList"]);
|
makeTypingTestSubjectList(jsonData["appList"]);
|
||||||
|
makeTypingExamSubjectList(jsonData["appList"]);
|
||||||
makeTypingAppSubjectList(jsonData["appList"]);
|
makeTypingAppSubjectList(jsonData["appList"]);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -163,6 +164,13 @@ function makeTypingTestSubjectList(appList) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeTypingExamSubjectList(appList) {
|
||||||
|
$("#typing_exam_subject_list").empty();
|
||||||
|
|
||||||
|
addSubjectBundleItem("#typing_exam_subject_list", 1004, "한글 긴글 (시험) 묶음");
|
||||||
|
addSubjectBundleItem("#typing_exam_subject_list", 1005, "영문 긴글 (시험) 묶음");
|
||||||
|
}
|
||||||
|
|
||||||
function makeTypingAppSubjectList(appList) {
|
function makeTypingAppSubjectList(appList) {
|
||||||
$("#typing_app_subject_list").empty();
|
$("#typing_app_subject_list").empty();
|
||||||
|
|
||||||
@@ -240,8 +248,10 @@ function getPlayerRecordList(limitCount) {
|
|||||||
|
|
||||||
var requestURL = "";
|
var requestURL = "";
|
||||||
|
|
||||||
if(appID == 3000)
|
if(appID == 3000) // license
|
||||||
requestURL = "./../server/record/request_license_timer_player_record_list.php";
|
requestURL = "./../server/record/request_license_timer_player_record_list.php";
|
||||||
|
else if(appID == 1004 || appID == 1005) // typing exam
|
||||||
|
requestURL = "./../server/record/request_writing_player_record_list.php";
|
||||||
else
|
else
|
||||||
requestURL = "./../server/record/request_app_player_record_list.php";
|
requestURL = "./../server/record/request_app_player_record_list.php";
|
||||||
|
|
||||||
@@ -404,6 +414,12 @@ function addRecordListItem($date, $time, $name, $subject, $record) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label for="time" class="col-sm-2 col-form-label py-0">긴글 (시험)</label>
|
||||||
|
<div id="typing_exam_subject_list" class="col-sm-10 mb-2">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label for="time" class="col-sm-2 col-form-label py-0">타자 앱</label>
|
<label for="time" class="col-sm-2 col-form-label py-0">타자 앱</label>
|
||||||
<div id="typing_app_subject_list" class="col-sm-10 mb-2">
|
<div id="typing_app_subject_list" class="col-sm-10 mb-2">
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../lib/maestro_account_info.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
$maestro_id = $_POST["MaestroID"];
|
||||||
|
$start_date = $_POST["StartDate"];
|
||||||
|
$end_date = $_POST["EndDate"];
|
||||||
|
$player_name_list = $_POST["PlayerNameList"];
|
||||||
|
$app_id = $_POST["AppID"];
|
||||||
|
$limit_count = $_POST["LimitCount"];
|
||||||
|
// echo "start_date : ".$start_date."\n";
|
||||||
|
// echo "end_date : ".$end_date."\n";
|
||||||
|
// echo "player_name_list : ".$player_name_list."\n";
|
||||||
|
// echo "app_id : ".$app_id."\n";
|
||||||
|
// echo "limit_count : ".$limit_count."\n";
|
||||||
|
// echo "\n";
|
||||||
|
|
||||||
|
$date_statement = makeDateStatement($start_date, $end_date);
|
||||||
|
$player_name_statement = makePlayerNameStatement($player_name_list);
|
||||||
|
$subject_statement = makeSubjectSentence($app_id);
|
||||||
|
$where_statement = make_where_statement($date_statement, $player_name_statement, $subject_statement);
|
||||||
|
// echo "maestro : ".$maestro_id."\n";
|
||||||
|
// echo "date : ".$date_statement."\n";
|
||||||
|
// echo "player_name : ".$player_name_statement."\n";
|
||||||
|
// echo "subject : ".$subject_statement."\n";
|
||||||
|
// echo "where_statement : ".$where_statement."\n";
|
||||||
|
|
||||||
|
$recordTotalCount = get_player_record_total_count($maestro_id, $where_statement);
|
||||||
|
// echo "recordTotalCount : ".$recordTotalCount."\n";
|
||||||
|
$replyJSON = get_player_record_list($maestro_id, $where_statement, $limit_count);
|
||||||
|
if($replyJSON.length === 0) {
|
||||||
|
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_data("RecordTotalCount", $recordTotalCount);
|
||||||
|
set_data("RecordList", $replyJSON);
|
||||||
|
send_result_success();
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function makeDateStatement($start_date, $end_date) {
|
||||||
|
return " '".$start_date."' < TE.RecordDateTime AND TE.RecordDateTime < '".$end_date."'";
|
||||||
|
// return " '2017-01-01' < TE.RecordDateTime AND TE.RecordDateTime < '".$end_date."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeSubjectSentence($app_id) {
|
||||||
|
if($app_id == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
$subject_statement = "";
|
||||||
|
if(is_subject_bundle_item($app_id)) {
|
||||||
|
switch($app_id) {
|
||||||
|
case 1004: // korean exam
|
||||||
|
$subject_statement = $subject_statement."WR.Language='korean'";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1005: // english exam
|
||||||
|
$subject_statement = $subject_statement."WR.Language='english'";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$subject_statement = $subject_statement."WR.WritingID=".$app_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $subject_statement." AND TE.WritingID=WR.WritingID";
|
||||||
|
}
|
||||||
|
|
||||||
|
function makePlayerNameStatement($player_name_list) {
|
||||||
|
$player_name_statement = "TE.PlayerID=P.PlayerID";
|
||||||
|
if(strlen($player_name_list) > 0)
|
||||||
|
$player_name_statement = $player_name_statement." AND P.Name LIKE '%".$player_name_list."%'";
|
||||||
|
|
||||||
|
return $player_name_statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function is_subject_bundle_item($app_id) {
|
||||||
|
if($app_id >= 1000)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function make_where_statement($date_statement, $player_name_statement, $subject_statement) {
|
||||||
|
// add date condition
|
||||||
|
$where_statement = $date_statement;
|
||||||
|
if(strlen($where_statement) > 0 and strlen($player_name_statement) > 0)
|
||||||
|
$where_statement = $where_statement." AND ";
|
||||||
|
|
||||||
|
// add player name condition
|
||||||
|
$where_statement = $where_statement.$player_name_statement;
|
||||||
|
|
||||||
|
// add subject condition
|
||||||
|
if(strlen($where_statement) > 0 and strlen($subject_statement) > 0)
|
||||||
|
$where_statement = $where_statement." AND ";
|
||||||
|
$where_statement = $where_statement.$subject_statement;
|
||||||
|
|
||||||
|
return $where_statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_player_record_total_count($maestro_id, $where_statement) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM typing_exam_record TE, player P, writing WR
|
||||||
|
WHERE TE.MaestroID = ? AND ".$where_statement."
|
||||||
|
";
|
||||||
|
|
||||||
|
// echo $query;
|
||||||
|
// return;
|
||||||
|
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $maestro_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($record_count);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $record_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT DATE(TE.RecordDateTime) AS Date, TIME(TE.RecordDateTime) AS Time,
|
||||||
|
P.Name AS Name, WR.Name AS Subject, TE.Record AS Record
|
||||||
|
FROM typing_exam_record TE, player P, writing WR
|
||||||
|
WHERE TE.MaestroID = ? AND TE.WritingID=WR.WritingID AND TE.PlayerID=P.PlayerID AND ".$where_statement."
|
||||||
|
ORDER BY TE.RecordDateTime DESC
|
||||||
|
";
|
||||||
|
|
||||||
|
if($limit_count > 0)
|
||||||
|
$query = $query." LIMIT ".$limit_count;
|
||||||
|
|
||||||
|
// echo $query;
|
||||||
|
// return;
|
||||||
|
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('i', $maestro_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($date, $time, $player_name, $subject, $record);
|
||||||
|
|
||||||
|
$record_array = array();
|
||||||
|
while($stmt->fetch()) {
|
||||||
|
$record_date['Date'] = $date;
|
||||||
|
$record_date['Time'] = $time;
|
||||||
|
$record_date['PlayerName'] = $player_name;
|
||||||
|
$record_date['Subject'] = $subject;
|
||||||
|
$record_date['Record'] = $record;
|
||||||
|
array_push($record_array, $record_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $record_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user