diff --git a/src/game/lib/db_connect_manager.js b/src/game/lib/db_connect_manager.js index 23dacc5..9eda0b9 100644 --- a/src/game/lib/db_connect_manager.js +++ b/src/game/lib/db_connect_manager.js @@ -513,6 +513,23 @@ DBConnectManager.prototype.requestLicenseScore = function(maestroID, playerID, o 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) { diff --git a/src/game/license_timer/input_score.js b/src/game/license_timer/input_score.js index 2f2cbdd..915c70c 100644 --- a/src/game/license_timer/input_score.js +++ b/src/game/license_timer/input_score.js @@ -71,8 +71,6 @@ function InputScore(licenseDataManager, timer, chart) { this.makeSubjectPanel(); this.setVisibleCompanyPanel(false); this.setVisibleSubjectPanel(false, ""); - - this.loadMaestroPasswordFromServer(); } InputScore.prototype.initVariables = function() { @@ -290,25 +288,70 @@ InputScore.prototype.makePanelSprite = function(x, y, width, height, color) { return game.add.sprite(x, y, btnTexture); } - - -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.alert = function(message) { + console.log("Alert message : " + message); } -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( sessionStorageManager.getMaestroID(), (function(replyJson) { - // console.log(replyJson); - this.maestroPassword = replyJson.maestroPassword; + console.log(replyJson); + + 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), (function(replyJson) { diff --git a/src/game/license_timer/license_data/company_subject.js b/src/game/license_timer/license_data/company_subject.js index 9aa57a8..2a85e04 100644 --- a/src/game/license_timer/license_data/company_subject.js +++ b/src/game/license_timer/license_data/company_subject.js @@ -33,7 +33,7 @@ var licenseDataList = [ gradeList: [ { score: 160, grade: "고급" }, { score: 120, grade: "중급" }, - { score: 80, grade: "초금" } + { score: 80, grade: "초급" } ], subjects: [ "프리젠테이션", @@ -49,7 +49,7 @@ var licenseDataList = [ gradeList: [ { score: 80, grade: "고급" }, { score: 60, grade: "중급" }, - { score: 40, grade: "초금" } + { score: 40, grade: "초급" } ], subjects: [ "인터넷정보검색", diff --git a/src/web/server/license_timer/add_license_score.php b/src/web/server/license_timer/add_license_score.php new file mode 100644 index 0000000..891a465 --- /dev/null +++ b/src/web/server/license_timer/add_license_score.php @@ -0,0 +1,58 @@ +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; +} +*/ +?> \ No newline at end of file diff --git a/src/web/server/license_timer/get_license_score.php b/src/web/server/license_timer/get_license_score.php index ff19617..2519ed2 100644 --- a/src/web/server/license_timer/get_license_score.php +++ b/src/web/server/license_timer/get_license_score.php @@ -25,6 +25,7 @@ function get_score_list($maestro_id, $player_id) { SELECT SubjectName, Score, ScoreDateTime FROM license_score WHERE MaestroID = ? AND PlayerID = ? + ORDER BY ScoreDateTime DESC "; $stmt = $db_conn->prepare($query); $stmt->bind_param("ii", $maestro_id, $player_id);