[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Test.pm Repository:
ViewVC logotype

View of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Test.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4296 - (download) (as text) (annotate)
Tue Jul 25 23:02:12 2006 UTC (6 years, 9 months ago) by sh002i
File size: 3497 byte(s)
playing with request methods

    1 ################################################################################
    2 # WeBWorK Online Homework Delivery System
    3 # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/
    4 # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Skeleton.pm,v 1.5 2006/07/08 14:07:34 gage Exp $
    5 #
    6 # This program is free software; you can redistribute it and/or modify it under
    7 # the terms of either: (a) the GNU General Public License as published by the
    8 # Free Software Foundation; either version 2, or (at your option) any later
    9 # version, or (b) the "Artistic License" which comes with this package.
   10 #
   11 # This program is distributed in the hope that it will be useful, but WITHOUT
   12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13 # FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
   14 # Artistic License for more details.
   15 ################################################################################
   16 
   17 package WeBWorK::ContentGenerator::Test;
   18 use base qw(WeBWorK::ContentGenerator);
   19 
   20 =head1 NAME
   21 
   22 WeBWorK::ContentGenerator::Test - Test area for monkeying around with stuff.
   23 
   24 =cut
   25 
   26 use strict;
   27 use warnings;
   28 
   29 #use CGI;
   30 use WeBWorK::CGI;
   31 #use WeBWorK::CGIParamShim;
   32 use WeBWorK::Utils qw/undefstr/;
   33 
   34 sub body {
   35   my ($self) = @_;
   36   my $r = $self->r;
   37   my $ce = $r->ce;
   38   my $db = $r->db;
   39   my $authz = $r->authz;
   40   my $urlpath = $r->urlpath;
   41 
   42   $self->{pwd} = $r->param("pwd") || "helloworld";
   43 
   44   print CGI::p(
   45     "REQUEST_METHOD is $ENV{REQUEST_METHOD}", CGI::br(),
   46     "CONTENT_TYPE is $ENV{CONTENT_TYPE}", CGI::br(),
   47     "CONTENT_LENGTH is $ENV{CONTENT_LENGTH}",
   48   );
   49 
   50   use Data::Dumper;
   51   print CGI::pre(CGI::escapeHTML(Dumper($CGI::Q)));
   52 
   53   #print CGI::start_form(-method=>"POST", -action=>$r->uri);
   54   my $start_form = CGI::start_form(
   55     -method=>"POST",
   56     -action=>$r->uri,
   57     #-enctype=>'application/x-www-form-urlencoded',
   58     -enctype=>'multipart/form-data',
   59   );
   60   print CGI::pre(CGI::escapeHTML($start_form));
   61   print $start_form;
   62   print $self->hidden_authen_fields;
   63 
   64   print CGI::p("before action:" . CGI::br()
   65     . " \$r->param('pwd')=" . (defined $r->param('pwd') ? $r->param('pwd') : "UNDEF") . CGI::br()
   66     . " CGI::param('pwd')=" . (defined CGI::param('pwd') ? CGI::param('pwd') : "UNDEF") . CGI::br()
   67     . " \$CGI::Q->{pwd}=" . (defined $CGI::Q->{pwd} ? "@{$CGI::Q->{pwd}}" : "UNDEF") . CGI::br()
   68     . " \$self->{pwd}=" . (defined $self->{pwd} ? $self->{pwd} : "UNDEF"));
   69 
   70   if (defined $r->param("submit") and $r->param("submit") eq "ChangePWD") {
   71     $self->{pwd} = $r->param("new_pwd");
   72     print CGI::p("pwd change requested, new pwd is ", $self->{pwd});
   73   }
   74 
   75   print "new_pwd: ", CGI::textfield({name=>"new_pwd",value=>$self->{pwd}}), CGI::br();
   76 
   77   print CGI::p("after action:" . CGI::br()
   78     . " \$r->param('pwd')=" . (defined $r->param('pwd') ? $r->param('pwd') : "UNDEF") . CGI::br()
   79     . " CGI::param('pwd')=" . (defined CGI::param('pwd') ? CGI::param('pwd') : "UNDEF") . CGI::br()
   80     . " \$CGI::Q->{pwd}=" . (defined $CGI::Q->{pwd} ? "@{$CGI::Q->{pwd}}" : "UNDEF") . CGI::br()
   81     . " \$self->{pwd}=" . (defined $self->{pwd} ? $self->{pwd} : "UNDEF"));
   82 
   83   my $hidden_pwd = CGI::hidden({name=>"pwd",value=>$self->{pwd}});
   84   print CGI::p("hidden field is being passed value=>".$self->{pwd}, CGI::br(),
   85     "hidden field is ", CGI::pre(CGI::escapeHTML($hidden_pwd)));
   86   print $hidden_pwd;
   87 
   88   print CGI::submit({name=>"submit",value=>"Refresh"});
   89   print CGI::submit({name=>"submit",value=>"ChangePWD"});
   90 
   91   print CGI::end_form();
   92 
   93   return "";
   94 }
   95 
   96 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9