Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

dhoss additions but broken merge due to kd git brain damage

  • Loading branch information...
commit 19a8b3e3aca36702d280ec53111214ec548dd5c1 2 parents e02ef9b + 12cd478
Kieren Diment authored
View
BIN  Survey-Perl/db/answers.db
Binary file not shown
View
70 Survey-Perl/lib/Survey/Perl/Controller/Survey.pm
@@ -3,42 +3,52 @@ use Moose;
use Config::Any;
BEGIN { extends 'Catalyst::Controller' }
use Data::Dumper;
-sub survey_base :Chained("/") :PathPart("survey") :CaptureArgs(0) {
- my ($self, $c) = @_;
-# if (! $c->user) {
-# if ($c->req->params->{'dest'} && ! $c->session->{human}) {
-
-# $c->forward('/recaptcha/test_user');
-# }
-# elsif (! $c->session->{human}) {
-# $c->detach('/recaptcha/test_user');
-# }
-# }
-}
-sub get_root :Chained("survey_base") :PathPart("") :Args(0) {
- my ($self, $c) = @_;
- my $questions = do($c->path_to('survey/en.pl'));
- $c->stash(sections => $questions,
- template => 'survey/index.tt');
+sub survey_base : Chained("/") : PathPart("survey") : CaptureArgs(0) {
+ my ( $self, $c ) = @_;
+
+ # if (! $c->user) {
+ # if ($c->req->params->{'dest'} && ! $c->session->{human}) {
+
+ # $c->forward('/recaptcha/test_user');
+ # }
+ # elsif (! $c->session->{human}) {
+ # $c->detach('/recaptcha/test_user');
+ # }
+ # }
}
-sub finish_survey :Chained("survey_base") :PathPart("finish") :Args(0) {
- my ($self, $c) = @_;
- my $user = $c->session->{human};
- $c->res->body($c->sessionid);
+sub get_root : Chained("survey_base") : PathPart("") : Args(0) {
+ my ( $self, $c ) = @_;
+ my $questions = do( $c->path_to('survey/en.pl') );
+ $c->stash(
+ sections => $questions,
+ template => 'survey/index.tt'
+ );
}
sub finish_survey : Chained("survey_base") PathPart("finish") Args(0) {
- my ($self, $c) = @_;
- my $answers = $c->req->params;
- $c->log->debug("Params: " . Dumper $answers);
- delete $answers->{'submit'};
- my $rs = $c->model('Answers')->txn_do(sub{
- $c->model('Answers::Survey')->create($answers)
- or die "Could not submit survey answers: $!";
- });
-
+ my ( $self, $c ) = @_;
+ my $answers = $c->req->params;
+ $c->log->debug( "Params: " . Dumper $answers);
+ delete $answers->{'submit'};
+ my @multis;
+ $c->log->debug( "Answers: " . Dumper @{ $answers->{'field'} } );
+ push @multis, { industries => $_ } for @{ $answers->{'industries'} };
+ push @multis, { perl_versions => $_ } for @{ $answers->{'perl_versions'} };
+ push @multis, { os_dev => $_ } for @{ $answers->{'os_dev'} };
+ delete $answers->{$_} for qw/ industries perl_versions os_dev field /;
+ $c->log->debug( "multis: " . Dumper @multis );
+ my $rs = $c->model('Answers')->txn_do(
+ sub {
+ $c->model('Answers::Survey')->populate( \@multis )
+ or die "Could not submit survey answers: $!";
+
+ $c->model('Answers::Survey')->create($answers)
+ or die "Could not submit survey answers: $!";
+ }
+ );
+
}
1;
View
13 Survey-Perl/script/survey_csv_matrix.pl
@@ -16,15 +16,10 @@
while ( my $answer = $answer_rs->next ) {
print Dumper $answer->columns;
for my $column ( $answer->columns ) {
- if ( ref $answer->$column eq "ARRAY" ) {
- print "Arrayref found\n";
- print $fh $column . "," . @{$answer->$column} . "\n"
- or die "couldn't write row: $!";
- }
- else {
- print $fh $column . "," . $answer->$column . "\n"
- or die "couldn't write row: $!";
- }
+
+ print $fh $column . "," . $answer->$column . "\n"
+ or die "couldn't write row: $!";
+
}
}
close $fh;
View
76 Survey-Perl/test.csv
@@ -1,76 +0,0 @@
-surveyid,1
-gender,1
-age,2
-country_birth,
-country_residence,
-highest_qual,3
-field,ARRAY(0x103804b20)
-perl_formal,2
-other_dynamic_formal,3
-other_dynamic_taught,ruby
-income,1
-industries,Computers - Services>
-prog_length,3
-perl_length,3
-percent_programming,4
-percent_management,4
-percent_perl,4
-spare_time,4
-perl_versions,ARRAY(0x103804c00)
-os_dev,ARRAY(0x100d15700)
-os_deployment,
-lang,
-lang1,
-lang2,
-lang3,
-lang4,
-perl_freq,4
-pm_list,3
-tech_list,3
-tech_list_non_perl,3
-local_pm,3
-pm_meetings,2
-conference,
-cpan_modules,
-handover_modules,
-bug_report_interpreter,
-fix_bug_interpreter,
-feature_interpreter,
-cpan_bug,
-cpan_fix_bug,
-cpan_feature,
-legacy,4
-eliminate,4
-startup,4
-unmaintainable,4
-scale,4
-management_encourages,4
-management_outdated,4
-management_unmaintainable,4
-management_scale,4
-first,4
-beginner,4
-early_career,4
-experienced,4
-sysadmins,4
-netengs,4
-embedded,4
-apps,4
-best,asdf
-frustrates,
-words,
-cert_me,3
-cert_other,3
-cert_comments,asdf
-cpan_important,
-cpan1,
-cpan2,
-cpan3,
-cpan4,
-run_tests,
-force,
-understand,
-report,
-x_platform,3
-x_comments,324tgegrasg
-email,
Please sign in to comment.
Something went wrong with that request. Please try again.