update csv
This commit is contained in:
parent
cdae1c9c85
commit
3e28b0d1f0
9
.idea/workspace.xml
generated
9
.idea/workspace.xml
generated
@ -2,11 +2,12 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/IDManager.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data/questionare.xlsx" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.xlsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pyExcel.py" beforeDir="false" afterPath="$PROJECT_DIR$/pyExcel.py" 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/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>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -105,7 +106,7 @@
|
||||
<workItem from="1666752468427" duration="1563000" />
|
||||
<workItem from="1667205217155" duration="3357000" />
|
||||
<workItem from="1667357110859" duration="5735000" />
|
||||
<workItem from="1667456828218" duration="6141000" />
|
||||
<workItem from="1667456828218" duration="10885000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -124,6 +125,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<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="" />
|
||||
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1667476942264" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||
</component>
|
||||
</project>
|
4
IDManager.py
Normal file
4
IDManager.py
Normal file
@ -0,0 +1,4 @@
|
||||
class idManager():
|
||||
|
||||
def getLevels(self,ip):
|
||||
return ["test1","test2"]
|
BIN
__pycache__/IDManager.cpython-39.pyc
Normal file
BIN
__pycache__/IDManager.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
7
data/questionare.csv
Normal file
7
data/questionare.csv
Normal file
@ -0,0 +1,7 @@
|
||||
127.0.0.1,D,A,D
|
||||
127.0.0.1,A,B,D
|
||||
127.0.0.1,A,B,D
|
||||
127.0.0.1,D,A,A
|
||||
127.0.0.1,A,A,B
|
||||
127.0.0.1,C,A,A
|
||||
127.0.0.1,D,A,B
|
|
Binary file not shown.
34
main.py
34
main.py
@ -1,14 +1,16 @@
|
||||
import os
|
||||
from pyExcel import ExcelWork
|
||||
import csv
|
||||
from IDManager import idManager
|
||||
|
||||
from flask import Flask, render_template, request, redirect, url_for
|
||||
|
||||
app = Flask(__name__, static_folder='')
|
||||
idm = idManager()
|
||||
|
||||
replayDataPath = "reps/"
|
||||
evalDataPath = "evals/"
|
||||
|
||||
questionarePath = "data/questionare.xlsx"
|
||||
questionarePath = "data/questionare.csv"
|
||||
|
||||
|
||||
@app.route('/annotation')
|
||||
@ -22,15 +24,16 @@ def gamepreplay():
|
||||
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)
|
||||
write_csv(questionarePath,[ip,result.get("gamestyle"),result.get("frequency"),result.get("age")])
|
||||
# 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))
|
||||
|
||||
@ -42,8 +45,8 @@ def gamequestion():
|
||||
|
||||
@app.route('/gameplay/<id>')
|
||||
def gameplay(id):
|
||||
print(id)
|
||||
return render_template('GamePlay.html')
|
||||
gamelevels = idm.getLevels(id)
|
||||
return render_template('GamePlay.html',gamelevels = gamelevels)
|
||||
|
||||
|
||||
@app.route('/annotation/<id>')
|
||||
@ -78,7 +81,10 @@ def saveFile(path, filename, content):
|
||||
f = open(file_path, "w", encoding="utf8")
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
def write_csv(path, data):
|
||||
with open(path,'a+') as f:
|
||||
csv_write = csv.writer(f)
|
||||
csv_write.writerow(data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
|
@ -234,7 +234,7 @@
|
||||
<div class="col-md-2"></div>
|
||||
|
||||
<div class="col-md-5">
|
||||
<h4>Level A Review</h4>
|
||||
<h4>Level B Review</h4>
|
||||
<p style="color:darkgrey">Drag Picture To Move</p>
|
||||
|
||||
<div style="overflow-x: scroll; height: 350px;" >
|
||||
|
@ -207,13 +207,15 @@
|
||||
return element;
|
||||
}*/
|
||||
var divElement = document.getElementById("GameWindow");
|
||||
var level1 = "test1";
|
||||
var level2 = "test2";
|
||||
cheerpjCreateDisplay(500,500,divElement);
|
||||
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
|
||||
console.log("Cheerpj Initialize Succeed!");
|
||||
|
||||
PlayLevel("test1", "test1")
|
||||
|
||||
PlayLevel(level1, level1)
|
||||
.then(function (){alert("Game Over!")})
|
||||
.then(PlayLevel("test2", "test2")
|
||||
.then(PlayLevel(level2, level2)
|
||||
.then(function (){
|
||||
alert("Go to Evaluation Window")
|
||||
window.location.href = "/annotation"
|
||||
|
@ -63,4 +63,18 @@ function PlayLevel(group, level){
|
||||
// var addressID = $("input[name='sex']:checked").val();
|
||||
// alert(addressID)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getLevels(){
|
||||
var gameLevelstr = "{{gamelevels}}";
|
||||
var levels = gameLevelstr.split(",")
|
||||
levels.replace("'","")
|
||||
gameLevels.replace("[","")
|
||||
gameLevels.replace("]","")
|
||||
|
||||
console.log(levels);
|
||||
console.log(levels[0]);
|
||||
var level1 = "test1";
|
||||
var level2 = "test2";
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user