Add: writing_info.php
This commit is contained in:
@@ -37,8 +37,8 @@ function TypingExamButton(x, y, iconName, buttonText, writingID) {
|
|||||||
|
|
||||||
TypingExamButton.prototype.onClick = function() {
|
TypingExamButton.prototype.onClick = function() {
|
||||||
sessionStorageManager.setWritingID(this.writingID);
|
sessionStorageManager.setWritingID(this.writingID);
|
||||||
// location.href = '../../web/client/typing_examination.html';
|
location.href = '../../web/client/typing_examination.html';
|
||||||
printSessionStorage();
|
// printSessionStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,4 +71,21 @@ DBService.prototype.requestWritingPlayerList = function(onSucceededListener, onF
|
|||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
xhr.send("maestroID=" + this.maestroID + "&playerID=" + this.playerID);
|
xhr.send("maestroID=" + this.maestroID + "&playerID=" + this.playerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
DBService.prototype.requestWritingInfo = function(writingID, onSucceededListener, onFailedListener) {
|
||||||
|
var xhr = this.makeXhr(
|
||||||
|
"php/writing/writing_info.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("writingID=" + writingID);
|
||||||
}
|
}
|
||||||
@@ -109,23 +109,6 @@ var MenuTypingExam = {
|
|||||||
this.downloadListFailed(jsonData);
|
this.downloadListFailed(jsonData);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
var dbConnectManager = new DBConnectManager();
|
|
||||||
dbConnectManager.requestTypingTestAppList(
|
|
||||||
sessionStorageManager.getMaestroID(),
|
|
||||||
sessionStorageManager.getPlayerID(),
|
|
||||||
// self.downloadListSucceeded,
|
|
||||||
// self.downloadListFailed
|
|
||||||
(function(replyJSON) {
|
|
||||||
this.downloadListSucceeded(replyJSON);
|
|
||||||
}).bind(this),
|
|
||||||
(function(replyJSON) {
|
|
||||||
this.downloadListFailed(replyJSON);
|
|
||||||
}).bind(this)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
hasApp: function(appID, appList) {
|
hasApp: function(appID, appList) {
|
||||||
@@ -190,104 +173,8 @@ var MenuTypingExam = {
|
|||||||
indexEnglishWriting++;
|
indexEnglishWriting++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
var buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingExam.BUTTON_GAP;
|
|
||||||
|
|
||||||
var koreanTypingPracticeAppCount = replyJSON.KoreanAppList.length; // Object.keys(replyJSON.KoreanAppList).length;
|
|
||||||
var englishTypingPracticeAppCount = replyJSON.EnglishAppList.length; // Object.keys(replyJSON.EnglishAppList).length;
|
|
||||||
|
|
||||||
for(var i = 0; i < koreanTypingPracticeAppCount; i++) {
|
|
||||||
var activeApp = replyJSON.KoreanAppList[i];
|
|
||||||
|
|
||||||
var posX = this.getButtonPosX(i, koreanTypingPracticeAppCount);
|
|
||||||
var posY = this.getButtonPosY(i, koreanTypingPracticeAppCount,
|
|
||||||
TypingAppButton.BUTTON_UPPER_POS_Y
|
|
||||||
);
|
|
||||||
|
|
||||||
var typingTestButton = new TypingAppButton(
|
|
||||||
TypingAppButton.TYPE_TEST_KOREAN,
|
|
||||||
posX, posY,
|
|
||||||
this.getAnimalSprite(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
|
||||||
activeApp.KoreanName,
|
|
||||||
{
|
|
||||||
AppID: activeApp.AppID,
|
|
||||||
AppName: activeApp.AppName,
|
|
||||||
KoreanName: activeApp.KoreanName
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
|
|
||||||
typingTestButton.setInputEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var i = 0; i < englishTypingPracticeAppCount; i++) {
|
|
||||||
var activeApp = replyJSON.EnglishAppList[i];
|
|
||||||
|
|
||||||
var posX = this.getButtonPosX(i, englishTypingPracticeAppCount);
|
|
||||||
var posY = this.getButtonPosY(i, englishTypingPracticeAppCount,
|
|
||||||
TypingAppButton.BUTTON_LOWER_POS_Y
|
|
||||||
);
|
|
||||||
|
|
||||||
var typingTestButton = new TypingAppButton(
|
|
||||||
TypingAppButton.TYPE_TEST_ENGLISH,
|
|
||||||
posX, posY,
|
|
||||||
this.getAnimalSprite(replyJSON.EnglishHighScoreList, activeApp.AppID),
|
|
||||||
activeApp.KoreanName,
|
|
||||||
{
|
|
||||||
AppID: activeApp.AppID,
|
|
||||||
AppName: activeApp.AppName,
|
|
||||||
KoreanName: activeApp.KoreanName
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
|
|
||||||
typingTestButton.setInputEnabled(false);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getButtonPosX: function(index, buttonCount) {
|
|
||||||
var gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
|
||||||
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
|
|
||||||
// console.log("maxColumnNum : " + maxColumnNum);
|
|
||||||
var rowCount = Math.ceil(buttonCount / maxColumnNum);
|
|
||||||
// console.log("rowCount : " + rowCount);
|
|
||||||
|
|
||||||
var columnIndex = index % maxColumnNum;
|
|
||||||
// console.log("columnIndex : " + columnIndex);
|
|
||||||
var rowIndex = Math.floor(index / maxColumnNum);
|
|
||||||
// console.log("rowIndex : " + rowIndex);
|
|
||||||
|
|
||||||
var columnCountForThisRow = 0;
|
|
||||||
if(rowIndex < rowCount - 1)
|
|
||||||
columnCountForThisRow = maxColumnNum;
|
|
||||||
else
|
|
||||||
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
|
|
||||||
// console.log("columnCountForThisRow : " + columnCountForThisRow);
|
|
||||||
|
|
||||||
var startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
|
|
||||||
return startX + gap * columnIndex;
|
|
||||||
},
|
|
||||||
|
|
||||||
getButtonPosY: function(index, buttonCount, startPosY) {
|
|
||||||
var rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
|
|
||||||
|
|
||||||
var columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
|
||||||
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
|
|
||||||
// console.log("maxColumnNum : " + maxColumnNum);
|
|
||||||
// console.log("buttonCount : " + buttonCount);
|
|
||||||
var rowCount = Math.ceil(buttonCount / maxColumnNum);
|
|
||||||
// console.log("rowCount : " + rowCount);
|
|
||||||
|
|
||||||
var rowIndex = Math.floor(index / maxColumnNum);
|
|
||||||
// console.log("rowIndex : " + rowIndex);
|
|
||||||
|
|
||||||
var startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
|
|
||||||
return startY + rowGap * rowIndex;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
downloadListFailed: function(replyJSON) {
|
downloadListFailed: function(replyJSON) {
|
||||||
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
|
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ var TypingExamination = {
|
|||||||
|
|
||||||
back: function() {
|
back: function() {
|
||||||
sessionStorageManager.resetPlayingAppData();
|
sessionStorageManager.resetPlayingAppData();
|
||||||
location.href = '../../web/client/menu_typing_test.html';
|
location.href = '../../web/client/menu_typing_exam.html';
|
||||||
},
|
},
|
||||||
|
|
||||||
startGame: function() {
|
startGame: function() {
|
||||||
@@ -333,15 +333,33 @@ var TypingExamination = {
|
|||||||
|
|
||||||
|
|
||||||
loadExaminationContent: function() {
|
loadExaminationContent: function() {
|
||||||
var path = "./../../../resources/file/typing_exam/";
|
var dbService = new DBService();
|
||||||
|
dbService.setMaestroID(sessionStorageManager.getMaestroID());
|
||||||
|
dbService.setPlayerID(sessionStorageManager.getPlayerID());
|
||||||
|
|
||||||
// get the writing data from session storage
|
dbService.requestWritingInfo(
|
||||||
// get the writing data from DB
|
sessionStorageManager.getWritingID(),
|
||||||
|
(function(jsonData) { // onSucceeded
|
||||||
|
this.downloadListSucceeded(jsonData);
|
||||||
|
}).bind(this),
|
||||||
|
(function(jsonData) { // onFailed
|
||||||
|
this.downloadListFailed(jsonData);
|
||||||
|
}).bind(this)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
var filename = "korean_heoseng.txt";
|
downloadListSucceeded: function(jsonData) {
|
||||||
var writer = "system";
|
console.log(jsonData);
|
||||||
|
var writingInfo = jsonData["writingInfo"];
|
||||||
|
console.log(writingInfo);
|
||||||
|
|
||||||
|
var writer = writingInfo["writer"];
|
||||||
var writerID = "";
|
var writerID = "";
|
||||||
|
writingInfo["writerID"] == null ? writerID = "" : writerID = writingInfo["writerID"];
|
||||||
|
|
||||||
|
var path = "./../../../resources/file/typing_exam/";
|
||||||
var directory = writer + writerID + "/";
|
var directory = writer + writerID + "/";
|
||||||
|
var filename = writingInfo["filename"];
|
||||||
var url = path + directory + filename;
|
var url = path + directory + filename;
|
||||||
|
|
||||||
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
||||||
@@ -351,6 +369,10 @@ var TypingExamination = {
|
|||||||
game.load.start();
|
game.load.start();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
downloadListFailed: function(jsonData) {
|
||||||
|
console.log(jsonData);
|
||||||
|
},
|
||||||
|
|
||||||
completeLoadingWriting: function() {
|
completeLoadingWriting: function() {
|
||||||
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
||||||
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
|
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<script src="../../game/lib/util/number_util.js"></script>
|
<script src="../../game/lib/util/number_util.js"></script>
|
||||||
<script src="../../game/lib/util/record_util.js"></script>
|
<script src="../../game/lib/util/record_util.js"></script>
|
||||||
|
|
||||||
<script src="../../game/lib/text/input_type_text.js?update=20190622"></script>
|
<script src="../../game/lib/text/input_type_text.js"></script>
|
||||||
<script src="../../game/lib/text/time_over_text.js"></script>
|
<script src="../../game/lib/text/time_over_text.js"></script>
|
||||||
<script src="../../game/lib/text/mission_clear_text.js"></script>
|
<script src="../../game/lib/text/mission_clear_text.js"></script>
|
||||||
<script src="../../game/lib/text/screen_top_ui.js"></script>
|
<script src="../../game/lib/text/screen_top_ui.js"></script>
|
||||||
@@ -57,13 +57,14 @@
|
|||||||
<script src="../../game/lib/button/back_button.js"></script>
|
<script src="../../game/lib/button/back_button.js"></script>
|
||||||
<script src="../../game/lib/button/fullscreen_button.js"></script>
|
<script src="../../game/lib/button/fullscreen_button.js"></script>
|
||||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||||
|
<script src="../../game/lib/db_service.js"></script>
|
||||||
<script src="../../game/lib/experience_app_timer.js"></script>
|
<script src="../../game/lib/experience_app_timer.js"></script>
|
||||||
<script src="../../game/lib/stage_timer.js?update=20190622"></script>
|
<script src="../../game/lib/stage_timer.js"></script>
|
||||||
|
|
||||||
<!-- Examination typing : source files -->
|
<!-- Examination typing : source files -->
|
||||||
<script src="../../game/typing/lib/content_progress.js"></script>
|
<script src="../../game/typing/lib/content_progress.js"></script>
|
||||||
<script src="../../game/typing/lib/typing_text_manager.js?update=20190622"></script>
|
<script src="../../game/typing/lib/typing_text_manager.js"></script>
|
||||||
<!-- <script src="../../game/typing/lib/typing_content_bg.js?update=20190622"></script> -->
|
<!-- <script src="../../game/typing/lib/typing_content_bg.js"></script> -->
|
||||||
<script src="../../game/typing/lib/key_mapper.js"></script>
|
<script src="../../game/typing/lib/key_mapper.js"></script>
|
||||||
<!--
|
<!--
|
||||||
<script src="../../game/typing/lib/key_button.js"></script>
|
<script src="../../game/typing/lib/key_button.js"></script>
|
||||||
|
|||||||
@@ -30,6 +30,29 @@ class WritingCollection extends DBMethodContainer
|
|||||||
return $resultArray;
|
return $resultArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWritingInfo($writingID)
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT Name, Filename, Writer, WriterID
|
||||||
|
FROM writing
|
||||||
|
WHERE WritingID = ?";
|
||||||
|
$stmt = $this->mysqli->prepare($query);
|
||||||
|
$stmt->bind_param("i", $writingID);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->bind_result($name, $filename, $writer, $writerID);
|
||||||
|
|
||||||
|
$stmt->fetch();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
$rowArray = array();
|
||||||
|
$rowArray["name"] = $name;
|
||||||
|
$rowArray["filename"] = $filename;
|
||||||
|
$rowArray["writer"] = $writer;
|
||||||
|
$rowArray["writerID"] = $writerID;
|
||||||
|
|
||||||
|
return $rowArray;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// get parameters from client
|
||||||
|
$writingID = $_POST["writingID"];
|
||||||
|
|
||||||
|
|
||||||
|
include "./../lib/json_builder.php";
|
||||||
|
include "./../lib/connect_db.php";
|
||||||
|
|
||||||
|
$jsonBuilder = new JsonBuilder();
|
||||||
|
$dbConnector = new DBConnector();
|
||||||
|
|
||||||
|
$isConnected = $dbConnector->connectDB();
|
||||||
|
if (!$isConnected) {
|
||||||
|
$jsonBuilder->setErrorMessage("DB connection : failed");
|
||||||
|
$jsonBuilder->sendResultFail();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include "./../db/db_method_container.php";
|
||||||
|
include "./../db/writing_collection.php";
|
||||||
|
|
||||||
|
$writingCollection = new WritingCollection($dbConnector->getMysqli());
|
||||||
|
$writingInfo = $writingCollection->getWritingInfo($writingID);
|
||||||
|
|
||||||
|
// $jsonBuilder->setData("name", $writingInfo["name"]);
|
||||||
|
// $jsonBuilder->setData("filename", $writingInfo["filename"]);
|
||||||
|
// $jsonBuilder->setData("writer", $writingInfo["writer"]);
|
||||||
|
// $jsonBuilder->setData("writerID", $writingInfo["writerID"]);
|
||||||
|
$jsonBuilder->setData("writingInfo", $writingInfo);
|
||||||
|
$jsonBuilder->sendResultSuccess();
|
||||||
|
|
||||||
|
?>
|
||||||
+2
-2
@@ -13,8 +13,8 @@ QUnit.test( "DBConnector", function( assert ) {
|
|||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
|
|
||||||
var writingArray = jsonData["writingArray"];
|
var writingArray = jsonData["writingArray"];
|
||||||
assert.equal(writingArray[0].name, "봄 - 윤동주", "name");
|
assert.equal(writingArray[0].name, "봄2", "name");
|
||||||
assert.equal(writingArray[3].name, "허생전 - 박지원", "name");
|
assert.equal(writingArray[3].name, "허생전", "name");
|
||||||
done();
|
done();
|
||||||
},
|
},
|
||||||
(jsonData) => { // onFailed
|
(jsonData) => { // onFailed
|
||||||
|
|||||||
Reference in New Issue
Block a user