In PDFAssessment2_4.java, separateQuestions() and combineAndSplit() functions are executed one after the other, which are responsible for the glitch. Here is what I learnt from the code:
separateQuestions():
instruction block is identified based on the presence of "[i-j]" or
"i through j" or "question i and j"
For each question included in the question-range, instruction block is
prepended.
combineSplitQuestions():
If the text (instructions) preceding a group of questions is found to
contain options then those options are associated with each of the
questions in that group!
a) First, options are saved when such case is recognized.
b) Then, for each subsequent question recognized without options,
the stored options get associated! (appended)
c) The common text deemed as instructions preceding the options
is deleted!
The problem occurs in combineSplitQuestions() when a document has an
instruction block (e.g., "questions 1-5" or "questions 1 through 5")
followed by options for those questions also included in the instruction
block. In this case, separateQuestions() first associates the entire instruction block, including the options, with each of the questions 1 through 5. Then, combineSplitQuestions() looks at the text for question 1, saves the options
text and deletes the text, assuming that the text is only an instruction block that precedes a list of questions! Unfortunately, in this case, this operation results in deleting the question itself and hence, the final result seems to miss the questions 1-5!
Only two cases of text preceding a bunch of questions are currently distinguished and handled.
a) question numbers for which the common instructions are applicable are
specified in the text, e.g., "questions 1-8 ".
In this case, separateQuestions() would have marked the instructions
as an 'INSTRUCTION BLOCK' and would associate with each of
the questions in the range: 1-8!
b) question numbers aren't explicitly identified but common options are
specified, in which case,
the options are nicely associated with each question that
follows the common instructions until a question with its own
options is discovered. In this case, the common instructions
are rightly 'removed' (e.g., doc1.pdf)!
Hence, make amends in SeparateQuestions() first, to look for "options"
text within the common instructions block. If options found then
segregate options from common instructions and strip off the
question number qualifier so that combine-split will correctly
associate options to questions that follow.