diff --git a/src/game/lib/db_service.js b/src/game/lib/db_service.js
index 9056e8f..b0cd394 100644
--- a/src/game/lib/db_service.js
+++ b/src/game/lib/db_service.js
@@ -149,6 +149,7 @@ DBService.prototype.requestWritingInfo = function(writingID, onSucceededListener
// typing exam
DBService.prototype.addPrevHourTypingExamRecord = function(writingID, record, onSucceededListener, onFailedListener) {
+ // addPrevHourTypingExamRecord is for only TDD
var xhr = this.makeXhr(
"php/record/update_typing_exam_record.php",
(function() { // onreadystatechange
diff --git a/src/game/typing/examination/game.js b/src/game/typing/examination/game.js
index ac9d5e0..13e4d7c 100644
--- a/src/game/typing/examination/game.js
+++ b/src/game/typing/examination/game.js
@@ -365,6 +365,8 @@ TypingExamination.prototype.startGame = function() {
TypingExamination.prototype.timeOver = function() {
var timeOverText = new TimeOverText();
sessionStorageManager.setRecord(-1 * this.typingRecordTotal);
+ if(!isExperienceMaestroAccount())
+ this.updateResultRecord();
this.stopAndGoResult();
}
diff --git a/src/web/module/maestro_section_record.html b/src/web/module/maestro_section_record.html
index 4d912e3..f1a4551 100644
--- a/src/web/module/maestro_section_record.html
+++ b/src/web/module/maestro_section_record.html
@@ -315,16 +315,29 @@ function showNoResultContent() {
');
}
-function addRecordListItem($date, $time, $name, $subject, $record) {
- $("#record_table_content").append('\
-
\
- | ' + $date + ' | \
- ' + $time + ' | \
- ' + $name + ' | \
- ' + $subject + ' | \
- ' + $record + ' | \
-
\
- ');
+function addRecordListItem(date, time, name, subject, record) {
+ if(record >= 0) {
+ $("#record_table_content").append('\
+ \
+ | ' + date + ' | \
+ ' + time + ' | \
+ ' + name + ' | \
+ ' + subject + ' | \
+ ' + record + ' | \
+
\
+ ');
+ } else {
+ var disqualificationRecord = -1 * record;
+ $("#record_table_content").append('\
+ \
+ | ' + date + ' | \
+ ' + time + ' | \
+ ' + name + ' | \
+ ' + subject + ' | \
+ (실격) ' + disqualificationRecord + ' | \
+
\
+ ');
+ }
}
diff --git a/src/web/php/record/update_typing_exam_record.php b/src/web/php/record/update_typing_exam_record.php
index 4ae2d09..9aa1500 100644
--- a/src/web/php/record/update_typing_exam_record.php
+++ b/src/web/php/record/update_typing_exam_record.php
@@ -6,6 +6,7 @@ $playerID = $_POST["playerID"];
$writingID = $_POST["writingID"];
$record = $_POST["record"];
$isPrevHourFlag = $_POST["isPrevHourFlag"];
+// $isPrevHourFlag is for only TDD (addPrevHourTypingExamRecord)
include "./../lib/json_builder.php";
include "./../lib/connect_db.php";
@@ -28,13 +29,19 @@ $typingExam = new TypingExamCollection($dbConnector->getMysqli());
if (isset($isPrevHourFlag)) {
addPrevHourRecord($maestroID, $playerID, $writingID, $record);
- updateHighestRecord($maestroID, $playerID, $writingID, $record);
+ if($record >= 0) {
+ updateHighestRecord($maestroID, $playerID, $writingID, $record);
+ }
$jsonBuilder->sendResultSuccess();
exit;
}
-updateRecord($maestroID, $playerID, $writingID, $record);
-updateHighestRecord($maestroID, $playerID, $writingID, $record);
+if($record >= 0) {
+ updateRecord($maestroID, $playerID, $writingID, $record);
+ updateHighestRecord($maestroID, $playerID, $writingID, $record);
+} else {
+ updateMinusRecord($maestroID, $playerID, $writingID, $record);
+}
$jsonBuilder->sendResultSuccess();
@@ -82,4 +89,26 @@ function updateHighestRecord($maestroID, $playerID, $writingID, $record)
}
}
}
+
+function updateMinusRecord($maestroID, $playerID, $writingID, $minusRecord)
+{
+ global $typingExam, $jsonBuilder;
+
+ $record = -1 * $minusRecord;
+ $thisHourRecordData = $typingExam->getThisHourRecord($maestroID, $playerID, $writingID);
+ // $jsonBuilder->setData("thisHourRecordData", $thisHourRecordData);
+ if ($thisHourRecordData["record"] === null) {
+ $typingExam->addRecord($maestroID, $playerID, $writingID, $minusRecord);
+ // $jsonBuilder->setData("record", "added : ".$record);
+ } else {
+ if($thisHourRecordData["record"] < 0) {
+ if ($minusRecord < $thisHourRecordData["record"]) { // ex : -300 < -100
+ $typingExam->updateRecord($thisHourRecordData["typingExamRecordID"], $minusRecord);
+ // $jsonBuilder->setData("record", "updated : ".$record);
+ }
+ }
+
+ // if $thisHourRecordData["record"] >= 0 then do nothing
+ }
+}
?>
\ No newline at end of file
diff --git a/test/tdd.js b/test/tdd.js
index ac6ea47..cb8be4c 100644
--- a/test/tdd.js
+++ b/test/tdd.js
@@ -93,7 +93,7 @@ QUnit.test( "AppList", function( assert ) {
(function(jsonData) {
assert.equal(jsonData.appGroup, appGroup, "#0 appGroup : typing practice, English");
assert.equal(jsonData.appData.appList.length, 7, "appList");
- assert.equal(jsonData.appData.activeAppList.length, 5, "activeAppList");
+ assert.equal(jsonData.appData.activeAppList.length, 6, "activeAppList");
assert.equal(jsonData.appData.highestRecordList.length, 7, "highestRecordList");
asyncTypingPracticeEnglish();
}).bind(this),
@@ -462,6 +462,159 @@ QUnit.test( "TypingExamDB", function( assert ) {
});
+//////////////////////////////////////////////////
+// typing exam DB - minus record
+
+QUnit.test( "TypingExamDB - minus record", function( assert ) {
+ var MAESTRO_ID = 3; // 삼화초
+ var PLAYER_ID = 35; // 박지상
+ var WRITING_ID = 1;
+ var RECORD = -117.89;
+
+ var dbService = new DBService();
+ dbService.setMaestroID(MAESTRO_ID);
+ dbService.setPlayerID(PLAYER_ID);
+
+ dbService.tddSetup(
+ "deleteWritingRecordAll",
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+ addPrevHourTypingExamRecord();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ }).bind(this)
+ );
+
+ function addPrevHourTypingExamRecord()
+ {
+ console.log("record : " + RECORD);
+ dbService.addPrevHourTypingExamRecord(
+ WRITING_ID, //writingRecord
+ RECORD, // record : -117.89
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+ updateTypingExamRecord();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ }).bind(this)
+ );
+ }
+
+ // add this hour record + 10
+ function updateTypingExamRecord()
+ {
+ console.log("record : " + (RECORD + 20));
+ dbService.updateTypingExamRecord(
+ WRITING_ID, //writingRecord
+ RECORD + 20, // record
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+ updateTypingExamRecord2();
+
+ // getTypingExamRecord();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ }).bind(this)
+ );
+ }
+
+ // update this hour record
+ function updateTypingExamRecord2()
+ {
+ dbService.updateTypingExamRecord(
+ WRITING_ID, //writingRecord
+ RECORD, // record
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+ getTypingExamHighestRecord();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ }).bind(this)
+ );
+ }
+
+ var done = assert.async();
+ function getTypingExamRecord() {
+ setTimeout(function() {
+ dbService.getTypingExamHighestRecord(
+ WRITING_ID,
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+
+ var highestRecord = jsonData["highestRecordData"];
+ assert.equal(highestRecord["highestRecord"], 0, "highest record");
+ updateTypingExamRecord3();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ done();
+ }).bind(this)
+ );
+ });
+ }
+ function getTypingExamHighestRecord()
+ {
+ setTimeout(function() {
+ dbService.getTypingExamHighestRecord(
+ WRITING_ID,
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+
+ var highestRecord = jsonData["highestRecordData"];
+ assert.equal(highestRecord["highestRecord"], null, "highest record");
+ updateTypingExamRecord3();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ done();
+ }).bind(this)
+ );
+ });
+ }
+
+ // update this hour record
+ function updateTypingExamRecord3()
+ {
+ console.log("record : " + (RECORD - 10));
+ dbService.updateTypingExamRecord(
+ WRITING_ID, //writingRecord
+ RECORD - 10, // record
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+ getTypingExamHighestRecord2();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ done();
+ }).bind(this)
+ );
+ }
+
+ function getTypingExamHighestRecord2()
+ {
+ dbService.getTypingExamHighestRecord(
+ WRITING_ID,
+ (function(jsonData) { // onSucceeded
+ // console.log(jsonData);
+
+ var highestRecord = jsonData["highestRecordData"];
+ assert.equal(highestRecord["highestRecord"], null, "highest record");
+ done();
+ }).bind(this),
+ (function(jsonData) { // onFailed
+ // console.log(jsonData);
+ done();
+ }).bind(this)
+ );
+ }
+
+});
+
+
//////////////////////////////////////////////////
// DBConnector