Jump to content

This topic is 7774 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Sorry, I'm a little new to cdml and FMP so hope I have enough info here. I appreciate the help in advance. I inherited a class registration system and am attempting to add online grading functionality. From the class registration page I have thrown in a quiz (via quizconfig.js which grades the quiz).I want to import the result back into the registration.fp6 file (ideally tied to the onclick="gradeit()" or if not at least from the results.html page.

I've seen how to pull fields from the FP files and add to text but haven't seen how to do it from a javascript file. Thanks.

Posted

The Javascript file will need to assign data to Form Elements. For example:

document.cdmlmyform.myfield.value = myjsvar ;

These Form Elements need to be the same as the fields in the database.

Then the CDML Form can be submitted to the WebCompanion.

Hope this helps.

Garry

Posted

Thanks Garry.

Still having 2 problems. Help much appreciated.

1.

function validForm() {

quizconfig.js = document.rsform.regstatus.value

Doesn't autopopulate the Graded results. I'm thinking I have to reference the field (q) in which to carryover the value. I can manually enter the value in the cdml form and it will be sent to the FMP registration file.

2. Once the result is posted to the registration file it creates a new record with the regstatus field populated instead of modifying the existing student's class grade/regstatus.

Posted

I understand if you don't want to get too much into this. but below is part of the code so far. Pointers not necessarily corrections would be great. I'm still learning. Again thanks.

<!--

function validForm() {

quizconfig.js = document.rsform.regstatus.value

}

//-->

</SCRIPT>

</head>

<body bgcolor="#FFFFFF">

<p align="center"><strong><font face="Arial">

<script src="quizconfig.js">

</script>

<big>Quiz Results</big></font></strong></p>

<div align="center"><center>

<table border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="100%"><form method="POST" name="result"><table border="0" width="100%" cellpadding="0" height="116">

<tr>

<td height="25" bgcolor="#D3FFA8"><strong><font face="Arial"># of questions you got right:</font></strong></td>

<td height="25"><p><input type="text" name="p" size="24"></td>

</tr>

<tr>

<td height="17" bgcolor="#D3FFA8"><strong><font face="Arial">The questions you got wrong:</font></strong></td>

<td height="17"><p><textarea name="T2" rows="3" cols="24" wrap="virtual"></textarea></td>

</tr>

<tr>

<td height="25" bgcolor="#D3FFA8"><strong><font face="Arial">Grade in percentage:</font></strong></td>

<td height="25"><input type="text" name="q" size="8"></td>

</tr>

</table>

</form>

</td>

</tr>

</table>

</center></div>

<form method="POST"><div

align="center"><center><p>

<FORM onSubmit="return validForm()" ACTION="FMPro" METHOD="POST" NAME="rsform">

<INPUT TYPE="hidden" NAME="-DB" VALUE="registration.fp4">

<INPUT TYPE="hidden" NAME="-Lay" VALUE="webentry">

<INPUT TYPE="hidden" NAME="-Format" VALUE="/registration/studentinfo.htm">

<TABLE BORDER="1" WIDTH="375" CELLPADDING="5">

<TR>

<TH ALIGN="left" VALIGN="top">Result:</TH>

<TD ALIGN="left" VALIGN="top">

<INPUT TYPE=text NAME=regstatus VALUE="" SIZE=7 MAXLENGTH=7>&nbsp;&nbsp;

</TD>

</TR>

<TR>

<TD COLSPAN="2" ALIGN="left" VALIGN="middle">

<INPUT TYPE="submit" NAME="-New" VALUE="Submit Results">

</TD>

</TR>

</TABLE>

</TD>

</TR>

</TABLE>

</FORM>

Posted

I would really need to look at the contents of the quizconfig.js file.

The line:

quizconfig.js = document.rsform.regstatus.value

would cause a problem because you cannot assign a value to a file! You would need to be able to either, assign a value to a variable in the file, or pass a value to a function in the file. I think the latter would be the case.

Good Luck.

Garry

Posted

Figured that was a problem. Still confused on how to pass a value to a function in the file.

BtW: #2 is ok now.

PS. I spent time in Oz, and Manely, several years back great place!!

Posted

Can you post the js file here so that we can have a look at it.

I love Maleny, I moved here three years ago from Sydney. Up here in the hills, with the hippies, near the Sunshine Coast is very relaxing smile.gif

All the best.

Garry

Posted

There are 2 parts. The result script which calculates the percent (the value I want) and the js file. I have included both, it seems as though I would want to reflect:

document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%"

Percent script of results page:

var incorrect=results[parse].split("=")

incorrect=incorrect[1].split("/")

if (incorrect[incorrect.length-1]=='b')

incorrect=""

document.result[0].value=totalquestions-incorrect.length+" out of "+totalquestions

document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%"

for (temp=0;temp<incorrect.length;temp++)

document.result[1].value+=incorrect[temp]+", "

JS File contents:

//Enter total number of questions:

var totalquestions=7

//Enter the solutions corresponding to each question:

var correctchoices=new Array()

correctchoices[1]='c' //question 1 solution

correctchoices[2]='a' //question 2 solution, and so on.

correctchoices[3]='c'

correctchoices[4]='c'

correctchoices[5]='c'

correctchoices[6]='c'

correctchoices[7]='b'

/////Don't edit beyond here//////////////////////////

function gradeit(){

var incorrect=null

for (q=1;q<=totalquestions;q++){

var thequestion=eval("document.myquiz.question"+q)

for (c=0;c<thequestion.length;c++){

if (thequestion[c].checked==true)

actualchoices[q]=thequestion[c].value

}

if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice

if (incorrect==null)

incorrect=q

else

incorrect+="/"+q

}

}

if (incorrect==null)

incorrect="a/b"

document.cookie='q='+incorrect

if (document.cookie=='')

alert("Your browser does not accept cookies. Please adjust your browser settings.")

else

window.location="results.htm"

}

function showsolution(){

var win2=window.open("","win2","width=200,height=350, scrollbars")

win2.focus()

win2.document.open()

win2.document.write('<title>Solution</title>')

win2.document.write('<body bgcolor="#FFFFFF">')

win2.document.write('<center><h3>Solution to Quiz</h3></center>')

win2.document.write('<center><font face="Arial">')

for (i=1;i<=totalquestions;i++){

for (temp=0;temp<incorrect.length;temp++){

if (i==incorrect[temp])

wrong=1

}

if (wrong==1){

win2.document.write("Question "+i+"="+correctchoices.fontcolor("red")+"<br>")

wrong=0

}

else

win2.document.write("Question "+i+"="+correctchoices+"<br>")

}

win2.document.write('</center></font>')

win2.document.write("<h5>Note: The solutions in red are the ones to the questions you had incorrectly answered.</h5><p

win2.document.close()

Posted

The quizconfig.js file needs to be included in the <head> of the "Questions" page (not the "Results" page). For example:

<script src="quizconfig.js">

</script>

</head>

A Form containing the questions needs to be named "myquiz". For example:

<form name="myquiz" action="" method="POST" onsubmit="Javascript:gradeit(); return false;">

Each question needs to use a <select> with the values being a,b,c, etc. Each question is to be named "question1", "question2" etc. For example:

Q1. What is my name?<br>

a. Joe?<br>

b. Bill?<br>

c. Garry?<br>

<select name="question1">

<option value="a">a</option>

<option value="b">b</option>

<option value="c">c</option>

</select><p>

To have the quiz graded use this as the final line in the Form:

<input type="button" onclick="Javascript:gradeit();" value="Grade It">

</form>

The result is then stored in a Cookie. The "result.htm" page is then loaded. I guess that the "result.htm" page should have some Javascript which reads the Cookie and fills in the results. The result can then be sent to FM via a Form (or URL).

Hope this helps.

Garry

This topic is 7774 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.