Skip to content

Commit b27dd32

Browse files
committed
[ADD] website_slides_require_completion
1 parent 787961f commit b27dd32

23 files changed

+793
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../website_slides_require_completion
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
===================================================
2+
Courses's Slides Require Previous Slides Completion
3+
===================================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ee4378b92b13f8ef9d5e45aaa9ac42feeeba2a7ac88e5d58c1b60bea420e0853
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--learning-lightgray.png?logo=github
20+
:target: https://github.com/OCA/e-learning/tree/16.0/website_slides_require_completion
21+
:alt: OCA/e-learning
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/e-learning-16-0/e-learning-16-0-website_slides_require_completion
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-learning&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows you to enforce the completion of previous slides before accessing the next one in an e-learning course.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Usage
39+
=====
40+
41+
To use this module, you need to:
42+
43+
#. Go to an e-learning course form view "Options" tab
44+
#. Under the "Display" section, check the "Require previous slides completion" option
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-learning/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/OCA/e-learning/issues/new?body=module:%20website_slides_require_completion%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
~~~~~~~
61+
62+
* Binhex
63+
64+
Contributors
65+
~~~~~~~~~~~~
66+
67+
* Adasat Torres de León <[email protected]>
68+
* Rolando Pérez Rebollo <[email protected]>
69+
70+
Maintainers
71+
~~~~~~~~~~~
72+
73+
This module is maintained by the OCA.
74+
75+
.. image:: https://odoo-community.org/logo.png
76+
:alt: Odoo Community Association
77+
:target: https://odoo-community.org
78+
79+
OCA, or the Odoo Community Association, is a nonprofit organization whose
80+
mission is to support the collaborative development of Odoo features and
81+
promote its widespread use.
82+
83+
.. |maintainer-adasatorres| image:: https://github.com/adasatorres.png?size=40px
84+
:target: https://github.com/adasatorres
85+
:alt: adasatorres
86+
87+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
88+
89+
|maintainer-adasatorres|
90+
91+
This module is part of the `OCA/e-learning <https://github.com/OCA/e-learning/tree/16.0/website_slides_require_completion>`_ project on GitHub.
92+
93+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from . import models
5+
from . import controllers
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Courses's Slides Require Previous Slides Completion",
6+
"summary": """If checked, the user has to complete previous slides before """
7+
"""moving to the next one.""",
8+
"version": "16.0.1.0.0",
9+
"category": "Website/eLearning",
10+
"author": "Binhex, Odoo Community Association (OCA)",
11+
"website": "https://github.com/OCA/e-learning",
12+
"depends": ["web", "website_slides"],
13+
"data": [
14+
"views/slide_channel_views.xml",
15+
"views/website_slides_templates_course.xml",
16+
"views/website_slides_templates_lesson_fullscreen.xml",
17+
"views/website_slides_templates_lesson_embed.xml",
18+
"views/website_slides_templates_utils.xml",
19+
],
20+
"assets": {
21+
"web.assets_frontend": [
22+
"website_slides_require_completion/static/src/js/*.js",
23+
"website_slides_require_completion/static/src/xml/*.xml",
24+
],
25+
},
26+
"license": "AGPL-3",
27+
"maintainers": ["adasatorres"],
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo.http import request, route
4+
5+
from odoo.addons.website_slides.controllers.main import WebsiteSlides
6+
7+
8+
class WebsiteSlidesRequireCompletion(WebsiteSlides):
9+
@route(
10+
"/slides/channel/require_completion", type="json", auth="user", methods=["POST"]
11+
)
12+
def require_completion(self, slide_id):
13+
"""
14+
Check if the chanell of the slide requires completion.
15+
"""
16+
slide = request.env["slide.slide"].sudo().browse(slide_id)
17+
return {"is_required": slide.channel_id.require_slides_completion}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from . import slide_channel
4+
from . import slide_slide
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class SlideChannel(models.Model):
7+
_inherit = "slide.channel"
8+
9+
require_slides_completion = fields.Boolean(
10+
string="Require previous slides completion",
11+
help="""If checked, the user has to complete previous slides before """
12+
"""moving to the next one""",
13+
default=False,
14+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2025 Binhex - Adasat Torres de León
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class SlideSlide(models.Model):
7+
_inherit = "slide.slide"
8+
9+
is_blocked = fields.Boolean(compute="_compute_is_blocked", compute_sudo=False)
10+
11+
def _get_previous_slide(self):
12+
return self.search(
13+
[
14+
("is_category", "=", False),
15+
("sequence", "<", self.sequence),
16+
("channel_id", "=", self.channel_id.id),
17+
],
18+
order="sequence desc",
19+
limit=1,
20+
)
21+
22+
def _compute_is_blocked(self):
23+
for slide in self:
24+
previous_slide = slide._get_previous_slide()
25+
if not previous_slide or not slide.channel_id.require_slides_completion:
26+
slide.is_blocked = False
27+
else:
28+
slide.is_blocked = not previous_slide.user_has_completed

0 commit comments

Comments
 (0)