3 Replies Latest reply on May 18, 2015 1:02 PM by Design Proj Dev

    Is is possible to 1) Use a paragraph style to trigger building a table and 2) Locate a table row based on the paragraph style it contains and move that row within the table.

    Design Proj Dev

      I have been tasked with finding out if this is possible, but I don't know scripting (except a bit of the tutorial I've done so far).

      I just want to know if anyone thinks this can be done. If so, it'll be worth my time to try to search, learn and figure it out.

       

      I have a PDF (or 600 of them!) of an exam. There is a question and either 4 or 2 answers. One answer is correct.

      I have a number of GREP scripts I made that are able to format the text to the proper paragraph styles: Exam Question (style), Exam Answer (style), and Exam Correct Answer (style).

       

      Now what I need to know is if it is possible to script finding the Exam Question style and to make a table out of it and the following answer styles. Then when it finds another Exam Question style, start a new table, and so on.

       

      The reason I need to do this is because I then need match the correct answers to the questions to an existing answer key and, of course, the answers aren't in the right order in the PDFs I get the info from! So, what I'm hoping is that is that it is possible to make a script that locates the table row containing the Exam Correct Answer style in the first table and then moves that row to the proper position in that table, then does the same in the next table and the next...on through the 50 questions in the exam.

       

      I know that paragraphs that are automatically numbered (as my styles are set up) can't be searched, so I am hoping that I could find a particular question and properly position the answer row based on the order of the tables in the document..

       

      I have no idea if I'm right, but I was thinking that with separate tables, the number of the table (1-50) could be targeted so that the correct answer in that table could be moved to the right spot for that particular question/table number. I know that table rows can be alphabetized, but have no clue whether they can be rearranged in the way I propose.

       

      Thanks in advance for any advice you may have!

        • 1. Re: Is is possible to 1) Use a paragraph style to trigger building a table and 2) Locate a table row based on the paragraph style it contains and move that row within the table.
          Design Proj Dev Level 1

          Oh, and I'm looking to do this in jsx. Since I don't know any scripting, I might as well learn something more generally useful than Actionscript!

          • 2. Re: Is is possible to 1) Use a paragraph style to trigger building a table and 2) Locate a table row based on the paragraph style it contains and move that row within the table.
            Vamitul Level 4

            Could you show a before/after indesign file? It is kind of hard to follow all that text description, but from what I understand from it, the answer is yes, it should be possible and it should be a nice beginner-level project to get you started with jsx.

            • 3. Re: Is is possible to 1) Use a paragraph style to trigger building a table and 2) Locate a table row based on the paragraph style it contains and move that row within the table.
              Design Proj Dev Level 1

              Thanks for responding Vamitul. See if this image with explanation helps you see what I'm talking about.
              1st script action:  Each Question/Answer unit needs to be scripted to convert to a table, one table for each of 50 Question/Answer units.

              2nd script action:  Each row with green correct-answer text needs to move to the row location within it's current table that matches the standardized answer key.

              Examples: (see image below right): Green text table row in question 1 needs to move to become the 5th table row within it's 6-row table (it doesn't matter what order the other answer rows are in).

              Green text table row in question 2 needs to move to become the 3rd table row within it's 4-row table. (In this case, the answer rows would trade places.)

               

              Please note that the table is to have no rules around or within it at all (the blue just shows where the rules would be if there were any). The table has a style, but the table width and the height of the last (empty) row will have to be scripted.

               

              Some of the questions only have two answers (True/False).

               

              The last row serves as the spacing between the separate Question/Answers tables (empty row was created from the return at the end of the last question in a Question/Answer unit when the table was made).

               

              Three Paragraph Styles involved: Exam Question (bold), Exam Answer, Exam Correct Answer (green).

              Sample.jpg

              Potential challenges I see:

              • Creating each table turns the last return between Question/Answer units into an empty row. That works for using that row as spacing, but I'm thinking it causes a problem with locating the next question because there is no longer a return between the table and the next question. I wanted to use locating the style to start the next table. When I get to the point of targeting each table to reorder the rows, will I even be able to do that without returns between them?

              Note: I cannot add a return between tables because that causes the automatic numbering to
                        add in an extra number for that return.

              • I will need to script it so that the tables don't break between columns and pages. I think I've seen reference to doing this elsewhere in this forum.
              • I will then have to script to style the entire table units so that they don't indent within the text frame (as it does in the last example above).

              Shoot, the explanation is still really long, but thanks for looking at it!