Serves Demo Scene 8. Per spec this is glue only, not a custom LMS:
mc.batch gets one new field (channel_id -> slide.channel), and
mc.enrollment's create()/write() calls the stock
slide.channel._action_add_members() when an enrollment becomes active
for a batch that has a channel - that's the entire feature. 40 lines
of model code, well under the spec's own "~200 lines or something has
gone wrong" ceiling.
Demo data matches Scene 8's script exactly - "Mathematics - Algebra
Basics": a video lesson, a PDF handout, a 5-question quiz (verified:
each question has exactly one correct and one incorrect answer, the
minimum website_slides itself requires).
This module took far longer to get right than its size suggests, and
the reason is worth recording. A ForeignKeyViolation on an unrelated
model (mc.batch referencing a channel Postgres said was never
inserted, despite that channel being created earlier in the same
file) sent the investigation looking for an install-time flush-
ordering bug for a long time - checking whether attachment=True
binary fields interact badly with a pending FK write in the same
flush batch, splitting the demo data across multiple files, even
routing the batch-channel link through a post_init_hook to sidestep
it. All of that was chasing a symptom. Bisecting the actual XML down
to a single record eventually surfaced the real, simple cause:
type="base64" on an XML <field> is only valid paired with a file=
attribute pointing to a real file in the addon - inline base64 text
raises a ValueError that Odoo's demo-data loader catches and
downgrades to "installed without demo data", and in an earlier
configuration (batch-link in the same file) that same swallowed
error surfaced instead as the confusing FK violation. Fixed by saving
the handout as a real file (static/demo/algebra_handout.pdf) and
referencing it properly; the post_init_hook and file-splitting were
reverted since the real fix needed neither. Verified byte-for-byte:
the attachment Odoo stores is exactly 604 bytes, detected as
application/pdf, matching the source file's md5sum.
Also caught before it reached git: line-ending conversion on this
binary PDF ("LF will be replaced by CRLF"), which would have silently
corrupted it on checkout for any contributor with Windows's
core.autocrlf on. Added *.pdf (and common image types) as binary to
.gitattributes and confirmed the staged blob's md5sum matches the
source file exactly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
130 lines
5.8 KiB
XML
130 lines
5.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- Matches shared/DEMO_SCRIPT.md Scene 8 exactly: "Mathematics -
|
|
Algebra Basics": a video lesson, a PDF handout, a 5-question
|
|
quiz. website_slides skips external metadata fetching during
|
|
module/demo install (its own create() checks
|
|
self.env.context.get('install_mode')), so this loads with no
|
|
network access and no risk of an install-time failure.
|
|
video_url is a well-known placeholder ("never gonna give you
|
|
up") - swap for the school's real lesson video before an actual
|
|
client demo; it is only here to prove the video slide renders
|
|
and plays inline, not as real course content. -->
|
|
<record id="demo_channel_grade8_math" model="slide.channel">
|
|
<field name="name">Mathematics - Algebra Basics</field>
|
|
<field name="enroll">invite</field>
|
|
</record>
|
|
|
|
<record id="mc_education_base.demo_batch_grade8_a" model="mc.batch">
|
|
<field name="channel_id" ref="demo_channel_grade8_math"/>
|
|
</record>
|
|
|
|
<record id="demo_slide_algebra_video" model="slide.slide">
|
|
<field name="name">Algebra Basics - Video Lesson</field>
|
|
<field name="channel_id" ref="demo_channel_grade8_math"/>
|
|
<field name="slide_category">video</field>
|
|
<field name="video_url">https://www.youtube.com/watch?v=dQw4w9WgXcQ</field>
|
|
<field name="is_published">True</field>
|
|
<field name="sequence">1</field>
|
|
</record>
|
|
|
|
<record id="demo_slide_algebra_handout" model="slide.slide">
|
|
<field name="name">Algebra Basics - Handout</field>
|
|
<field name="channel_id" ref="demo_channel_grade8_math"/>
|
|
<field name="slide_category">document</field>
|
|
<!-- type="base64" is only valid paired with file= (a real file
|
|
in the addon) - it is NOT for inline base64 text, which
|
|
raises a ValueError swallowed by Odoo's demo-data error
|
|
recovery in a way that manifested as a deeply confusing
|
|
foreign-key error on an unrelated model (mc.batch) rather
|
|
than the real, simple cause. Found only by bisecting down
|
|
to a single record against a live container. -->
|
|
<field name="binary_content" type="base64" file="mc_education_lms/static/demo/algebra_handout.pdf"/>
|
|
<field name="is_published">True</field>
|
|
<field name="sequence">2</field>
|
|
</record>
|
|
|
|
<record id="demo_slide_algebra_quiz" model="slide.slide">
|
|
<field name="name">Algebra Basics - Quiz</field>
|
|
<field name="channel_id" ref="demo_channel_grade8_math"/>
|
|
<field name="slide_category">quiz</field>
|
|
<field name="is_published">True</field>
|
|
<field name="sequence">3</field>
|
|
</record>
|
|
|
|
<record id="demo_quiz_q1" model="slide.question">
|
|
<field name="slide_id" ref="demo_slide_algebra_quiz"/>
|
|
<field name="sequence">1</field>
|
|
<field name="question">What is the value of x in x + 5 = 12?</field>
|
|
</record>
|
|
<record id="demo_quiz_q1_a1" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q1"/>
|
|
<field name="text_value">7</field>
|
|
<field name="is_correct">True</field>
|
|
</record>
|
|
<record id="demo_quiz_q1_a2" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q1"/>
|
|
<field name="text_value">17</field>
|
|
</record>
|
|
|
|
<record id="demo_quiz_q2" model="slide.question">
|
|
<field name="slide_id" ref="demo_slide_algebra_quiz"/>
|
|
<field name="sequence">2</field>
|
|
<field name="question">Simplify: 3x + 2x</field>
|
|
</record>
|
|
<record id="demo_quiz_q2_a1" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q2"/>
|
|
<field name="text_value">5x</field>
|
|
<field name="is_correct">True</field>
|
|
</record>
|
|
<record id="demo_quiz_q2_a2" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q2"/>
|
|
<field name="text_value">6x</field>
|
|
</record>
|
|
|
|
<record id="demo_quiz_q3" model="slide.question">
|
|
<field name="slide_id" ref="demo_slide_algebra_quiz"/>
|
|
<field name="sequence">3</field>
|
|
<field name="question">What is the coefficient of x in 4x + 3?</field>
|
|
</record>
|
|
<record id="demo_quiz_q3_a1" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q3"/>
|
|
<field name="text_value">4</field>
|
|
<field name="is_correct">True</field>
|
|
</record>
|
|
<record id="demo_quiz_q3_a2" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q3"/>
|
|
<field name="text_value">3</field>
|
|
</record>
|
|
|
|
<record id="demo_quiz_q4" model="slide.question">
|
|
<field name="slide_id" ref="demo_slide_algebra_quiz"/>
|
|
<field name="sequence">4</field>
|
|
<field name="question">Solve for y: 2y = 10</field>
|
|
</record>
|
|
<record id="demo_quiz_q4_a1" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q4"/>
|
|
<field name="text_value">5</field>
|
|
<field name="is_correct">True</field>
|
|
</record>
|
|
<record id="demo_quiz_q4_a2" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q4"/>
|
|
<field name="text_value">20</field>
|
|
</record>
|
|
|
|
<record id="demo_quiz_q5" model="slide.question">
|
|
<field name="slide_id" ref="demo_slide_algebra_quiz"/>
|
|
<field name="sequence">5</field>
|
|
<field name="question">Which of these is a linear equation?</field>
|
|
</record>
|
|
<record id="demo_quiz_q5_a1" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q5"/>
|
|
<field name="text_value">y = 2x + 1</field>
|
|
<field name="is_correct">True</field>
|
|
</record>
|
|
<record id="demo_quiz_q5_a2" model="slide.answer">
|
|
<field name="question_id" ref="demo_quiz_q5"/>
|
|
<field name="text_value">y = x^2</field>
|
|
</record>
|
|
</odoo>
|