Skip to content
Permalink
Browse files

pimpr esults

  • Loading branch information
tde-banana-odoo committed Dec 2, 2019
1 parent 224d767 commit bfaf48b68653eef1822efd8c76e5353ec417397a
Showing with 39 additions and 29 deletions.
  1. +7 −10 addons/survey/models/survey_question.py
  2. +32 −19 addons/survey/views/survey_templates_statistics.xml
@@ -298,10 +298,8 @@ def _prepare_statistics(self, user_input_lines):

# fetch answer lines, separate comments from real answers
all_line_ids = user_input_lines.filtered(lambda line: line.question_id == question)
if question.question_type in ['simple_choice', 'multiple_choice']:
answer_line_ids = all_line_ids.filtered(lambda line: line.answer_type != 'text')
elif question.question_type == 'matrix':
answer_line_ids = all_line_ids.filtered(lambda line: line.answer_type != 'text')
if question.question_type in ['simple_choice', 'multiple_choice', 'matrix']:
answer_line_ids = all_line_ids.filtered(lambda line: line.answer_type == 'suggestion')
else:
answer_line_ids = all_line_ids
comment_line_ids = all_line_ids - answer_line_ids
@@ -397,12 +395,11 @@ def _get_stats_table_data_matrix(self, user_input_lines):

return [{
'row': row,
'suggested_answer': sug_answer,
'count': count_data[(row, sug_answer)]
}
for row in matrix_rows
for sug_answer in suggested_answers
]
'columns': [{
'suggested_answer': sug_answer,
'count': count_data[(row, sug_answer)]
} for sug_answer in suggested_answers],
} for row in matrix_rows]

def _get_stats_summary_data(self, user_input_lines):
if self.question_type in ['numerical_box']:
@@ -173,57 +173,67 @@


<template id="question_result_matrix_new" name="Question: matrix result (matrix)">
<t t-set="matrix_result" t-value="prepare_result"/>
<!-- Tabs -->
<t t-set="graph_data" t-value="question_data['graph_data']"/>
<t t-set="table_data" t-value="question_data['table_data']"/>
<ul class="nav nav-tabs d-print-none" role="tablist">
<li class="nav-item">
<a t-att-href="'#graph_question_%d' % question.id" t-att-aria-controls="'graph_question_%d' % question.id" class="nav-link active" data-toggle="tab" role="tab">
<i class="fa fa-bar-chart"></i>
Graph
<a t-att-href="'#survey_graph_question_%d' % question.id"
t-att-aria-controls="'survey_graph_question_%d' % question.id"
class="nav-link active" data-toggle="tab" role="tab">
<i class="fa fa-bar-chart"></i> Graph
</a>
</li>
<li class="nav-item">
<a t-att-href="'#data_question_%d' % question.id" t-att-aria-controls="'data_question_%d' % question.id" class="nav-link" data-toggle="tab" role="tab">
<i class="fa fa-list-alt"></i>
Data
<a t-att-href="'#survey_data_question_%d' % question.id"
t-att-aria-controls="'survey_data_question_%d' % question.id"
class="nav-link" data-toggle="tab" role="tab">
<i class="fa fa-list-alt"></i> Data
</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active with-3d-shadow with-transitions survey_graph" t-att-id="'graph_question_%d' % question.id" t-att-data-question_id= "question.id" data-graph-type= "multi_bar" t-att-data-graph-data="graph_data">
<div role="tabpanel" class="tab-pane active with-3d-shadow with-transitions survey_graph"
t-att-id="'survey_graph_question_%d' % question.id"
t-att-data-question_id= "question.id"
data-graph-type= "multi_bar"
t-att-data-graph-data="graph_data">
<!-- canvas element for drawing Multibar chart -->
<canvas/>
</div>
<div role="tabpanel" class="tab-pane" t-att-id="'data_question_%d' % question.id">
<div role="tabpanel" class="tab-pane" t-att-id="'survey_data_question_%d' % question.id">
<table class="table table-hover table-sm text-right">
<thead>
<tr>
<th></th>
<th class="text-right" t-foreach="matrix_result['answers']" t-as="answer_id">
<!-- <th class="text-right" t-foreach="matrix_result['answers']" t-as="answer_id">
<span t-esc="matrix_result['answers'][answer_id]"></span>
</th>
</th> -->
</tr>
</thead>
<tbody>
<tr t-foreach="matrix_result['rows']" t-as="row_id">
<tr t-foreach="table_data" t-as="choice_data">
<td>
<span t-esc="matrix_result['rows'][row_id]"></span>
<span t-esc="choice_data['row'].value"></span>
</td>
<td class="survey_answer" 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="badge badge-primary" t-esc="matrix_result['result'][(row_id,answer_id)]"></span><i class="fa fa-filter text-primary survey_filter" t-att-data-question_id="question.id" t-att-data-row_id="row_id" t-att-data-answer_id="answer_id" role="img" aria-label="Survey filter" title="Survey filter"></i>
<td class="survey_answer" t-foreach="choice_data['columns']" t-as="column_data">
<span t-esc="round(column_data['count'] * 100.0/ (len(choice_data['columns']) or 1), 2)"></span> %
<span class="badge badge-primary" t-esc="column_data['count']"></span>
<!-- <i class="fa fa-filter text-primary survey_filter"
t-att-data-question_id="question.id"
t-att-data-row_id="row_id"
t-att-data-answer_id="answer_id" role="img" aria-label="Survey filter" title="Survey filter"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<!-- handle comments to matrix -->
<div>
<!-- <div>
<t t-set="comments" t-value="matrix_result['comments']" />
<t t-if="comments">
<t t-call="survey.question_result_comments" />
</t>
</div>
</div> -->
</div>
</template>

@@ -288,6 +298,9 @@
<t t-elif="question.question_type in ['simple_choice', 'multiple_choice']">
<t t-call="survey.question_result_choice_new"></t>
</t>
<t t-elif="question.question_type in ['matrix']">
<t t-call="survey.question_result_matrix_new"></t>
</t>
</div>
</div>

0 comments on commit bfaf48b

Please sign in to comment.
You can’t perform that action at this time.