/Users/lyon/j4p/src/net/server/servlets/FormCHtml.java
|
1 package net.server.servlets;
2
3 /**
4 * FormCHtml Class
5 */
6
7 public class FormCHtml {
8
9 String hdr1 = "Form C: Competency - based Review Form for Basic Knowledge,"
10 + " Skills and Abilities";
11
12 String hdr2 = "Complete for all students in your class using a scale from 1 to 5:";
13 String hdr3 = "see other side for explanation";
14
15
16 private final String header = Html.getImage(Html.quote(
17 "../images/logo.jpg"), "center")
18 + Html.getBreak()
19 + Html.getBold(Html.getFont(hdr1, "+2"))
20 + Html.getBreak()
21 + hdr2
22 + Html.getUnderline(hdr3);
23
24 private final String bodyTitle = "Basic Competencies";
25
26 private final String bodyColumnTitle[] =
27 {"S.No",
28 "Students Name",
29 "Analytical" + Html.getBreak() + "Skills",
30 "Communic." + Html.getBreak() + "Skills",
31 "Creative " + Html.getBreak() + "Problem" + Html.getBreak() + "Solving",
32 "Life-Long " + Html.getBreak() + "Learning",
33 "Project" + Html.getBreak() + "Management",
34 "Research" + Html.getBreak() + "Skills",
35 "System" + Html.getBreak() + "Thinking",
36 "Teamwork"};
37
38
39 private final String footer[] = {"1=Not at All ",
40 "2=To a Limited Extent",
41 "3=To a Satisfactory Extent",
42 "4=To a Great Extent",
43 "5=To a Very Great Extent"};
44
45
46 private final String errorMsg[] =
47 {Html.getBold(Html.getFont("Error: Unable to Locate FormC.Property File", "+2")),
48 Html.getBold(Html.getFont("Error: Unable to Locate FormC.Csv File", "+2")),
49 Html.getBold(Html.getFont("Error: Unknown", "+2")),
50 Html.getBold(Html.getFont(" Section and Term do not exist for this class<p>Please select the Back button on your browser and try again ", "+2"))};
51
52 private final String title = "Form C";
53 private final String formMethod = "GET";
54
55 /**
56 * getFormCSheet Method
57 *
58 * @return String
59 */
60
61 private String getFormCSheet(String a[][]) {
62 String s = "";
63
64 for (int i = 0; i < a.length; i++) {
65 if (i == 0) {
66 s = s + "<tr align=" + Html.quote("Center") + ">";
67 s = s + Html.getTd(a[i][i], (11 + ""));
68 } else {
69 s = s + "<tr>";
70
71 for (int j = 0; j < a[i].length; j++) {
72 s = s + Html.getTd(a[i][j]);
73 }
74 }
75
76 s = s + "</tr>\n";
77 }
78
79 return s;
80 }
81
82
83 /**
84 * getSelectionData Method
85 *
86
87 * @return String
88 */
89
90 private String getSelectionData(String[] term, String[] course,
91 String[] section) {
92
93
94 String data = "Course Number & Name"
95 + Html.getComboBox("cboCourse", course)
96 + Html.getBreak()
97 + "Section"
98 + Html.getComboBox("cboSection", section)
99 + "Term"
100 + Html.getComboBox("cboTerm", term);
101
102
103 return Html.getTable(Html.getRow(Html.getTd(data), "Center"), "0", "100%", "Nowrap");
104
105 }
106
107
108 /**
109 * getCommandSubmit Method
110 *
111 * @return String
112 */
113
114 private String getCommandSubmit() {
115
116 return Html.getTable(
117 Html.getRow(
118 Html.getTd(Html.getSubmitButton()), "Center"),
119 "0", "100%", "Nowrap");
120
121 }
122
123
124 /**
125 * getHeader Method
126 *
127 * @return String
128 */
129
130 private String getHeader() {
131
132 return Html.getTable(Html.getRow(Html.getTd(header), "Center"), "0", "100%", "Nowrap");
133
134 }
135
136
137 /**
138 * getHeaderDetail Method
139 *
140 * @return String
141 */
142
143 private String getHeaderDetail(String term, String course,
144 String instructor) {
145
146 String headerDetail[] = {"Course Number & Name : " + Html.getBold(course),
147 "Instructor : " + Html.getBold(instructor),
148 "Term : " + Html.getBold(term)};
149
150
151 return Html.getTable(Html.getRow(Html.getTd(headerDetail), "Center"), "0", "100%", "Nowrap");
152
153 }
154
155 /**
156 * getBody Method
157 *
158 * @return String
159 */
160
161 private String getBody(String[] students) {
162 int noOfRows = students.length + 2;
163 int noOfColumns = 10;
164
165 String data[][] = new String[noOfRows][noOfColumns];
166 String colTitle[] = bodyColumnTitle;
167
168 for (int i = 0; i < 2; i++) {
169 for (int j = 0; j < data[i].length; j++) {
170 switch (i) {
171 case 0:
172 if (j == 0)
173 data[i][j] = bodyTitle;
174 else
175 data[i][j] = " ";
176 break;
177 case 1:
178 data[i][j] = colTitle[j];
179 break;
180 }
181 }
182 }
183
184 for (int i = 2; i < data.length; i++) {
185 for (int j = 0; j < data[i].length; j++) {
186 switch (j) {
187 case 0:
188 data[i][j] = (i - 1) + "";
189 break;
190 case 1:
191 data[i][j] = students[i - 2];
192 break;
193 default:
194 //deh added n/a to list of choices for professor
195 data[i][j] = Html.getComboBox(("cbo" + (i - 2) + (j - 2)), 5, "n/a");
196 break;
197 }
198 }
199 }
200
201 return Html.getTable(getFormCSheet(data), "1", "100%", "Nowrap");
202
203 }
204
205
206 /**
207 * getBody Method
208 *
209 * @return String
210 */
211
212 private String getBody(String[] students, String[] fields,
213 String[] fValues) {
214 int noOfRows = students.length + 2;
215 int noOfColumns = 10;
216
217 String data[][] = new String[noOfRows][noOfColumns];
218
219 String colTitle[] = new String[bodyColumnTitle.length];
220 colTitle = bodyColumnTitle;
221
222 for (int i = 0; i < 2; i++) {
223 for (int j = 0; j < data[i].length; j++) {
224 switch (i) {
225 case 0:
226 if (j == 0)
227 data[i][j] = bodyTitle;
228 else
229 data[i][j] = " ";
230 break;
231 case 1:
232 data[i][j] = colTitle[j];
233 break;
234 }
235 }
236 }
237
238 for (int i = 2; i < data.length; i++) {
239 for (int j = 0; j < data[i].length; j++) {
240 switch (j) {
241 case 0:
242 data[i][j] = (i - 1) + "";
243 break;
244 case 1:
245 data[i][j] = students[i - 2];
246 break;
247 default:
248 for (int k = 0; k < fields.length; k++) {
249 if (fields[k].equals("cbo" + (i - 2) + (j - 2))) {
250 data[i][j] = Html.getCenter(fValues[k]);
251 break;
252 }
253 }
254 break;
255 }
256 }
257 }
258
259 return Html.getTable(getFormCSheet(data), "1", "100%", "Nowrap");
260
261 }
262
263
264 /**
265 * getFooter Method
266 *
267 * @return String
268 */
269
270 private String getFooter() {
271
272 return Html.getTable(Html.getRow(Html.getTd(footer), "Center"), "0", "100%", "Nowrap");
273
274 }
275
276 /**
277 * getErrorMessage Method
278 * @return String
279 */
280
281 private String getErrorMessage(int error) {
282
283 return Html.getTable(Html.getRow(Html.getTd(errorMsg[error]),
284 "Center"), "0", "100%", "Nowrap");
285
286 }
287
288 /**
289 * Returns FormC Selection page
290 *
291 * @return String
292 */
293
294 public String formCSelect(String[] term, String[] course,
295 String[] section, String action) {
296
297 return
298 Html.getHtml(
299 Html.getHead(Html.getTitle(title)) +
300 Html.getBody(
301 Html.getForm(action, formMethod,
302 Html.getBreak()
303 + getHeader()
304 + Html.getHiddenField("txtNextAction", "CollectData")
305 + Html.getBreak()
306 + getSelectionData(term, course, section)
307 + Html.getBreak()
308 + getCommandSubmit())
309 )
310 );
311 }
312
313
314 /**
315 * Returns FormC page
316 *
317 * @return String
318 */
319
320 public String formC() {
321
322 String students[] = {"Student0", "Student 1", "Student 2"};
323
324 return
325 Html.getHtml(
326 Html.getHead(Html.getTitle(title)) +
327 Html.getBody(
328 Html.getForm("", formMethod,
329 getHeader()
330 + Html.getHiddenField("txtNextAction", "DisplayData")
331 + Html.getBreak()
332 + getHeaderDetail("", "", "")
333 + getBody(students)
334 + Html.getBreak()
335 + getFooter())
336 )
337 );
338 }
339
340
341 /**
342 * Returns FormC page
343 *
344 * @return String
345 */
346
347 public String formC(String term, String course, String instructor,
348 String[] students, String action) {
349
350 return
351 Html.getHtml(
352 Html.getHead(Html.getTitle(title)) +
353 Html.getBody(
354 Html.getForm(action, formMethod,
355 getHeader()
356 + Html.getHiddenField("txtNextAction", "DisplayData")
357 + Html.getBreak()
358 + getHeaderDetail(term, course, instructor)
359 + getBody(students)
360 + Html.getBreak()
361 + getCommandSubmit()
362 + Html.getBreak()
363 + getFooter())
364 )
365 );
366 }
367
368 /**
369 * Returns FormC pre confirmation page
370 *
371 * @return String
372 */
373
374 public String formCData(String term, String course,
375 String instructor, String[] students,
376 String[] fields, String[] fValues) {
377
378 return
379 Html.getHtml(
380 Html.getHead(Html.getTitle(title)) +
381 Html.getBody(
382 Html.getForm("", formMethod,
383 getHeader()
384 + Html.getHiddenField("txtNextAction", "SQL")
385 + Html.getBreak()
386 + getHeaderDetail(term, course, instructor)
387 + getBody(students, fields, fValues)
388 + Html.getBreak()
389 + getCommandSubmit()
390 + Html.getBreak()
391 + getFooter())
392 )
393 );
394 }
395
396 /**
397 * Returns FormC post confirmation page
398 *
399 * @return String
400 */
401
402 public String formCUpdate() {
403
404 String updateHdr =
405 Html.getBold(Html.getFont("User Data has been written to All_forms Database", "+2"));
406
407
408 return
409 Html.getHtml(
410 Html.getHead(Html.getTitle(title)) +
411 Html.getScript("JavaScript") +
412 Html.getBody(
413 Html.getForm("", formMethod,
414 Html.getBreak()
415 + getHeader()
416 + Html.getBreak()
417 + Html.getTable(Html.getRow(Html.getTd(updateHdr), "Center"),
418 "0", "100%", "Nowrap")
419 + Html.getBreak()
420 + Html.getCenter(Html.getCommandButton("cmdOK", "OK",
421 "onClick", "window.close()"))
422 + Html.getBreak())
423 )
424 );
425 }
426
427 /**
428 * Returns FormC error page
429 *
430 * @return String
431 */
432
433 public String formCError(int error) {
434
435 return
436 Html.getHtml(
437 Html.getHead(Html.getTitle(title + " " + "Error")) +
438 Html.getBody(
439 Html.getForm("", formMethod,
440 Html.getBreak()
441 + getErrorMessage(error))
442 )
443 );
444 }
445 }