|
|
# 1 | ||
|
Moderator
![]() Join Date: Jul 2007
Posts: 2,487
|
Hey everyone. I figured out how to use PHP to email the results of a quiz. (This does not work with Articulate '09, only the 5.x products. Click here for the Articulate '09 solution.
Essentially, I changed the "SendQuiz" function so that it posts the data to "sendmail.php". sendmail.php is not universally installed on every server. So, this may not work for you. For simplicity sake, I have attached a .zip file (at the bottom) with the "quizmaker.html", "backup.txt", and the "sendmail.php". You should be able to copy and paste these into your output folder (the folder that contains your published quiz). Be sure to make backup copies on your side. I'm not responsible for problems that you have since I have not tested this on any other machines. I replaced the "SendQuiz" function in "quizmaker.html" with the following code: Code:
function SendQuiz()
{
g_strQuizResults = g_strQuizResults.replace(/'/g,"'");
var sHTML = "";
sHTML += '<FORM id="formQuiz" method="POST" action="sendmail.php">';
sHTML += '<INPUT TYPE="hidden" NAME="QuizResults" VALUE=\'' + g_strQuizResults.replace(/\\n/g,"\n") + '\'>';
sHTML += '<br><input type="submit"><br>';
sHTML += '</FORM>';
document.getElementById("divQuiz").innerHTML = sHTML;
document.forms["formQuiz"].submit();
}
Code:
function player_DoFSCommand(command, args)
{
args = String(args);
args = args.replace(/%_q_%/g,"\"")
args = args.replace(/;/g,"|$s$|")
args = args.replace(/%_s_%/g,";")
command = String(command);
var F_intData = args.split("|$s$|");
switch (command)
{
case "ART_CloseAndExit":
if (!g_bLMS)
{
//QM customized//
if (FF)
{
setTimeout("CloseWindow()", 100);
}
else
{
window.close();
}
}
break;
//Email//
case "emailEmail":
g_strEmail = args;
break;
case "QuizResults":
var strTemp = args.replace(/\|\$s\$\|/g,";");
g_strQuizResults = strTemp;
break;
case "Quiz Results":
case "emailSubject":
g_strSubject = args;
break;
case "emailSubmit":
SendQuiz();
break;
case "StoreQuestionResult":
StoreResult(args);
break;
case "StoreQuizResult":
StoreQuizResult(args);
break;
case "DisplayPrintScreen":
ShowResult(args);
break;
case "ART_QMAttachment":
g_strAttachment = args;
if (IESP2)
{
OpenAttachment()
}
else
{
setTimeout("OpenAttachment()", 100)
}
break;
case "QM_ZoomImage":
PopZoomImage(F_intData[0], F_intData[1], F_intData[2]);
break;
}
if (g_bLMS)
{
customFScommandHandler(command, args);
}
}
Code:
<? $email = $_REQUEST['email']; $QuizResults = $_REQUEST['QuizResults']; $Replace = "\\\""; $QuizResults = str_replace($Replace, "", $QuizResults); mail( "none@none.com", "Quiz Name", $QuizResults, "From: Quiz Name" ); print "Congratulations! Your quiz has been submitted!"; ?> ========== Core Data Status,Raw Score,Passing Score,Max Score,Min Score,Time failed,10,80,100,0, Date,Time,Score,Interaction ID,Objective ID,Interaction Type,Student Response,Result,Weight,Latency 07/11/07,15:17:24,0,I0001,I0001,choice,Build-A-Brochure, Co-Marketing, Yellow Pages, Consumer Extended Warranty Notification;,wrong,1,00:00:02 07/11/07,15:17:26,0,I0002,I0002,choice,Can provide additional sell up opportunities;,wrong,1,00:00:02 07/11/07,15:17:28,0,I0003,I0003,choice,6 month No Interest No Pay;,wrong,1,00:00:02 07/11/07,15:17:30,0,I0004,I0004,true-false,false;,wrong,1,00:00:02 07/11/07,15:17:32,0,I0005,I0005,choice,Commercial Leasing Program;,wrong,1,00:00:02 07/11/07,15:17:34,0,I0006,I0006,true-false,true;,wrong,1,00:00:02 07/11/07,15:17:36,0,I0007,I0007,choice,$15;,wrong,1,00:0 0:02 07/11/07,15:17:38,0,I0008,I0008,choice,Dealer Locator;,wrong,1,00:00:02 07/11/07,15:17:39,0,I0009,I0009,choice,16%;,wrong,1,00:0 0:02 07/11/07,15:17:42,0,I00010,I00010,choice,None of the above;,wrong,1,00:00:03 07/11/07,15:17:44,0,I00011,I00011,choice,www.Hvacr.com;,wrong,1,00:00:02 07/11/07,15:17:46,5,I00012,I00012,choice,NetProphet;,cor rect,1,00:00:02 07/11/07,15:17:47,0,I00013,I00013,choice,Ad Planner;,wrong,1,00:00:01 07/11/07,15:17:49,5,I00014,I00014,choice,All of the Above;,correct,1,00:00:02 07/11/07,15:17:51,0,I00015,I00015,choice,All of the above;,wrong,1,00:00:02 07/11/07,15:17:53,0,I00016,I00016,choice,200;,wrong,1,00 :00:02 07/11/07,15:17:55,0,I00017,I00017,choice,Ad Planner;,wrong,1,00:00:02 07/11/07,15:17:57,0,I00018,I00018,true-false,false;,wrong,1,00:00:03 07/11/07,15:17:59,0,I00019,I00019,choice,In business for at least 3 years;,wrong,1,00:00:02 07/11/07,15:18:01,0,I00020,I00020,choice,Performance Consulting;,wrong,1,00:00:02 ========== The following information was edited on 8/28/2007: I recently ran into a problem in which the receiver of the emails didn't get all of the results that were submitted. After pondering a few days about a solution to this problem, I figured out a way to create a "backup" for the results. Essentially, I created a "backup.txt" file that is initially empty. In the "sendmail.php" file, I added some code that opens up the text file & appends it. So, every time a user "Emails Results", it also writes the same data to a text file. When uploading the "backup.txt", be sure to change the attributes to "767" For simplicity sake, I have attached a .zip file with the "quizmaker.html", "backup.txt", and the "sendmail.php". You should be able to copy and paste these into your output folder. Be sure to make backup copies on your side. I'm not responsible for problems that you have since I have not tested this on any other machines. The following information was edited on 12/19/2007: Thanks to desabol, the tutorial has been updated so that it now works with Firefox! Good luck!
__________________
Brian Batt Customer Support Engineer Articulate - Empowering Rapid E-Learning www.articulate.com Using the latest versions? Get 63 product enhancements with Studio '09 Update 5 You twitter? Follow me here. Last edited by beeneeb : 04-09-2009 at 02:22 PM. |
||
|
|
|
|
# 2 | ||
|
Member
Join Date: Feb 2006
Location: Woodbury, MN
Posts: 5,564
|
WAY COOL! Congrats! Looking forward to trying this out ourselves.
Best. - Gerry |
||
|
|
|
|
# 3 | ||
|
Moderator
![]() Join Date: Jul 2007
Posts: 2,487
|
Quote:
If anyone tries this, I would love to see some feedback on it. Thanks! |
||
|
|
|
|
# 4 | ||
|
Member
Join Date: Jul 2007
Posts: 5
|
I;'m having a little difficulty with this. I had no problems editing quizmaker.html nor creating the sendmail.php. I can load sendmail.php with nio issues and it emails just fine. But when I finish a quiz and press "Email Results" It never loads sendmail.php and just hangs.
I also tried using the files from the zip. And before I am asked. User permissions are correct, 755 and 777 on both files (tried both) sendmail.php is in the same directory as quizmaker.html. loading sendmail.php manually does work. Anything else I could try? |
||
|
|
|
|
# 5 | ||
|
Moderator
![]() Join Date: Jul 2007
Posts: 2,487
|
Would you mind uploading your quizmaker.html & sendmail.php? I'll take a look at it & compare it to my source.
|
||
|
|
|
|
# 6 | ||
|
Member
Join Date: Jul 2007
Posts: 5
|
You bet! Keep in mind the quizmaker.html is the one from your zip file.
|
||
|
|
|
|
# 7 | ||
|
Moderator
![]() Join Date: Jul 2007
Posts: 2,487
|
Quote:
Install Sendmail at Holy Shmoly! Sendmail.org - Downloads You might try those...I don't know anything about installing functions on the server-side, maybe someone here can help you with that. For me, I got lucky enough to have a hosting company that has sendmail. So, good luck & I hope that it works out for you. Sorry I couldn't help more. |
||
|
|
|
|
# 8 | ||
|
Member
Join Date: Jul 2007
Posts: 5
|
I'm still working on this... The server this was originally on is a SuSE 10.2 box running postfix. Both the Quiz work as well as the sendmail.php (by loading sendmail.php directly instead of calling it from PHP.) So as a test, I went ahead and moved it over to my personal host, which is FreeBSD running sendmail. Same thing... the quiz hangs when it should be loading sendmail.php. Again, you can load sendmail.php directly in a browser and it works (it just sends me a blank message.) I checked permissions on sendmail.php as well... It just plain and simply will not call this script on either of my servers...
Here's the test quiz the training guy threw together for me to test... Rick's Test And here's the sendmail script... http://www.acceptable-risk.org/test_quiz/sendmail.php I think I'm just going to give up here soon. Maybe they'll incorporate this feature in future revisions of Articulate... |
||
|
|
|
|
# 9 | ||
|
Moderator
![]() Join Date: Jul 2007
Posts: 2,487
|
Quote:
By the way, I just tried your "Rick's Test" link & it did go through. After I answered question 3, I selected "Email Results" & it went through. This leads me to believe that your browser settings are different than mine. Check your email & see if you got my results. I think I submitted my results 2 or 3 times. What browser are you using? Last edited by beeneeb : 07-19-2007 at 04:26 PM. |
||
|
|
|
|
# 10 | ||
|
Administrator
![]() ![]() Join Date: Feb 2006
Location: NY
Posts: 2,139
|
Clicking email results also works for me in IE6, but not in FF2 (which is to be expected). In IE6 after clicking email results, I get this:
Quote:
__________________
Gabe Anderson Director of Customer Advocacy Articulate - Empowering Rapid E-Learning Get the latest Articulate news: Subscribe to Word of Mouth You should follow me on Twitter here. |
||
|
|