Parent Directory
|
Revision Log
test development branch
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/ProblemRenderer.pm,v 1.1 2008/04/29 19:27:34 sh002i 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::ProblemRenderer; 18 use base qw(WeBWorK::ContentGenerator); 19 20 =head1 NAME 21 22 WeBWorK::ContentGenerator::ProblemRenderer - render a problem with a minimal 23 amount of UI garbage. 24 25 =cut 26 27 use strict; 28 use warnings; 29 use WeBWorK::CGI; 30 use WeBWorK::Utils::Tasks qw(renderProblems); 31 32 sub pre_header_initialize { 33 my ($self) = @_; 34 my $r = $self->r; 35 36 my $pg = $r->param('pg'); 37 my $file = $r->param('file'); 38 my $seed = $r->param('seed'); 39 my $mode = $r->param('mode'); 40 my $hint = $r->param('hint'); 41 my $sol = $r->param('sol'); 42 43 die "must specify either a PG problems (param 'pg') or a path to a PG file (param 'file') and not both" 44 unless defined $pg and length $pg xor defined $file and length $file; 45 46 my $problem = $self->get_problem($pg, $file); 47 my @options = (r=>$r, problem_list=>[\$pg]); 48 49 #push @options, (problem_seed=>$seed) if defined $seed; 50 #push @options, (displayMode=>$mode) if defined $mode; 51 #push @options, (showHints=>$hint) if defined $hint; 52 #push @options, (showSolutions=>$sol) if defined $sol; 53 54 ($self->{result}) = renderProblems(@options); 55 } 56 57 sub get_problem { 58 my ($self, $pg, $file) = @_; 59 60 if (defined $pg) { 61 return \$pg; 62 } else { 63 return $file; 64 } 65 } 66 67 use Data::Dumper; 68 sub content { 69 my ($self) = @_; 70 my $result = $self->{result}; 71 my $dump = Dumper($result); 72 73 print <<EOF; 74 <html> 75 <head> 76 <title>Yuck!</title> 77 </head> 78 <body> 79 <pre>$dump</pre> 80 </body> 81 </html> 82 EOF 83 } 84 85 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |