Add: add license score
This commit is contained in:
@@ -513,6 +513,23 @@ DBConnectManager.prototype.requestLicenseScore = function(maestroID, playerID, o
|
|||||||
xhr.send("MaestroID=" + maestroID + "&PlayerID=" + playerID);
|
xhr.send("MaestroID=" + maestroID + "&PlayerID=" + playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBConnectManager.prototype.addLicenseScore = function(maestroID, playerID, subjectName, score, onSucceededListener, onFailedListener) {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", this.phpPath + "server/license_timer/add_license_score.php", true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||||
|
var replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
|
||||||
|
if(replyJSON != null)
|
||||||
|
onSucceededListener(replyJSON);
|
||||||
|
else
|
||||||
|
onFailedListener(replyJSON);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send("MaestroID=" + maestroID + "&PlayerID=" + playerID + "&SubjectName=" + subjectName + "&Score=" + score);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DBConnectManager.prototype.loadTempPlayerHistory = function(historyRecordManager) {
|
DBConnectManager.prototype.loadTempPlayerHistory = function(historyRecordManager) {
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ function InputScore(licenseDataManager, timer, chart) {
|
|||||||
this.makeSubjectPanel();
|
this.makeSubjectPanel();
|
||||||
this.setVisibleCompanyPanel(false);
|
this.setVisibleCompanyPanel(false);
|
||||||
this.setVisibleSubjectPanel(false, "");
|
this.setVisibleSubjectPanel(false, "");
|
||||||
|
|
||||||
this.loadMaestroPasswordFromServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputScore.prototype.initVariables = function() {
|
InputScore.prototype.initVariables = function() {
|
||||||
@@ -290,25 +288,70 @@ InputScore.prototype.makePanelSprite = function(x, y, width, height, color) {
|
|||||||
return game.add.sprite(x, y, btnTexture);
|
return game.add.sprite(x, y, btnTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputScore.prototype.alert = function(message) {
|
||||||
|
console.log("Alert message : " + message);
|
||||||
InputScore.prototype.onClickSendToServerButton = function() {
|
|
||||||
console.log("send data to server");
|
|
||||||
|
|
||||||
console.log(this.subjectFullname);
|
|
||||||
console.log(this.scoreText.value);
|
|
||||||
var subjectData = this.licenseDataManager.getSubjectDataByName(this.subjectFullname);
|
|
||||||
if(subjectData != null)
|
|
||||||
console.log(subjectData.getGrade(this.scoreText.value))
|
|
||||||
console.log(this.passwordText.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InputScore.prototype.loadMaestroPasswordFromServer = function() {
|
InputScore.prototype.onClickSendToServerButton = function() {
|
||||||
|
if(this.subjectFullname == "") {
|
||||||
|
this.alert("no subject error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.scoreText.value == "") {
|
||||||
|
this.alert("no score error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.passwordText.value == "") {
|
||||||
|
this.alert("no password error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.maestroPassword = this.passwordText.value;
|
||||||
|
|
||||||
|
console.log("send data to server");
|
||||||
|
|
||||||
|
this.checkMaestroPasswordFromServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
InputScore.prototype.addScoreToServer = function(subjectName, score) {
|
||||||
|
this.dbConnectManager.addLicenseScore(
|
||||||
|
sessionStorageManager.getMaestroID(),
|
||||||
|
sessionStorageManager.getPlayerID(),
|
||||||
|
subjectName,
|
||||||
|
score,
|
||||||
|
(function(replyJson) {
|
||||||
|
console.log(replyJson);
|
||||||
|
|
||||||
|
this.chart.loadScoreFromServer();
|
||||||
|
}).bind(this),
|
||||||
|
|
||||||
|
(function(replyJson) {
|
||||||
|
console.log(replyJson);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputScore.prototype.checkMaestroPasswordFromServer = function() {
|
||||||
this.dbConnectManager.requestLicenseMaestroPassword(
|
this.dbConnectManager.requestLicenseMaestroPassword(
|
||||||
sessionStorageManager.getMaestroID(),
|
sessionStorageManager.getMaestroID(),
|
||||||
(function(replyJson) {
|
(function(replyJson) {
|
||||||
// console.log(replyJson);
|
console.log(replyJson);
|
||||||
this.maestroPassword = replyJson.maestroPassword;
|
|
||||||
|
console.log(this.maestroPassword);
|
||||||
|
console.log(replyJson.maestroPassword);
|
||||||
|
|
||||||
|
if(replyJson.maestroPassword == null || replyJson.maestroPassword == "") {
|
||||||
|
this.alert("set password!!!");
|
||||||
|
return;
|
||||||
|
} else if(this.maestroPassword != replyJson.maestroPassword) {
|
||||||
|
this.alert("wrong password");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addScoreToServer(this.subjectFullname, this.scoreText.value);
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
|
|
||||||
(function(replyJson) {
|
(function(replyJson) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ var licenseDataList = [
|
|||||||
gradeList: [
|
gradeList: [
|
||||||
{ score: 160, grade: "고급" },
|
{ score: 160, grade: "고급" },
|
||||||
{ score: 120, grade: "중급" },
|
{ score: 120, grade: "중급" },
|
||||||
{ score: 80, grade: "초금" }
|
{ score: 80, grade: "초급" }
|
||||||
],
|
],
|
||||||
subjects: [
|
subjects: [
|
||||||
"프리젠테이션",
|
"프리젠테이션",
|
||||||
@@ -49,7 +49,7 @@ var licenseDataList = [
|
|||||||
gradeList: [
|
gradeList: [
|
||||||
{ score: 80, grade: "고급" },
|
{ score: 80, grade: "고급" },
|
||||||
{ score: 60, grade: "중급" },
|
{ score: 60, grade: "중급" },
|
||||||
{ score: 40, grade: "초금" }
|
{ score: 40, grade: "초급" }
|
||||||
],
|
],
|
||||||
subjects: [
|
subjects: [
|
||||||
"인터넷정보검색",
|
"인터넷정보검색",
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
$maestro_id = $_POST["MaestroID"];
|
||||||
|
$player_id = $_POST["PlayerID"];
|
||||||
|
$subjectName = $_POST["SubjectName"];
|
||||||
|
$score = $_POST["Score"];
|
||||||
|
// echo $maestro_id." / ".$player_id." / ".$score;
|
||||||
|
|
||||||
|
include "./../lib/send_reply_json.php";
|
||||||
|
include "./../setup/connect_db.php";
|
||||||
|
|
||||||
|
insert_score($maestro_id, $player_id, $subjectName, $score);
|
||||||
|
|
||||||
|
send_result_success();
|
||||||
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function insert_score($maestro_id, $player_id, $subject_name, $score) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
INSERT INTO license_score (MaestroID, PlayerID, SubjectName, Score, ScoreDateTime)
|
||||||
|
VALUES (?, ?, ?, ?, NOW());
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("iisi", $maestro_id, $player_id, $subject_name, $score);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
function get_score_list($maestro_id, $player_id) {
|
||||||
|
global $db_conn;
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT SubjectName, Score, ScoreDateTime
|
||||||
|
FROM license_score
|
||||||
|
WHERE MaestroID = ? AND PlayerID = ?
|
||||||
|
";
|
||||||
|
$stmt = $db_conn->prepare($query);
|
||||||
|
$stmt->bind_param("ii", $maestro_id, $player_id);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($subject_name, $score, $score_date_time);
|
||||||
|
|
||||||
|
$score_list = array();
|
||||||
|
while($stmt->fetch()) {
|
||||||
|
$score_data["SubjectName"] = $subject_name;
|
||||||
|
$score_data["Score"] = $score;
|
||||||
|
$score_data["ScoreDateTime"] = $score_date_time;
|
||||||
|
array_push($score_list, $score_data);
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
return $score_list;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
?>
|
||||||
@@ -25,6 +25,7 @@ function get_score_list($maestro_id, $player_id) {
|
|||||||
SELECT SubjectName, Score, ScoreDateTime
|
SELECT SubjectName, Score, ScoreDateTime
|
||||||
FROM license_score
|
FROM license_score
|
||||||
WHERE MaestroID = ? AND PlayerID = ?
|
WHERE MaestroID = ? AND PlayerID = ?
|
||||||
|
ORDER BY ScoreDateTime DESC
|
||||||
";
|
";
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param("ii", $maestro_id, $player_id);
|
$stmt->bind_param("ii", $maestro_id, $player_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user