Add: writing exam - save and update record (incompleted)

This commit is contained in:
2019-07-15 09:50:08 +09:00
parent 5d1090e652
commit cfb843f91c
7 changed files with 447 additions and 10 deletions
+88 -3
View File
@@ -6,7 +6,7 @@ function DBService() {
this.maestroID = 0;
this.playerID = 0;
this.appName = "";
this.dateAndTime = null;
this.dateTime = null;
}
DBService.prototype.getPath = function() {
@@ -39,11 +39,11 @@ DBService.prototype.setAppName = function(appName) {
}
DBService.prototype.setDateTime = function(date, time) {
this.dateAndTime = date + time;
this.dateTime = date + time;
}
DBService.prototype.resetDateTime = function() {
this.dateAndTime = null;
this.dateTime = null;
}
@@ -56,6 +56,25 @@ DBService.prototype.makeXhr = function(filepath, onreadystatechange) {
return xhr;
}
// tdd setup
DBService.prototype.tddSetup = function(command, onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/db/tdd_setup.php",
(function() { // onreadystatechange
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
}).bind(this)
);
xhr.send("command=" + command);
}
// writing
DBService.prototype.requestWritingPlayerList = function(onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/writing/player_list.php",
@@ -88,4 +107,70 @@ DBService.prototype.requestWritingInfo = function(writingID, onSucceededListener
}).bind(this)
);
xhr.send("writingID=" + writingID);
}
// typing exam
DBService.prototype.addPrevHourTypingExamRecord = function(writingID, record, onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/writing/update_result_record.php",
(function() { // onreadystatechange
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
}).bind(this)
);
xhr.send(
"maestroID=" + this.maestroID
+ "&playerID=" + this.playerID
+ "&writingID=" + writingID
+ "&record=" + record
+ "&isPrevHourFlag=true"
);
}
DBService.prototype.updateTypingExamRecord = function(writingID, record, onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/writing/update_result_record.php",
(function() { // onreadystatechange
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
}).bind(this)
);
xhr.send(
"maestroID=" + this.maestroID
+ "&playerID=" + this.playerID
+ "&writingID=" + writingID
+ "&record=" + record
);
}
DBService.prototype.getHighestRecord = function(onSucceededListener, onFailedListener) {
var xhr = this.makeXhr(
"php/writing/get_highest_record.php",
(function() { // onreadystatechange
if(xhr.readyState == 4 && xhr.status == 200) {
var replyJSON = JSON.parse(xhr.responseText);
if(replyJSON != null)
onSucceededListener(replyJSON);
else
onFailedListener(replyJSON);
}
}).bind(this)
);
xhr.send(
"maestroID=" + this.maestroID
+ "&playerID=" + this.playerID
);
}
+14 -6
View File
@@ -17,7 +17,11 @@ var TypingExamination = {
this.dbConnectManager = new DBConnectManager();
// this.dbConnectManager = new DBConnectManager();
this.dbService = new DBService();
this.dbService.setMaestroID(sessionStorageManager.getMaestroID());
this.dbService.setPlayerID(sessionStorageManager.getPlayerID());
sessionStorageManager.setRecord(0);
var self = this;
@@ -304,12 +308,20 @@ var TypingExamination = {
updateResultRecord: function() {
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
this.dbService.updateTypingExamRecord(
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
sessionStorageManager.getPlayingAppID(),
sessionStorageManager.getRecord()
);
/*
this.dbConnectManager.updateResultRecord(
sessionStorageManager.getMaestroID(),
sessionStorageManager.getPlayerID(),
sessionStorageManager.getPlayingAppID(),
sessionStorageManager.getRecord()
);
*/
}
},
@@ -333,11 +345,7 @@ var TypingExamination = {
loadExaminationContent: function() {
var dbService = new DBService();
dbService.setMaestroID(sessionStorageManager.getMaestroID());
dbService.setPlayerID(sessionStorageManager.getPlayerID());
dbService.requestWritingInfo(
this.dbService.requestWritingInfo(
sessionStorageManager.getWritingID(),
(function(jsonData) { // onSucceeded
this.downloadListSucceeded(jsonData);