|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have an issue that has been frustrating me for a little while. I am rewriting an online assessment testing system that is used to get an idea of a potential prospects skill level. I am trying to set up this system to be completely user friendly and customizable.
The problem I'm having is this. When someone takes a test it gets graded and inserted into an access database table called grades upon completion. I want to query that table to see what tests that person has completed. After that I want to be able to show the user what has been completed and what has not. Because an unlimited amount of tests can be created by an administrator, it also has its own table in the database. When I try to match these two tables up to only display a link to tests that have not been taken, it only blocks the first one it sees from the query. For example, if a user takes tests 2, 4 and 5. Using the code below it only blocks the link for test # 2. This is what I have for code: Code:
<cfset testarray=arraynew(1)>
<cfset testarray2=arraynew(1)>
<cfloop query="tests">
<cfset testarray[CurrentRow][1]=testtitle>
<cfset testarray2[CurrentRow][1]=testtype>
</cfloop>
<cfset total_records=tests.recordcount>
<cfloop index="Counter" from=1 to="#Total_Records#">
<tr>
<td valign="top">
<cfif #grades.testtype# neq #testArray2[Counter][1]#>
<a href="javascript:win('testing/test.cfm?recordID=<cfoutput>#testArray2[Counter][1]#</cfoutput>&testtitle=<cfoutput>#testArray[Counter][1]#</cfoutput>')"><cfoutput>#testArray[Counter][1]#</cfoutput></a>
</cfif>
<cfif #grades.testtype# eq #testArray2[Counter][1]#>
<cfoutput>#testArray[Counter][1]#</cfoutput> Complete
</cfif>
</td>
</tr>
</cfloop>
I found this code in the documentation, but I don't even know if it is the right process for this type of action. Any help would be greatly appreciated. |
|
#2
|
|||
|
|||
|
Yes I don't understand what you're doing with the arrays. If you have a query that shows records for all of the tests the user didn't take, why not just loop over the query and output it?
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
First off, thanks for the response and you make it sound so easy . I have tried simple loops and have had no luck. This was my last attempt at it and I posted what I tried, I've been banging my head on the wall for at least a week on this. Everything I've tried only blocks the link for the first one the loop catches in the query. I'll try to explain what I am trying to do a little better.1. There are a number of tests that are in the "tests" table which have been created by the test administrator. 2. A user takes a test. 3. Grade and testtype for test get inserted into "grade" table. 4. Users main page queries the "grade" table and compares it to all tests in the "tests" table. 5. Users main page shows tests not taken (and a visual confirmation of what tests have been taken). I might have to try a different angle on this one anyway because I just found out that I am going to have tp assign certain users to certain tests which may throw all of this out of whack. Again, Thanks for all your help. |
|
#4
|
|||
|
|||
|
You create 1-d arrays for test title and type, yet access them as a 2-d arrays?
Code:
<cfloop query="tests"> <cfset testarray[CurrentRow]=testtitle> <cfset testarray2[CurrentRow]=testtype> </cfloop> I think that may work a little better for you. The code in your cfif blocks will need to be changed as well. Maybe that will help? ![]() |
|
#5
|
|||
|
|||
|
Quote:
Thanks! That did work. I'm still trying to figure out this whole array thing. Still new to this sort of thing. ![]() |
|
#6
|
|||
|
|||
|
good job! glad that helped you out.
![]() |
|
#7
|
|||
|
|||
|
I'm glad that you found a way to make it work, but it still seems odd to me. If you have a table with all possible tests, and you have a table for all the tests a user took, you can write a query to give you back only the tests the user didn't take (tests which exist in the full test table but do not exist in the user's tests table). This could be done with an outer join, or an EXISTS clause, or a subquery. If it's working now you might not want to worry about it but for future use, these would probably be more efficient.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Not displaying a link after completion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|