학생 기록 삭제 기능 추가
- 기록 삭제시 highest_record 최고 기록도 갱신
This commit is contained in:
@@ -182,7 +182,9 @@ function makeTypingAppSubjectList(appList) {
|
|||||||
|
|
||||||
for(var i = 0; i < appList.length; i++) {
|
for(var i = 0; i < appList.length; i++) {
|
||||||
var appData = appList[i];
|
var appData = appList[i];
|
||||||
if(appData.appID < 50)
|
if(appData.appID == 200) // 긴 글 시험
|
||||||
|
continue;
|
||||||
|
else if(appData.appID < 50) // 손가락 연습, 단어/문장 연습
|
||||||
continue;
|
continue;
|
||||||
else if(appData.koreanName == "")
|
else if(appData.koreanName == "")
|
||||||
continue;
|
continue;
|
||||||
@@ -269,7 +271,7 @@ function getPlayerRecordList(limitCount) {
|
|||||||
+ "&AppID=" + appID + "&LimitCount=" + limitCount,
|
+ "&AppID=" + appID + "&LimitCount=" + limitCount,
|
||||||
|
|
||||||
(function(jsonData) {
|
(function(jsonData) {
|
||||||
// console.log(jsonData);
|
console.log(jsonData);
|
||||||
showRecordCount(jsonData);
|
showRecordCount(jsonData);
|
||||||
makeRecordTableContent(jsonData["RecordList"]);
|
makeRecordTableContent(jsonData["RecordList"]);
|
||||||
}),
|
}),
|
||||||
@@ -303,43 +305,92 @@ function makeRecordTableContent(recordList) {
|
|||||||
// console.log(recordList);
|
// console.log(recordList);
|
||||||
for(var i = 0; i < recordList.length; i++) {
|
for(var i = 0; i < recordList.length; i++) {
|
||||||
var record = recordList[i];
|
var record = recordList[i];
|
||||||
addRecordListItem(record.Date, record.Time, record.PlayerName, record.Subject, record.Record);
|
addRecordListItem(record.Id, record.Date, record.Time, record.PlayerName, record.Subject, record.Record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNoResultContent() {
|
function showNoResultContent() {
|
||||||
|
$("#record_table_content").empty();
|
||||||
$("#record_table_content").append('\
|
$("#record_table_content").append('\
|
||||||
<tr>\
|
<tr>\
|
||||||
<th scope="row" class="table-warning text-center" colspan="5">데이터가 없습니다.</th>\
|
<th scope="row" class="table-warning text-center" colspan="6">데이터가 없습니다.</th>\
|
||||||
</tr>\
|
</tr>\
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRecordListItem(date, time, name, subject, record) {
|
function addRecordListItem(id, date, time, name, subject, record) {
|
||||||
if(record >= 0) {
|
if(record >= 0) {
|
||||||
$("#record_table_content").append('\
|
$("#record_table_content").append('\
|
||||||
<tr>\
|
<tr>\
|
||||||
|
<td class="text-center d-none">' + id + '</td>\
|
||||||
<th scope="row" class="text-center">' + date + '</th>\
|
<th scope="row" class="text-center">' + date + '</th>\
|
||||||
<td class="text-center">' + time + '</td>\
|
<td class="text-center">' + time + '</td>\
|
||||||
<td class="text-center">' + name + '</td>\
|
<td class="text-center">' + name + '</td>\
|
||||||
<td class="text-center">' + subject + '</td>\
|
<td class="text-center">' + subject + '</td>\
|
||||||
<td class="text-right">' + record + '</td>\
|
<td class="text-right">' + record + '</td>\
|
||||||
|
<td class="text-center"><button class="btn btn-danger" type="button" onClick="deleteRecord(this)"> X </button></td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
');
|
');
|
||||||
} else {
|
} else {
|
||||||
var disqualificationRecord = -1 * record;
|
var disqualificationRecord = -1 * record;
|
||||||
$("#record_table_content").append('\
|
$("#record_table_content").append('\
|
||||||
<tr>\
|
<tr>\
|
||||||
|
<td class="text-center d-none">' + id + '</td>\
|
||||||
<th scope="row" class="text-center">' + date + '</th>\
|
<th scope="row" class="text-center">' + date + '</th>\
|
||||||
<td class="text-center">' + time + '</td>\
|
<td class="text-center">' + time + '</td>\
|
||||||
<td class="text-center">' + name + '</td>\
|
<td class="text-center">' + name + '</td>\
|
||||||
<td class="text-center">' + subject + '</td>\
|
<td class="text-center">' + subject + '</td>\
|
||||||
<td class="text-right text-danger">(아깝) ' + disqualificationRecord + '</td>\
|
<td class="text-right text-danger">(아깝) ' + disqualificationRecord + '</td>\
|
||||||
|
<td class="text-center"><button class="btn btn-danger" type="button" onClick="deleteRecord(this)"> X </button></td>\
|
||||||
</tr>\
|
</tr>\
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteRecord(target) {
|
||||||
|
console.log(target);
|
||||||
|
var id = $(target).parent().siblings().eq(0).text();
|
||||||
|
var date = $(target).parent().siblings().eq(1).text();
|
||||||
|
var time = $(target).parent().siblings().eq(2).text();
|
||||||
|
var name = $(target).parent().siblings().eq(3).text();
|
||||||
|
var subject = $(target).parent().siblings().eq(4).text();
|
||||||
|
var record = $(target).parent().siblings().eq(5).text();
|
||||||
|
|
||||||
|
var message = "선택한 기록을 삭제하시겠습니까?\n"
|
||||||
|
+ "(경고: 기록을 삭제한 후에는 되살릴 수 없습니다)\n\n"
|
||||||
|
+ "* 날짜: " + date + "\n"
|
||||||
|
+ "* 시간: " + time + "\n"
|
||||||
|
+ "* 이름: " + name + "\n"
|
||||||
|
+ "* 과목: " + subject + "\n"
|
||||||
|
+ "* 기록: " + record;
|
||||||
|
if (confirm(message)) {
|
||||||
|
console.log("delete record: " + id);
|
||||||
|
|
||||||
|
var appID = $(":radio[name='subject_group']:checked").val();
|
||||||
|
if(typeof(appID) == "undefined") {
|
||||||
|
showErrorMessage("검색할 과목을 선택하세요.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
|
||||||
|
"./../server/record/delete_record.php",
|
||||||
|
"MaestroID=" + maestroID
|
||||||
|
+ "&AppID=" + appID
|
||||||
|
+ "&BestRecordID=" + id,
|
||||||
|
|
||||||
|
(function(jsonData) {
|
||||||
|
console.log(jsonData);
|
||||||
|
requestPlayerRecordListAll();
|
||||||
|
}),
|
||||||
|
|
||||||
|
(function(errorMessage, errorCode) {
|
||||||
|
showErrorMessage(errorMessage, "error");
|
||||||
|
})
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@@ -491,17 +542,19 @@ function addRecordListItem(date, time, name, subject, record) {
|
|||||||
<table class="table table-striped" id="dataTable">
|
<table class="table table-striped" id="dataTable">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col" class="text-center d-none">RecordID</th>
|
||||||
<th scope="col" class="text-center">날짜</th>
|
<th scope="col" class="text-center">날짜</th>
|
||||||
<th scope="col" class="text-center">시간</th>
|
<th scope="col" class="text-center">시간</th>
|
||||||
<th scope="col" class="text-center">이름</th>
|
<th scope="col" class="text-center">이름</th>
|
||||||
<th scope="col" class="text-center">과목</th>
|
<th scope="col" class="text-center">과목</th>
|
||||||
<th scope="col" class="text-center">점수</th>
|
<th scope="col" class="text-center">점수</th>
|
||||||
|
<th scope="col" class="text-center">기록 삭제</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="record_table_content">
|
<tbody id="record_table_content">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" class="table-warning text-center" colspan="5">데이터가 없습니다.</th>
|
<th scope="row" class="table-warning text-center" colspan="6">데이터가 없습니다.</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -0,0 +1,386 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$maestro_id = $_POST["MaestroID"];
|
||||||
|
$selected_app_id = $_POST["AppID"];
|
||||||
|
$best_record_id = $_POST["BestRecordID"];
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
include "./../lib/app_highest_record.php";
|
||||||
|
include "./../lib/util_app.php";
|
||||||
|
|
||||||
|
|
||||||
|
function sendSuccessReplyForTest() {
|
||||||
|
global $db_conn;
|
||||||
|
global $maestro_id;
|
||||||
|
global $selected_app_id;
|
||||||
|
global $best_record_id;
|
||||||
|
|
||||||
|
set_data("maestro_id", $maestro_id);
|
||||||
|
set_data("selected_app_id", $selected_app_id);
|
||||||
|
set_data("best_record_id", $best_record_id);
|
||||||
|
send_result_success();
|
||||||
|
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//sendSuccessReplyForTest();
|
||||||
|
|
||||||
|
|
||||||
|
// 앱 종류에 따라
|
||||||
|
if($selected_app_id == 3000) { // 자격증 타이머
|
||||||
|
// 기록 삭제 : license_score
|
||||||
|
$deletedRecordCount = delete_license_score($best_record_id);
|
||||||
|
if($deletedRecordCount < 1) {
|
||||||
|
sendErrorMessageAndExit("자격증 타이머 기록 삭제 실패");
|
||||||
|
}
|
||||||
|
} else if($selected_app_id == 1004 || $selected_app_id == 1005) { // 긴글 (시험)
|
||||||
|
$record_info_array = get_typing_exam_record_info($best_record_id);
|
||||||
|
$player_id = $record_info_array["PlayerID"];
|
||||||
|
$writing_id = $record_info_array["WritingID"];
|
||||||
|
if($player_id === null || $writing_id === null) {
|
||||||
|
sendErrorMessageAndExit("긴글 (시험) 기록 오류");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 기록 삭제 : typing_exam_record
|
||||||
|
$deletedRecordCount = delete_typing_exam_record($best_record_id);
|
||||||
|
if($deletedRecordCount < 1) {
|
||||||
|
sendErrorMessageAndExit("긴글 (시험) 기록 삭제 실패");
|
||||||
|
}
|
||||||
|
|
||||||
|
// typing_exam_highest_record 업데이트
|
||||||
|
updateTypingExamHighestRecord($maestro_id, $player_id, $writing_id);
|
||||||
|
}
|
||||||
|
else { // 일반 앱
|
||||||
|
$record_info_array = get_best_record_info($best_record_id);
|
||||||
|
$player_id = $record_info_array["PlayerID"];
|
||||||
|
$app_id = $record_info_array["AppID"];
|
||||||
|
if($player_id === null || $app_id === null) {
|
||||||
|
sendErrorMessageAndExit("기록 오류");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 기록 삭제 : best_record
|
||||||
|
$deletedRecordCount = delete_best_record($best_record_id);
|
||||||
|
if($deletedRecordCount < 1) {
|
||||||
|
sendErrorMessageAndExit("기록 삭제 실패");
|
||||||
|
}
|
||||||
|
|
||||||
|
// app_highest_record 업데이트
|
||||||
|
updateAppHighestRecord($maestro_id, $player_id, $app_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_data("message", "기록 삭제 성공");
|
||||||
|
send_result_success();
|
||||||
|
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
function sendErrorMessageAndExit($message) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
set_error_message($message);
|
||||||
|
send_result_fail();
|
||||||
|
$db_conn->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateTypingExamHighestRecord($maestro_id, $player_id, $writing_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$record_info_array = get_typing_exam_best_record_info($maestro_id, $player_id, $writing_id);
|
||||||
|
$record = $record_info_array["Record"];
|
||||||
|
$record_date_time = $record_info_array["RecordDateTime"];
|
||||||
|
if ($record === null || $record_date_time === null) {
|
||||||
|
delete_typing_exam_highest_record($maestro_id, $player_id, $writing_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$highest_record_id = get_typing_exam_highest_record_id($maestro_id, $player_id, $writing_id);
|
||||||
|
if ($highest_record_id !== null && $highest_record_id > 0) {
|
||||||
|
update_typing_exam_highest_record($highest_record_id, $record, $record_date_time);
|
||||||
|
} else {
|
||||||
|
insert_new_typing_exam_highest_record($maestro_id, $player_id, $writing_id, $record, $record_date_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAppHighestRecord($maestro_id, $player_id, $app_id) {
|
||||||
|
$record_info_array = get_best_record_record_info($maestro_id, $player_id, $app_id);
|
||||||
|
$best_record = $record_info_array["BestRecord"];
|
||||||
|
$record_date_time = $record_info_array["RecordDateTime"];
|
||||||
|
if ($best_record === null || $record_date_time === null) {
|
||||||
|
delete_app_highest_record($maestro_id, $player_id, $app_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$highest_record_id = get_app_highest_record_id($maestro_id, $player_id, $app_id);
|
||||||
|
if ($highest_record_id !== null && $highest_record_id > 0) {
|
||||||
|
update_app_highest_record($highest_record_id, $best_record, $record_date_time);
|
||||||
|
} else {
|
||||||
|
insert_new_app_highest_record($maestro_id, $player_id, $app_id, $best_record, $record_date_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_license_score($best_record_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
DELETE FROM license_score
|
||||||
|
WHERE LicenseScoreID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $best_record_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_typing_exam_record_info($best_record_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT PlayerID, WritingID
|
||||||
|
FROM typing_exam_record
|
||||||
|
WHERE TypingExamRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $best_record_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($player_id, $writing_id);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return array("PlayerID" => $player_id, "WritingID" => $writing_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_typing_exam_record($best_record_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
DELETE FROM typing_exam_record
|
||||||
|
WHERE TypingExamRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $best_record_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_typing_exam_best_record_info($maestro_id, $player_id, $writing_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT Record, RecordDateTime
|
||||||
|
FROM typing_exam_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND WritingID = ? AND Record > 0
|
||||||
|
ORDER BY Record DESC
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $writing_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($record, $record_date_time);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return array("Record" => $record, "RecordDateTime" => $record_date_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_typing_exam_highest_record_id($maestro_id, $player_id, $writing_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT TypingExamHighestRecordID
|
||||||
|
FROM typing_exam_highest_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND WritingID = ? AND HighestRecord > 0
|
||||||
|
ORDER BY HighestRecord DESC
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $writing_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($new_best_record_id);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $new_best_record_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_typing_exam_highest_record($maestro_id, $player_id, $writing_id)
|
||||||
|
{
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
DELETE FROM typing_exam_highest_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND WritingID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $writing_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_typing_exam_highest_record($highest_record_id, $record, $record_date_time) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
UPDATE typing_exam_highest_record
|
||||||
|
SET HighestRecord = ?, RecordDateTime = ?
|
||||||
|
WHERE TypingExamHighestRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("dsi", $record, $record_date_time, $highest_record_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert_new_typing_exam_highest_record($maestro_id, $player_id, $writing_id, $record, $record_date_time) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
INSERT INTO typing_exam_highest_record (MaestroID, PlayerID, WritingID, HighestRecord, RecordDateTime)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iiids", $maestro_id, $player_id, $writing_id, $record, $record_date_time);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_best_record_info($best_record_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT PlayerID, AppID
|
||||||
|
FROM best_record
|
||||||
|
WHERE BestRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $best_record_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($player_id, $app_id);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return array("PlayerID" => $player_id, "AppID" => $app_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_best_record($best_record_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
DELETE FROM best_record
|
||||||
|
WHERE BestRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("i", $best_record_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_best_record_record_info($maestro_id, $player_id, $app_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$orderStatement = is_highest_record_prefer_app($app_id) ? "ORDER BY BestRecord DESC" : "ORDER BY BestRecord ASC";
|
||||||
|
$query = "
|
||||||
|
SELECT BestRecord, RecordDateTime
|
||||||
|
FROM best_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND AppID = ?
|
||||||
|
".$orderStatement."
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $app_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($best_record, $record_date_time);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return array("BestRecord" => $best_record, "RecordDateTime" => $record_date_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_app_highest_record_id($maestro_id, $player_id, $app_id)
|
||||||
|
{
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$orderStatement = is_highest_record_prefer_app($app_id) ? "ORDER BY HighestRecord DESC" : "ORDER BY HighestRecord ASC";
|
||||||
|
$query = "
|
||||||
|
SELECT AppHighestRecordID
|
||||||
|
FROM app_highest_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND AppID = ?
|
||||||
|
".$orderStatement."
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $app_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($highest_record_id);
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $highest_record_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_app_highest_record($maestro_id, $player_id, $app_id)
|
||||||
|
{
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
DELETE FROM app_highest_record
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ? AND AppID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iii", $maestro_id, $player_id, $app_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_app_highest_record($highest_record_id, $record, $record_date_time) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
UPDATE app_highest_record
|
||||||
|
SET HighestRecord = ?, RecordDateTime = ?
|
||||||
|
WHERE AppHighestRecordID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("dsi", $record, $record_date_time, $highest_record_id);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function insert_new_app_highest_record($maestro_id, $player_id, $app_id, $record, $record_date_time) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
INSERT INTO app_highest_record (MaestroID, PlayerID, AppID, HighestRecord, RecordDateTime)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param('iiids', $maestro_id, $player_id, $app_id, $record, $record_date_time);
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -165,7 +165,7 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT DATE(BR.RecordDateTime) AS Date, TIME(BR.RecordDateTime) AS Time,
|
SELECT BR.BestRecordID AS Id, DATE(BR.RecordDateTime) AS Date, TIME(BR.RecordDateTime) AS Time,
|
||||||
P.Name AS Name, A.KoreanName AS Subject, BR.BestRecord AS Record
|
P.Name AS Name, A.KoreanName AS Subject, BR.BestRecord AS Record
|
||||||
FROM best_record BR, player P, app A
|
FROM best_record BR, player P, app A
|
||||||
WHERE BR.MaestroID = ? AND ".$where_statement."
|
WHERE BR.MaestroID = ? AND ".$where_statement."
|
||||||
@@ -181,10 +181,11 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('i', $maestro_id);
|
$stmt->bind_param('i', $maestro_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($date, $time, $player_name, $subject, $record);
|
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||||
|
|
||||||
$record_array = array();
|
$record_array = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
|
$record_date['Id'] = $id;
|
||||||
$record_date['Date'] = $date;
|
$record_date['Date'] = $date;
|
||||||
$record_date['Time'] = $time;
|
$record_date['Time'] = $time;
|
||||||
$record_date['PlayerName'] = $player_name;
|
$record_date['PlayerName'] = $player_name;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT DATE(LS.ScoreDateTime) AS Date, TIME(LS.ScoreDateTime) AS Time,
|
SELECT LS.LicenseScoreID AS ID, DATE(LS.ScoreDateTime) AS Date, TIME(LS.ScoreDateTime) AS Time,
|
||||||
P.Name AS Name, LS.SubjectName AS Subject, LS.Score AS Record
|
P.Name AS Name, LS.SubjectName AS Subject, LS.Score AS Record
|
||||||
FROM license_score LS, player P
|
FROM license_score LS, player P
|
||||||
WHERE LS.MaestroID = ? AND ".$where_statement."
|
WHERE LS.MaestroID = ? AND ".$where_statement."
|
||||||
@@ -183,10 +183,11 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('i', $maestro_id);
|
$stmt->bind_param('i', $maestro_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($date, $time, $player_name, $subject, $record);
|
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||||
|
|
||||||
$record_array = array();
|
$record_array = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
|
$record_date['Id'] = $id;
|
||||||
$record_date['Date'] = $date;
|
$record_date['Date'] = $date;
|
||||||
$record_date['Time'] = $time;
|
$record_date['Time'] = $time;
|
||||||
$record_date['PlayerName'] = $player_name;
|
$record_date['PlayerName'] = $player_name;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT DATE(TE.RecordDateTime) AS Date, TIME(TE.RecordDateTime) AS Time,
|
SELECT TE.TypingExamRecordID as Id, DATE(TE.RecordDateTime) AS Date, TIME(TE.RecordDateTime) AS Time,
|
||||||
P.Name AS Name, WR.Name AS Subject, TE.Record AS Record
|
P.Name AS Name, WR.Name AS Subject, TE.Record AS Record
|
||||||
FROM typing_exam_record TE, player P, writing WR
|
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."
|
WHERE TE.MaestroID = ? AND TE.WritingID=WR.WritingID AND TE.PlayerID=P.PlayerID AND ".$where_statement."
|
||||||
@@ -149,10 +149,11 @@ function get_player_record_list($maestro_id, $where_statement, $limit_count) {
|
|||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('i', $maestro_id);
|
$stmt->bind_param('i', $maestro_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($date, $time, $player_name, $subject, $record);
|
$stmt->bind_result($id, $date, $time, $player_name, $subject, $record);
|
||||||
|
|
||||||
$record_array = array();
|
$record_array = array();
|
||||||
while($stmt->fetch()) {
|
while($stmt->fetch()) {
|
||||||
|
$record_date['Id'] = $id;
|
||||||
$record_date['Date'] = $date;
|
$record_date['Date'] = $date;
|
||||||
$record_date['Time'] = $time;
|
$record_date['Time'] = $time;
|
||||||
$record_date['PlayerName'] = $player_name;
|
$record_date['PlayerName'] = $player_name;
|
||||||
|
|||||||
Reference in New Issue
Block a user