Emailing SCORM published survey results using script
November 13, 2011 12:00 AM
I am trying to create a survey and have it posted on blackboard. I want the user to take this survey and then have all results (Q's & A's) sent to my email account, which can also be my blackboard email for simplicity. I don't want to use the 'email results to' option because that requires the users computer to have microsoft outlook configured.
I was told to use the CGI option and use a script.
I called Lectora and they said that they don't give advice for script usage, so they sent me a link to a forum conversation.
Below is a script that some other forum question said would work. However, I don't have any clue how to implement it or if anything needs to be changed so that the info is emailed to my address or what. So far, I have successfully published my survey to my blackboard account using SCORM. However, I have not been able to retrieve any of the results. Any help will be thoroughly appreciated, thanks!!!!
<%@ Language=VBScript %>
<%
'Get the parameters posted from the test'
testname=Request.form("TestName")
surveyname=Request.form("SurveyName")
score=Request.form("Score")
user=Request.form("name")
numQuestions=Request.form("NumQuestions")
passingGrade=Request.form("PassingGrade")
strbody=""
subjectline=""
fromaddress=""
if len(surveyname)>0 then score="NA"
if len(surveyname)>0 then passingGrade="NA"
if len(surveyname)>0 then testname=surveyname
'Validate that this is actually from a Lectora test'
if testname="" Or score="" Or user="" Or numQuestions="" Or passingGrade="" then
Response.Write ""
Response.Write "Failure"
Response.Write ""
Response.Write "STATUS=501"
Response.Write "
"
Response.Write "Could not parse test results due to a parameter error."
Response.Write ""
else
'Write the results'
strbody = strbody & "Date: " & Date & ", " & Time & "
"
strbody = strbody & "Name: " & Replace(user,"%20"," ") & "
"
if len(surveyname)>0 then
strbody = strbody & "Survey: " & testname & "
"
else
strbody = strbody & "Test: " & testname & "
"
end if
strbody = strbody & "Score: " & score & "
"
'Older courses produced by Lectora used a zero based index for the questions (i.e. Question0 is the first question)' 'Newer courses are one based (i.e. Question1 is the first question)'
'determine which one it is'
Dim startIndex
valTemp = Request.form("Question0")
if( valTemp="" ) then
startIndex=1
else
startIndex=0
end if
'Write all of the questions and answers'
for i = startIndex to cint(startIndex + numQuestions-1)
nameQ = "Question" + CStr(i)
nameA = "Answer" + CStr(i)
valQ = Request.form(nameQ)
valA = Request.form(nameA)
strbody= strbody & nameQ &": " & valQ & "
"
strbody= strbody & nameA & ": " & valA & "
"
Next
strbody = strbody & ""
'Create Subject Line'
if len(surveyname)>0 then
subjectline = "Survey: " & testname &", User:"& Replace(user,"%20"," ")
else
subjectline = "Test: " & testname &", User:"& Replace(user,"%20"," ")
end if
'Create From Address'
if len(surveyname)>0 then
fromaddress="surveyresults@domain.com"
else
fromaddress="testresults@domain.com"
end if
'Send the Email'
Set objMessage = CreateObject("CDO.Message")
With objMessage
Set Header = .Fields
With Header
.Item("urn:schemas:mailheader:X-Mailer") = "Html Mailer"
.Item("urn:schemas:mailheader:Content-Type") = "text/html; charset=us-ascii"
.Item("urn:schemas:mailheader:Content-Transfer-Encoding") = "7bit"
.Update
End With
end with
objMessage.Subject = subjectline
objMessage.From = fromaddress
objMessage.To = "testresults@domain.com"
objMessage.TextBody = "This is an HTML Email"
objMessage.HTMLBody = strbody
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server'
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.3.23"
'Server port (typically 25)'
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section=='
objMessage.Send
end if
%>
Discussions have been disabled for this post