Sharedwww / 08Survey / xml2tex.plOpen in CoCalc
Author: William A. Stein
1
#!/usr/bin/perl
2
#
3
# Transform survey xml into TeX
4
# read xml data from standard input and writes a TeX file to standard output
5
# will need a small amount of tweaking in future years
6
#
7
# uses XML::Simple (http://theoryx5.uwinnipeg.ca/CPAN/data/XML-Simple/index.html)
8
#
9
# dlu 12-July-2005
10
#
11
12
use strict;
13
use XML::Simple;
14
15
my ($response, $response_number, $category, %category_labels, %misc_labels);
16
my @categories_with_ratings = qw(EducationalExp Theme Interactions Expectations Lectures Notes Projects Website);
17
my @categories_sans_ratings = qw(Courses FutureOrg FutureTopics Other);
18
19
#set up labels
20
foreach (@categories_with_ratings, @categories_sans_ratings) {
21
$category_labels{$_} = $_;
22
}
23
$category_labels{"EducationalExp"} = "Educational Experience";
24
$category_labels{"Website"} = "Web Site";
25
$category_labels{"FutureOrg"} = "Future Organization";
26
$category_labels{"FutureTopics"} = "Future Topics";
27
28
$misc_labels{"jrgrad"} = "Jr.~grad student";
29
$misc_labels{"srgrad"} = "Sr.~grad student";
30
$misc_labels{"postdoc"} = "Post-doc";
31
$misc_labels{"ttfaculty"} = "Tenure track faculty";
32
$misc_labels{"other"} = "Other";
33
$misc_labels{"none"} = "None";
34
$misc_labels{"air"} = "Airfare";
35
$misc_labels{"hotel"} = "Hotel";
36
$misc_labels{"both"} = "Airfare and Hotel";
37
$misc_labels{"yes"} = "Yes";
38
$misc_labels{"no"} = "No";
39
40
41
42
# input XML data from standard input
43
my $data = XMLin('-');
44
# to see data format (a hash of arrays of hashes of ...):
45
# Data::Dumper;
46
# print Dumper($data);
47
48
49
50
# write first page of Tex file, giving questions
51
sub write_head {
52
print '\font\twelverm=cmr12
53
\centerline{\twelverm Arizona Winter School 2006}
54
\centerline{\twelverm Participant Survey}
55
\bigskip
56
\noindent{\bf The questions:} (The types of responses collected are indicated in square brackets.)
57
\medskip\narrower\narrower\parindent=0pt
58
Please answer the following questions on a scale of 1 to 5 where 1 signifies the lowest rating or least extent and 5 signifies the highest rating or extent:
59
\smallskip
60
{\obeylines
61
What is your rating of the overall quality of the educational experience at AWS 2006?
62
[Rating, Comments]
63
\smallskip
64
What is your rating of the overall appropriateness and interest of the general theme (´┐ŻComputational and algorithmic aspects of algebra and arithmetic´┐Ż) of AWS 2006?
65
[Rating, Comments]
66
\smallskip
67
What is your rating of the overall quality of the interactions, such as the evening working sessions, at AWS 2006?
68
[Rating, Comments]
69
\smallskip
70
To what extent were your expectations for AWS 2006 met?
71
[Rating, Comments]
72
\smallskip
73
What is your rating of the overall quality of the lectures at AWS 2006?
74
[Rating, Comments]
75
\smallskip
76
What is your rating of the overall quality of the notes provided for AWS 2006?
77
[Rating, Comments]
78
\smallskip
79
What is your rating of the overall quality of the proposed student projects at AWS 2006?
80
[Rating, Comments]
81
\smallskip
82
What is your rating of the overall quality of the Southwestern Center web site?
83
[Rating, Comments]
84
\smallskip
85
Do you have any mathematical or organizational comments about any of the courses at AWS 2006?
86
[Comments]
87
\smallskip
88
Do you have any suggestions for improving the organization of future Arizona Winter Schools?
89
[Comments]
90
\smallskip
91
Do you have any suggestions for topics or speakers for future Arizona Winter Schools?
92
[Comments]
93
\smallskip
94
Do you have any other comments or suggestions?
95
[Comments]
96
\smallskip
97
Which category best describes you? (Jr grad student = not yet working on a thesis; Sr grad student = working on a thesis.)
98
[(Jr grad student, Sr grad student, Post-doc, Tenure track faculty, Other), Comments]
99
\smallskip
100
If you are student, where you involved in a project?
101
[Yes, No]
102
\smallskip
103
What funding will you receive from the Southwestern Center for AWS 2006?
104
[None, Hotel, Airfare, Airfare and Hotel]
105
\smallskip
106
Which previous Arizona Winter Schools have you attended?
107
[1998-2005]
108
\smallskip
109
110
}
111
\hrule\filbreak\bigskip
112
\parindent=0pt
113
114
';
115
}
116
117
# write the end of the TeX file
118
sub write_tail {
119
print "\\end\n";
120
}
121
122
# next 3 subroutines detect whether a response is there by using "ref";
123
# an empty XML tag generates a hash entry which is a reference to an empty hash
124
125
# print out ratings, when they are there
126
sub rating_print {
127
if (ref($_[0])) {
128
print "(No response) "; }
129
else { print $_[0], ' '; }
130
}
131
132
# print out other check boxes, when they are there, using labels rather than actual box names
133
sub labeled_print {
134
if (ref($_[0])) {
135
print "(No response) "; }
136
else { print $misc_labels{$_[0]}, ' '; }
137
}
138
139
# print out comments, when they are there
140
sub comments_print {
141
if ( ! ref($_[0])) {
142
print $_[0], ' '; }
143
}
144
145
146
# put it all together ...
147
148
&write_head;
149
150
$response_number = 1;
151
152
foreach $response (@{$data->{"RESPONSE"}}) {
153
print "\\centerline{{\\bf Response Number:} ", $response_number, "\\hfil{\\bf Date:} ",
154
$response->{"Date"}, "\\hfil{\\bf Time:} ", $response->{"Time"}, "}\n",
155
"\\medskip\n";
156
$response_number += 1;
157
foreach $category (@categories_with_ratings) {
158
print "{\\bf ", $category_labels{$category}, ":} ";
159
rating_print($response->{$category});
160
print "\\quad\n";
161
comments_print($response->{$category . "Comments"});
162
print "\\medskip\n";
163
}
164
foreach $category (@categories_sans_ratings) {
165
print "{\\bf ", $category_labels{$category}, ":} ";
166
print "\n";
167
comments_print($response->{$category . "Comments"});
168
print "\\medskip\n";
169
}
170
print "{\\bf Status:} ";
171
labeled_print($response->{"Status"});
172
print "\\quad\n";
173
comments_print($response->{"StatusComments"});
174
print "\\medskip\n";
175
print "{\\bf Project?} ";
176
labeled_print($response->{"Project"});
177
print "\\medskip\n";
178
print "{\\bf Funding:} ";
179
labeled_print($response->{"Funding"});
180
print "\\medskip\n";
181
print "{\\bf Previous Winter Schools:} ";
182
foreach (qw(AWS1998 AWS1999 AWS2000 AWS2001 AWS2002 AWS2003 AWS2004 AWS2005)) {
183
if ($response->{$_} eq 'on') {
184
print substr($_,3,4), " ";
185
}
186
}
187
print "\n\\medskip\n";
188
print "\\hrule\\filbreak\\bigskip\n";
189
}
190
191
&write_tail;
192