Back to the LMS journey
Technical note

Keeping AI answers tied to the lesson sources

The LMS assistant answers learners from lesson material. Laravel saves that material in versions and searches only what the learner may open. It keeps a citation only when its passage supports the answer.

The question

The LMS has an AI assistant that answers a learner’s questions. Each answer cites passages from the lesson material, which means it names the passages it used. That material is the lesson text, extracts from documents, and LMS · LMS AI Core · The Laravel sideLesson sourcesEach lesson is saved as a source with a version number, split into small chunks of text. Each chunk gets a fingerprint, a short code that changes when its content changes. Searches look only inside the learner’s own courses.See it in the LMS build of lesson videos. Three things have to be true. The material is up to date. The learner is allowed to open it. And each cited passage really supports the answer.

What made it hard

None of the three can be read from a label or a score. Material can be marked ready while its text is empty. A transcript can belong to a video that has since been replaced. A high search score means a passage is related to the question. It does not mean the learner may see it, or that it backs up the answer.

What I chose

I started with keeping the material up to date. Laravel, the main LMS application, saves each piece of lesson material as a lesson source with a version. Each version has a fingerprint of its content, a short code that changes when the content changes. If new material matches a fingerprint, Laravel reuses that version. New content replaces the older versions. A version with empty text stays unavailable, whatever an earlier status says. A transcript attached to a replaced video is left out.

Access comes next. The assistant feature has to be switched on, and the learner’s LMS · The platformEnrolment and accessEvery request is checked against the learner’s enrolment, or the course the instructor is assigned to.See it in the LMS build has to be active. The assistant must also be switched on for that course. Then Laravel checks the course and lesson the learner asked about. Only passages that pass these checks go on to a separate Python service in the LMS. That service ranks passages and checks answers.

Last comes the answer. Laravel has the AI write it from those passages. Then it hands the answer to a LMS · LMS AI Core · The AI serviceClaim checkingSplits an answer into claims, which are single statements, and checks that the lesson supports each one. It also spots clashes in numbers, dates and names. And it spots clashes in quotes, in the order of things, and where one side says “not”.See it in the LMS build, the part that compares an answer with the passages. The checker splits the answer into claims, which are its separate statements. It says which claims have support. Laravel keeps a citation only if its passage supports a claim. It also confirms that the citation points at the right lesson.

Some answers go wrong in different ways, and each way gets its own response. Weak support gets one response, and an answer the passages do not fully cover gets another. A badly formed answer and a failed call to the AI provider each get their own too. A search score is never treated as permission or proof.