diff options
| author | Jérémy Hennecart <jeh@odoo.com> | 2019-07-22 12:23:22 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-08-05 08:40:33 +0000 |
| commit | 4587e6a3965b1963920670d7cda755c7bd9d6367 (patch) | |
| tree | 73a9720b651cb57eae2ac525897bc4a37a3f8de7 /addons/website_slides/models/slide_question.py | |
| parent | ad9d7c5c06a6e00a6942fe312c7087bfb62865de (diff) | |
[REF] website_slides: make eLearning an application with its own menu structure
PURPOSE
eLearning should have its own application in manager. Indeed this is becoming
a big application and having it embedded inside Website application is not
enough anymore. It should also hold updated and easy-to-use menus,
navigation, actions and views in backend.
SPECIFICATIONS
Update manifest and make website_slides an application separated from
website embedded menus.
Implement new menu structure
* Courses
* Courses
List view: Course Name, # Views, # Attendees, # Ratings, Revenues,
Reviews
* Contents
* Reporting
* Courses: list view on slide.channel model, ordered by # views.
* add a graph view (group by content)
* Contents: graph view on slide.slide model
Area Graph: X month
Y measure: # Views (others measures: Attendees, ...)
Group by: course (color)
* Reviews: see kanban of latest reviews;
* Quiz: list view on slide.question model.
List view: Add # Quizz Trials, # Quizz Passed, Avg Attempts
* Configuration
* Settings
* Allow Forum on Courses (installs website_slides_forum)
* Allow Certifications (installs website_slides_survey)
* Allow Selling Courses (installs website_sale_slides)
* Course Tags
* See channel.tags.group with label Course Tags, form view allow to
configure group tags
* https://drive.google.com/a/odoo.com/file/d/1G0g2UnG5cZG55EXQ5icbgwe7T2eSZskT/view?usp=drivesdk
* On click: open :https://drive.google.com/a/odoo.com/file/d/1I_PW3aZAbrslXadiYqmVF-_6dGXx8knd/view?usp=drivesdk
* Content Tags
This structure will gain new items in sub-modules, notably bridge with
form and website_sale. Those will be implemented in next commits.
LINKS
Task 1978729
PR #35061
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Jérémy Hennecart <jeh@odoo.com>
Diffstat (limited to 'addons/website_slides/models/slide_question.py')
| -rw-r--r-- | addons/website_slides/models/slide_question.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/addons/website_slides/models/slide_question.py b/addons/website_slides/models/slide_question.py index 9d497190434..98c51585dda 100644 --- a/addons/website_slides/models/slide_question.py +++ b/addons/website_slides/models/slide_question.py @@ -14,6 +14,10 @@ class SlideQuestion(models.Model): question = fields.Char("Question Name", required=True, translate=True) slide_id = fields.Many2one('slide.slide', string="Slide", required=True) answer_ids = fields.One2many('slide.answer', 'question_id', string="Answer") + # statistics + attempts_count = fields.Integer(compute='_compute_statistics', groups='website.group_website_publisher') + attempts_avg = fields.Float(compute="_compute_statistics", digits=(6, 2), groups='website.group_website_publisher') + done_count = fields.Integer(compute="_compute_statistics", groups='website.group_website_publisher') @api.constrains('answer_ids') def _check_only_one_good_answer(self): @@ -37,6 +41,23 @@ class SlideQuestion(models.Model): if len(question.answer_ids) < 2: raise ValidationError(_("A question must at least have two possible answers")) + @api.depends('slide_id') + def _compute_statistics(self): + slide_partners = self.env['slide.slide.partner'].sudo().search([('slide_id', 'in', self.slide_id.ids)]) + slide_stats = dict((s.slide_id.id, dict({'attempts_count': 0, 'attempts_unique': 0, 'done_count': 0})) for s in slide_partners) + + for slide_partner in slide_partners: + slide_stats[slide_partner.slide_id.id]['attempts_count'] += slide_partner.quiz_attempts_count + slide_stats[slide_partner.slide_id.id]['attempts_unique'] += 1 + if slide_partner.completed: + slide_stats[slide_partner.slide_id.id]['done_count'] += 1 + + for question in self: + stats = slide_stats.get(question.slide_id.id) + question.attempts_count = stats.get('attempts_count', 0) if stats else 0 + question.attempts_avg = stats.get('attempts_count', 0) / stats.get('attempts_unique', 1) if stats else 0 + question.done_count = stats.get('done_count', 0) if stats else 0 + class SlideAnswer(models.Model): _name = "slide.answer" |
