[system] / trunk / webwork-modperl / lib / WeBWorK / ContentGenerator / ProblemSets.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator/ProblemSets.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 403 Revision 494
1################################################################################
2# WeBWorK mod_perl (c) 2000-2002 WeBWorK Project
3# $Id$
4################################################################################
5
1package WeBWorK::ContentGenerator::ProblemSets; 6package WeBWorK::ContentGenerator::ProblemSets;
2our @ISA = qw(WeBWorK::ContentGenerator);
3 7
8=head1 NAME
9
10WeBWorK::ContentGenerator::ProblemSets - Display a list of built problem sets.
11
12=cut
13
14use strict;
15use warnings;
16use base qw(WeBWorK::ContentGenerator);
17use Apache::Constants qw(:common);
18use CGI qw();
4use WeBWorK::ContentGenerator; 19use WeBWorK::ContentGenerator;
5use Apache::Constants qw(:common); 20use WeBWorK::DB::WW;
6use CGI qw(-compile :html :form); 21use WeBWorK::Utils qw(formatDateTime);
22
23sub initialize {
24 my $self = shift;
25 my $courseEnvironment = $self->{courseEnvironment};
26
27 # Open a database connection that we can use for the rest of
28 # the content generation.
29
30 my $wwdb = new WeBWorK::DB::WW $courseEnvironment;
31 $self->{wwdb} = $wwdb;
32}
33
34sub path {
35 my ($self, $args) = @_;
36
37 my $ce = $self->{courseEnvironment};
38 my $root = $ce->{webworkURLs}->{root};
39 my $courseName = $ce->{courseName};
40 return $self->pathMacro($args,
41 "Home" => "$root",
42 $courseName => "",
43 );
44}
7 45
8sub title { 46sub title {
9 my $self = shift; 47 my $self = shift;
10 my $r = $self->{r};
11 my $courseEnvironment = $self->{courseEnvironment}; 48 my $courseEnvironment = $self->{courseEnvironment};
12 my $user = $r->param('user'); 49
13 50 return $courseEnvironment->{courseName};
14 return "Problem Sets for $user";
15} 51}
16 52
17sub body { 53sub body {
18 my $self = shift; 54 my $self = shift;
19 my $r = $self->{r}; 55 my $r = $self->{r};
20 my $courseEnvironment = $self->{courseEnvironment}; 56 my $courseEnvironment = $self->{courseEnvironment};
21 my $user = $r->param('user'); 57 my $user = $r->param('user');
58 my $wwdb = $self->{wwdb};
22 59
23 print startform({-method=>"POST", -action=>$r->uri."set0/"}); 60 print CGI::startform(-method=>"POST", -action=>$r->uri."/hardcopy");
61 print CGI::start_table();
62 print CGI::Tr(
63 CGI::th("Sel."),
64 CGI::th("Name"),
65 CGI::th("Status"),
66 CGI::th("Hardcopy"),
67 );
68
69 my @sets;
70 push @sets, $wwdb->getSet($user, $_) foreach ($wwdb->getSets($user));
71 foreach my $set (sort { $a->open_date <=> $b->open_date } @sets) {
72 print $self->setListRow($set);
73 }
74
75 print CGI::end_table();
24 print $self->hidden_authen_fields; 76 print $self->hidden_authen_fields;
25 print input({-type=>"submit", -value=>"Do Set 0"}); 77 print CGI::p(CGI::submit("hardcopy", "Download Harcopy for Selected Sets"));
26 print endform; 78 print CGI::endform();
27 ""; 79
80 return "";
81}
82
83sub setListRow($$) {
84 my $self = shift;
85 my $set = shift;
86
87 my $name = $set->id;
88
89 my $interactiveURL = "set$name/?" . $self->url_authen_args;
90 my $hardcopyURL = "hardcopy/set$name/?" . $self->url_authen_args;
91
92 my $openDate = formatDateTime($set->open_date);
93 my $dueDate = formatDateTime($set->due_date);
94 my $answerDate = formatDateTime($set->answer_date);
95
96 my $checkbox = CGI::checkbox(-name=>"set", -value=>$set->id, -label=>"");
97 my $interactive = CGI::a({-href=>$interactiveURL}, $name);
98 my $hardcopy = CGI::a({-href=>$hardcopyURL}, "download hardcopy");
99
100 my $status;
101 if (time < $set->open_date) {
102 $status = "opens at $openDate";
103 $checkbox = "";
104 $interactive = $name;
105 $hardcopy = "";
106 } elsif (time < $set->due_date) {
107 $status = "open, due at $dueDate";
108 } elsif (time < $set->answer_date) {
109 $status = "closed, answers at $answerDate";
110 } else {
111 $status = "closed, answers available";
112 }
113
114 return CGI::Tr(CGI::td([
115 $checkbox,
116 $interactive,
117 $status,
118 $hardcopy,
119 ]));
28} 120}
29 121
301; 1221;

Legend:
Removed from v.403  
changed lines
  Added in v.494

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9