How to Add Answer Areas Manually in Custom Designed OMR Forms

Version 10 (Hiroya Kubo, 2010-05-03 21:54)

1 3 Hiroya Kubo
h2. How to Add Answer Areas Manually in Custom Designed OMR Forms
2 1 Hiroya Kubo
3 2 Hiroya Kubo
h3. Overview of the sqm file
4 2 Hiroya Kubo
5 2 Hiroya Kubo
You should learn how to write your own OMR master file, which is called sqm file. The sqm file contains mark area position information and OMR metadata.
6 2 Hiroya Kubo
7 2 Hiroya Kubo
SourceEditor generates a pdf file with 2 attachment files: sqs(SQS questionnaire source file) and sqm(SQS questionnaire master file).
8 2 Hiroya Kubo
The sqm file in a pdf file can be replaced with your manually modified sqm file. 
9 2 Hiroya Kubo
Thus, you can design your own OMR form with using any kind of DTP applications, if you can create your sqm file manually with your text editors or xml editors.
10 2 Hiroya Kubo
11 2 Hiroya Kubo
In such cases, you can put a bare sqm file(with ".sqm" suffix) into your source folder which is to be processed by MarkReader.
12 2 Hiroya Kubo
The bare sqm file in your folder will be work as a substitute of the pdf file with the 2 attachment files.
13 2 Hiroya Kubo
14 4 Hiroya Kubo
First, you should extract a sqm file of your OMR form pdf file. It can be used as a template.
15 4 Hiroya Kubo
16 2 Hiroya Kubo
h3. Inside the sqm file
17 2 Hiroya Kubo
18 5 Hiroya Kubo
h4. Extension of SVG Print format
19 5 Hiroya Kubo
20 5 Hiroya Kubo
An sqm data is mark-upped as an XML instance. Its host language is W3C SVG Print and extended with W3C XForms and SQS original vocabulary.
21 5 Hiroya Kubo
22 5 Hiroya Kubo
There are a page set structure, the same as SVG Print format. There are one svg:masterPage element and one or more svg:page elements in it.
23 5 Hiroya Kubo
24 5 Hiroya Kubo
The coordinates of the origin point is at the upper-left corner of the page, the same as SVG image's coordinate of the origin point is at the upper-left.
25 5 Hiroya Kubo
26 5 Hiroya Kubo
27 5 Hiroya Kubo
<pre>
28 5 Hiroya Kubo
29 5 Hiroya Kubo
(0,0)______________
30 5 Hiroya Kubo
  |               |__
31 5 Hiroya Kubo
  |               | |__
32 5 Hiroya Kubo
  |               | | |__
33 5 Hiroya Kubo
  |               | | | |
34 5 Hiroya Kubo
  |               | | | |
35 5 Hiroya Kubo
  |               | | | |
36 5 Hiroya Kubo
  |               | | | |
37 5 Hiroya Kubo
  |               | | | |
38 5 Hiroya Kubo
  |               | | | |
39 5 Hiroya Kubo
  |               | | | |
40 5 Hiroya Kubo
  |               | | | |
41 5 Hiroya Kubo
  |               | | | |
42 5 Hiroya Kubo
  ~|~~~~~~~~~~~~~~~ | | |
43 5 Hiroya Kubo
    ~|~~~~~~~~~~~~~~  | |
44 5 Hiroya Kubo
     ~~|~~~~~~~~~~~~~~  |
45 5 Hiroya Kubo
       ~~~~~~~~~~~~~~~~~~
46 5 Hiroya Kubo
</pre>
47 5 Hiroya Kubo
48 2 Hiroya Kubo
h4. Page width, height and the coordinates
49 2 Hiroya Kubo
50 2 Hiroya Kubo
At the begging of the sqm file, there are the page width and height definitions as follows:
51 2 Hiroya Kubo
52 2 Hiroya Kubo
<pre>
53 2 Hiroya Kubo
 svg:width="595" svg:height="842"
54 2 Hiroya Kubo
</pre>
55 2 Hiroya Kubo
56 2 Hiroya Kubo
In this example, the width and height values are calculated the image size of a PDF page rendered at 72 dpi. 
57 2 Hiroya Kubo
The following coordinate values in this article are proportion to this page width and page height.
58 2 Hiroya Kubo
59 2 Hiroya Kubo
h4. The corner black rectangle definitions
60 2 Hiroya Kubo
61 2 Hiroya Kubo
In sqm file, there are some point definitions in master page:
62 2 Hiroya Kubo
63 2 Hiroya Kubo
* corner data (4 point)
64 1 Hiroya Kubo
* upsidedownchecker (2 rect)
65 2 Hiroya Kubo
* evenoddchecker (2 rect)
66 2 Hiroya Kubo
67 5 Hiroya Kubo
At 72 dpi, the corner points are positioned as following illustration:
68 2 Hiroya Kubo
69 2 Hiroya Kubo
<pre>
70 7 Hiroya Kubo
(0,0)____________________
71 7 Hiroya Kubo
  |                     |__
72 9 Hiroya Kubo
  | (99,29)   (497,29)  | |__
73 7 Hiroya Kubo
  |   ##1         ##2   | | |__
74 7 Hiroya Kubo
  |                     | | | | 
75 7 Hiroya Kubo
  |                     | | | |
76 7 Hiroya Kubo
  |                     | | | |
77 7 Hiroya Kubo
  |                     | | | |
78 7 Hiroya Kubo
  |                     | | | |
79 7 Hiroya Kubo
  |                     | | | |
80 7 Hiroya Kubo
  |                     | | | |
81 7 Hiroya Kubo
  |                     | | | |
82 7 Hiroya Kubo
  |                     | | | |
83 8 Hiroya Kubo
  |   !#3          !#4    | | | |
84 7 Hiroya Kubo
  | (94,810)   (492,810)| | | |
85 7 Hiroya Kubo
  |                     | | | |
86 10 Hiroya Kubo
  ~|~~~~~~~~~~~~~~~(594,841)| |
87 8 Hiroya Kubo
   ~~|~~~~~~~~~~~~~~~~~~~~~ | |
88 7 Hiroya Kubo
     ~~|~~~~~~~~~~~~~~~~~~~~~ |
89 7 Hiroya Kubo
       ~~~~~~~~~~~~~~~~~~~~~~~~
90 2 Hiroya Kubo
</pre>
91 2 Hiroya Kubo
92 2 Hiroya Kubo
h4. The upside down checker
93 2 Hiroya Kubo
94 2 Hiroya Kubo
It is very often that there are some upside down sheets in your heap of OMR form sheets to be scanned.
95 2 Hiroya Kubo
To find out the the upside down OMR form sheets, the black rectangles at the upper left corner and at the lower left corner are distinguished by their width. The lower black rectangles are half width of upper black rectangles. So you must point the position of the upper left and the lower left black rectangles.
96 2 Hiroya Kubo
97 2 Hiroya Kubo
h4. The even odd checker
98 2 Hiroya Kubo
99 2 Hiroya Kubo
You can print your OMR form on dual-side of your sheet if it has 2 or more pages per a respondent.
100 2 Hiroya Kubo
On the ODD page, there is a "page number area" at the bottom RIGHT corner.
101 2 Hiroya Kubo
On the other hand, on the EVEN page, there is at the bottom LEFT corner.
102 2 Hiroya Kubo
Suppose you scan a heap of OMR form sheet. They should be scanned correctly like this:
103 2 Hiroya Kubo
<pre>
104 2 Hiroya Kubo
 ODD, EVEN, ODD, EVEN, ODD, EVEN, ...
105 2 Hiroya Kubo
</pre>
106 2 Hiroya Kubo
However, sometimes they might be scanned like this: 
107 2 Hiroya Kubo
<pre>
108 2 Hiroya Kubo
ODD, EVEN, EVEN, ODD, ODD, EVEN, ...
109 2 Hiroya Kubo
</pre>
110 2 Hiroya Kubo
This shows that the second sheet might be accidentally reversed. 
111 2 Hiroya Kubo
So you must point the positions of the page number areas, at the bottom LEFT corner and the bottom RIGHT corner.
112 2 Hiroya Kubo
113 2 Hiroya Kubo
You can disable them by comment out <upsideDownChecker/> element and/or <evenOddChecker/> element in your sqm file.
114 2 Hiroya Kubo
115 2 Hiroya Kubo
116 2 Hiroya Kubo
h4. mark areas and their locations
117 2 Hiroya Kubo
118 2 Hiroya Kubo
In sqm file, mark areas and their locations are defined as follows:
119 2 Hiroya Kubo
120 2 Hiroya Kubo
<pre>
121 2 Hiroya Kubo
 <svg:rect svg:x="84" svg:y="800" svg:width="4" svg:height="12">
122 2 Hiroya Kubo
   <svg:metadata>
123 2 Hiroya Kubo
      .....
124 2 Hiroya Kubo
   </svg:metadata>
125 2 Hiroya Kubo
 </svg:rect>
126 2 Hiroya Kubo
</pre>
127 2 Hiroya Kubo
128 2 Hiroya Kubo
It may be easy to render the page set of your OMR form pdf file into bitmap image files at 72 dpi, and then, pick-up the x,y,width,height values.
129 2 Hiroya Kubo
130 2 Hiroya Kubo
h4. questionnaire item definitions
131 2 Hiroya Kubo
132 2 Hiroya Kubo
You must rewrite some sets of svg:metadata/xforms:select elements in your svg:rect elements, too.
133 2 Hiroya Kubo
134 6 Hiroya Kubo
... under construction ...
135 6 Hiroya Kubo
136 2 Hiroya Kubo
----
137 2 Hiroya Kubo
138 2 Hiroya Kubo
h2. よく、「学籍番号欄をどうやって作ったらよいでしょうか?」と聞かれます。
139 1 Hiroya Kubo
140 1 Hiroya Kubo
学籍番号欄に限らず、「もっといろいろな体裁での帳票を作りたい」 
141 1 Hiroya Kubo
という要望が寄せられておりますが、他に優先度の高い機能開発が 
142 1 Hiroya Kubo
あることなどから、個人的には、このための時間が取れずにおります。 
143 1 Hiroya Kubo
Java(Swing), XML(XSLT,FO,SVG)について知識のある技術者で、 
144 1 Hiroya Kubo
手伝ってくれる方がいるといいのですが…。 
145 1 Hiroya Kubo
あるいは、どうしても今すぐ学籍番号欄の読み取りを実現したいならば…、 
146 1 Hiroya Kubo
SourceEditorは、調査票のPDFファイルを作成するときに、 
147 1 Hiroya Kubo
同時に「SQM形式」と名づけているXMLデータを作成して、 
148 1 Hiroya Kubo
PDFファイルに添付しています。 
149 1 Hiroya Kubo
このSQMデータは、W3C標準のSVG Printという形式を基本としていて、 
150 1 Hiroya Kubo
ページの中のひとつひとつのマークの位置をsvg:rectというタグで定義し、 
151 1 Hiroya Kubo
さらに、svg:metadataというタグの中に、設問の型情報などを、 
152 1 Hiroya Kubo
W3C標準のXFormsという形式て記述するといったような内容になっています。 
153 1 Hiroya Kubo
ようするに、このファイルを自作すればよいのです。 
154 1 Hiroya Kubo
そのためには、まずは、 
155 1 Hiroya Kubo
SourceEditorで作成したPDFファイルをAdobe Illustratorなどで読み込み、 
156 1 Hiroya Kubo
その余白の部分に学籍番号欄を描き足したPDFをつくります。 
157 1 Hiroya Kubo
これが、印刷原稿になります。 
158 1 Hiroya Kubo
次に、このPDFを、 
159 1 Hiroya Kubo
ページ全体を72dpiでラスタライズしたビットマップ画像を作成します。 
160 1 Hiroya Kubo
この画像の中の、自分が描き足した学籍番号のマーク欄のひとつひとつの 
161 1 Hiroya Kubo
マークについて、x,y,width,heightの数字を拾ってメモしておきます。 
162 1 Hiroya Kubo
そうしてメモしておいた数字を使って、SQM形式のデータの中に、 
163 1 Hiroya Kubo
svg:rectのタグを、自分が描き足したマークの数だけ、 
164 1 Hiroya Kubo
見よう見まねで書き足してやればOK、ということになります。 
165 1 Hiroya Kubo
ちなみにぼく自身、 
166 1 Hiroya Kubo
択一選択式設問中の最後の設問を「その他:(   )」というようにしておいて 
167 1 Hiroya Kubo
PDFを生成し、ここに添付されたSQMファイルを開いて編集し、 
168 1 Hiroya Kubo
「その他」の括弧部分の位置に相当するsvg:rectを書き足して、 
169 1 Hiroya Kubo
そのsvg:metadata内には自由記述式設問を表したxforms:textareaを指定する… 
170 1 Hiroya Kubo
といったようなことを、ときどきやります。