Skip to content

Commit

Permalink
Feature: First approach Karma Tab functionality, for finishing quizze…
Browse files Browse the repository at this point in the history
…s, leaving reviews
  • Loading branch information
AlexMendozaPrado committed Dec 1, 2024
1 parent 3f72a51 commit 952715b
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea/
__pycache__/
odoo/custom-addons/wizelineacademy-academy-lms/eLearning_upgraded/__pycache__
eLearning_upgraded/__pycache__/
5 changes: 3 additions & 2 deletions eLearning_upgraded/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
""",
'company': 'systemBlue',
'website' : 'https://github.com/oszac/Sistemas-de-Software/wiki',
'depends' : ['website_slides', 'auth_oauth', 'auth_signup_upgraded'],
'depends' : ['website_slides', 'auth_oauth', 'auth_signup_upgraded', 'gamification'],
'data' : [
'security/ir.model.access.csv',
'wizard/import_course_view.xml',
Expand All @@ -23,7 +23,8 @@
'views/course_language_view.xml',
'views/course_audience_view.xml',
'views/course_main_lecturers_tab.xml',
'data/skills_data.xml'
'data/skills_data.xml',
'views/slide_channel_views.xml',
],
'assets': {
'web.assets_frontend': [
Expand Down
Binary file removed eLearning_upgraded/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file removed eLearning_upgraded/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
4 changes: 3 additions & 1 deletion eLearning_upgraded/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from . import course_skills
from . import slide_skill_tag
from . import slide_skill_partner
from . import slide_channel_extended
from . import slide_channel_extended
from . import slide_channel
from . import slide_slide_partner
7 changes: 7 additions & 0 deletions eLearning_upgraded/models/slide_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import api, fields, models, _

class SlideChannel(models.Model):
_inherit = 'slide.channel'

karma_slide_complete = fields.Integer(string="Karma por completar contenido", default=5)
karma_quiz_correct = fields.Integer(string="Karma por respuesta correcta", default=10)
30 changes: 30 additions & 0 deletions eLearning_upgraded/models/slide_slide_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from odoo import api, fields, models, _

class SlideSlidePartner(models.Model):
_inherit = 'slide.slide.partner'

@api.model_create_multi
def create(self, vals_list):
res = super(SlideSlidePartner, self).create(vals_list)
for record in res:
if record.completed:
record._grant_karma_for_slide_completion()
return res

def write(self, values):
res = super(SlideSlidePartner, self).write(values)
if 'completed' in values and values['completed']:
self._grant_karma_for_slide_completion()
return res

def _grant_karma_for_slide_completion(self):
for record in self:
user = record.partner_id.user_ids[:1] # Obtener el primer usuario asociado al partner
if user:
karma = record.channel_id.karma_slide_complete
if karma > 0:
user._add_karma(
karma,
source=record.slide_id,
reason=_("Lección completada: %s" % record.slide_id.name)
)
14 changes: 14 additions & 0 deletions eLearning_upgraded/views/slide_channel_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="slide_channel_form_view_inherit_karma">
<field name="name">slide.channel.form.view.inherit.karma</field>
<field name="model">slide.channel</field>
<field name="inherit_id" ref="website_slides.view_slide_channel_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='karma_rules']/group/group[field[@name='karma_gen_channel_rank']]" position="inside">
<field name="karma_slide_complete" string="Karma por completar contenido"/>
<field name="karma_quiz_correct" string="Karma por respuesta correcta"/>
</xpath>
</field>
</record>
</odoo>
17 changes: 9 additions & 8 deletions odoo.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[options]
admin_passwd = 12345
db_host = False
db_port = False
db_user = aylin.reyes
db_password =
dbfilter = ^academy.*$
db_list = True
addons_path = /Users/aylin.reyes/Documents/Odoo-community/odoo/addons,/Users/aylin.reyes/wizelineacademy-academy-lms
db_user = alexadmin
db_password = alexadmin
db_name = odoo
db_host = localhost
db_port = 5432
admin_passwd = admin
xmlrpc_port = 8069
addons_path = C:/Users/Alejandro/Odoo17/odoo/addons,C:\Users\Alejandro\Odoo17\odoo\custom-addons\wizelineacademy-academy-lms

0 comments on commit 952715b

Please sign in to comment.