| 1 | package WeBWorK::ContentGenerator; |
1 | package WeBWorK::ContentGenerator; |
| 2 | |
2 | |
| 3 | use strict; |
3 | use strict; |
| 4 | use warnings; |
4 | use warnings; |
| 5 | use CGI qw(-compile :html :form); |
5 | use CGI (); |
| 6 | use Apache::Constants qw(:common); |
6 | use Apache::Constants qw(:common); |
| 7 | |
7 | |
| 8 | # Send 'die' message to the browser window |
8 | # Send 'die' message to the browser window |
| 9 | #use CGI::Carp qw(fatalsToBrowser); |
9 | #use CGI::Carp qw(fatalsToBrowser); |
| 10 | |
10 | |
| … | |
… | |
| 30 | # statement, it just prints out $begining$name$middle$value$end for every |
30 | # statement, it just prints out $begining$name$middle$value$end for every |
| 31 | # field who's name doesn't match $qr_omit, a quoted regex. |
31 | # field who's name doesn't match $qr_omit, a quoted regex. |
| 32 | # In it's current incarnation, it should be called from subclasses only, |
32 | # In it's current incarnation, it should be called from subclasses only, |
| 33 | # by saying $self->print_form_data. Of course, you could construct a |
33 | # by saying $self->print_form_data. Of course, you could construct a |
| 34 | # hashref with ->{r} being an Apache::Request, I suppose. |
34 | # hashref with ->{r} being an Apache::Request, I suppose. |
| 35 | |
|
|
| 36 | sub print_form_data { |
35 | sub print_form_data { |
| 37 | my ($self, $begin, $middle, $end, $qr_omit) = @_; |
36 | my ($self, $begin, $middle, $end, $qr_omit) = @_; |
| 38 | my $return_string = ""; |
37 | my $return_string = ""; |
| 39 | |
38 | |
| 40 | my $r=$self->{r}; |
39 | my $r=$self->{r}; |
| … | |
… | |
| 54 | } |
53 | } |
| 55 | } |
54 | } |
| 56 | |
55 | |
| 57 | return $return_string; |
56 | return $return_string; |
| 58 | } |
57 | } |
|
|
58 | # P.S. This function is beat, but I use it in places. We'll kill it eventually, I guess. |
| 59 | |
59 | |
| 60 | sub hidden_authen_fields { |
60 | sub hidden_authen_fields { |
| 61 | my $self = shift; |
61 | my $self = shift; |
| 62 | my $r = $self->{r}; |
62 | my $r = $self->{r}; |
| 63 | my $courseEnvironment = $self->{courseEnvironment}; |
63 | my $courseEnvironment = $self->{courseEnvironment}; |
| 64 | my $html = ""; |
64 | my $html = ""; |
| 65 | |
65 | |
| 66 | foreach my $param ("user","effectiveUser","key") { |
66 | foreach my $param ("user","effectiveUser","key") { |
| 67 | my $value = $r->param($param); |
67 | my $value = $r->param($param); |
| 68 | $html .= input({-type=>"hidden",-name=>"$param",-value=>"$value"}); |
68 | $html .= CGI::input({-type=>"hidden",-name=>"$param",-value=>"$value"}); |
| 69 | } |
69 | } |
| 70 | return $html; |
70 | return $html; |
| 71 | } |
71 | } |
| 72 | |
72 | |
| 73 | #sub hidden_authen_fields($) { |
73 | #sub hidden_authen_fields($) { |
| … | |
… | |
| 83 | my $courseEnvironment = $self->{courseEnvironment}; |
83 | my $courseEnvironment = $self->{courseEnvironment}; |
| 84 | my $html = ""; |
84 | my $html = ""; |
| 85 | |
85 | |
| 86 | foreach my $param (@fields) { |
86 | foreach my $param (@fields) { |
| 87 | my $value = $r->param($param); |
87 | my $value = $r->param($param); |
| 88 | $html .= input({-type=>"hidden",-name=>"$param",-value=>"$value"}); |
88 | $html .= CGI::input({-type=>"hidden",-name=>"$param",-value=>"$value"}); |
| 89 | } |
89 | } |
| 90 | return $html; |
90 | return $html; |
| 91 | } |
91 | } |
| 92 | |
92 | |
| 93 | ### Functions that subclasses /should/ override under most circumstances |
93 | ### Functions that subclasses /should/ override under most circumstances |