Add: regist minus record for typing exam

This commit is contained in:
2019-09-26 17:44:11 +09:00
parent 6af26fb926
commit 76481a4caa
5 changed files with 212 additions and 14 deletions
+1
View File
@@ -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
+2
View File
@@ -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();
}
+23 -10
View File
@@ -315,16 +315,29 @@ function showNoResultContent() {
');
}
function addRecordListItem($date, $time, $name, $subject, $record) {
$("#record_table_content").append('\
<tr>\
<th scope="row" class="text-center">' + $date + '</th>\
<td class="text-center">' + $time + '</td>\
<td class="text-center">' + $name + '</td>\
<td class="text-center">' + $subject + '</td>\
<td class="text-right">' + $record + '</td>\
</tr>\
');
function addRecordListItem(date, time, name, subject, record) {
if(record >= 0) {
$("#record_table_content").append('\
<tr>\
<th scope="row" class="text-center">' + date + '</th>\
<td class="text-center">' + time + '</td>\
<td class="text-center">' + name + '</td>\
<td class="text-center">' + subject + '</td>\
<td class="text-right">' + record + '</td>\
</tr>\
');
} else {
var disqualificationRecord = -1 * record;
$("#record_table_content").append('\
<tr>\
<th scope="row" class="text-center">' + date + '</th>\
<td class="text-center">' + time + '</td>\
<td class="text-center">' + name + '</td>\
<td class="text-center">' + subject + '</td>\
<td class="text-right text-danger">(실격) ' + disqualificationRecord + '</td>\
</tr>\
');
}
}
</script>
@@ -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
}
}
?>