Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
%  my $qnum = 1;
Session	DateTime	\
%  foreach my $question ( @{$vstruct->{questions}} ) {
%	if ( $question->{range} ) {
%		foreach my $choice ( @{ $question->{choices} } ) {
<% $choice->{choice} %>	\
%		}
%	} elsif ( $question->{allow_multi} ) {
%		foreach my $choice ( @{ $question->{choices} } ) {
<% $choice->{choice} %>	\
%		}
%	} else {
<% $question->{question} %>	\
%	}
%  }
%  $m->out("\n");
%  foreach my $voice ( @$voices ) {
%	my $vote = JSON::XS->new->decode($voice->voting);
%	my $qnum = 1;
%	my $ctime = Contenido::DateTime->new( postgres => $voice->ctime );
<% $voice->session_id %>	<% $ctime->ymd('-').' '.$ctime->hms %>	\
%	foreach my $question ( @{$vstruct->{questions}} ) {
%		if ( $question->{range} ) {
%			my $chc = 1;
%			foreach my $choice ( @{ $question->{choices} } ) {
<% exists $vote->{$qnum}{$chc} ? $vote->{$qnum}{$chc} : '0' %>	\
%				$chc++;
%			}
%		} elsif ( $question->{allow_multi} ) {
%			my $chc = 1;
%			foreach my $choice ( @{ $question->{choices} } ) {
<% exists $vote->{$qnum}{$chc} ? 1 : 0 %>	\
%				$chc++;
%			}
%		} else {
%			my $chc = 1;
%			my $ans;
%			foreach my $choice ( @{ $question->{choices} } ) {
%				if ( exists $vote->{$qnum}{$chc} ) {
%					$ans = $choice->{choice};
%					last;
%				}
%				$chc++;
%			}
<% $ans ? $ans : 0 %>	\
%		}
%		$qnum++;
%	}
%	$m->out("\n");
%  }
%#<% Dumper($vstruct) %>
<%args>

	$id	=> undef

</%args>
<%init>

  my $prj = $request->{project};
  my $profile = $request->{project_profile};
  my $root = $request->{project_section};
  &abort404	unless $id && $id =~ /^\d+$/;

  my ($document, $voices, $vstruct);
  if ( $id ) {
	$document = $keeper->get_document_by_id ($id,
		class   => 'promosuite::Voting',
		status  => 1,
	);
	&abort404	unless ref $document;
	$vstruct = $document->get_image('voting');
	$voices = $keeper->get_documents(
		class		=> 'promosuite::Voice',
		order_by	=> 'dtime',
		object_id	=> $document->id,
		no_limit	=> 1,
		return_mode	=> 'array_ref',
	);
  }
  return	unless ref $voices eq 'ARRAY' && @$voices;
  $r->header_out('Content-Disposition', 'attachment; filename="result_'.$id.'.txt"');

</%init>