My very own feedback gathering system! The blackbox can now gather feedback via the feedback_set(var_name,amt), feedback_inc(var_name,amt) and feedback_dec(var_name,amt) procs.

The way feedback is gathered is that the three procs are placed in code where feedback is wanted, these in turn set variables in the blackbox (Yes, I could have done it in an out-of-world datum or object, but I just prefer having an actual physical object gather this stuff.) At the end of the round, all acquired data is saved to a database. I still need to get ahold of TLE to make the required tables and bugtest some things.

The saving proc exsists, but is not yet called due to the lack for a table to save to. The rest of it should work fine tho, so you can place the feedbac_set, _inc and _dec procs around code and see what they provide via view variables, it just won't save it to the database yet.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2092 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2011-09-03 01:00:01 +00:00
parent 51ec2499d9
commit e6aa3fc0b1
2 changed files with 159 additions and 1 deletions
+68
View File
@@ -197,3 +197,71 @@ proc/statistic_cycle()
sleep(600)
sql_poll_admins()
sleep(6000) // Poll every ten minutes
//This proc is used for feedback. It is executed at round end.
proc/sql_commit_feedback()
if(!blackbox)
log_game("Round ended without a blackbox recorder. No feedback was sent to the database.")
return
//content is a list of lists. Each item in the list is a list with two fields, a variable name and a value. Items MUST only have these two values.
var/list/datum/feedback_variable/content = blackbox.get_round_feedback()
if(!content)
log_game("Round ended without any feedback being generated. No feedback was sent to the database.")
return
var/DBConnection/dbcon = new()
dbcon.Connect("dbi:mysql:[sqldb]:[sqladdress]:[sqlport]","[sqllogin]","[sqlpass]")
if(!dbcon.IsConnected())
log_game("SQL ERROR during feedback reporting. Failed to connect.")
else
var/DBQuery/max_query = dbcon.NewQuery("SELECT MAX(roundid) AS max_round_id FROM erro_feedback")
max_query.Execute()
var/newroundid
while(max_query.NextRow())
newroundid = max_query.item[1]
if(!(isnum(newroundid)))
newroundid = text2num(newroundid)
if(isnum(newroundid))
newroundid++
else
newroundid = 1
for(var/datum/feedback_variable/item in content)
var/variable = item.get_variable()
var/value = item.get_value()
var/DBQuery/query = dbcon.NewQuery("INSERT INTO erro_feedback (id, roundid, time, variable, value) VALUES (null, [newroundid], Now(), '[variable]', '[value]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
dbcon.Disconnect()
proc/debug_sql_commit_feedback()
if(!blackbox)
world << "Round ended without a blackbox recorder. No feedback was sent to the database."
return
//content is a list of lists. Each item in the list is a list with two fields, a variable name and a value. Items MUST only have these two values.
var/list/datum/feedback_variable/content = blackbox.get_round_feedback()
if(!content)
world << "Round ended without any feedback being generated. No feedback was sent to the database."
return
for(var/datum/feedback_variable/item in content)
var/variable = item.get_variable()
var/value = item.get_value()
world << "INSERT INTO erro_feedback (id, roundid, time, variable, value) VALUES (null, ABC, Now(), '[variable]', '[value]')"
world << "end"