[IMP] survey : Kanban card revamp
In order to display some stats on survey's card (in the kanban view), the survey's card has been reorganized: We remove all the button present in the bottom of the card, button concerned are: • analyze answers • test • share We recreate the button "share" in the dropdown menu of the card. We add the next information: - For each survey with scoring, the number of people who passed the test is displayed as well as the success rate. - For each survey with scoring and certification, a certification icon is displayed and the string "passed" (corresponding to the number of people who passed the test) bec$ TASK-ID : 2045617 closes odoo/odoo#35479 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -74,8 +74,8 @@ class Survey(models.Model):
|
||||
answer_count = fields.Integer("Registered", compute="_compute_survey_statistic")
|
||||
answer_done_count = fields.Integer("Attempts", compute="_compute_survey_statistic")
|
||||
answer_score_avg = fields.Float("Avg Score %", compute="_compute_survey_statistic")
|
||||
certified_count = fields.Integer("Certified", compute="_compute_survey_statistic")
|
||||
certified_ratio = fields.Integer("Certified Ratio", compute="_compute_certified_ratio")
|
||||
success_count = fields.Integer("Success", compute="_compute_survey_statistic")
|
||||
success_ratio = fields.Integer("Success Ratio", compute="_compute_survey_statistic")
|
||||
# scoring and certification fields
|
||||
scoring_type = fields.Selection([
|
||||
('no_scoring', 'No scoring'),
|
||||
@@ -121,31 +121,27 @@ class Survey(models.Model):
|
||||
for survey in self:
|
||||
survey.users_can_signup = signup_allowed
|
||||
|
||||
@api.depends('user_input_ids.input_type', 'user_input_ids.state', 'user_input_ids.test_entry', 'user_input_ids.quizz_score', 'user_input_ids.quizz_passed')
|
||||
@api.depends('user_input_ids.state', 'user_input_ids.test_entry', 'user_input_ids.quizz_score', 'user_input_ids.quizz_passed')
|
||||
def _compute_survey_statistic(self):
|
||||
stat = dict((cid, dict(answer_count=0, answer_done_count=0, certified_count=0, answer_score_avg_total=0.0)) for cid in self.ids)
|
||||
stat = dict((cid, dict(answer_count=0, answer_done_count=0, success_count=0, answer_score_avg_total=0.0)) for cid in self.ids)
|
||||
UserInput = self.env['survey.user_input']
|
||||
base_domain = ['&', ('survey_id', 'in', self.ids), ('test_entry', '!=', True)]
|
||||
|
||||
read_group_res = UserInput.read_group(base_domain, ['survey_id', 'state'], ['survey_id', 'input_type', 'state', 'quizz_score', 'quizz_passed'], lazy=False)
|
||||
read_group_res = UserInput.read_group(base_domain, ['survey_id', 'state'], ['survey_id', 'state', 'quizz_score', 'quizz_passed'], lazy=False)
|
||||
for item in read_group_res:
|
||||
stat[item['survey_id'][0]]['answer_count'] += item['__count']
|
||||
stat[item['survey_id'][0]]['answer_score_avg_total'] += item['quizz_score']
|
||||
if item['state'] == 'done':
|
||||
stat[item['survey_id'][0]]['answer_done_count'] += item['__count']
|
||||
if item['quizz_passed']:
|
||||
stat[item['survey_id'][0]]['certified_count'] += item['__count']
|
||||
stat[item['survey_id'][0]]['success_count'] += item['__count']
|
||||
|
||||
for survey in self:
|
||||
avg_total = stat[survey.id].pop('answer_score_avg_total')
|
||||
stat[survey.id]['answer_score_avg'] = avg_total / (stat[survey.id]['answer_done_count'] or 1)
|
||||
stat[survey.id]['success_ratio'] = (stat[survey.id]['success_count'] / (stat[survey.id]['answer_done_count'] or 1.0))*100
|
||||
survey.update(stat[survey.id])
|
||||
|
||||
@api.depends('certified_count', 'answer_done_count')
|
||||
def _compute_certified_ratio(self):
|
||||
for survey in self:
|
||||
survey.certified_ratio = survey.certified_count / (survey.answer_done_count or 1.0)
|
||||
|
||||
def _compute_survey_url(self):
|
||||
""" Computes a public URL for the survey """
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="trophy" class="svg-inline--fa fa-trophy fa-w-18" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M552 64H448V24c0-13.3-10.7-24-24-24H152c-13.3 0-24 10.7-24 24v40H24C10.7 64 0 74.7 0 88v56c0 35.7 22.5 72.4 61.9 100.7 31.5 22.7 69.8 37.1 110 41.7C203.3 338.5 240 360 240 360v72h-48c-35.3 0-64 20.7-64 56v12c0 6.6 5.4 12 12 12h296c6.6 0 12-5.4 12-12v-12c0-35.3-28.7-56-64-56h-48v-72s36.7-21.5 68.1-73.6c40.3-4.6 78.6-19 110-41.7 39.3-28.3 61.9-65 61.9-100.7V88c0-13.3-10.7-24-24-24zM99.3 192.8C74.9 175.2 64 155.6 64 144v-16h64.2c1 32.6 5.8 61.2 12.8 86.2-15.1-5.2-29.2-12.4-41.7-21.4zM512 144c0 16.1-17.7 36.1-35.3 48.8-12.5 9-26.7 16.2-41.8 21.4 7-25 11.8-53.6 12.8-86.2H512v16z"></path></svg>
|
||||
|
After Width: | Height: | Size: 812 B |
@@ -1,9 +1,19 @@
|
||||
.o_kanban_card_survey {
|
||||
.certification_icon {
|
||||
font-size: 20px;
|
||||
& > .row {
|
||||
min-height: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
.o_kanban_card_survey_successed{
|
||||
background-image:
|
||||
linear-gradient(rgba(255,255,255,.9),
|
||||
rgba(255,255,255,.9)),
|
||||
url(/survey/static/src/img/trophy-solid.svg);
|
||||
background-repeat: no-repeat;
|
||||
background-position: bottom 6px left -45px;
|
||||
background-size: 100px;
|
||||
}
|
||||
|
||||
table.o_section_list_view tr.o_data_row.o_is_section {
|
||||
font-weight: bold;
|
||||
background-color: #DDD;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class="oe_stat_button"
|
||||
attrs="{'invisible': [('certificate', '=', False)]}"
|
||||
icon="fa-trophy">
|
||||
<field string="Certified" name="certified_count" widget="statinfo"/>
|
||||
<field string="Certified" name="success_count" widget="statinfo"/>
|
||||
</button>
|
||||
<button name="action_survey_user_input_completed"
|
||||
type="object"
|
||||
@@ -134,8 +134,8 @@
|
||||
<field name="state"/>
|
||||
<field name="answer_count"/>
|
||||
<field name="answer_done_count"/>
|
||||
<field name="certified_count"/>
|
||||
<field name="certified_ratio"/>
|
||||
<field name="success_count"/>
|
||||
<field name="success_ratio"/>
|
||||
<field name="answer_score_avg"/>
|
||||
<button name="certificate" icon="fa-trophy" title="Certificate" aria-label="Certificate" attrs="{'invisible': [('certificate', '=', False)]}"/>
|
||||
<!-- Tweak as icons aren't directly supported in xml -->
|
||||
@@ -151,19 +151,25 @@
|
||||
<field name="title" />
|
||||
<field name="answer_done_count" />
|
||||
<field name="certificate" />
|
||||
<field name="scoring_type" />
|
||||
<field name="color" />
|
||||
<field name="access_mode"/>
|
||||
<field name="activity_ids" />
|
||||
<field name="activity_state" />
|
||||
<field name="success_count"/>
|
||||
<field name="success_ratio"/>
|
||||
<templates>
|
||||
<div t-name="kanban-box" t-attf-class="{{!selection_mode ? 'oe_kanban_color_' + kanban_getcolor(record.color.raw_value) : ''}} oe_kanban_card oe_kanban_global_click o_kanban_card_survey">
|
||||
<div class="o_dropdown_kanban dropdown" t-if="widget.editable and !selection_mode">
|
||||
<div t-name="kanban-box"
|
||||
t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click o_kanban_card_survey
|
||||
#{record.certificate.raw_value ? 'o_kanban_card_survey_successed' : ''}">
|
||||
<div class="o_dropdown_kanban dropdown" t-if="widget.editable">
|
||||
|
||||
<a role="button" class="dropdown-toggle o-no-caret btn" data-toggle="dropdown" data-display="static" href="#" aria-label="Dropdown menu" title="Dropdown menu">
|
||||
<span class="fa fa-ellipsis-v"/>
|
||||
</a>
|
||||
<div class="dropdown-menu" role="menu">
|
||||
<a role="menuitem" type="edit" class="dropdown-item">Edit Survey</a>
|
||||
<a t-if="record.state.raw_value != 'closed'" role="menuitem" type="object" class="dropdown-item" name="action_send_survey">Share</a>
|
||||
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Delete</a>
|
||||
<div role="separator" class="dropdown-divider"/>
|
||||
<div role="separator" class="dropdown-item-text">Color</div>
|
||||
@@ -171,29 +177,41 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_kanban_record_top">
|
||||
<div class="col-10 p-0">
|
||||
<h4 class="o_kanban_record_title mb4"><field name="title" /></h4>
|
||||
<h4 class="o_kanban_record_title p-0 mb4"><field name="title" /></h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-10 p-0 pb-1">
|
||||
<div class="container o_kanban_card_content" t-if="record.answer_done_count.raw_value != 0 or record.state.raw_value != 'draft'">
|
||||
<div class="row mt-4 ml-5">
|
||||
<div class="col-4 p-0">
|
||||
<a name="action_result_survey" type="object" class="d-flex flex-column align-items-center">
|
||||
<span class="font-weight-bold"><field name="answer_done_count"/></span>
|
||||
<span class="text-muted">Answers</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-4 p-0 border-left" t-if="record.scoring_type.raw_value != 'no_scoring'" >
|
||||
<a name="action_survey_user_input_certified" type="object" class="d-flex flex-column align-items-center">
|
||||
<span class="font-weight-bold"><field name="success_count"/></span>
|
||||
<span class="text-muted" t-if="!record.certificate.raw_value">Passed</span>
|
||||
<span class="text-muted" t-else="">Certified</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-4 p-0 border-left" t-if="record.scoring_type.raw_value != 'no_scoring'" >
|
||||
<a name="action_survey_user_input_completed" type="object" class="d-flex flex-column align-items-center">
|
||||
<span class="font-weight-bold"> <t t-esc="Math.round(record.success_ratio.raw_value)"></t> %</span>
|
||||
<span class="text-muted" >Success</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2"><i t-if="record.certificate.raw_value === true" title="Certification" class="certification_icon fa fa-trophy"></i></div>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom" t-if="!selection_mode">
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<a type="object" name="action_test_survey">Test</a>
|
||||
</li>
|
||||
<li>
|
||||
<a type="object" name="action_send_survey">Share &amp; Invite</a>
|
||||
</li>
|
||||
<li>
|
||||
<t t-if="record.answer_done_count.raw_value > 0"><a name="action_result_survey" type="object">Analyze Answers</a> <span t-if="record.answer_done_count.raw_value > 0">(<field name="answer_done_count" />)</span></t>
|
||||
<t t-if="record.answer_done_count.raw_value <= 0"><a style="color: #aaaaaa;">Analyze Answers</a></t>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom" t-if="!selection_mode">
|
||||
<div class="oe_kanban_bottom_left"/>
|
||||
<div class="oe_kanban_bottom_right">
|
||||
<field name="activity_ids" widget="kanban_activity" />
|
||||
<div class="col-2 align-self-end">
|
||||
<div class="o_kanban_record_bottom">
|
||||
<div class="oe_kanban_bottom_left"/>
|
||||
<div class="oe_kanban_bottom_right">
|
||||
<field name="activity_ids" widget="kanban_activity"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user