odoo/addons/survey/views/survey_result.xml

337 lines
17 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="result" name="Survey Result">
<t t-call="website.layout">
<div class="container">
<t t-set="head">
<link href="/web_graph/static/src/css/nv.d3.css" rel="stylesheet" type="text/css"></link>
<link href="/survey/static/src/css/survey_result.css" rel="stylesheet" type="text/css"></link>
<script src="/web_graph/static/lib/nvd3/d3.v3.js"></script>
<script src="/web_graph/static/lib/nvd3/nv.d3.js"></script>
<script type="text/javascript" src="/survey/static/src/js/survey_result.js" />
</t>
<h1>Survey Result</h1>
<h2><span t-field='survey.title'></span></h2>
<div t-foreach='survey.page_ids' t-as='page' class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title" t-field='page.title'></h3></div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div t-foreach='page.question_ids' t-as='question' class="panel panel-default mt16">
<t t-set="input_summary" t-value="get_input_summary(question)"/>
<div class="panel-heading">
<h3 class="panel-title">
<b>Question </b>
<span t-field='question.question'></span>
<span class="pull-right">
<span class="label label-success"><span t-esc="input_summary['answered']"></span> Answered</span>
<span class="label label-danger"><span t-esc="input_summary['skipped']"></span> Skipped</span>
</span>
</h3>
</div>
<t t-if="question.type in ['textbox', 'free_text', 'datetime']">
<t t-call="survey.result_text"></t>
</t>
<t t-if="question.type in ['simple_choice', 'multiple_choice']">
<t t-call="survey.result_choice"></t>
</t>
<t t-if="question.type == 'matrix'">
<t t-call="survey.result_matrix"></t>
</t>
<t t-if="question.type == 'numerical_box'">
<t t-call="survey.result_number"></t>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>
<!-- Result for free_text,textbox and datetime -->
<template id="result_text" name="Text Result">
<t t-if="input_summary['answered'] != 0">
<table class="table table-hover" t-att-id="'table_question_'+str(question.id)">
<thead>
<tr>
<th>#</th>
<th>User Responses</th>
</tr>
</thead>
<tbody>
<tr class="hidden" t-foreach="question.user_input_line_ids" t-as="user_input">
<td><t t-esc="user_input_index+1"></t></td>
<t t-if="question.type == 'free_text'">
<td>
<span t-field="user_input.value_free_text"></span><br/>
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p></small>
<span class="pull-right">
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</td>
</t>
<t t-if="question.type == 'textbox'">
<td>
<span t-field="user_input.value_text"></span><br/>
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p>
<span class="pull-right">
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</small>
</td>
</t>
<t t-if="question.type == 'datetime'">
<td>
<span class="oe_date" t-field="user_input.value_date"></span><br/>
<span class="pull-right">
<a t-att-href="user_input.user_input_id.print_url+user_input.user_input_id.token"> <i class="fa fa-print"></i> Print respondent's answers</a><br/>
</span>
</td>
</t>
</tr>
</tbody>
</table>
<!-- Pagination Element -->
<ul t-att-id="'pagination_'+str(question.id)" class="pagination" >
<t t-if="len(question.user_input_line_ids) > 5">
<li t-foreach="page_range(len(question.user_input_line_ids))" t-as="num">
<a href="#" t-esc="num"></a>
</li>
</t>
</ul>
<!-- Dynamic Script for Pagination Element -->
<script>
$( document ).ready(function() {
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt(5)').removeClass('hidden');
$('#<t t-esc="'pagination_'+str(question.id)"></t> li:first').addClass('active');
$('#<t t-esc="'pagination_'+str(question.id)"></t> li a').click(function(event){
event.preventDefault();
$('#<t t-esc="'pagination_'+str(question.id)"></t> li').removeClass('active');
$(this).parent('li').addClass('active');
$('#table_question_<t t-esc="question.id"></t> tbody tr').addClass('hidden');
var num = $(this).text();
min = (5 * (num-1))-1;
if (min == -1){
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt('+5 * num+')').removeClass('hidden');
}
else{
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt('+5 * num+'):gt('+min+')').removeClass('hidden');
}
});
});
</script>
</t>
<t t-if="input_summary['answered'] == 0">
<h2 style="padding-top:30px;padding-bottom:30px;text-align:center;" class="text-muted">Sorry, No one answered this question.</h2>
</t>
</template>
<!-- Result for simple_choice and multiple_choice -->
<template id="result_choice" name="Choice Result">
<div>
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active">
<a t-att-href="'#graph_question_'+str(question.id)" data-toggle="tab">
<i class="fa fa-bar-chart-o"></i> Graph
</a>
</li>
<li>
<a t-att-href="'#data_question_'+str(question.id)" data-toggle="tab">
<i class="fa fa-list-alt"></i> Data
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active survey_graph" t-att-id="'graph_question_'+str(question.id)" t-att-data-question_id= "question.id" data-graph_type= "bar">
<!-- svg element for drawing bar chart -->
<svg style="height:20em"></svg>
</div>
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
<table class="table table-hover">
<thead>
<tr>
<th>Answer Choices</th>
<th>User Responses</th>
</tr>
</thead>
<tbody>
<tr t-foreach="prepare_result(question)" t-as="user_input">
<td>
<p t-esc="user_input['text']"></p>
</td>
<td>
<span t-esc="round(user_input['count']*100.0/(input_summary['answered'] or 1),2)"></span> %
<span t-esc="user_input['count']" class="label label-primary">Vote</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<!-- Result for matrix -->
<template id="result_matrix" name="Matrix Result">
<t t-set="matrix_result" t-value="prepare_result(question)" />
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active">
<a t-att-href="'#graph_question_'+str(question.id)" data-toggle="tab">
<i class="fa fa-bar-chart-o"></i>
Graph
</a>
</li>
<li>
<a t-att-href="'#data_question_'+str(question.id)" data-toggle="tab">
<i class="fa fa-list-alt"></i>
Data
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active with-3d-shadow with-transitions survey_graph" t-att-id="'graph_question_'+str(question.id)" t-att-data-question_id= "question.id" data-graph_type= "multi_bar">
<!-- svg element for drawing Multibar chart -->
<svg style="height:20em"></svg>
</div>
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
<table class="table table-hover text-right">
<thead>
<tr>
<th></th>
<th class="text-right" t-foreach="matrix_result['answers']" t-as="answer_id">
<span t-esc="matrix_result['answers'][answer_id]"></span>
</th>
</tr>
</thead>
<tbody>
<tr t-foreach="matrix_result['rows']" t-as="row_id">
<td>
<span t-esc="matrix_result['rows'][row_id]"></span>
</td>
<td t-foreach="matrix_result['answers']" t-as="answer_id">
<span t-esc="round(matrix_result['result'][(row_id,answer_id)]*100.0/(input_summary['answered'] or 1),2)"></span> %
<span class="label label-primary" t-esc="matrix_result['result'][(row_id,answer_id)]"></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<!-- Result for Numeric Data -->
<template id="result_number" name="Number Result">
<t t-set="number_result" t-value="prepare_result(question)" />
<span class="pull-right mt8">
<span class="label label-default only_right_radius">Maximum </span> <span class="label label-success only_left_radius" t-esc="number_result['max']"></span>
<span class="label label-default only_right_radius">Minimum </span> <span class="label label-danger only_left_radius" t-esc="number_result['min']"></span>
<span class="label label-default only_right_radius">Average </span> <span class="label label-warning only_left_radius" t-esc="number_result['average']"></span>
</span>
<ul class="nav nav-tabs">
<li class="active">
<a t-att-href="'#most_common_'+str(question.id)" data-toggle="tab">
<i class="fa fa-list-ol"></i>
Most Common <span t-esc="len(number_result['most_comman'])"></span>
</a>
</li>
<li>
<a t-att-href="'#data_question_'+str(question.id)" data-toggle="tab">
<i class="fa fa-list-alt"></i>
All Data
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active with-3d-shadow with-transitions" t-att-id="'most_common_'+str(question.id)">
<table class="table table-hover">
<thead>
<tr>
<th>User Responce</th>
<th>Occurence</th>
</tr>
</thead>
<tbody>
<tr t-foreach="number_result['most_comman']" t-as="row">
<td>
<span t-esc="row[0]"></span>
</td>
<td>
<span t-esc="row[1]"></span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane" t-att-id="'data_question_'+str(question.id)">
<table class="table table-hover" t-att-id="'table_question_'+str(question.id)">
<thead>
<tr>
<th>#</th>
<th>User Responses</th>
</tr>
</thead>
<tbody>
<tr class="hidden" t-foreach="question.user_input_line_ids" t-as="user_input">
<td><t t-esc="user_input_index+1"></t></td>
<td>
<span t-field="user_input.value_number"></span><br/>
<small><p t-field="user_input.date_create" class="fa fa-calendar oe_date text-muted"></p></small>
</td>
</tr>
</tbody>
</table>
<!-- Pagination Element -->
<ul t-att-id="'pagination_'+str(question.id)" class="pagination" >
<t t-if="len(question.user_input_line_ids) > 5">
<li t-foreach="page_range(len(question.user_input_line_ids))" t-as="num">
<a href="#" t-esc="num"></a>
</li>
</t>
</ul>
<!-- Dynamic Script for Pagination Element -->
<script>
$( document ).ready(function() {
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt(5)').removeClass('hidden');
$('#<t t-esc="'pagination_'+str(question.id)"></t> li:first').addClass('active');
$('#<t t-esc="'pagination_'+str(question.id)"></t> li a').click(function(event){
event.preventDefault();
$('#<t t-esc="'pagination_'+str(question.id)"></t> li').removeClass('active');
$(this).parent('li').addClass('active');
$('#table_question_<t t-esc="question.id"></t> tbody tr').addClass('hidden');
var num = $(this).text();
min = (5 * (num-1))-1;
if (min == -1){
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt('+5 * num+')').removeClass('hidden');
}
else{
$('#table_question_<t t-esc="question.id"></t> tbody tr:lt('+5 * num+'):gt('+min+')').removeClass('hidden');
}
});
});
</script>
</div>
</div>
</template>
<template id="no_result" name="Survey Result">
<t t-call="website.layout">
<div class="container">
<h2><span t-field='survey.title'></span></h2>
<div class="jumbotron mt32">
<h2 class="text-muted">
<span>
<i style="font-size:1.8em" class="fa fa-users pull-right"></i>
</span>
Sorry, No one answered this survey yet
</h2>
</div>
</div>
</t>
</template>
</data>
</openerp>