CodeSOD: Circle Space
Are you satisfied with your service today?Answer a brief survey and enter to win a New* IPAD!!!!**
The nice thing about working in an outsourced development firm was that the type of work varied from day to day. One client might want an eCommerce website, while the next wanted an app to plug into their eCommerce site, and the next wanted to set their old eCommerce site on fire and replace it with WordPress. Endless variety!
The downside, of course, was that sometimes the assignments were ... less than glamorous. Today's client was a repeat customer, but since the original dev had left the company, Jason received the assignment to update their customer satisfaction survey. It should've been simple, just a layout tweak and adding some new questions.
Taking a look under the hood, Jason found a kludge of technologies: Ruby on Rails, generating PHP, which would then be interpreted into HTML and served to the customer, where it'd be picked apart and updated in JavaScript. When a user finished answering survey questions, a PDF was generated by overlaying circles on a static form that had been scanned in from their original, paper solution.
On the form, each question had an initial bounding text box where the question and the answer checkboxes were defined. To ensure that the marks were placed in exactly the right spot, the developer had tweaked the font sizes in each text box, and used a series of spaces to adjust the horizontal position before printing a Unicode circle. It had been a laborous task of trial and error, and clearly the previous developer had gotten far too clever: not only did he use the standard space character you can type from your keyboard, but he also used "full-width spaces" to span larger gaps, dropping to normal ones for fine tweaking.
"purpose" => array( //Q1 "width" => 150, "height" => 30, "x" => 9, "y" => 83, "size" => 18, "sample" => "a-", "choice" => array( "a-", "aaaaaaaaaaaa-", "aaaaaaaaaaaaaaa a a-", ), ),"symptom" => array( //Q2 "width" => 180, "height" => 30, "x" => 10, "y" => 98, "size" => 14, "sample" => "a-\na-\na-", "choice" => array( "aaaaaa-", "aaaaaaaaaaaaaaa-", "aaaaaaaaaaaaaaaaaaaaaaaa-", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-", "\naaaaaa-", "\naaaaaaaaaaaaaa-", "\naaaaaaaaaaaaaaaaaaaaaaaa-", "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-", "\n\na-", "\n\naaaaaaaaaaaaaa-", "\n\naaaaaaaaaaaaaaaaaa-", "\n\naaaaaaaaaaaaaaaaaaaaa-", "\n\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-", "\n\n\naaaa-", ), "which_choice" => array( array("a-","aa-","a aa-",), array(" aaaaaaaaaa-"," aaaaaaaaaaa-"," a aaaaaaaa aaa-",), array("a aaaaaaaaaaaaaaaaa-","a aaaaaaaaaaaaaaaaaa-","a aaaaaaaaaaaaaaaaa aa-",), array(" aaaaaaaaaaaaaaaaaaaaaaaaaaa-"," aaaaaaaaaaaaaaaaaaaaaaaaaaaa-"," aaaaaa aaaaaaaaaaaaaaaaaaaaaaa-",), array("\na-","\naa-","\na aa-",), array("\naaaaaaaaa-","\naaaaaaaaaaa-","\naaaaaaaaaaaa-",), array("\naaaaaaaaaaaaaaaaaa-","\naaaaaaaaaaaaaaaaaaaa-","\naaaaaaaaaaaaaaaaaa aaa-",), array("\n aaaaaaaaaaaaaaaaaaaaaaaaaaa-","\n aaaaaaaaaaaaaaaaaaaaaaaaaaaa-","\n aaaaaaaaaaaaaaaaaaaaaaaaa >aa aa-",), array("\n\naaaa-","\n\naaaa a-","\n\naaa aaaaa-",), "", "", "", array("\n\naaaaaaaaaaaaaaaaaaaaaaaaa-","\n\naaaaaaaaaaaaaaaaaaaaaaaaaa-","\n\naaaaaaaaaaaaaaaaaaaaaaaaaa a-",), ), ),
What should have been a 30-minute tweak grew to fill 30 hours. Not only did the client want to enter new questions, but they wanted to re-order the sequence in which some of them were presented to the user, and the only way to validate that the right answers were placed in the right checkboxes was to take a survey, write down the answers you entered, and print off the PDF to verify. If all the questions had been yes-or-no, it would take 2n surveys to check all answer combinations, but of course some of them had 3 or 4 answers. And then Jason would find a single misplaced circle and have to start over ...
[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!