[system] / branches / rel-2-0-pr1-hardcopy-changes / webwork2 / lib / WeBWorK / ContentGenerator / ProblemSets.pm Repository:
ViewVC logotype

View of /branches/rel-2-0-pr1-hardcopy-changes/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 449 - (download) (as text) (annotate)
Thu Aug 1 20:23:22 2002 UTC (10 years, 9 months ago) by sh002i
Original Path: trunk/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm
File size: 2498 byte(s)
more CGI fixes, started playing around with ProblemSets.
-sam

    1 package WeBWorK::ContentGenerator::ProblemSets;
    2 our @ISA = qw(WeBWorK::ContentGenerator);
    3 
    4 use strict;
    5 use warnings;
    6 use Apache::Constants qw(:common);
    7 use CGI qw();
    8 use WeBWorK::ContentGenerator;
    9 use WeBWorK::DB::WW;
   10 use WeBWorK::Utils qw(formatDateTime);
   11 
   12 sub initialize {
   13   my $self = shift;
   14   my $courseEnvironment = $self->{courseEnvironment};
   15 
   16   # Open a database connection that we can use for the rest of
   17   # the content generation.
   18 
   19   my $wwdb = new WeBWorK::DB::WW $courseEnvironment;
   20   $self->{wwdb} = $wwdb;
   21 }
   22 
   23 sub title {
   24   my $self = shift;
   25   my $r = $self->{r};
   26   my $courseEnvironment = $self->{courseEnvironment};
   27   my $user = $r->param('user');
   28 
   29   return "Problem Sets for $user";
   30 }
   31 
   32 sub body {
   33   my $self = shift;
   34   my $r = $self->{r};
   35   my $courseEnvironment = $self->{courseEnvironment};
   36   my $user = $r->param('user');
   37   my $wwdb = $self->{wwdb};
   38 
   39 # if (!defined $wwdb->getSets($user)) {
   40 #   print "undefined".CGI::br();
   41 # }
   42 
   43   print CGI::startform(-method=>"POST", -action=>$r->uri);
   44   print CGI::start_table();
   45   print CGI::Tr(
   46     CGI::th(""),
   47     CGI::th("Name"),
   48     CGI::th("Status"),
   49     CGI::th({-colspan=>2}, "Actions"),
   50   );
   51 
   52   my @setNames = $wwdb->getSets($user);
   53   foreach my $setName (sort @setNames) {
   54     my $set = $wwdb->getSet($user, $setName);
   55     print setListRow($set);
   56   }
   57 
   58   print CGI::end_table();
   59   print CGI::endform();
   60 
   61   return "";
   62 
   63 # print "Set Names", CGI::br(), "\n";
   64 # print join(CGI::br()."\n", sort @setNames);
   65 # print CGI::p();
   66 #
   67 # print CGI::startform({-method=>"POST", -action=>$r->uri."set0/"});
   68 # print $self->hidden_authen_fields;
   69 # print CGI::input({-type=>"submit", -value=>"Do Set 0"});
   70 # print CGI::endform();
   71 # "";
   72 }
   73 
   74 sub setListRow($) {
   75   my $set = shift;
   76 
   77   my $name = $set->id;
   78 
   79   my $openDate = formatDateTime($set->open_date);
   80   my $dueDate = formatDateTime($set->due_date);
   81   my $answerDate = formatDateTime($set->answer_date);
   82 
   83   my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>"");
   84   my $interactive = CGI::submit("", "do problem set");
   85   my $hardcopy = CGI::submit("", "get hard copy");
   86 
   87   my $status;
   88   if (time < $set->open_date) {
   89     $status = "opens at $openDate";
   90     $checkbox = "";
   91     $interactive = "";
   92     $hardcopy = "";
   93   } elsif (time < $set->due_date) {
   94     $status = "open, due at $dueDate";
   95   } elsif (time < $set->answer_date) {
   96     $status = "closed, answers at $answerDate";
   97   } else {
   98     $status = "closed, answers available";
   99   }
  100 
  101   return CGI::Tr(CGI::td([
  102     $checkbox,
  103     $name,
  104     $status,
  105     $interactive,
  106     $hardcopy,
  107   ]));
  108 }
  109 
  110 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9