Quiz Results - How to use them

Questions about the Character Builder, primarily for content creators.

Quiz Results - How to use them

Postby polding on Fri Dec 08, 2006 8:23 am

I think the Q and A sessions that can be created, are excellent.

At the end of a quiz, it is already possible to show the results, ie: the sum of correct answers.

However, I would like to know if there is any way to further use these results.

Is it possible for these results to be emailed to an address or written to a database?
polding
 
Posts: 22
Joined: Fri Mar 21, 2008 6:24 am

Postby staff on Fri Dec 08, 2006 9:33 am

Yes, missing from the template at the moment is any kind of sample server-side script to handle the Exchange Variables command. Think of the Exchange Variables action as like the Submit button in an HTML Form, except that the fields that are sent are the values of the variables that you declare. Let's say you have a URL of Save.asp on your Exhange Variables action. Then you create a Save.asp, in the Output directory, as follows:

Save.asp:

<%@ Language=VBScript %>
<%
Response.Expires = -1

set fso = Server.CreateObject("Scripting.FileSystemObject")
set ts = fso.OpenTextFile(Server.MapPath("Data\User" & Session.SessionID & ".xml"), 2, True)
ts.WriteLine "<Record>" & Chr(13)+Chr(10)
ts.WriteLine " <A>" & Request.Form("A") & "</A>" & Chr(13)&Chr(10)
ts.WriteLine " <B>" & Request.Form("B") & "</B>" & Chr(13)&Chr(10)
ts.WriteLine " <C>" & Request.Form("C") & "</C>" & Chr(13)&Chr(10)
ts.WriteLine "</Record>" & Chr(13)+Chr(10)
ts.Close()

Response.Write "ExchangeDone=true"
%>

This assumes your project has declared variables A, B, and C. It will use the current users's unique session id to create an xml file, which it then fills with the values of the variables. You would normally also have the user's userid at this point in a more complete solution, which you could use instead of the session id to store the data in the right row of a database.

However for this to work you need to run your project through your web server. You can do this via Project Options, General tab, Run this project via a custom URL, and specifying, eg. http://localhost/projects/myproject/out ... oject.html, assuming you've used My Computer > Manage to create a virtual root "projects" for your My Character Builder Projects directory, as we recommend when working with the Character Server. Then Run in Browser will run your project through the local web server, and, providing you have given IIS permission to write to the Output\Data subdirectory, you should start seeing files appear there.
staff
Site Admin
 
Posts: 634
Joined: Fri Mar 21, 2008 6:24 am
Location: Bellevue, Washington

Postby polding on Fri Dec 08, 2006 10:31 am

Thank you.

Do I need the Character Server to do this or can it be done with the Character Builder?
polding
 
Posts: 22
Joined: Fri Mar 21, 2008 6:24 am

Postby staff on Fri Dec 08, 2006 4:48 pm

You just need the Character Builder.
staff
Site Admin
 
Posts: 634
Joined: Fri Mar 21, 2008 6:24 am
Location: Bellevue, Washington

Postby polding on Thu Dec 14, 2006 4:31 am

Thanks again.

You mention localhost, IIS and ASP. That's fine for local testing but I would like to set this up on our virtual Unix server so that clients can login and use it for their own staff and/or customers.

Do you have any pointers as to what I need to do?
polding
 
Posts: 22
Joined: Fri Mar 21, 2008 6:24 am

Postby staff on Thu Dec 14, 2006 4:59 pm

I don't, but everything would be roughly the same. Assuming you use php instead of asp, you would just need to make the appropriate syntax changes - the server-side script can happily pretend that it's talking to a regular HTML form on the client side - imagine a form with one edit field per variable.
staff
Site Admin
 
Posts: 634
Joined: Fri Mar 21, 2008 6:24 am
Location: Bellevue, Washington

Postby polding on Fri Dec 15, 2006 6:37 am

I am trying to get an ASP to PHP translation on the above code.

If I get it, and get this working, I will post my findings here for others to use.

In the meantime, if anybody has a translation already, I would love to see it because that could in fact save me an amount of time, effort and grief.
polding
 
Posts: 22
Joined: Fri Mar 21, 2008 6:24 am

Postby polding on Fri Dec 22, 2006 2:34 am

Okay, I have it. The PHP translation of the above code is ...

<?php
session_start();

// Obtain POST variables from form
$A = $_POST['Correct'];
$B = $_POST['Incorrect'];
$C = $_POST['Total'];

// Create file contents
$data="<Record>\n<A>$A</A>\n<B>$B</B>\n<C>$C</C>\n</Record>";

// Obtain sessionid and create file
$session_id = session_id();
$file = "/home/path/to/file/Data/User".$session_id.".xml";

if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; }
if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; }
fclose($file_handle);
?>

The next steps for us will be ...

1 - to have the user provide an email address or name before taking the quiz

2 - create a user ID instead of a session ID

3 - write the info to a database instead of a file

If anyone is interested, I will post our solutions here when we have them.
polding
 
Posts: 22
Joined: Fri Mar 21, 2008 6:24 am


Return to Character Builder

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron
Image 01