Parent Directory
|
Revision Log
fixed problem with deciding when to generate images in math2img mode finished adding template escapes to ProblemSets, ProblemSet, and Problem fixed a problem where modules were removed from the courseEnv while being loaded (whups.) -sam
1 ################################################################################ 2 # WeBWorK mod_perl (c) 1995-2002 WeBWorK Team, Univeristy of Rochester 3 # $Id$ 4 ################################################################################ 5 6 package WeBWorK::ContentGenerator::ProblemSet; 7 8 =head1 NAME 9 10 WeBWorK::ContentGenerator::ProblemSet - display an index of the problems in a 11 problem set. 12 13 =cut 14 15 use strict; 16 use warnings; 17 use base qw(WeBWorK::ContentGenerator); 18 use Apache::Constants qw(:common); 19 use CGI qw(); 20 use WeBWorK::ContentGenerator; 21 22 sub initialize { 23 my $self = shift; 24 my $courseEnvironment = $self->{courseEnvironment}; 25 26 # Open a database connection that we can use for the rest of 27 # the content generation. 28 29 my $wwdb = new WeBWorK::DB::WW $courseEnvironment; 30 $self->{wwdb} = $wwdb; 31 } 32 33 sub path { 34 my ($self, $setName, $args) = @_; 35 $setName =~ s/^set//; 36 37 38 my $ce = $self->{courseEnvironment}; 39 my $root = $ce->{webworkURLs}->{root}; 40 my $courseName = $ce->{courseName}; 41 return $self->pathMacro($args, 42 "Home" => "$root", 43 $courseName => "$root/$courseName", 44 $setName => "", 45 ); 46 } 47 48 sub siblings { 49 my ($self, $setName) = @_; 50 $setName =~ s/^set//; 51 52 my $ce = $self->{courseEnvironment}; 53 my $root = $ce->{webworkURLs}->{root}; 54 my $courseName = $ce->{courseName}; 55 56 my $wwdb = $self->{wwdb}; 57 my $user = $self->{r}->param("user"); 58 my @sets; 59 push @sets, $wwdb->getSet($user, $_) foreach ($wwdb->getSets($user)); 60 foreach my $set (sort { $a->open_date <=> $b->open_date } @sets) { 61 if (time >= $set->open_date) { 62 print CGI::a({-href=>"$root/$courseName/".$set->id."/?" 63 . $self->url_authen_args}, $set->id), CGI::br(); 64 } else { 65 print $set->id, CGI::br(); 66 } 67 } 68 } 69 70 sub title { 71 my ($self, $setName) = @_; 72 $setName =~ s/^set//; 73 74 return $setName; 75 } 76 77 sub body { 78 my ($self, $setName) = @_; 79 $setName =~ s/^set//; 80 my $r = $self->{r}; 81 my $courseEnvironment = $self->{courseEnvironment}; 82 my $user = $r->param('user'); 83 my $wwdb = $self->{wwdb}; 84 85 # *** *** *** *** 86 # somewhere in here, we have to print the problem set header! 87 # *** *** *** *** 88 89 print CGI::start_table(); 90 print CGI::Tr( 91 CGI::th("Name"), 92 CGI::th("Attempts"), 93 CGI::th("Remaining"), 94 CGI::th("Status"), 95 ); 96 97 my $set = $wwdb->getSet($user, $setName); 98 my @problemNumbers = $wwdb->getProblems($user, $setName); 99 foreach my $problemNumber (sort { $a <=> $b } @problemNumbers) { 100 my $problem = $wwdb->getProblem($user, $setName, $problemNumber); 101 print $self->problemListRow($set, $problem); 102 } 103 104 print CGI::end_table(); 105 106 return ""; 107 } 108 109 sub problemListRow($$$) { 110 my $self = shift; 111 my $set = shift; 112 my $problem = shift; 113 114 my $name = $problem->id; 115 my $interactiveURL = "prob$name/?" . $self->url_authen_args; 116 my $interactive = CGI::a({-href=>$interactiveURL}, "Problem $name"); 117 my $attempts = $problem->num_correct + $problem->num_incorrect; 118 my $remaining = $problem->max_attempts < 0 119 ? "unlimited" 120 : $problem->max_attempts - $attempts; 121 my $status = $problem->status * 100 . "%"; 122 123 return CGI::Tr(CGI::td([ 124 $interactive, 125 $attempts, 126 $remaining, 127 $status, 128 ])); 129 } 130 131 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |