Fix: update result record to DB
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
초코마에
|
||||||
|
지나주
|
||||||
@@ -3,18 +3,19 @@ var TypingExamination = {
|
|||||||
create: function() {
|
create: function() {
|
||||||
|
|
||||||
// for developing
|
// for developing
|
||||||
sessionStorageManager.setMaestroName("삼화초");
|
// sessionStorageManager.setMaestroName("삼화초");
|
||||||
sessionStorageManager.setMaestroID(3);
|
// sessionStorageManager.setMaestroID(3);
|
||||||
sessionStorageManager.setMaestroAccountType(4);
|
// sessionStorageManager.setMaestroAccountType(4);
|
||||||
sessionStorageManager.setPlayerName("박지상");
|
// sessionStorageManager.setPlayerName("박지상");
|
||||||
sessionStorageManager.setPlayerID(35);
|
// sessionStorageManager.setPlayerID(35);
|
||||||
sessionStorageManager.setPlayerAccountType(0);
|
// sessionStorageManager.setPlayerAccountType(0);
|
||||||
sessionStorageManager.setPlayingAppID(100);
|
// sessionStorageManager.setPlayingAppID(100);
|
||||||
sessionStorageManager.setPlayingAppName("examination_korean");
|
// sessionStorageManager.setPlayingAppName("examination_korean");
|
||||||
|
// sessionStorageManager.setPlayingAppKoreanName("타자 검정");
|
||||||
|
// sessionStorageManager.setRecord(0);
|
||||||
|
// sessionStorageManager.setAppHighestRecord(100.123);
|
||||||
|
sessionStorageManager.setPlayingAppName("typing_examination_korean");
|
||||||
sessionStorageManager.setPlayingAppKoreanName("타자 검정");
|
sessionStorageManager.setPlayingAppKoreanName("타자 검정");
|
||||||
sessionStorageManager.setRecord(0);
|
|
||||||
sessionStorageManager.setAppHighestRecord(100.123);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this.dbConnectManager = new DBConnectManager();
|
// this.dbConnectManager = new DBConnectManager();
|
||||||
@@ -303,25 +304,21 @@ var TypingExamination = {
|
|||||||
if(!isExperienceMaestroAccount())
|
if(!isExperienceMaestroAccount())
|
||||||
this.updateResultRecord();
|
this.updateResultRecord();
|
||||||
|
|
||||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
// game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateResultRecord: function() {
|
updateResultRecord: function() {
|
||||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||||
this.dbService.updateTypingExamRecord(
|
this.dbService.updateTypingExamRecord(
|
||||||
sessionStorageManager.getMaestroID(),
|
sessionStorageManager.getWritingID(),
|
||||||
sessionStorageManager.getPlayerID(),
|
sessionStorageManager.getRecord(),
|
||||||
sessionStorageManager.getPlayingAppID(),
|
(function(replyJSON) {
|
||||||
sessionStorageManager.getRecord()
|
console.log(replyJSON);
|
||||||
|
}).bind(this),
|
||||||
|
(function(replyJSON) {
|
||||||
|
console.log(replyJSON);
|
||||||
|
}).bind(this)
|
||||||
);
|
);
|
||||||
/*
|
|
||||||
this.dbConnectManager.updateResultRecord(
|
|
||||||
sessionStorageManager.getMaestroID(),
|
|
||||||
sessionStorageManager.getPlayerID(),
|
|
||||||
sessionStorageManager.getPlayingAppID(),
|
|
||||||
sessionStorageManager.getRecord()
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -369,11 +366,13 @@ var TypingExamination = {
|
|||||||
var directory = writer + writerID + "/";
|
var directory = writer + writerID + "/";
|
||||||
var filename = writingInfo["filename"];
|
var filename = writingInfo["filename"];
|
||||||
var url = path + directory + filename;
|
var url = path + directory + filename;
|
||||||
|
if(isDebugMode()) {
|
||||||
|
url = path + "system/sample.txt";
|
||||||
|
console.log(url);
|
||||||
|
}
|
||||||
|
|
||||||
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
||||||
|
|
||||||
game.load.text("writing", url);
|
game.load.text("writing", url);
|
||||||
|
|
||||||
game.load.start();
|
game.load.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -32,24 +32,24 @@ if ($command === "addTypingExamHighestRecord") {
|
|||||||
|
|
||||||
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
||||||
$typingExam->addHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID, WRITING_RECORD);
|
$typingExam->addHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID, WRITING_RECORD);
|
||||||
// $typingExamHighestRecordData = $typingExam->getHighestRecordForWriting(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
// $typingExamHighestRecordData = $typingExam->getHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
||||||
// $jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
// $jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
||||||
} elseif ($command === "updateTypingExamHighestRecord") {
|
} elseif ($command === "updateTypingExamHighestRecord") {
|
||||||
include "./db_method_container.php";
|
include "./db_method_container.php";
|
||||||
include "./typing_exam_collection.php";
|
include "./typing_exam_collection.php";
|
||||||
|
|
||||||
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
||||||
$typingExamHighestRecordData = $typingExam->getHighestRecordForWriting(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
$typingExamHighestRecordData = $typingExam->getHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
||||||
// $jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
// $jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
||||||
$typingExam->updateHighestRecord($typingExamHighestRecordData["typingExamHighestRecordID"], WRITING_RECORD + 10);
|
$typingExam->updateHighestRecord($typingExamHighestRecordData["typingExamHighestRecordID"], WRITING_RECORD + 10);
|
||||||
// $typingExamHighestRecordData = $typingExam->getHighestRecordForWriting(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
// $typingExamHighestRecordData = $typingExam->getHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
||||||
// $jsonBuilder->setData("updateTypingExamHighestRecord", $typingExamHighestRecordData);
|
// $jsonBuilder->setData("updateTypingExamHighestRecord", $typingExamHighestRecordData);
|
||||||
} elseif ($command === "getTypingExamHigestRecord") {
|
} elseif ($command === "getTypingExamHigestRecord") {
|
||||||
include "./db_method_container.php";
|
include "./db_method_container.php";
|
||||||
include "./typing_exam_collection.php";
|
include "./typing_exam_collection.php";
|
||||||
|
|
||||||
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
||||||
$typingExamHighestRecordData = $typingExam->getHighestRecordForWriting(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
$typingExamHighestRecordData = $typingExam->getHighestRecord(MAESTRO_ID, PLAYER_ID, WRITING_ID);
|
||||||
$jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
$jsonBuilder->setData("typingExamHighestRecordData", $typingExamHighestRecordData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,14 +85,14 @@ class TypingExamCollection extends DBMethodContainer
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThisHourRecord($maestroID, $playerID)
|
public function getThisHourRecord($maestroID, $playerID, $writingID)
|
||||||
{
|
{
|
||||||
$query = "
|
$query = "
|
||||||
SELECT TypingExamRecordID, Record
|
SELECT TypingExamRecordID, Record
|
||||||
FROM typing_exam_record
|
FROM typing_exam_record
|
||||||
WHERE MaestroID = ? AND PlayerID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())";
|
WHERE MaestroID = ? AND PlayerID = ? AND WritingID = ? AND DATE(RecordDateTime) = DATE(NOW()) AND HOUR(RecordDateTime) = HOUR(NOW())";
|
||||||
$stmt = $this->mysqli->prepare($query);
|
$stmt = $this->mysqli->prepare($query);
|
||||||
$stmt->bind_param("ii", $maestroID, $playerID);
|
$stmt->bind_param("iii", $maestroID, $playerID, $writingID);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bind_result($typingExamRecordID, $record);
|
$stmt->bind_result($typingExamRecordID, $record);
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ class TypingExamCollection extends DBMethodContainer
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHighestRecordForWriting($maestroID, $playerID, $writingID)
|
public function getHighestRecord($maestroID, $playerID, $writingID)
|
||||||
{
|
{
|
||||||
$query = "
|
$query = "
|
||||||
SELECT TypingExamHighestRecordID, WritingID, HighestRecord
|
SELECT TypingExamHighestRecordID, WritingID, HighestRecord
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ include "./../db/typing_exam_collection.php";
|
|||||||
|
|
||||||
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
$typingExam = new TypingExamCollection($dbConnector->getMysqli());
|
||||||
|
|
||||||
$highestRecordData = $typingExam->getHighestRecordForWriting($maestroID, $playerID, $writingID);
|
$highestRecordData = $typingExam->getHighestRecord($maestroID, $playerID, $writingID);
|
||||||
$jsonBuilder->setData("highestRecordData", $highestRecordData);
|
$jsonBuilder->setData("highestRecordData", $highestRecordData);
|
||||||
|
|
||||||
if ($highestRecordData === null) {
|
if ($highestRecordData === null) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ if (isset($isPrevHourFlag)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
addHighestRecord($maestroID, $playerID, $writingID, $record);
|
updateRecord($maestroID, $playerID, $writingID, $record);
|
||||||
updateHighestRecord($maestroID, $playerID, $writingID, $record);
|
updateHighestRecord($maestroID, $playerID, $writingID, $record);
|
||||||
|
|
||||||
$jsonBuilder->sendResultSuccess();
|
$jsonBuilder->sendResultSuccess();
|
||||||
@@ -49,19 +49,19 @@ function addPrevHourRecord($maestroID, $playerID, $writingID, $record)
|
|||||||
// $jsonBuilder->setData("prevHourRecord", "added");
|
// $jsonBuilder->setData("prevHourRecord", "added");
|
||||||
}
|
}
|
||||||
|
|
||||||
function addHighestRecord($maestroID, $playerID, $writingID, $record)
|
function updateRecord($maestroID, $playerID, $writingID, $record)
|
||||||
{
|
{
|
||||||
global $typingExam, $jsonBuilder;
|
global $typingExam, $jsonBuilder;
|
||||||
|
|
||||||
$thisHourRecordData = $typingExam->getThisHourRecord($maestroID, $playerID);
|
$thisHourRecordData = $typingExam->getThisHourRecord($maestroID, $playerID, $writingID);
|
||||||
// $jsonBuilder->setData("thisHourRecordData", $thisHourRecordData);
|
// $jsonBuilder->setData("thisHourRecordData", $thisHourRecordData);
|
||||||
if ($thisHourRecordData["record"] === null) {
|
if ($thisHourRecordData["record"] === null) {
|
||||||
$typingExam->addRecord($maestroID, $playerID, $writingID, $record);
|
$typingExam->addRecord($maestroID, $playerID, $writingID, $record);
|
||||||
// $jsonBuilder->setData("record", "added : ".$record);
|
$jsonBuilder->setData("record", "added : ".$record);
|
||||||
} else {
|
} else {
|
||||||
if ($record > $thisHourRecordData["record"]) {
|
if ($record > $thisHourRecordData["record"]) {
|
||||||
$typingExam->updateRecord($thisHourRecordData["typingExamRecordID"], $record);
|
$typingExam->updateRecord($thisHourRecordData["typingExamRecordID"], $record);
|
||||||
// $jsonBuilder->setData("record", "updated : ".$record);
|
$jsonBuilder->setData("record", "updated : ".$record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ function updateHighestRecord($maestroID, $playerID, $writingID, $record)
|
|||||||
{
|
{
|
||||||
global $typingExam, $jsonBuilder;
|
global $typingExam, $jsonBuilder;
|
||||||
|
|
||||||
$highestRecordData = $typingExam->getHighestRecordForWriting($maestroID, $playerID, $writingID);
|
$highestRecordData = $typingExam->getHighestRecord($maestroID, $playerID, $writingID);
|
||||||
// $jsonBuilder->setData("highestRecordData", $highestRecordData);
|
// $jsonBuilder->setData("highestRecordData", $highestRecordData);
|
||||||
if ($highestRecordData["highestRecord"] === null) {
|
if ($highestRecordData["highestRecord"] === null) {
|
||||||
$typingExam->addHighestRecord($maestroID, $playerID, $writingID, $record);
|
$typingExam->addHighestRecord($maestroID, $playerID, $writingID, $record);
|
||||||
|
|||||||
+7
-7
@@ -122,7 +122,7 @@ QUnit.test( "TypingExamDB", function( assert ) {
|
|||||||
WRITING_ID, //writingRecord
|
WRITING_ID, //writingRecord
|
||||||
RECORD - 10, // record
|
RECORD - 10, // record
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
updateTypingExamRecord2();
|
updateTypingExamRecord2();
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
(function(jsonData) { // onFailed
|
(function(jsonData) { // onFailed
|
||||||
@@ -138,11 +138,11 @@ QUnit.test( "TypingExamDB", function( assert ) {
|
|||||||
WRITING_ID, //writingRecord
|
WRITING_ID, //writingRecord
|
||||||
RECORD, // record
|
RECORD, // record
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
getTypingExamHighestRecord();
|
getTypingExamHighestRecord();
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
(function(jsonData) { // onFailed
|
(function(jsonData) { // onFailed
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ QUnit.test( "TypingExamDB", function( assert ) {
|
|||||||
dbService.getTypingExamHighestRecord(
|
dbService.getTypingExamHighestRecord(
|
||||||
WRITING_ID,
|
WRITING_ID,
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
|
|
||||||
var highestRecord = jsonData["highestRecordData"];
|
var highestRecord = jsonData["highestRecordData"];
|
||||||
assert.equal(highestRecord["highestRecord"], RECORD + 10, "highest record");
|
assert.equal(highestRecord["highestRecord"], RECORD + 10, "highest record");
|
||||||
@@ -175,11 +175,11 @@ QUnit.test( "TypingExamDB", function( assert ) {
|
|||||||
WRITING_ID, //writingRecord
|
WRITING_ID, //writingRecord
|
||||||
RECORD + 20, // record
|
RECORD + 20, // record
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
getTypingExamHighestRecord2();
|
getTypingExamHighestRecord2();
|
||||||
}).bind(this),
|
}).bind(this),
|
||||||
(function(jsonData) { // onFailed
|
(function(jsonData) { // onFailed
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
done();
|
done();
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
@@ -190,7 +190,7 @@ QUnit.test( "TypingExamDB", function( assert ) {
|
|||||||
dbService.getTypingExamHighestRecord(
|
dbService.getTypingExamHighestRecord(
|
||||||
WRITING_ID,
|
WRITING_ID,
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
|
|
||||||
var highestRecord = jsonData["highestRecordData"];
|
var highestRecord = jsonData["highestRecordData"];
|
||||||
assert.equal(highestRecord["highestRecord"], RECORD + 20, "highest record");
|
assert.equal(highestRecord["highestRecord"], RECORD + 20, "highest record");
|
||||||
|
|||||||
Reference in New Issue
Block a user