Line # Revision Author
1 296 ahitrov % my $qnum = 1;
2 Session DateTime \
3 % foreach my $question ( @{$vstruct->{questions}} ) {
4 % if ( $question->{range} ) {
5 % foreach my $choice ( @{ $question->{choices} } ) {
6 <% $choice->{choice} %> \
7 % }
8 % } elsif ( $question->{allow_multi} ) {
9 % foreach my $choice ( @{ $question->{choices} } ) {
10 <% $choice->{choice} %> \
11 % }
12 % } else {
13 <% $question->{question} %> \
14 % }
15 % }
16 % $m->out("\n");
17 % foreach my $voice ( @$voices ) {
18 % my $vote = JSON::XS->new->decode($voice->voting);
19 % my $qnum = 1;
20 % my $ctime = Contenido::DateTime->new( postgres => $voice->ctime );
21 <% $voice->session_id %> <% $ctime->ymd('-').' '.$ctime->hms %> \
22 % foreach my $question ( @{$vstruct->{questions}} ) {
23 % if ( $question->{range} ) {
24 % my $chc = 1;
25 % foreach my $choice ( @{ $question->{choices} } ) {
26 <% exists $vote->{$qnum}{$chc} ? $vote->{$qnum}{$chc} : '0' %> \
27 % $chc++;
28 % }
29 % } elsif ( $question->{allow_multi} ) {
30 % my $chc = 1;
31 % foreach my $choice ( @{ $question->{choices} } ) {
32 <% exists $vote->{$qnum}{$chc} ? 1 : 0 %> \
33 % $chc++;
34 % }
35 % } else {
36 % my $chc = 1;
37 % my $ans;
38 % foreach my $choice ( @{ $question->{choices} } ) {
39 % if ( exists $vote->{$qnum}{$chc} ) {
40 % $ans = $choice->{choice};
41 % last;
42 % }
43 % $chc++;
44 % }
45 <% $ans ? $ans : 0 %> \
46 % }
47 % $qnum++;
48 % }
49 % $m->out("\n");
50 % }
51 %#<% Dumper($vstruct) %>
52 <%args>
53
54 $id => undef
55
56 </%args>
57 <%init>
58
59 my $prj = $request->{project};
60 my $profile = $request->{project_profile};
61 my $root = $request->{project_section};
62 &abort404 unless $id && $id =~ /^\d+$/;
63
64 my ($document, $voices, $vstruct);
65 if ( $id ) {
66 $document = $keeper->get_document_by_id ($id,
67 class => 'promosuite::Voting',
68 status => 1,
69 );
70 &abort404 unless ref $document;
71 $vstruct = $document->get_image('voting');
72 $voices = $keeper->get_documents(
73 class => 'promosuite::Voice',
74 order_by => 'dtime',
75 object_id => $document->id,
76 no_limit => 1,
77 return_mode => 'array_ref',
78 );
79 }
80 return unless ref $voices eq 'ARRAY' && @$voices;
81 $r->header_out('Content-Disposition', 'attachment; filename="result_'.$id.'.txt"');
82
83 </%init>