update csv

This commit is contained in:
bigJIU 2022-11-03 20:03:04 +08:00
parent cdae1c9c85
commit 3e28b0d1f0
10 changed files with 57 additions and 23 deletions

9
.idea/workspace.xml generated
View File

@ -2,11 +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$/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$/.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$/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/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" /> <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" />
@ -105,7 +106,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" /> <workItem from="1667456828218" duration="10885000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -124,6 +125,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="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> </component>
</project> </project>

4
IDManager.py Normal file
View File

@ -0,0 +1,4 @@
class idManager():
def getLevels(self,ip):
return ["test1","test2"]

Binary file not shown.

Binary file not shown.

7
data/questionare.csv Normal file
View 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
1 127.0.0.1 D A D
2 127.0.0.1 A B D
3 127.0.0.1 A B D
4 127.0.0.1 D A A
5 127.0.0.1 A A B
6 127.0.0.1 C A A
7 127.0.0.1 D A B

Binary file not shown.

34
main.py
View File

@ -1,14 +1,16 @@
import os import os
from pyExcel import ExcelWork import csv
from IDManager import idManager
from flask import Flask, render_template, request, redirect, url_for from flask import Flask, render_template, request, redirect, url_for
app = Flask(__name__, static_folder='') app = Flask(__name__, static_folder='')
idm = idManager()
replayDataPath = "reps/" replayDataPath = "reps/"
evalDataPath = "evals/" evalDataPath = "evals/"
questionarePath = "data/questionare.xlsx" questionarePath = "data/questionare.csv"
@app.route('/annotation') @app.route('/annotation')
@ -22,15 +24,16 @@ def gamepreplay():
result = request.form result = request.form
ip = request.remote_addr ip = request.remote_addr
# Save the result to questionare # Save the result to questionare
excel = ExcelWork(questionarePath) write_csv(questionarePath,[ip,result.get("gamestyle"),result.get("frequency"),result.get("age")])
questionareLine = excel.getMaxRow()+1 # excel = ExcelWork(questionarePath)
print(questionareLine) # questionareLine = excel.getMaxRow()+1
excel.setCell(questionareLine,1,ip) # print(questionareLine)
excel.setCell(questionareLine, 2, result.get("gamestyle")) # excel.setCell(questionareLine,1,ip)
excel.setCell(questionareLine, 3, result.get("frequency")) # excel.setCell(questionareLine, 2, result.get("gamestyle"))
excel.setCell(questionareLine, 4, result.get("age")) # excel.setCell(questionareLine, 3, result.get("frequency"))
excel.saveFile() # excel.setCell(questionareLine, 4, result.get("age"))
print(questionareLine) # excel.saveFile()
# print(questionareLine)
print(result.get("gamestyle")) print(result.get("gamestyle"))
return redirect(url_for('gameplay', id=ip)) return redirect(url_for('gameplay', id=ip))
@ -42,8 +45,8 @@ def gamequestion():
@app.route('/gameplay/<id>') @app.route('/gameplay/<id>')
def gameplay(id): def gameplay(id):
print(id) gamelevels = idm.getLevels(id)
return render_template('GamePlay.html') return render_template('GamePlay.html',gamelevels = gamelevels)
@app.route('/annotation/<id>') @app.route('/annotation/<id>')
@ -78,7 +81,10 @@ def saveFile(path, filename, content):
f = open(file_path, "w", encoding="utf8") f = open(file_path, "w", encoding="utf8")
f.write(content) f.write(content)
f.close() 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__': if __name__ == '__main__':
app.debug = True app.debug = True

View File

@ -234,7 +234,7 @@
<div class="col-md-2"></div> <div class="col-md-2"></div>
<div class="col-md-5"> <div class="col-md-5">
<h4>Level A Review</h4> <h4>Level B Review</h4>
<p style="color:darkgrey">Drag Picture To Move</p> <p style="color:darkgrey">Drag Picture To Move</p>
<div style="overflow-x: scroll; height: 350px;" > <div style="overflow-x: scroll; height: 350px;" >

View File

@ -207,13 +207,15 @@
return element; return element;
}*/ }*/
var divElement = document.getElementById("GameWindow"); var divElement = document.getElementById("GameWindow");
var level1 = "test1";
var level2 = "test2";
cheerpjCreateDisplay(500,500,divElement); cheerpjCreateDisplay(500,500,divElement);
cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l"); cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l");
console.log("Cheerpj Initialize Succeed!"); console.log("Cheerpj Initialize Succeed!");
PlayLevel("test1", "test1") PlayLevel(level1, level1)
.then(function (){alert("Game Over!")}) .then(function (){alert("Game Over!")})
.then(PlayLevel("test2", "test2") .then(PlayLevel(level2, level2)
.then(function (){ .then(function (){
alert("Go to Evaluation Window") alert("Go to Evaluation Window")
window.location.href = "/annotation" window.location.href = "/annotation"

View File

@ -63,4 +63,18 @@ function PlayLevel(group, level){
// var addressID = $("input[name='sex']:checked").val(); // var addressID = $("input[name='sex']:checked").val();
// alert(addressID) // alert(addressID)
} }
function getLevels(){
var gameLevelstr = "{{gamelevels}}";
var levels = gameLevelstr.split(",")
levels.replace("&#39;","")
gameLevels.replace("[","")
gameLevels.replace("]","")
console.log(levels);
console.log(levels[0]);
var level1 = "test1";
var level2 = "test2";
return 0;
}