Not sure how to label this issue that I am trying to solve...
What I am trying to do is take a list of students from a database query recordset and assign them the a counselor from a database query recordset and place them in an alternating rotation Monday through Friday for the remainder of the year.
Example of desired result.
student1 - June 6, 2011 | Counselor1 |
student1 - June 7, 2011 | Counselor2 |
student1 - June 8, 2011 | Counselor3 |
student1 - June 9, 2011 | Counselor4 |
student1 - June 10, 2011 | Counselor5 |
student1 - June 11, 2011 | Counselor6 |
student1 - June 12, 2011 | Counselor7 |
student1 - June 13, 2011 | Counselor8 |
student1 - June 14, 2011 | Counselor9 |
student1 - June 15, 2011 | Counselor10 |
student1 - June 16, 2011 | Counselor11 |
student1 - June 17, 2011 | Counselor12 |
student1 - June 18, 2011 | Counselor1 |
student1 - June 19, 2011 | Counselor2 |
student1 - June 20, 2011 | Counselor3 |
student1 - June 21, 2011 | Counselor4 |
student1 - June 22, 2011 | Counselor5 |
student1 - June 23, 2011 | Counselor6 |
student1 - June 24, 2011 | Counselor7 |
student1 - June 25, 2011 | Counselor8 |
student1 - June 26, 2011 | Counselor9 |
student1 - June 27, 2011 | Counselor10 |
student1 - June 28, 2011 | Counselor11 |
student1 - June 29, 2011 | Counselor12 |
student1 - June 30, 2011 | Counselor1 |
student2 - June 6, 2011 | Counselor2 |
student2 - June 7, 2011 | Counselor3 |
student2 - June 8, 2011 | Counselor4 |
student2 - June 9, 2011 | Counselor5 |
student2 - June 10, 2011 | Counselor6 |
student2 - June 11, 2011 | Counselor7 |
student2 - June 12, 2011 | Counselor8 |
student2 - June 13, 2011 | Counselor9 |
student2 - June 14, 2011 | Counselor10 |
student2 - June 15, 2011 | Counselor11 |
student2 - June 16, 2011 | Counselor12 |
student2 - June 17, 2011 | Counselor1 |
student2 - June 18, 2011 | Counselor2 |
student2 - June 19, 2011 | Counselor3 |
student2 - June 20, 2011 | Counselor4 |
student2 - June 21, 2011 | Counselor5 |
student2 - June 22, 2011 | Counselor6 |
student2 - June 23, 2011 | Counselor7 |
student2 - June 24, 2011 | Counselor8 |
student2 - June 25, 2011 | Counselor9 |
student2 - June 26, 2011 | Counselor10 |
student2 - June 27, 2011 | Counselor11 |
student2 - June 28, 2011 | Counselor12 |
student2 - June 29, 2011 | Counselor1 |
student2 - June 30, 2011 | Counselor2 |
student3 - June 6, 2011 | Counselor3 |
student3 - June 7, 2011 | Counselor4 |
student3 - June 8, 2011 | Counselor5 |
student3 - June 9, 2011 | Counselor6 |
student3 - June 10, 2011 | Counselor7 |
student3 - June 11, 2011 | Counselor8 |
student3 - June 12, 2011 | Counselor9 |
student3 - June 13, 2011 | Counselor10 |
student3 - June 14, 2011 | Counselor11 |
student3 - June 15, 2011 | Counselor12 |
student3 - June 16, 2011 | Counselor1 |
student3 - June 17, 2011 | Counselor2 |
student3 - June 18, 2011 | Counselor3 |
student3 - June 19, 2011 | Counselor4 |
student3 - June 20, 2011 | Counselor5 |
student3 - June 21, 2011 | Counselor6 |
student3 - June 22, 2011 | Counselor7 |
student3 - June 23, 2011 | Counselor8 |
student3 - June 24, 2011 | Counselor9 |
student3 - June 25, 2011 | Counselor10 |
student3 - June 26, 2011 | Counselor11 |
student3 - June 27, 2011 | Counselor12 |
student3 - June 28, 2011 | Counselor1 |
student3 - June 29, 2011 | Counselor2 |
student3 - June 30, 2011 | Counselor3 |
I have tried a combination of lists, nested index loops, and mutli dimensional arrays. I have seemed to be dead locked. This is a start to the example of what I have been trying and I am sure you can see it isn't the desired result. It will provide only a student schedule without an assigned counselor. The problem has been fitting the counselor into the rotation.
<cfset daysleft = DaysinYear(todaysDate) - DayofYear(todaysDate) >
<cfoutput query="StudentQuery">
<cfloop index = "LoopCount" from = "0" to = "#daysleft#">
<cfset scheduledate = DayOfWeek(todaysdate+Loopcount)>
<cfif DayOfWeek(scheduledate) is not 7 AND DayOfWeek(scheduledate) is not 1>
#StudentName# - #DayofWeekAsString(DayOfWeek(scheduledate))# - #DateFormat((todaysdate+Loopcount), 'long')#<br>
</cfif>
</cfloop><br />
</cfoutput>
Keep in mind there needs to be an finite number of students and counselors determined by database records that do change. The plan is to rerun the script weekly as these records change. The dates are finite and simply reduce from week to week. December 31st is the last day. Any help is appreciated.