Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Creating a database to record the number of users

Ravish Ampan
Registered User
Join date: 25 Mar 2009
Posts: 3
03-25-2009 13:32
Hi guys,

I am a creating a class room where in i want to record the attendance of the students who come in the class, Is there any way that we can create a database to store records of the students who come in, so which backend database does second life support, is it MY-SQL?
does anyone has a sample script that i can refer to create a database to store records

~Regrds
Ravish Katoch
Cyd Woolley
Carpe Cerevisiam
Join date: 6 Jan 2007
Posts: 21
03-25-2009 14:49
From: Ravish Ampan
Hi guys,

I am a creating a class room where in i want to record the attendance of the students who come in the class, Is there any way that we can create a database to store records of the students who come in, so which backend database does second life support, is it MY-SQL?
does anyone has a sample script that i can refer to create a database to store records

~Regrds
Ravish Katoch

Hello Ravish. If you go the XML-RPC route, the choice of database is pretty much open. You might want to checkout the XML-RPC article in the LSL Portal: http://wiki.secondlife.com/wiki/Category:LSL_XML-RPC
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
03-25-2009 15:36
Yes you can use mysql to record the attendance of the students who come in your class, you maybe need some board where the students touch to "sign" assistence or maybe some type of visitor tracker to record the time spended too of each one.

For comunication with your outslside ,you need to take a look at this functions.

llHTTPRequest

http://wiki.secondlife.com/wiki/LlHTTPRequest

llHTTPResponse


http://wiki.secondlife.com/wiki/LlHTTPResponse

And for the visitor tracker :

llSensor
http://wiki.secondlife.com/wiki/LlSensor

and follow the respective links on the wiki page for

llSensorRepeat
llSensorRemove

Also for the board "sigin" with a simple Touch event its enough to send the httprequest to your database.
_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
Alberrt Steptoe
Second Life Resident
Join date: 31 Oct 2004
Posts: 19
03-25-2009 15:52
Hello,

Not sure because I have yet to try it myself but I dont think llHTTPResponse is available yet.

I could be wrong.

- Alberrt
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
03-25-2009 17:31
http_response is not the same as http_server

http_response is used to get the response from the server when an httprequest was made it.
_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
03-26-2009 01:23
I really wouldn't use XMLRPC for this. llHTTPRequest is really all you need. Use the touch event to capture a student's Sign In/Sign Out, then if you need to actually "watch" them, use llSensorRepeat and sensor to scan the room every once in a while and see if they are still there. Here's how it would work:

CODE

key requestid;
key student;
string studentname;
default
{

touch_start(integer number)
{
student = llDetectedKey(0);
studentname = llKey2Name(student);

string time = llGetTimestamp();
string datetime = llGetSubString(time,0,9) + " " + llGetSubString(time,11,18);
// puts the timestamp into the DATETIME format used by MySQL
requestid = llHTTPRequest("http://www.yourdomain.com/yourscript.php",
[HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],
"parameter1=" + studentname + "&parameter2=" + (string)student + "&parameter3="
+ datetime); //This is the script send to the php script, which will process and connect
with the database
}

http_response(key request_id, integer status, list metadata, string body)
{ //this is where the response from the php script on your server will be processed
if (request_id == requestid)
{
integer intx = llSubStringIndex(body,"<");
string tbody = llGetSubString(body,0,intx);
string error = llGetSubString(body,0,5);
if(llStringTrim(error,STRING_TRIM) != "Error:") //check for error message
{
llInstantMessage(student, tbody);
//llGiveInventory(student, name of item); //uncomment line if you want to
give the students something like a notecard of rules or a pop quiz or whatever.
llInstantMessage(llGetOwner(), studentname + " has joined the class.");
}
else //response if the body is an error message
{
llInstantMessage(llGetOwner(), "There has been an error: " + body);
llInstantMessage(student, "There is an error. The owner has been notified.");
}
}
}
}


okay, I dunno if that compiles or not lol..but it's still not totally complete anyway. A good
start though. You're still going to have to get a web server, and create your database with
fields ID (int, auto_increment, primary), studentName (varchar), studentKey (varchar),
Time_In (datetime), Time_Out (datetime).

Your php script (represented by "yourscript.php" above), will need to gather the parameters sent, use those to populate a new record in the MySQL database, also checking whether the datetime variable goes into the Time_In or the Time_Out fields. Then, it will need to send a response using echo. The way I put it in this example, the error response would need to be something like "Error: " + mysql_error()".

As you can see, I wouldn't go with XMLRPC for this, you need it to be initiated from inworld rather than from the web server. Hope it helps!

/me gets ready for people to tear the code apart lol
WhiteStar Magic
Build it+Script it=RUN!
Join date: 24 Jul 2008
Posts: 36
03-26-2009 05:12
Here is a Basic Visitor Logger that posts the info to a Web Server. I think its a good starting point.

http://wiki.secondlife.com/wiki/Visitor_Logger_%28Web/Basic%29

WhiteStar
_____________________
Build it, Script it & Enjoy It, then Share it !!!