EnCoach Odoo 19 custom modules

Full backend implementation with custom Odoo modules:
- encoach_api: Core API, user management, JWT auth
- encoach_exam: Exam generation (reading, writing, listening, speaking)
- encoach_evaluate: AI-powered evaluation (writing, speaking)
- encoach_training: Training tips and walkthrough
- encoach_storage: File storage management
- encoach_payment: Stripe, PayPal, Paymob integration
- encoach_mail: Email notifications

Made-with: Cursor
This commit is contained in:
Talal Sharabi
2026-03-14 16:46:46 +04:00
commit f5b627256f
168 changed files with 13428 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
from odoo import models, fields
MODULE_SELECTION = [
("reading", "Reading"),
("listening", "Listening"),
("writing", "Writing"),
("speaking", "Speaking"),
("level", "Level"),
]
class EncoachStat(models.Model):
_name = "encoach.stat"
_description = "EnCoach Exam Statistic"
_order = "date desc"
user_id = fields.Many2one("res.users", required=True, index=True)
exam_id = fields.Many2one("encoach.exam", index=True)
exercise = fields.Char()
session_id = fields.Many2one("encoach.session", index=True)
date = fields.Datetime(default=fields.Datetime.now)
module = fields.Selection(MODULE_SELECTION, index=True)
solutions = fields.Json(help="User solution objects for this stat")
stat_type = fields.Char(string="Type")
time_spent = fields.Integer(help="Seconds spent on this exercise")
inactivity = fields.Integer(help="Seconds of inactivity")
assignment_id = fields.Many2one("encoach.assignment", index=True)
score_correct = fields.Integer(default=0)
score_total = fields.Integer(default=0)
score_missing = fields.Integer(default=0)
is_disabled = fields.Boolean(default=False)
shuffle_maps = fields.Json()
is_practice = fields.Boolean(default=False)
pdf_url = fields.Char()
legacy_id = fields.Char(index=True)
def to_encoach_dict(self):
self.ensure_one()
result = {
"id": self.id,
"user": self.user_id.id,
"exam": self.exam_id.id if self.exam_id else None,
"exercise": self.exercise or "",
"session": self.session_id.id if self.session_id else None,
"date": (
int(self.date.timestamp() * 1000) if self.date else None
),
"module": self.module,
"solutions": self.solutions or [],
"type": self.stat_type or "",
"timeSpent": self.time_spent,
"inactivity": self.inactivity,
"assignment": (
self.assignment_id.id if self.assignment_id else None
),
"score": {
"correct": self.score_correct,
"total": self.score_total,
"missing": self.score_missing,
},
"isDisabled": self.is_disabled,
"shuffleMaps": self.shuffle_maps or [],
"isPractice": self.is_practice,
}
if self.pdf_url:
result["pdf"] = {"path": self.pdf_url, "version": "1"}
return result