Skip to content
github-actions[bot] edited this page Jul 25, 2026 · 1 revision

QCMs | Learn how to get QCM data with Linkdirecte.

The Forms/QCMs module manages online assessments, questionnaires, and multi-choice quizzes (QCMs) assigned to students by teachers.


🚀 Getting Started

Here's how to fetch assigned quizzes, inspect their structures, and respond to questions.

import { getQcms, getQcmDetail } from "linkdirecte";

// 1. Fetch available quizzes
const result = await getQcms();
const activeQuiz = result.associations?.[0];

if (activeQuiz) {
  console.log(`Let's work on: ${activeQuiz.titre || "Untitled Quiz"}`);

  // 2. Fetch questions for this quiz
  const details = await getQcmDetail(activeQuiz.idQcm, activeQuiz.id);

  details.questions.forEach((question, index) => {
    console.log(`Question ${index + 1}: ${question.libelle}`);
    question.choices.forEach(choice => {
      console.log(`  [ ] ID: ${choice.id} | ${choice.libelle}`);
    });
  });
} else {
  console.log("No quizzes assigned right now!");
}

📖 API Reference

getQcms

Retrieves a list of all assigned questionnaires/QCMs.

function getQcms(): Promise<QcmsResult>

getQcmDetail

Retrieves the question set and candidate choices for a specific QCM.

function getQcmDetail(
  idQcm: number,
  idAssociation: number,
): Promise<QcmDetailResult>

updateQcmStatus

Updates the student's status on a quiz (e.g., when they start or complete it).

function updateQcmStatus(
  idQcm: number,
  idAssociation: number,
  idParticipant: number,
  action: "updateStartDate" | "updateEndDate",
): Promise<{ success: boolean }>
  • idParticipant: Participant ID returned in the QCM details.
  • action: Use "updateStartDate" when the student opens/starts the test, and "updateEndDate" when finalizing and submitting the complete exam.

submitQcmAnswer

Submits selected choice IDs for a single question.

function submitQcmAnswer(
  params: {
    idQcm: number;
    idAssociation: number;
    idParticipant: number;
    idReponse: number;
    idQuestion: number;
    choiceIds: number[];
  },
): Promise<{ success: boolean }>
  • choiceIds: An array of numeric choice IDs the student selected for this question.

🗂️ Type Definitions

QcmsResult

interface QcmsResult {
  associations?: QcmEntry[];
}

QcmEntry

Property Type Description
id number The association ID.
idQcm number The questionnaire ID. (raw key)
titre string (optional) Title of the test. (raw key)
libelleMatiere string (optional) Subject label.
nomProf string (optional) Teacher who assigned the QCM.
date Date (optional) The date when the quiz was assigned.
status string (optional) Quiz state (e.g. "Not Started", "In Progress").

QcmDetailResult

interface QcmDetailResult {
  idQcm: number;
  questions: Array<{
    id: number;
    libelle: string; // (raw key)
    choices: Array<{ id: number; libelle: string }>; // (raw key)
  }>;
}

Clone this wiki locally