Advertisement

07.22.2003 at 11:07AM PDT, ID: 20686646
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Difficult weekly calendar algorithm

Asked by GroverDill in PHP Scripting Language

Tags: ,

This one is a bit of a toughie. I've been wracking my brain over this for a couple of days now, and I haven't been able to come up with any result except for giving myself a headache. Ouch.

I'm trying to use PHP to develop a weekly (7 day) calendar which displays the weekly appointments in a tabular view, like you find in any personal organizer (palm pilot, outlook, etc). The thing is, I need to be able to list an indeterminate number of simultaneous events side by side on my calendar, and I need an algorithm that determines (for each day) the maximum number of columns needed to list all the simultaneous events and (for each event) the appropriate colspan for said event. <a href="http://www.horde.org/kronolith/screenshots/workweek.png">Here's a screenshot</a> from Kronolith, which is doing exactly what I want (I don't want to mess with Kronolith for this application since I don't want all the overhead of the horde libraries. For my purposes, I just need a weekly calendar).

I have everything working fine (all the display stuff) except for the above algorithm. What I'm using now is kind of a kludge that will print incorrect output every once in a while. That's not ideal.

Here's how I have this structured: I have an associative array filled with all my events for the week (day of event along with starttime and endtime), which I can preprocess in any way I see fit. For each day, I need to be able to determine the total number of table columns needed to correctly display the information, as well as the number of columns each individual event will span. I am hardcoding my table to work in 15 minute increments, and you can assume that your algorithm wont have to deal with any messiness on that front (ie events will only start and end at 00, 15, 30, or 45).

The display requirements for each day are that 1.) the events for each day must fill up the entire day column at some point. For example, if you have one group of events situated to be three events across (giving a maxcolumn value of 3 for that day), and a single event later in the day, that event must be given a colspan of 3, to fill up the entire day column. However, if you have a three events simultaneously earlier in the day, and then two events simultaneously later, it's okay for one of those two events to have a colspan of 1 and the other a colspan of 2. Your algorithm should divvy up these colspans between the two in some manner. Also, keep in mind that there are several possible logic states that dictate whether or not a new column needs to be added for a particular day, and I need your algorithm to successfully deal with every combination. I'm going to run your algorithm once for every day of the week, so you only need to deal with the events for one day. You may assume that the array of events you're dealing with only contains events for the day you're working on.

Your algorithm can be done in pseudocode that just details the logic of what you're doing, but please be specific with what your arrays are up to so that it it's pretty clear what's going on. You basically need to populate some value with the max number of columns I need to print for that day, as well as populate the event array (which contains each event) with the colspan I will need to display each of them at in my table. You can take as many processing loops as you need to come up with these values.

Thanks in advance for considering this. I know it's a bear of a problem, which will probably take some considerable figuring. I will consider adding more points if it becomes clear that several people have contributed to painting a clearer picture for me. Let me know if you have any questions!Start Free Trial
[+][-]07.22.2003 at 03:20PM PDT, ID: 8980935

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2003 at 04:12PM PDT, ID: 8981206

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2003 at 06:00PM PDT, ID: 8981683

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: event, php
Sign Up Now!
Solution Provided By: TunaMan
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.29.2003 at 10:15AM PDT, ID: 9029608

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32