diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 171769104..001589837 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -694,22 +694,20 @@ sub www_graph { my $i18n = WebGUI::International->new($session, "Asset_Survey"); - my $ac = $self->getAdminConsole; - eval { require GraphViz }; if ($@) { - return $ac->render('Survey Visualization requires the GraphViz module', $i18n->get('survey visualization')); + return '

' . $i18n->get('survey visualization') . '

Survey Visualization requires the GraphViz module'; } my $format = $self->session->form->param('format'); my $layout = $self->session->form->param('layout'); - my $f = WebGUI::HTMLForm->new($session); - $f->hidden( + my $f = WebGUI::FormBuilder->new($session, action => $self->getUrl); + $f->addField( "hidden", name=>'func', value=>'graph' ); - $f->selectBox( + $f->addField( "selectBox", name => 'format', label => $i18n->get('visualization format'), hoverHelp => $i18n->get('visualization format help'), @@ -717,7 +715,7 @@ sub www_graph { defaultValue => [$format], sortByValue => 1, ); - $f->selectBox( + $f->addField( "selectBox", name => 'layout', label => $i18n->get('visualization layout algorithm'), hoverHelp => $i18n->get('visualization layout algorithm help'), @@ -725,7 +723,7 @@ sub www_graph { defaultValue => [$layout], sortByValue => 1, ); - $f->submit( + $f->addField( "submit", defaultValue => $i18n->get('generate'), ); @@ -735,7 +733,7 @@ sub www_graph { $output .= "

" . $i18n->get('visualization success') . qq{ survey.$format

}; } } - return $ac->render($f->print . $output, $i18n->get('survey visualization')); + return '

' . $i18n->get('survey visualization') . '

' . $f->toHtml . $output; } =head2 hasResponses diff --git a/t/Asset/Wobject/Survey.t b/t/Asset/Wobject/Survey.t index a3c0720ac..b45297071 100644 --- a/t/Asset/Wobject/Survey.t +++ b/t/Asset/Wobject/Survey.t @@ -8,6 +8,7 @@ use Test::More; use Test::Deep; use Data::Dumper; use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Test::Mechanize; use WebGUI::Session; #---------------------------------------------------------------------------- @@ -16,7 +17,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 47; +plan tests => 51; #---------------------------------------------------------------------------- # put your tests here @@ -261,6 +262,21 @@ like($storage->getFileContentsAsScalar($filename), qr{ stop$ # ..and end with stop }xs, 'Generated graph looks roughly okay'); +my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file ); +$mech->get_ok( '/' ); +$mech->session->user({ userId => 3 }); +$mech->get_ok( $survey->getUrl( 'func=graph' ) ); +$mech->submit_form_ok({ + fields => { + format => "plain", + layout => "dot", + }, + }, + "generate a graph", +); +# Can only test for the uploads, mech doesn't have uploads handler +$mech->content_contains( 'uploads/temp', 'uploads link exists' ); + } ####################################################