Add Questionare & Excel Saving
This commit is contained in:
parent
49ca55bfb5
commit
cdae1c9c85
15
.idea/workspace.xml
generated
15
.idea/workspace.xml
generated
@ -2,14 +2,12 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
|
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/pyExcel.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Mario-AI-Interface/reps/f_l_sav.rep" beforeDir="false" afterPath="$PROJECT_DIR$/Mario-AI-Interface/reps/f_l_sav.rep" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/reps/1.txt" beforeDir="false" afterPath="$PROJECT_DIR$/reps/1.txt" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pyExcel.py" beforeDir="false" afterPath="$PROJECT_DIR$/pyExcel.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/reps/2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/reps/2.txt" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation.html" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/templates/GamePlay.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GamePlay.html" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/templates/GamePlay.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GamePlay.html" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/templates/GameQuestion.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameQuestion.html" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/templates/data.js" beforeDir="false" afterPath="$PROJECT_DIR$/templates/data.js" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -82,6 +80,10 @@
|
|||||||
<option name="launchJavascriptDebuger" value="false" />
|
<option name="launchJavascriptDebuger" value="false" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Flask server.Flask (main.py)" />
|
||||||
|
<item itemvalue="Python.MarioWeb" />
|
||||||
|
</list>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Flask server.Flask (main.py)" />
|
<item itemvalue="Flask server.Flask (main.py)" />
|
||||||
@ -103,6 +105,7 @@
|
|||||||
<workItem from="1666752468427" duration="1563000" />
|
<workItem from="1666752468427" duration="1563000" />
|
||||||
<workItem from="1667205217155" duration="3357000" />
|
<workItem from="1667205217155" duration="3357000" />
|
||||||
<workItem from="1667357110859" duration="5735000" />
|
<workItem from="1667357110859" duration="5735000" />
|
||||||
|
<workItem from="1667456828218" duration="6141000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -121,6 +124,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1667362305523" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1667466353217" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
Binary file not shown.
BIN
__pycache__/pyExcel.cpython-39.pyc
Normal file
BIN
__pycache__/pyExcel.cpython-39.pyc
Normal file
Binary file not shown.
BIN
data/questionare.xlsx
Normal file
BIN
data/questionare.xlsx
Normal file
Binary file not shown.
64
main.py
64
main.py
@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
from pyExcel import ExcelWork
|
||||||
|
|
||||||
from flask import Flask, render_template, request, redirect, url_for
|
from flask import Flask, render_template, request, redirect, url_for
|
||||||
|
|
||||||
@ -8,40 +8,78 @@ app = Flask(__name__, static_folder='')
|
|||||||
replayDataPath = "reps/"
|
replayDataPath = "reps/"
|
||||||
evalDataPath = "evals/"
|
evalDataPath = "evals/"
|
||||||
|
|
||||||
@app.route('/gameplay')
|
questionarePath = "data/questionare.xlsx"
|
||||||
def gameplay():
|
|
||||||
|
|
||||||
|
@app.route('/annotation')
|
||||||
|
def gamepreanno():
|
||||||
|
return redirect(url_for('gameanno', id=request.remote_addr))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/result', methods=['POST', 'GET'])
|
||||||
|
def gamepreplay():
|
||||||
|
if request.method == 'POST':
|
||||||
|
result = request.form
|
||||||
|
ip = request.remote_addr
|
||||||
|
# Save the result to questionare
|
||||||
|
excel = ExcelWork(questionarePath)
|
||||||
|
questionareLine = excel.getMaxRow()+1
|
||||||
|
print(questionareLine)
|
||||||
|
excel.setCell(questionareLine,1,ip)
|
||||||
|
excel.setCell(questionareLine, 2, result.get("gamestyle"))
|
||||||
|
excel.setCell(questionareLine, 3, result.get("frequency"))
|
||||||
|
excel.setCell(questionareLine, 4, result.get("age"))
|
||||||
|
excel.saveFile()
|
||||||
|
print(questionareLine)
|
||||||
|
print(result.get("gamestyle"))
|
||||||
|
return redirect(url_for('gameplay', id=ip))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def gamequestion():
|
||||||
|
return render_template('GameQuestion.html')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/gameplay/<id>')
|
||||||
|
def gameplay(id):
|
||||||
|
print(id)
|
||||||
return render_template('GamePlay.html')
|
return render_template('GamePlay.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/gameanno')
|
@app.route('/annotation/<id>')
|
||||||
def gameanno():
|
def gameanno(id):
|
||||||
|
print("anno " + id)
|
||||||
return render_template('GameAnnotation.html')
|
return render_template('GameAnnotation.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/gameplay', methods=['POST'])
|
#
|
||||||
def getJSONData():
|
@app.route('/gameplay/<id>/data', methods=['POST'])
|
||||||
|
def getJSONData(id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("POST Game")
|
print("POST Game")
|
||||||
print(request.json)
|
print(request.values)
|
||||||
saveFile(replayDataPath, request.json[4], request.json)
|
saveFile(replayDataPath, request.json[4], request.json)
|
||||||
return "Catch JSON Data"
|
return "Catch JSON Data"
|
||||||
|
|
||||||
@app.route('/gameanno', methods=['POST'])
|
|
||||||
def getRadioData():
|
@app.route('/annotation/<id>/data', methods=['POST'])
|
||||||
|
def getRadioData(id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
print("POST Eval")
|
print("POST Eval")
|
||||||
print(request.values)
|
print(request.values)
|
||||||
|
|
||||||
#saveFile(evalDataPath,"gameanno",request.json[0]+request.json[1]+request.json[2])
|
# saveFile(evalDataPath,"gameanno",request.json[0]+request.json[1]+request.json[2])
|
||||||
return "catch Radio"
|
return "catch Radio"
|
||||||
|
|
||||||
def saveFile(path,filename,content):
|
|
||||||
|
def saveFile(path, filename, content):
|
||||||
file_dir = os.path.join(os.getcwd(), path)
|
file_dir = os.path.join(os.getcwd(), path)
|
||||||
file_path = os.path.join(file_dir, filename+".txt")
|
file_path = os.path.join(file_dir, filename + ".txt")
|
||||||
f = open(file_path, "w", encoding="utf8")
|
f = open(file_path, "w", encoding="utf8")
|
||||||
f.write(content)
|
f.write(content)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.debug = True
|
app.debug = True
|
||||||
app.run()
|
app.run()
|
||||||
|
@ -119,3 +119,8 @@ class ExcelWork:
|
|||||||
for temp in range(1, self.sheet.max_row + 1):
|
for temp in range(1, self.sheet.max_row + 1):
|
||||||
columnList.append(self.getCell(temp, c))
|
columnList.append(self.getCell(temp, c))
|
||||||
return columnList
|
return columnList
|
||||||
|
def getMaxRow(self):
|
||||||
|
return self.sheet.max_row
|
||||||
|
|
||||||
|
def saveFile(self):
|
||||||
|
self.excel.save(self.filePath)
|
@ -216,7 +216,7 @@
|
|||||||
.then(PlayLevel("test2", "test2")
|
.then(PlayLevel("test2", "test2")
|
||||||
.then(function (){
|
.then(function (){
|
||||||
alert("Go to Evaluation Window")
|
alert("Go to Evaluation Window")
|
||||||
window.location.href = window.location.href + "\eval"
|
window.location.href = "/annotation"
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -26,15 +26,20 @@ function getValue(){
|
|||||||
// }
|
// }
|
||||||
// httpRequest.send(JSON.stringify(data)); //设置为发送给服务器数据
|
// httpRequest.send(JSON.stringify(data)); //设置为发送给服务器数据
|
||||||
// }
|
// }
|
||||||
function PostToServer(data) {
|
function PostToServer(url,data) {
|
||||||
$.post(window.location.href, {'key1':'5'});
|
if(url == null){
|
||||||
|
$.post(window.location.href, data);
|
||||||
|
}else{
|
||||||
|
$.post(url, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function PlayLevel(group, level){
|
function PlayLevel(group, level){
|
||||||
var returnVal = cjCall("Play", "playGameMain", group, level);
|
var returnVal = cjCall("Play", "playGameMain", group, level);
|
||||||
return returnVal.then(function(){
|
return returnVal.then(function(){
|
||||||
console.log("the return val is ready");
|
console.log("the return val is ready");
|
||||||
console.log(returnVal.value);
|
console.log(returnVal.value);
|
||||||
PostToServer(level,returnVal.value);
|
PostToServer(window.location.href+"/data",returnVal.value);
|
||||||
|
//Array.from()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user