|
Home About
FAQs
General Admin Assist Student
Docs
Admin Assistant
CGI
Admin Assistant Download Form Student
Packages
AdminInterface Assignments AssistantInterface Form Interface Record Roster StudentInterface SystemVariables Teams VincentFile VincentLog |
|
0 #Form interface and processing module
1 #Copyright 2000 Matt Jadud
2 #This program is free software; you can redistribute it and/or
3 #modify it under the terms of the GNU General Public License
4 #as published by the Free Software Foundation; either version 2
5 #of the License, or (at your option) any later version.
6 #
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 #GNU General Public License for more details.
11 #
12 #You should have received a copy of the GNU General Public License
13 #along with this program; if not, write to the Free Software
14 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
16 use SystemVariables;
17 use AssistantInterface;
18 use AdminInterface;
19 use Interface;
20 use Record;
21 use VincentLog;
22 use Fcntl qw(:flock); # imports LOCK_EX, LOCK_SH, LOCK_NB
23 use CGI qw(:standard);
24
25 package Form;
26
27 #Turn debugging on or off;
28 $DEBUG = 1;
29 $| = 1;
30
31 #########################################
32 # Main Menu
33 #########################################
34 # The main menu accepts any number of parameters,
35 # which get incorporated into the title bar
36 # at the top of the page. If one of those parameters
37 # happens to be one of the control options
38 # ("Create", "ModifyChooser," etc.), then the menu
39 # branches, and calls the appropriate subroutine
40 # to generate that aspect of the admin interface, instead
41 # of the default menu.
42 sub mainMenu {
43
44 my ($choices,
45 $choice,
46 %menuOptions,
47 $key
48 );
49 $choices = 0;
50 $username = $_[0];
51
52
53 %menuOptions = ("createFormOne" => &createFormOne,
54 "createFormTwo" => &createFormTwo,
55 "do" => &doForm,
56 "answerSelection" => &answerSelection,
57 "displayQuestions" => &displayQuestions);
58
59 #This is now a toggled menu... I may have made this too
60 # complex this way... it branches based on the parameters
61 # passed to mainMenu, and defaults to a basic first page.
62 foreach $choice (@_) {
63
64 #Cycle through the various keys in the menuOptions hash;
65 # if any of them are equal to the current value in the CGI
66 # query, then print the top and bottom of the display,
67 # and route to the function contained in the hash.
68 #
69 # This loop sets $choices to 1, indicating that
70 # the user had selected some choice, and the default
71 # view should not be presented.
72
73 foreach $key (keys %menuOptions) {
74 if($choice eq $key) {
75
76
77 Interface::menuTop("Vincent: Form Interface", @_);
78 $choices = 1;
79 $menuOptions{$key}->(@_);
80 Interface::menuBottom();
81
82 #Branch the linkback script based on the class
83 # of the user.
84 if (Record::isAssistant($username)) {
85 $script = "assistant";
86 } elsif (Record::isAdministrator($username)
87 || Record::isGod($username)) {
88 $script = "admin";
89 } else {
90 $script = "student";
91 }
92
93 print"<CENTER><A HREF='" . $script .".cgi'>Return to the $script script.</A></CENTER>";
94
95 exit();
96
97 }
98 }
99 }
100
101 #Default choices: if no control choices were
102 # hit above, then we present the standard
103 # options presented below
104
105 if(!$choices) {
106
107 ##LOGGING
108 #VincentLog::clickLog(Form, "Default admin page.");
109
110
111 print "<TABLE WIDTH='100%'><TR><TD VALIGN='TOP'>";
112 $classID = SystemVariables::getClassID();
113 $classID .= " ";
114 $classID .= SystemVariables::getClassTagline();
115 $classID =~ s/(.)/$1<BR>/g;
116 print "<H2>$classID</H2>";
117 print "</TD><TD VALIGN='TOP'>";
118
119
120
121 Interface::menuTop("Vincent: Form Interface", @_);
122
123
124 #If they are an administrator...
125 if(Record::isAdministrator($username) ||
126 Record::isGod($username)) {
127 createFormForm();
128 } else {
129
130 print "<TR><TD>";
131 print "<CENTER><H1>";
132 print "<FONT COLOR='RED'>";
133 print "Oops! You probably shouldn't be here!";
134 print "</FONT></H1>";
135 print "<P>If you found your way here by mistake, please";
136 print " let your course administrator know!";
137 print "</CENTER>";
138 print "</TD></TR>";
139 }
140
141
142 Interface::menuBottom();
143
144 #Branch the linkback script based on the class
145 # of the user.
146 if (Record::isAssistant($username)) {
147 $script = "assistant";
148 }
149 if (Record::isAdministrator($username)
150 || Record::isGod($username)) {
151 $script = "admin";
152 }
153 if(!$script) {
154 $script = "student";
155 }
156
157 print"<CENTER><A HREF='" . $script .".cgi'>Return to the $script script.</A></CENTER>";
158
159 print "</TD></TR></TABLE>";
160
161
162 }
163
164 }
165
166
167 sub displayQuestions {
168
169 my($form,
170 $sectionbool,
171 $section,
172 @questions,
173 $i,
174 $numquestions,
175 $query,
176 $data,
177 $sysID,
178 $formWebPath,
179 $maxgrade);
180
181 $username = $_[0];
182 $query = $_[2];
183
184
185 $form = $query->param("_formname");
186 $sectionbool = $query->param("_sectionnumberboolean");
187 $section = $query->param("_sectionnumber");
188 $numquestions = $query->param("_numquestions");
189 $data = Assignments::getAssignmentData($form);
190 $sysID = Assignments::getAssignmentSystemID($form);
191 $maxgrade = $$data{"_MAXVALUE"};
192
193 $formWebPath = SystemVariables::getFormWebPath();
194
195 for($i=0;$i<$numquestions;$i++) {
196 if(defined($query->param("QUESTION$i"))) {
197 push(@questions, "$i");
198 }
199 }
200
201 if($sectionbool) {
202 @users = @{Record::getAllUsernamesInSection($section)};
203 } else {
204 $sectionbool = "ALL";
205 @users = Record::getAllStudentUsernames();
206 }
207
208
209 #Alpha by last name.
210 @users = sort {Record::getLastName($a) cmp Record::getLastName($b)} @users;
211
212 print "<TR><TD>n";
213 Interface::tableTop("Answers to " . $$data{"_DESCRIPTION"});
214 Interface::startForm($formWebPath . "form.cgi");
215 Interface::hidden("PROCESSFORMGRADES", "1");
216 Interface::hidden("NUMBEROFQUESTIONS", $numquestions);
217 Interface::hidden("SYSID", $sysID);
218
219 #print "Sectionbool : $sectionbool - $section<P>";
220
221
222 @colors = ("CCCCCC", "FFFFFF");
223 foreach $question (@questions) {
224
225 $questiontext = getQuestionText($form, $question);
226 print "<TABLE WIDTH='100%'><TR><TD COLSPAN='6' bgcolor='CCFFCC'>";
227 print "<HR><STRONG>QUESTION ", $question+1, " : ", $questiontext, "</STRONG>";
228 print "</TD></TR>";
229 print "<TD><STRONG>Last</STRONG></TD>";
230 print "<TD><STRONG>First</STRONG></TD>";
231 print "<TD><STRONG>Answer</STRONG></TD>";
232 print "<TD><STRONG>Grade<BR><SMALL>(max $maxgrade)</SMALL></STRONG></TD>";
233 print "<TD><STRONG>Username</STRONG></TD>";
234
235 $colorindex = 0;
236 foreach $student (@users) {
237 $color = $colors[$colorindex%2];
238 SystemVariables::DEBUG("Form:", "Searching $student for question $question.");
239
240 if($matched = didForm($form, $student)) {
241 #mjadud|Test Form One|mjadud.17|Thisisatestform|2000,09,19,21:15:11|1|2.92
242
243 ($sysfilename, $ontime) = (split(/|/, $matched))[2,5];
244 $path = SystemVariables::getStudentRecordPath($student);
245 $path .= $sysfilename;
246
247 SystemVariables::DEBUG("Form:", "Trying to open $path");
248
249 if(open(ANSWERS, $path)) {
250 $printstuff = 0;
251 SystemVariables::DEBUG("Form:", "Opened $path.");
252
253 while(<ANSWERS>) {
254
255 #If we hit #\#QUESTION, we're probably
256 # done printing stuff...
257 if( (/##QUESTION/) && $printstuff) {
258 $printstuff = 0;
259 print "</TD><TD WIDTH='5%'><INPUT TYPE='TEXT' SIZE='2' ";
260 print "NAME='" . $student . $question . "'></TD>";
261 print "<TD WIDTH='5%' VALIGN='top'>$student</TD></TR>";
262 }
263
264 #If we're printing, then dump the row to the
265 # browser.
266 if($printstuff) {
267 $line = $_;
268 chomp $line;
269 $line =~ s/n/<P>/g;
270 print $line, "<BR>";
271 #}
272
273 }
274
275 #If we hit the answer we want to print,
276 # turn on printstuff for the next go round.
277 if(/##ANSWER$question/) {
278 #print "printing stuff for $question<P>";
279 $printstuff = 1;
280 print "<TR BGCOLOR='$color'><TD WIDTH='5%' VALIGN='top'>" . Record::getLastName($student);
281 print "</TD><TD WIDTH='5%' VALIGN='top'>" . Record::getFirstName($student);
282 print "</TD><TD VALIGN='top'>";
283 }
284 } #End of while(Answers)
285
286 #Need to handle the end of the file printing...
287 if($printstuff) {
288 print "</TD><TD WIDTH='5%'><INPUT TYPE='TEXT' SIZE='2' ";
289 print "NAME='" . $student . $question . "'></TD>";
290 print "<TD WIDTH='5%' VALIGN='top'>$student</TD></TR>";
291 }
292
293 }#end 'if the file exists'
294
295 } #end of if did form...
296
297 $colorindex++;
298 } #end of student foreach
299
300 print "</TABLE>";
301 }#end of question foreach
302
303
304 Interface::endForm();
305 Interface::tableBottom();
306
307 print "</TD></TR>";
308 }
309
310 sub getQuestionText {
311
312 my($form,
313 $number,
314 $answer,
315 $configpath,
316 $sysid,
317 $data);
318
319 $form = $_[0];
320 $number = $_[1];
321 $answer = $_[2];
322
323 chomp $number;
324
325 $configpath = SystemVariables::getCourseConfigPath();
326 $sysid = Assignments::getAssignmentSystemID($form);
327 $data = Assignments::getAssignmentData($form);
328
329 if(defined($answer)) {
330 return $$data{"QUESTION" . $number . "ANSWER" . $answer};
331 } else {
332 return $$data{"QUESTION" . $number};
333 }
334 }
335
336
337
338 sub didForm {
339
340 my($username,
341 $form,
342 $filelog,
343 $matched);
344
345 $username = $ENV{REMOTE_USER};
346 $form = $_[0];
347 $student = $_[1];
348
349 $filelog = Record::getStudentFilelog($student);
350
351 $matched = 0;
352
353 if(open(FILELOG, $filelog)) {
354 while(<FILELOG>) {
355
356 if(/$form/) {
357 $matched = $_;
358 }
359 }
360 close(FILELOG);
361 }
362
363 return $matched;
364 }
365
366 sub answerSelection {
367
368 my($form,
369 $sectionbool,
370 $section,
371 @users,
372 $key,
373 $Questions,
374 $formWebPath,
375 $data);
376
377 $form = $_[2];
378 $sectionbool = $_[3];
379 $section = $_[4];
380
381 $formWebPath = SystemVariables::getFormWebPath();
382
383 $data = Assignments::getAssignmentData($form);
384
385
386 print "<TR><TD>n";
387 Interface::tableTop("View which questions in $form?");
388 Interface::startForm($formWebPath . "form.cgi");
389 Interface::hidden("DISPLAYQUESTIONS", "1");
390 Interface::hidden("_formname", $form);
391 if(defined($sectionbool)) {
392 Interface::hidden("_sectionnumberboolean", $sectionbool);
393 }
394 Interface::hidden("_sectionnumber", $section);
395
396 $index=0;
397 foreach $key (sort keys %{$data}) {
398 chomp $key;
399
400 if($key =~ /^QUESTION(d)$/) {
401 $index++;
402
403 Interface::checkbox($key,
404 $key,
405 $$data{$key});
406 }
407 }
408
409 Interface::hidden("_numquestions", $index);
410
411 Interface::endForm();
412 Interface::tableBottom();
413
414 print "</TD></TR>";
415 }
416
417 sub getAllQuestions {
418
419 my($form,
420 $data,
421 %Questions);
422
423 $form = $_[0];
424 $data = Assignments::getAssignmentData($form);
425 %Questions = ();
426
427 $index = 0;
428 while($$data{"QUESTION$index"}) {
429 $Questions{$$data{"QUESTION$index"}\} = "QUESTION$index";
430 $index++;
431 }
432
433 return %Questions;
434 }
435
436 sub formViewer {
437
438
439 my ($formWebPath,
440 $defaults,
441 @months
442 );
443
444 $formWebPath = SystemVariables::getFormWebPath();
445
446 if(${Form::getAllFormIDs()}[0] !~ /NO ASSIGN/) {
447
448 print "<TR><TD>n";
449
450 Interface::tableTop("View Forms");
451 Interface::startForm($formWebPath . "form.cgi");
452 Interface::hidden("ANSWERSELECTION", "1");
453
454 Interface::selectInput("View answers from form ",
455 "_formname",
456 @{Form::getAllFormIDs()});
457
458
459 #######
460 # Section number selection
461 print "<TABLE WIDTH='100%'>n";
462 print "<TR><TD WIDTH='30%'>";
463 Interface::checkbox(1, "_sectionnumberboolean",
464 "Section Number",
465 CHECKED);
466 print "</TD><TD WIDTH='70%'>";
467
468 @sectionnumbers = Record::getAllSectionNumbers();
469 Interface::selectInput(" ",
470 "_sectionnumber",
471 @sectionnumbers);
472
473 print "</TD></TR></TABLE>";
474
475 Interface::endForm();
476 Interface::tableBottom();
477 print "</TD></TR>";
478
479 }
480
481 }
482
483
484 sub getAllFormIDs {
485
486 my ( $config_path,
487 @assign_files,
488 @assign_ids,
489 $file,
490 $id
491 );
492
493 #Snag the path to the config directory where
494 # assignments are stored.
495 $config_path = SystemVariables::getCourseConfigPath();
496
497 #Treat forms as assignments?
498 push(@assign_files, glob($config_path . "FORM" . "*"));
499
500 #Grab the ids from each of the files
501 foreach $file (@assign_files) {
502 open(FILE, $file);
503 while(<FILE>) {
504 if(/^_ASSIGNID/) {
505 ($id) = (split(/|/))[1];
506 push(@assign_ids, $id);
507 }
508 }
509 close(FILE);
510 }
511
512 if(@assign_ids) {
513 return @assign_ids;
514 } else {
515 @assign_ids = ("NO ASSIGNMENTS");
516 return @assign_ids;;
517 }
518 }
519
520 ########################################################
521 # STUDENT STUFF
522 ########################################################
523 sub doForm {
524
525 my ($form,
526 $configpath,
527 $key,
528 $val,
529 %Form);
530
531 $form = $_[1];
532 $configpath = SystemVariables::getCourseConfigPath();
533
534 if(open(FORM, $configpath . $form)) {
535 while(<FORM>) {
536 ($key, $val) = (split(/|/));
537 $key =~ s/$form//g;
538 $Form{$key} = $val;
539 }
540 }
541
542
543
544 print "<TR><TD>n";
545 Interface::tableTop("Complete the form!");
546 Interface::startForm("form.cgi");
547 Interface::hidden("HANDINFORM", 1);
548 Interface::hidden("_ASSIGNID", $Form{"_ASSIGNID"});
549
550 $index = 0;
551 while(defined($Form{"QUESTION$index"})) {
552
553 #print "<STRONG>" . $Form{"QUESTION$index"\} . "</STRONG>";
554
555 #Hide the questions in the form for extraction
556 # by the form processing step (the HANDINFORM step)
557 Interface::hidden("QUESTION$index", $Form{"QUESTION$index"});
558
559 #Grab the form type from the hash.
560 $type = $Form{"QUESTION$index" . "TYPE"};
561
562
563 #"TEXTAREA",
564 #"TEXTFIELD",
565 #"SELECT-ONE-MULT-CHOICE",
566 #"SELECT-MANY-MULT-CHOICE"
567 if($type =~ /TEXTAREA/) {
568 #($text, $name, $value, $cols, $rows)
569 print "<CENTER>";
570 Interface::textArea($Form{"QUESTION$index"}, "ANSWER$index", "", 40, 6);
571 print "</CENTER>";
572 } elsif ($type =~ /^TEXTFIELD/) {
573 Interface::textInput($Form{"QUESTION$index"}, "ANSWER$index", "", 40);
574 } elsif ($type =~ /URL-TEXTFIELD/) {
575 Interface::textInput($Form{"QUESTION$index"}, "ANSWER$index", "http://", 40);
576 } else {
577
578 print "<TABLE WIDTH='100%'><TR><TD COLSPAN='2'>";
579 print $Form{"QUESTION$index"};
580 print "</TD></TR>";
581
582 $fields = 0;
583 while($Form{"QUESTION$index" . "ANSWER$fields"}) {
584
585 if($fields == 0) {
586 $val = "CHECKED";
587 } else {
588 $val = "";
589 }
590
591 if($type =~ "SELECT-ONE-MULT-CHOICE") {
592 #($name, $value , $text, $status)
593 print "<TR><TD WIDTH='5%'> </TD><TD>";
594 Interface::radio($fields,
595 "ANSWER$index",
596 $Form{"QUESTION$index" . "ANSWER$fields"},
597 $val);
598 print "</TD></TR>";
599 } else {
600 print "<TR><TD WIDTH='5%'> </TD><TD>";
601 Interface::checkbox($fields,
602 "ANSWER$index-$fields",
603 $Form{"QUESTION$index" . "ANSWER$fields"});
604 print "</TD></TR>";
605 }
606
607 $fields++;
608 }
609
610 print "</TABLE>";
611
612 } #Done with mult choice possibilities
613
614
615 $index++;
616 }
617
618
619 Interface::endForm();
620 Interface::tableBottom();
621
622 print "</TD></TR>";
623 }
624
625 sub completeFormForm {
626
627 my($formWebPath,
628 $allforms,
629 $item,
630 $key,
631 $val,
632 %Form,
633 $configpath);
634
635 $formWebPath = SystemVariables::getFormWebPath();
636 $configpath = SystemVariables::getCourseConfigPath();
637
638 print "<TR><TD>n";
639
640 Interface::tableTop("Complete a form-based submission.");
641 Interface::startForm($formWebPath . "form.cgi");
642
643 $allforms = getAllForms();
644
645 print "<TABLE WIDTH='100%'>";
646 foreach $item (@{$allforms}) {
647
648 #Read the form in.
649 open(FORM, $configpath . $item);
650 while(<FORM>) {
651 ($key, $val) = (split(/|/));
652 $key =~ s/$item//g;
653 $Form{$key} = $val;
654 }
655 $Form{"SYSID"} = $item;
656 close(FORM);
657
658 print "<TR><TD>";
659 print $Form{"_DESCRIPTION"};
660 print "</TD><TD>";
661
662 $todo = $Form{"_ASSIGNID"};
663 $todo =~ s/s/%20/g;
664 print "<A HREF='form.cgi?do=" . $Form{"SYSID"} . "'>";
665 print $Form{"_ASSIGNID"};
666 print "</A>";
667 print "</TD></TR>";
668 }
669
670 print "</TABLE>";
671
672 print "</FORM>";
673 Interface::tableBottom();
674
675 print "</TD></TR>";
676
677 }
678
679
680 sub getAllForms {
681
682 my($configpath,
683 @dir,
684 $item,
685 @forms);
686
687 $configpath = SystemVariables::getCourseConfigPath();
688
689 opendir(CONFIGDIR, $configpath);
690 @dir = readdir(CONFIGDIR);
691
692 foreach $item (@dir) {
693 if($item =~ /^FORM/) {
694 push(@forms, $item);
695 }
696 }
697
698 return @forms;
699 }
700
701
702
703 ###################################################
704 ######## ADMIN STUFF
705 ###################################################
706 sub createFormForm {
707
708
709 my($formWebPath
710 );
711
712 $formWebPath = SystemVariables::getFormWebPath();
713
714 print "<TR><TD>n";
715
716 Interface::tableTop("Create a new form-based submission.");
717
718 Interface::startForm($formWebPath . "form.cgi");
719 Interface::hidden("FORMSTEP1", "Step 1");
720
721 Interface::textInput("Form. ID", "_ASSIGNID", "", "10");
722 Interface::textInput("Desc.", "_DESCRIPTION", "", "30");
723 Interface::textInput("# Of questions (approx.)", "NUMQUESTIONS", "6", "8");
724 Interface::textInput("Max Val.", "_MAXVALUE", "", "10");
725 Interface::textInput("Due Date", "_DUEDATE", "2000,12,31,12:59:59", "20");
726
727 Interface::hidden("_TYPE", "QUESTIONFORM");
728
729 #Toggling doneness....
730 if(SystemVariables::useDoneness()) {
731 Interface::textInput("Done",
732 "_DONE",
733 "",
734 "20");
735 } else {
736 Interface::textInput("Grade Visible After",
737 "_DONE",
738 SystemVariables::getCurrentTime(),
739 "20");
740 }
741
742
743
744 Interface::selectInput("Grade Mapping",
745 "_GRADEMAPPING",
746 @{SystemVariables::getAllGradeMappings()}
747 );
748
749
750 Interface::hidden("_JULESPROCESSOR", "NONE");
751
752 #Get all the post-processors available
753 $PostProcessors = SystemVariables::getAllPostProcessors();
754
755 Interface::selectInput("Post Processor",
756 "_POSTPROCESSOR",
757 "NONE",
758 @{$PostProcessors}
759 );
760
761 Interface::checkbox(1, "_ANONYMOUS", "Anonymous submission for this form.");
762
763 Interface::endForm();
764 Interface::tableBottom();
765
766 print "</TD></TR>";
767
768 }
769
770
771 sub createFormOne {
772
773 my($formWebPath,
774 $query,
775 $numquestions
776 );
777
778 $formWebPath = SystemVariables::getFormWebPath();
779 $query = $_[1];
780
781 print "<TR><TD>n";
782
783 Interface::tableTop($query->param("_ASSIGNID") . " : " . $query->param("_DESCRIPTION"));
784
785 Interface::startForm($formWebPath . "form.cgi");
786 Interface::hidden("FORMSTEP2", "Step 1");
787
788 foreach $key ($query->param()) {
789 if($key =~ /^_/) {
790 #print "$key - ", $query->param($key), "<P>";
791 Interface::hidden($key, $query->param($key));
792 }
793 }
794
795 $numquestions = $query->param("NUMQUESTIONS");
796
797 for ($i=0;$i<$numquestions;$i++) {
798
799 Interface::textInput("Question " . ($i+1) . " :", "QUESTION$i", "", "30");
800
801 print "<TABLE WIDTH='100%'><TR><TD>";
802 Interface::selectInput("Answer Type",
803 "QUESTION" . $i . "TYPE",
804 "TEXTAREA",
805 "TEXTFIELD",
806 "URL-TEXTFIELD",
807 "SELECT-ONE-MULT-CHOICE",
808 "SELECT-MANY-MULT-CHOICE"
809 );
810 print "</TD><TD>";
811 Interface::textInput("# answer fields:", "QUESTION$i" . "ANSWERFIELDS", "5", "2");
812 print "</TD></TR></TABLE>";
813
814
815
816 print "<HR>";
817 }
818
819 Interface::endForm();
820 Interface::tableBottom();
821
822 print "</TD></TR>";
823
824 }
825
826 sub createFormTwo {
827
828
829 my($formWebPath,
830 $query,
831 $numquestions,
832 $index,
833 $type,
834 $printed_something
835 );
836
837 $formWebPath = SystemVariables::getFormWebPath();
838 $query = $_[1];
839
840 print "<TR><TD>n";
841
842 Interface::tableTop($query->param("_ASSIGNID") . " : " . $query->param("_DESCRIPTION"));
843
844 Interface::startForm($formWebPath . "form.cgi");
845 Interface::hidden("WRITEFORM", "Step 1");
846
847 Interface::hidden("_ASSIGNID", $query->param("_ASSIGNID"));
848 Interface::hidden("_DESCRIPTION", $query->param("_DESCRIPTION"));
849
850 foreach $key ($query->param()) {
851 if($key =~ /^(_|QUESTION)/) {
852 Interface::hidden($key, $query->param($key));
853 }
854 }
855
856 $index = 0;
857 while(defined($query->param("QUESTION$index"))) {
858
859 $type = $query->param("QUESTION" . $index . "TYPE");
860
861 #"TEXTAREA",
862 #"TEXTFIELD",
863 #"SELECT-ONE-MULT-CHOICE",
864 #"SELECT-MANY-MULT-CHOICE"
865 if( ($type eq "SELECT-ONE-MULT-CHOICE")
866 || ($type eq "SELECT-MANY-MULT-CHOICE")) {
867
868 $printed_somthing = 1;
869
870 print "<STRONG>", $query->param("QUESTION$index"), "</STRONG>";
871
872
873 for($i=0;$i<$query->param("QUESTION$index" . "ANSWERFIELDS");$i++) {
874 Interface::textInput("Possible Answer " . ($i+1), "QUESTION$index" . "ANSWER$i", "", "30");
875 }
876
877 print "<HR>";
878 }
879
880 $index++;
881 }
882
883
884 if(!$printed_something) {
885 print "<CENTER><H1>Press submit.</H1></CENTER>";
886 }
887
888 Interface::endForm();
889 Interface::tableBottom();
890
891 print "</TD></TR>";
892 }
893
894
895 sub getNextFormID {
896
897 my ($form_id,
898 $form_index,
899 $form,
900 $config
901 );
902
903 $config = SystemVariables::getCourseConfigPath();
904 chomp $config;
905
906 $form_id = "FORM";
907 $form_index = 0;
908
909 $form = "$form_id$form_index";
910 chomp $form;
911
912 #Increment the index until the formment
913 # identifier doesn't exist.
914 while( -e "$config$form" ) {
915
916 #SystemVariables::webErrOut("File Exists.");
917
918 $form_index++;
919 $form = "$form_id$form_index";
920 chomp $form;
921
922 }
923
924 return $form;
925 }
926
927
928
929 sub getArrayIndex {
930
931
932 my ($item, @array, $i, $index);
933
934 ($item, @array) = @_;
935
936 $index = 0;
937
938 foreach $i (@array) {
939 if($item eq $i) {
940 return $index;
941 } else {
942 $index++;
943 }
944 }
945 }
946
947 sub useDebugging())'>DEBUG { if(SystemVariables::useDebugging()) { print "Form: ", @_, "n<P>"; } }
948
949
950
|
|
Last update: 1/6/01; 9:32:34 AM |